#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
int sumInt(int, int);
int fun_calls(int rounds) {
  int ret = 1;
  int i;
  for (i = 0; i < rounds; ++i) {
    if (i % 10 == 0) {
      printf("Current value after %d rounds: %d\n", i, ret);
    }
    ret = sumInt(i, ret);
  }
  return ret;
}


x86 assembly (clang, -O0):
<fun_calls>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1187 <fun_calls+0x67>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    116b <fun_calls+0x4b>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <sumInt@plt>
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1139 <fun_calls+0x19>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun_calls>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edi,%edi
jle    1184 <fun_calls+0x64>
mov    %edi,%r14d
mov    $0x1,%ebp
xor    %ebx,%ebx
mov    $0xcccccccd,%r12d
lea    0xebd(%rip),%r15
jmp    1163 <fun_calls+0x43>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <sumInt@plt>
mov    %eax,%ebp
add    $0x1,%ebx
cmp    %ebx,%r14d
je     1189 <fun_calls+0x69>
mov    %ebx,%eax
imul   %r12,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
cmp    %ebx,%eax
jne    1150 <fun_calls+0x30>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
jmp    1150 <fun_calls+0x30>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Current value after %d rounds: %d\0A\00"
define i32 @fun_calls(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %21, %1
%6 = load i32, i32* %4
%7 = load i32, i32* %2
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %24
9: ; preds = %5
%10 = load i32, i32* %4
%11 = srem i32 %10, 10
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i32, i32* %4
%15 = load i32, i32* %3
%16 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %15)
br label %17
17: ; preds = %13, %9
%18 = load i32, i32* %4
%19 = load i32, i32* %3
%20 = call i32 @sumInt(i32 %18, i32 %19)
store i32 %20, i32* %3
br label %21
21: ; preds = %17
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %5
24: ; preds = %5
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [35 x i8] c"Current value after %d rounds: %d\0A\00"
define i32 @fun_calls(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %14
3: ; preds = %1, %10
%4 = phi i32 [ %12, %10 ], [ 0, %1 ]
%5 = phi i32 [ %11, %10 ], [ 1, %1 ]
%6 = urem i32 %4, 10
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5)
br label %10
10: ; preds = %8, %3
%11 = tail call i32 @sumInt(i32 %4, i32 %5)
%12 = add nuw nsw i32 %4, 1
%13 = icmp eq i32 %12, %0
br i1 %13, label %14, label %3
14: ; preds = %10, %1
%15 = phi i32 [ 1, %1 ], [ %11, %10 ]
ret i32 %15
}