#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 f(int, int, int);
int g(int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int a = 1, b = 4, c = 2;
  a = f(g(b, a), a + c, b + c);
  printf("a=%d b=%d c=%d\n\n", a, b, c);
  b = f(b, a, c);
  printf("Notice how the value of b has changed: \n");
  printf("a=%d b=%d c=%d\n\n", a, b, c);
  c = f(f(c, b, a - 1), a, b);
  printf("Notice how the value of c has changed: \n");
  printf("a=%d b=%d c=%d\n\n", a, b, c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x4,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <g@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%esi
add    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
add    -0x10(%rbp),%edx
call   1030 <f@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <f@plt>
mov    %eax,-0xc(%rbp)
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
call   1030 <f@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <f@plt>
mov    %eax,-0x10(%rbp)
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x4,%edi
mov    $0x1,%esi
call   1060 <g@plt>
mov    %eax,%edi
mov    $0x3,%esi
mov    $0x6,%edx
call   1040 <f@plt>
mov    %eax,%ebx
lea    0xe90(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
mov    $0x4,%edx
mov    $0x2,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x4,%edi
mov    %ebx,%esi
mov    $0x2,%edx
call   1040 <f@plt>
mov    %eax,%ebp
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x2,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x1(%rbx),%edx
mov    $0x2,%edi
mov    %ebp,%esi
call   1040 <f@plt>
mov    %eax,%edi
mov    %ebx,%esi
mov    %ebp,%edx
call   1040 <f@plt>
mov    %eax,%r15d
lea    0xe5d(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"a=%d b=%d c=%d\0A\0A\00"
@.str.1 = [41 x i8] c"Notice how the value of b has changed: \0A\00"
@.str.2 = [41 x i8] c"Notice how the value of c has changed: \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 4, i32* %3
store i32 2, i32* %4
%5 = load i32, i32* %3
%6 = load i32, i32* %2
%7 = call i32 @g(i32 %5, i32 %6)
%8 = load i32, i32* %2
%9 = load i32, i32* %4
%10 = add nsw i32 %8, %9
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = add nsw i32 %11, %12
%14 = call i32 @f(i32 %7, i32 %10, i32 %13)
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16, i32 %17)
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = load i32, i32* %4
%22 = call i32 @f(i32 %19, i32 %20, i32 %21)
store i32 %22, i32* %3
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %25, i32 %26)
%28 = load i32, i32* %4
%29 = load i32, i32* %3
%30 = load i32, i32* %2
%31 = sub nsw i32 %30, 1
%32 = call i32 @f(i32 %28, i32 %29, i32 %31)
%33 = load i32, i32* %2
%34 = load i32, i32* %3
%35 = call i32 @f(i32 %32, i32 %33, i32 %34)
store i32 %35, i32* %4
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32, i32* %2
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %37, i32 %38, i32 %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"a=%d b=%d c=%d\0A\0A\00"
@str = [40 x i8] c"Notice how the value of b has changed: \00"
@str.3 = [40 x i8] c"Notice how the value of c has changed: \00"
define i32 @main() {
%1 = tail call i32 @g(i32 4, i32 1)
%2 = tail call i32 @f(i32 %1, i32 3, i32 6)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %2, i32 4, i32 2)
%4 = tail call i32 @f(i32 4, i32 %2, i32 2)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %4, i32 2)
%7 = add nsw i32 %2, -1
%8 = tail call i32 @f(i32 2, i32 %4, i32 %7)
%9 = tail call i32 @f(i32 %8, i32 %2, i32 %4)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.3, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %4, i32 %9)
ret i32 0
}