int main() {
  char s[512];
  printf("4! == %d\n", fac(4));
  printf("8! == %d\n", fac(8));
  printf("12! == %d\n", fac(12));
  strcpy(s, "abcdef");
  printf("reversing 'abcdef', we get '%s'\n", reverse(s));
  strcpy(s, "madam");
  printf("reversing 'madam', we get '%s'\n", reverse(s));
  int array[5] = {1, 2, 3, 4, 5};
  printf("%d\n", sum(array, 5));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4,%edi
mov    $0x0,%al
call   1050 <fac@plt>
mov    %eax,%esi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x8,%edi
mov    $0x0,%al
call   1050 <fac@plt>
mov    %eax,%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xc,%edi
mov    $0x0,%al
call   1050 <fac@plt>
mov    %eax,%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x210(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x210(%rbp),%rdi
mov    $0x0,%al
call   1030 <reverse@plt>
mov    %eax,%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x210(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x210(%rbp),%rdi
mov    $0x0,%al
call   1030 <reverse@plt>
mov    %eax,%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0xe51(%rip),%rax
mov    %rax,-0x230(%rbp)
mov    0xe4b(%rip),%rax
mov    %rax,-0x228(%rbp)
mov    0xe46(%rip),%eax
mov    %eax,-0x220(%rbp)
lea    -0x230(%rbp),%rdi
mov    $0x5,%esi
mov    $0x0,%al
call   1070 <sum@plt>
mov    %eax,%esi
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x220,%rsp
mov    $0x4,%edi
xor    %eax,%eax
call   1040 <fac@plt>
lea    0xea5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x8,%edi
xor    %eax,%eax
call   1040 <fac@plt>
lea    0xe93(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xc,%edi
xor    %eax,%eax
call   1040 <fac@plt>
lea    0xe81(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x64636261,0x20(%rsp)
64
movl   $0x666564,0x23(%rsp)
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <reverse@plt>
lea    0xe64(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x6164616d,0x20(%rsp)
61
movw   $0x6d,0x24(%rsp)
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <reverse@plt>
lea    0xe62(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xe86(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xe6b(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1060 <sum@plt>
lea    0xdfc(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"4! == %d\0A\00"
@.str.1 = [10 x i8] c"8! == %d\0A\00"
@.str.2 = [11 x i8] c"12! == %d\0A\00"
@.str.3 = [7 x i8] c"abcdef\00"
@.str.4 = [33 x i8] c"reversing 'abcdef', we get '%s'\0A\00"
@.str.5 = [6 x i8] c"madam\00"
@.str.6 = [32 x i8] c"reversing 'madam', we get '%s'\0A\00"
@__const.main.array = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@.str.7 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [512 x i8]
%3 = alloca [5 x i32]
store i32 0, i32* %1
%4 = call i32 (i32, ...) bitcast (i32 (...)* @fac to i32 (i32, ...)*)(i32 4)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 (i32, ...) bitcast (i32 (...)* @fac to i32 (i32, ...)*)(i32 8)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = call i32 (i32, ...) bitcast (i32 (...)* @fac to i32 (i32, ...)*)(i32 12)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%11 = call i8* @strcpy(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%13 = call i32 (i8*, ...) bitcast (i32 (...)* @reverse to i32 (i8*, ...)*)(i8* %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%16 = call i8* @strcpy(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%18 = call i32 (i8*, ...) bitcast (i32 (...)* @reverse to i32 (i8*, ...)*)(i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %18)
%20 = bitcast [5 x i32]* %3 to i8*
%21 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%22 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @sum to i32 (i32*, i32, ...)*)(i32* %21, i32 5)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"4! == %d\0A\00"
@.str.1 = [10 x i8] c"8! == %d\0A\00"
@.str.2 = [11 x i8] c"12! == %d\0A\00"
@.str.3 = [7 x i8] c"abcdef\00"
@.str.4 = [33 x i8] c"reversing 'abcdef', we get '%s'\0A\00"
@.str.5 = [6 x i8] c"madam\00"
@.str.6 = [32 x i8] c"reversing 'madam', we get '%s'\0A\00"
@__const.main.array = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@.str.7 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [512 x i8]
%2 = alloca [5 x i32]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @fac to i32 (i32, ...)*)(i32 4)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 (i32, ...) bitcast (i32 (...)* @fac to i32 (i32, ...)*)(i32 8)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = tail call i32 (i32, ...) bitcast (i32 (...)* @fac to i32 (i32, ...)*)(i32 12)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = call i32 (i8*, ...) bitcast (i32 (...)* @reverse to i32 (i8*, ...)*)(i8* %3)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %10)
%12 = call i32 (i8*, ...) bitcast (i32 (...)* @reverse to i32 (i8*, ...)*)(i8* %3)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %12)
%14 = bitcast [5 x i32]* %2 to i8*
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%16 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @sum to i32 (i32*, i32, ...)*)(i32* %15, i32 5)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %16)
ret i32 0
}