#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*/ assert(int);
int /*<<< orphan*/ printf(char *, int);
int rec(int);
int main() {
  int res = 0;
  res = rec(3);
  res = res + rec(3);
  res = res + rec(3);
  res = res + rec(3);
  printf(">>>>> res = %d\n", res);
  assert(res == 12);
  return res;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x3,%edi
call   1050 <rec@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x3,%edi
call   1050 <rec@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x3,%edi
call   1050 <rec@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x3,%edi
call   1050 <rec@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0xc,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x3,%edi
call   1050 <rec@plt>
mov    %eax,%ebx
mov    $0x3,%edi
call   1050 <rec@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    $0x3,%edi
call   1050 <rec@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    $0x3,%edi
call   1050 <rec@plt>
mov    %eax,%ebp
add    %ebx,%ebp
lea    0xe90(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
xor    %edi,%edi
cmp    $0xc,%ebp
sete   %dil
call   1040 <assert@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c">>>>> res = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = call i32 @rec(i32 3)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @rec(i32 3)
%6 = add nsw i32 %4, %5
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = call i32 @rec(i32 3)
%9 = add nsw i32 %7, %8
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = call i32 @rec(i32 3)
%12 = add nsw i32 %10, %11
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 12
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str = [16 x i8] c">>>>> res = %d\0A\00"
define i32 @main() {
%1 = tail call i32 @rec(i32 3)
%2 = tail call i32 @rec(i32 3)
%3 = add nsw i32 %2, %1
%4 = tail call i32 @rec(i32 3)
%5 = add nsw i32 %3, %4
%6 = tail call i32 @rec(i32 3)
%7 = add nsw i32 %5, %6
%8 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp eq i32 %7, 12
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
ret i32 %7
}