#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 foo(int *, int *, int);
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  int x = 7, y = 8, z = 9;
  printf("\e[1;31mX=%d \e[0m\e[1;36m Y=%d \e[0m\e[1;35m Z=%d\e[0m\n", x, y, z);
  int answer = foo(&x, &y, z);
  printf("\e[1;32mAnswer is %d\e[0m\n", answer);
  printf("\e[1;31mX=%d \e[0m\e[1;36m Y=%d \e[0m\e[1;35m Z=%d\e[0m\n", x, y, z);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x7,-0x8(%rbp)
movl   $0x8,-0xc(%rbp)
movl   $0x9,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%edx
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <foo@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x7,0xc(%rsp)
movl   $0x8,0x8(%rsp)
lea    0xec4(%rip),%rbx
mov    %rbx,%rdi
mov    $0x7,%esi
mov    $0x8,%edx
mov    $0x9,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x9,%edx
call   1040 <foo@plt>
lea    0xec3(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x9,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [51 x i8] c"\1B[1;31mX=%d \1B[0m\1B[1;36m Y=%d \1B[0m\1B[1;35m Z=%d\1B[0m\0A\00"
@.str.1 = [25 x i8] c"\1B[1;32mAnswer is %d\1B[0m\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 7, i32* %2
store i32 8, i32* %3
store i32 9, i32* %4
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = load i32, i32* %4
%9 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7, i32 %8)
%10 = load i32, i32* %4
%11 = call i32 @foo(i32* %2, i32* %3, i32 %10)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %15, i32 %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [51 x i8] c"\1B[1;31mX=%d \1B[0m\1B[1;36m Y=%d \1B[0m\1B[1;35m Z=%d\1B[0m\0A\00"
@.str.1 = [25 x i8] c"\1B[1;32mAnswer is %d\1B[0m\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 7, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 8, i32* %2
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 7, i32 8, i32 9)
%6 = call i32 @foo(i32* %1, i32* %2, i32 9)
%7 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9, i32 9)
ret i32 0
}