#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 bar(int);
int /*<<< orphan*/ exit(int);
int foo(int, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int one = bar(1) + bar(2);
  int res =
      one + foo(1, 2) + 17 * foo(9, 5) + 126 * foo(7, 2) + 3037 * foo(15, 9);
  printf("Result is: %d\n", res);
  if (res != 171822)
    exit(1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
call   1030 <bar@plt>
mov    %eax,-0x20(%rbp)
mov    $0x2,%edi
call   1030 <bar@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x1,%edi
mov    $0x2,%esi
call   1050 <foo@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    $0x9,%edi
mov    $0x5,%esi
call   1050 <foo@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
imul   $0x11,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    $0x7,%edi
mov    $0x2,%esi
call   1050 <foo@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
imul   $0x7e,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    $0xf,%edi
mov    $0x9,%esi
call   1050 <foo@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
imul   $0xbdd,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe10(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x29f2e,-0xc(%rbp)
je     120c <main+0xcc>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%edi
call   1030 <bar@plt>
mov    %eax,%ebx
mov    $0x2,%edi
call   1030 <bar@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    $0x1,%edi
mov    $0x2,%esi
call   1050 <foo@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    $0x9,%edi
mov    $0x5,%esi
call   1050 <foo@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
add    %eax,%ebp
add    %ebx,%ebp
mov    $0x7,%edi
mov    $0x2,%esi
call   1050 <foo@plt>
mov    %eax,%ebx
shl    $0x7,%ebx
sub    %eax,%ebx
sub    %eax,%ebx
add    %ebp,%ebx
mov    $0xf,%edi
mov    $0x9,%esi
call   1050 <foo@plt>
imul   $0xbdd,%eax,%ebp
add    %ebx,%ebp
lea    0xe40(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
cmp    $0x29f2e,%ebp
jne    11d8 <main+0x98>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"Result is: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @bar(i32 1)
%5 = call i32 @bar(i32 2)
%6 = add nsw i32 %4, %5
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = call i32 @foo(i32 1, i32 2)
%9 = add nsw i32 %7, %8
%10 = call i32 @foo(i32 9, i32 5)
%11 = mul nsw i32 17, %10
%12 = add nsw i32 %9, %11
%13 = call i32 @foo(i32 7, i32 2)
%14 = mul nsw i32 126, %13
%15 = add nsw i32 %12, %14
%16 = call i32 @foo(i32 15, i32 9)
%17 = mul nsw i32 3037, %16
%18 = add nsw i32 %15, %17
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %3
%22 = icmp ne i32 %21, 171822
br i1 %22, label %23, label %25
23: ; preds = %0
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %0
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Result is: %d\0A\00"
define i32 @main() {
%1 = tail call i32 @bar(i32 1)
%2 = tail call i32 @bar(i32 2)
%3 = add nsw i32 %2, %1
%4 = tail call i32 @foo(i32 1, i32 2)
%5 = add nsw i32 %3, %4
%6 = tail call i32 @foo(i32 9, i32 5)
%7 = mul nsw i32 %6, 17
%8 = add nsw i32 %5, %7
%9 = tail call i32 @foo(i32 7, i32 2)
%10 = mul nsw i32 %9, 126
%11 = add nsw i32 %8, %10
%12 = tail call i32 @foo(i32 15, i32 9)
%13 = mul nsw i32 %12, 3037
%14 = add nsw i32 %11, %13
%15 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = icmp eq i32 %14, 171822
br i1 %16, label %19, label %17
17: ; preds = %0
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %0
ret i32 0
}