#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 */
char EOF;
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, int *, int *, int *);
int main() {
  int a, b, c, largest, error;
  char ch;
  do {
    printf("Enter three numbers to find largest:");
    error = scanf("%d %d %d", &a, &b, &c);
    while ((ch = getchar()) != '\n' && ch != EOF)
      ;
  } while (error != 3);
  if (a > b) {
    if (a > c) {
      largest = a;
    } else {
      largest = c;
    }
  } else {
    if (b > c) {
      largest = b;
    } else {
      largest = c;
    }
  }
  printf("%d is the largest of %d,%d,%d.", largest, a, b, c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1050 <scanf@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x1a(%rbp)
je     1199 <main+0x69>
movsbl -0x19(%rbp),%eax
mov    0x2e5a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    11a9 <main+0x79>
jmp    11ae <main+0x7e>
jmp    1168 <main+0x38>
jmp    11b3 <main+0x83>
cmpl   $0x3,-0x18(%rbp)
jne    113f <main+0xf>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11eb <main+0xbb>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11e0 <main+0xb0>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11e6 <main+0xb6>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    120d <main+0xdd>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    1202 <main+0xd2>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1208 <main+0xd8>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    120d <main+0xdd>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xee0(%rip),%r15
lea    0x14(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0xc(%rsp),%rbx
mov    0x2e8d(%rip),%r14
jmp    1165 <main+0x35>
nopl   (%rax)
cmp    $0x3,%ebp
je     11a2 <main+0x72>
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
call   1050 <scanf@plt>
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     1160 <main+0x30>
cmp    (%r14),%al
jne    1190 <main+0x60>
jmp    1160 <main+0x30>
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
cmp    %ecx,%edx
mov    %ecx,%esi
cmovg  %edx,%esi
mov    0xc(%rsp),%r8d
cmp    %r8d,%esi
cmovle %r8d,%esi
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Enter three numbers to find largest:\00"
@.str.1 = [9 x i8] c"%d %d %d\00"
@EOF = global i8 0
@.str.2 = [31 x i8] c"%d is the largest of %d,%d,%d.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
store i32 0, i32* %1
br label %8
8: ; preds = %25, %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
store i32 %10, i32* %6
br label %11
11: ; preds = %23, %8
%12 = call signext i8 (...) @getchar()
store i8 %12, i8* %7
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br i1 %14, label %15, label %21
15: ; preds = %11
%16 = load i8, i8* %7
%17 = sext i8 %16 to i32
%18 = load i8, i8* @EOF
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %17, %19
br label %21
21: ; preds = %15, %11
%22 = phi i1 [ false, %11 ], [ %20, %15 ]
br i1 %22, label %23, label %24
23: ; preds = %21
br label %11
24: ; preds = %21
br label %25
25: ; preds = %24
%26 = load i32, i32* %6
%27 = icmp ne i32 %26, 3
br i1 %27, label %8, label %28
28: ; preds = %25
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = icmp sgt i32 %29, %30
br i1 %31, label %32, label %41
32: ; preds = %28
%33 = load i32, i32* %2
%34 = load i32, i32* %4
%35 = icmp sgt i32 %33, %34
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = load i32, i32* %2
store i32 %37, i32* %5
br label %40
38: ; preds = %32
%39 = load i32, i32* %4
store i32 %39, i32* %5
br label %40
40: ; preds = %38, %36
br label %50
41: ; preds = %28
%42 = load i32, i32* %3
%43 = load i32, i32* %4
%44 = icmp sgt i32 %42, %43
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = load i32, i32* %3
store i32 %46, i32* %5
br label %49
47: ; preds = %41
%48 = load i32, i32* %4
store i32 %48, i32* %5
br label %49
49: ; preds = %47, %45
br label %50
50: ; preds = %49, %40
%51 = load i32, i32* %5
%52 = load i32, i32* %2
%53 = load i32, i32* %3
%54 = load i32, i32* %4
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %51, i32 %52, i32 %53, i32 %54)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"Enter three numbers to find largest:\00"
@.str.1 = [9 x i8] c"%d %d %d\00"
@EOF = global i8 0
@.str.2 = [31 x i8] c"%d is the largest of %d,%d,%d.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
br label %7
7: ; preds = %16, %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
br label %10
10: ; preds = %10, %7
%11 = call signext i8 (...) @getchar()
%12 = icmp ne i8 %11, 10
%13 = load i8, i8* @EOF
%14 = icmp ne i8 %11, %13
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %10, label %16
16: ; preds = %10
%17 = icmp eq i32 %9, 3
br i1 %17, label %18, label %7
18: ; preds = %16
%19 = load i32, i32* %1
%20 = load i32, i32* %2
%21 = icmp sgt i32 %19, %20
%22 = load i32, i32* %3
%23 = select i1 %21, i32 %19, i32 %20
%24 = icmp sgt i32 %23, %22
%25 = select i1 %24, i32 %23, i32 %22
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 %19, i32 %20, i32 %22)
ret i32 0
}