#include int trinary( int var ); int ifelse( int var ); int trinary( int var ) { int to_return = var ? 1 : 0; return to_return; } int ifelse( int var ) { int to_return; if( var ) { to_return = 1; } else { to_return = 0; } return to_return; } int main(int argc, char **argv) { int got_trinary = trinary( 1 ); int got_ifelse = ifelse( 1 ); return 0; } #### $ gcc -v Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/specs Configured with: /var/tmp/portage/gcc-3.3.5.20050130-r1/work/gcc-3.3.5/configure --enable-version-specific-runtime-libs --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3.5-20050130 --includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3.5-20050130 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3.5-20050130/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3.5-20050130/info --with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/include/g++-v3 --host=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --disable-multilib --disable-libgcj --enable-languages=c,c++,f77 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu Thread model: posix gcc version 3.3.5-20050130 (Gentoo Hardened Linux 3.3.5.20050130-r1, ssp-3.3.5.20050130-1, pie-8.7.7.1) #### # trinary function .LC0: .string "trinary" .text .globl trinary .type trinary, @function trinary: # Start param passing pushl %ebp movl %esp, %ebp pushl %ebx subl $52, %esp call __i686.get_pc_thunk.bx addl $_GLOBAL_OFFSET_TABLE_, %ebx movl __guard@GOT(%ebx), %eax movl (%eax), %eax movl %eax, -24(%ebp) # End param passing cmpl $0, 8(%ebp) # var setne %al movzbl %al, %eax movl %eax, -28(%ebp) # to_return movl -28(%ebp), %eax # to_return movl __guard@GOT(%ebx), %edx movl (%edx), %edx cmpl %edx, -24(%ebp) je .L2 movl -24(%ebp), %eax movl %eax, 4(%esp) leal .LC0@GOTOFF(%ebx), %eax movl %eax, (%esp) call __stack_smash_handler@PLT .L2: addl $52, %esp popl %ebx popl %ebp ret .size trinary, .-trinary .globl __stack_smash_handler .section .rodata # ifelse function .LC1: .string "ifelse" .text .globl ifelse .type ifelse, @function ifelse: # Start param passing pushl %ebp movl %esp, %ebp pushl %ebx subl $52, %esp call __i686.get_pc_thunk.bx addl $_GLOBAL_OFFSET_TABLE_, %ebx movl __guard@GOT(%ebx), %eax movl (%eax), %eax movl %eax, -24(%ebp) # End param passing cmpl $0, 8(%ebp) # var je .L4 movl $1, -28(%ebp) # to_return jmp .L5 .L4: movl $0, -28(%ebp) # to_return .L5: movl -28(%ebp), %eax # to_return movl __guard@GOT(%ebx), %edx movl (%edx), %edx cmpl %edx, -24(%ebp) je .L6 movl -24(%ebp), %eax movl %eax, 4(%esp) leal .LC1@GOTOFF(%ebx), %eax movl %eax, (%esp) call __stack_smash_handler@PLT .L6: addl $52, %esp popl %ebx popl %ebp ret .size ifelse, .-ifelse .globl __stack_smash_handler .section .rodata #### # trinary movl %eax, -28(%ebp) # to_return # ifelse movl $1, -28(%ebp) # to_return