#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ dump_str(char *);
int /*<<< orphan*/ dump_uint32_t(int);
int fac(int);
int sum(int);
void main(void) {
  uint32_t i;
  for (i = 0; i < 10; i++) {
    dump_str("sum(");
    dump_uint32_t(i);
    dump_str(") = ");
    dump_uint32_t(sum(i));
    dump_str("\n");
    dump_str("fac(");
    dump_uint32_t(i);
    dump_str(") = ");
    dump_uint32_t(fac(i));
    dump_str("\n");
  }
  for (;;)
    ;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    11dd <main+0x9d>
lea    0xea0(%rip),%rdi
call   1060 <dump_str@plt>
mov    -0x4(%rbp),%edi
call   1050 <dump_uint32_t@plt>
lea    0xe91(%rip),%rdi
call   1060 <dump_str@plt>
mov    -0x4(%rbp),%edi
call   1040 <sum@plt>
mov    %eax,%edi
call   1050 <dump_uint32_t@plt>
lea    0xe7b(%rip),%rdi
call   1060 <dump_str@plt>
lea    0xe71(%rip),%rdi
call   1060 <dump_str@plt>
mov    -0x4(%rbp),%edi
call   1050 <dump_uint32_t@plt>
lea    0xe56(%rip),%rdi
call   1060 <dump_str@plt>
mov    -0x4(%rbp),%edi
call   1030 <fac@plt>
mov    %eax,%edi
call   1050 <dump_uint32_t@plt>
lea    0xe40(%rip),%rdi
call   1060 <dump_str@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114f <main+0xf>
jmp    11e2 <main+0xa2>
jmp    11e2 <main+0xa2>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
xor    %ebx,%ebx
lea    0xeae(%rip),%r14
lea    0xeac(%rip),%r15
lea    0xeaa(%rip),%r12
lea    0xea5(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1060 <dump_str@plt>
mov    %ebx,%edi
call   1050 <dump_uint32_t@plt>
mov    %r15,%rdi
call   1060 <dump_str@plt>
mov    %ebx,%edi
call   1040 <sum@plt>
mov    %eax,%edi
call   1050 <dump_uint32_t@plt>
mov    %r12,%rdi
call   1060 <dump_str@plt>
mov    %r13,%rdi
call   1060 <dump_str@plt>
mov    %ebx,%edi
call   1050 <dump_uint32_t@plt>
mov    %r15,%rdi
call   1060 <dump_str@plt>
mov    %ebx,%edi
call   1030 <fac@plt>
mov    %eax,%edi
call   1050 <dump_uint32_t@plt>
mov    %r12,%rdi
call   1060 <dump_str@plt>
add    $0x1,%ebx
cmp    $0xa,%ebx
jne    1170 <main+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
jmp    11e0 <main+0xa0>

LLVM IR (-O0):
@.str = [5 x i8] c"sum(\00"
@.str.1 = [5 x i8] c") = \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [5 x i8] c"fac(\00"
define void @main() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %22, %0
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 10
br i1 %4, label %5, label %25
5: ; preds = %2
%6 = call i32 @dump_str(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %1
%8 = call i32 @dump_uint32_t(i32 %7)
%9 = call i32 @dump_str(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = call i32 @sum(i32 %10)
%12 = call i32 @dump_uint32_t(i32 %11)
%13 = call i32 @dump_str(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @dump_str(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%15 = load i32, i32* %1
%16 = call i32 @dump_uint32_t(i32 %15)
%17 = call i32 @dump_str(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* %1
%19 = call i32 @fac(i32 %18)
%20 = call i32 @dump_uint32_t(i32 %19)
%21 = call i32 @dump_str(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %5
%23 = load i32, i32* %1
%24 = add nsw i32 %23, 1
store i32 %24, i32* %1
br label %2
25: ; preds = %2
br label %26
26: ; preds = %26, %25
br label %26
}

LLVM IR (-O2):
@.str = [5 x i8] c"sum(\00"
@.str.1 = [5 x i8] c") = \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [5 x i8] c"fac(\00"
define void @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %15, %1 ]
%3 = tail call i32 @dump_str(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @dump_uint32_t(i32 %2)
%5 = tail call i32 @dump_str(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @sum(i32 %2)
%7 = tail call i32 @dump_uint32_t(i32 %6)
%8 = tail call i32 @dump_str(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @dump_str(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%10 = tail call i32 @dump_uint32_t(i32 %2)
%11 = tail call i32 @dump_str(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @fac(i32 %2)
%13 = tail call i32 @dump_uint32_t(i32 %12)
%14 = tail call i32 @dump_str(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = add nuw nsw i32 %2, 1
%16 = icmp eq i32 %15, 10
br i1 %16, label %17, label %1
17: ; preds = %1, %17
br label %17
}