All pastes #635009 Raw Edit

gcc case opt

public text v1 · immutable
#635009 ·published 2007-07-26 19:41 UTC
rendered paste body
#include <stdio.h>                                                                                                        
                                                                                                                          
void one_two_three(int n){                                                                                                
switch(n) {                                                                                                               
case 1: printf("one"); break;                                                                                             
case 2: printf("two"); break;                                                                                             
case 3: printf("one"); break;                                                                                             
case 4: printf("four"); break;                                                                                            
case 5: printf("four"); break;                                                                                            
case 6: printf("four"); break;                                                                                            
case 7: printf("four"); break;                                                                                            
}}                                                                                                                        
                                                                                                                          
int main() { one_two_three(2); return 0; }                                                                                
                                                

	.file	"test.c"
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"one"
.LC1:
	.string	"two"
.LC2:
	.string	"four"
.LC3:
	.string	"five"
.LC4:
	.string	"six"
.LC5:
	.string	"seven"
	.text
	.p2align 4,,15
.globl one_two_three
	.type	one_two_three, @function
one_two_three:
	pushl	%ebp
	movl	%esp, %ebp
	movl	8(%ebp), %eax
	cmpl	$7, %eax
	ja	.L11
	jmp	*.L10(,%eax,4)
	.section	.rodata
	.align 4
	.align 4
.L10:
	.long	.L11
	.long	.L5
	.long	.L4
	.long	.L5
	.long	.L6
	.long	.L7
	.long	.L8
	.long	.L9
	.text
	.p2align 4,,7
.L11:
	popl	%ebp
	ret
	.p2align 4,,7
.L5:
	movl	$.LC0, 8(%ebp)
	popl	%ebp
	.p2align 4,,5
	jmp	printf
.L4:
	movl	$.LC1, 8(%ebp)
	popl	%ebp
	jmp	printf
.L9:
	movl	$.LC5, 8(%ebp)
	popl	%ebp
	jmp	printf
.L8:
	movl	$.LC4, 8(%ebp)
	popl	%ebp
	jmp	printf
.L7:
	movl	$.LC3, 8(%ebp)
	popl	%ebp
	jmp	printf
.L6:
	movl	$.LC2, 8(%ebp)
	popl	%ebp
	jmp	printf
	.size	one_two_three, .-one_two_three
	.p2align 4,,15
.globl main
	.type	main, @function
main:
	leal	4(%esp), %ecx
	andl	$-16, %esp
	pushl	-4(%ecx)
	pushl	%ebp
	movl	%esp, %ebp
	pushl	%ecx
	subl	$4, %esp
	movl	$2, (%esp)
	call	one_two_three
	addl	$4, %esp
	xorl	%eax, %eax
	popl	%ecx
	popl	%ebp
	leal	-4(%ecx), %esp
	ret
	.size	main, .-main
	.ident	"GCC: (GNU) 4.1.3 20070629 (prerelease) (Debian 4.1.2-13)"
	.section	.note.GNU-stack,"",@progbits