#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 larger(int, int);
int /*<<< orphan*/ printf(char *, ...);
int upper(char);
int main() {
  int x = 5, y = 10, z = 2;
  int bigger;
  char f = 'f', ch1, ch2;
  printf("Function Example 6\n\n");
  bigger = larger(x, y);
  printf("bigger=%d\n", bigger);
  printf("Larger of 20 and 15: %d\n", larger(20, 15));
  bigger = larger(x, larger(y, z));
  printf("Larger of x, y, z: %d", bigger);
  printf("Larger of 1, 2, 6, and 4: %d\n\n",
         larger(larger(1, 2), larger(6, 4)));
  ch1 = upper('a');
  ch2 = upper('d');
  printf("upper: %c %c %c\n\n", ch2, upper(f), upper('@'));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
movb   $0x66,-0x15(%rbp)
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <larger@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x14,%edi
mov    $0xf,%esi
call   1050 <larger@plt>
mov    %eax,%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <larger@plt>
mov    -0x28(%rbp),%edi
mov    %eax,%esi
call   1050 <larger@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
mov    $0x2,%esi
call   1050 <larger@plt>
mov    %eax,-0x24(%rbp)
mov    $0x6,%edi
mov    $0x4,%esi
call   1050 <larger@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%esi
call   1050 <larger@plt>
mov    %eax,%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x61,%edi
call   1040 <upper@plt>
mov    %al,-0x16(%rbp)
mov    $0x64,%edi
call   1040 <upper@plt>
mov    %al,-0x17(%rbp)
movsbl -0x17(%rbp),%eax
mov    %eax,-0x20(%rbp)
movsbl -0x15(%rbp),%edi
call   1040 <upper@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x40,%edi
call   1040 <upper@plt>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    %eax,%ecx
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xf21(%rip),%rdi
call   1030 <puts@plt>
mov    $0x5,%edi
mov    $0xa,%esi
call   1060 <larger@plt>
lea    0xe9b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x14,%edi
mov    $0xf,%esi
call   1060 <larger@plt>
lea    0xe87(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
mov    $0x2,%esi
call   1060 <larger@plt>
mov    $0x5,%edi
mov    %eax,%esi
call   1060 <larger@plt>
lea    0xe75(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
mov    $0x2,%esi
call   1060 <larger@plt>
mov    %eax,%ebx
mov    $0x6,%edi
mov    $0x4,%esi
call   1060 <larger@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1060 <larger@plt>
lea    0xe52(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x61,%edi
call   1050 <upper@plt>
mov    $0x64,%edi
call   1050 <upper@plt>
movsbl %al,%ebx
mov    $0x66,%edi
call   1050 <upper@plt>
mov    %eax,%ebp
mov    $0x40,%edi
call   1050 <upper@plt>
lea    0xe34(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Function Example 6\0A\0A\00"
@.str.1 = [11 x i8] c"bigger=%d\0A\00"
@.str.2 = [25 x i8] c"Larger of 20 and 15: %d\0A\00"
@.str.3 = [22 x i8] c"Larger of x, y, z: %d\00"
@.str.4 = [31 x i8] c"Larger of 1, 2, 6, and 4: %d\0A\0A\00"
@.str.5 = [18 x i8] c"upper: %c %c %c\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
store i32 0, i32* %1
store i32 5, i32* %2
store i32 10, i32* %3
store i32 2, i32* %4
store i8 102, i8* %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = call i32 @larger(i32 %10, i32 %11)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = call i32 @larger(i32 20, i32 15)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = call i32 @larger(i32 %18, i32 %19)
%21 = call i32 @larger(i32 %17, i32 %20)
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = call i32 @larger(i32 1, i32 2)
%25 = call i32 @larger(i32 6, i32 4)
%26 = call i32 @larger(i32 %24, i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = call i32 @upper(i8 signext 97)
%29 = trunc i32 %28 to i8
store i8 %29, i8* %7
%30 = call i32 @upper(i8 signext 100)
%31 = trunc i32 %30 to i8
store i8 %31, i8* %8
%32 = load i8, i8* %8
%33 = sext i8 %32 to i32
%34 = load i8, i8* %6
%35 = call i32 @upper(i8 signext %34)
%36 = call i32 @upper(i8 signext 64)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %33, i32 %35, i32 %36)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"bigger=%d\0A\00"
@.str.2 = [25 x i8] c"Larger of 20 and 15: %d\0A\00"
@.str.3 = [22 x i8] c"Larger of x, y, z: %d\00"
@.str.4 = [31 x i8] c"Larger of 1, 2, 6, and 4: %d\0A\0A\00"
@.str.5 = [18 x i8] c"upper: %c %c %c\0A\0A\00"
@str = [20 x i8] c"Function Example 6\0A\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @larger(i32 5, i32 10)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%4 = tail call i32 @larger(i32 20, i32 15)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%6 = tail call i32 @larger(i32 10, i32 2)
%7 = tail call i32 @larger(i32 5, i32 %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = tail call i32 @larger(i32 1, i32 2)
%10 = tail call i32 @larger(i32 6, i32 4)
%11 = tail call i32 @larger(i32 %9, i32 %10)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %11)
%13 = tail call i32 @upper(i8 signext 97)
%14 = tail call i32 @upper(i8 signext 100)
%15 = shl i32 %14, 24
%16 = ashr exact i32 %15, 24
%17 = tail call i32 @upper(i8 signext 102)
%18 = tail call i32 @upper(i8 signext 64)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %16, i32 %17, i32 %18)
ret i32 0
}