#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 4) {
    fprintf(stderr,
            "%s Expected 3 arguments, but instead received %d arguments\n",
            argv[0], argc - 1);
    exit(EXIT_FAILURE);
  } else {
    int arg1 = atoi(argv[1]);
    int arg2 = atoi(argv[2]);
    int arg3 = atoi(argv[3]);
    if (arg1 >= arg2 && arg1 >= arg3) {
      printf("Max is arg 1 with value %d", arg1);
    } else if (arg2 >= arg1 && arg2 >= arg3) {
      printf("Max is arg 2 with value %d", arg2);
    } else {
      printf("Max is arg 3 with value %d", arg3);
    }
    exit(EXIT_SUCCESS);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1190 <main+0x50>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
lea    0xe83(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jl     11ec <main+0xac>
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     11ec <main+0xac>
mov    -0x14(%rbp),%esi
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
jmp    122c <main+0xec>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     1218 <main+0xd8>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     1218 <main+0xd8>
mov    -0x18(%rbp),%esi
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
jmp    1227 <main+0xe7>
mov    -0x1c(%rbp),%esi
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
jmp    122c <main+0xec>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbp
cmp    $0x4,%edi
jne    1182 <main+0x42>
mov    0x8(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    0x18(%rbp),%rdi
call   1050 <atoi@plt>
cmp    %ebx,%r14d
jl     11ae <main+0x6e>
cmp    %eax,%r14d
jl     11ae <main+0x6e>
lea    0xebf(%rip),%rdi
mov    %r14d,%ebx
jmp    11d0 <main+0x90>
mov    %edi,%ecx
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
add    $0xffffffff,%ecx
lea    0xe65(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
cmp    %r14d,%ebx
setl   %cl
cmp    %eax,%ebx
setl   %dl
or     %cl,%dl
cmovne %eax,%ebx
lea    0xead(%rip),%rax
lea    0xe8b(%rip),%rdi
cmovne %rax,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [60 x i8] c"%s Expected 3 arguments, but instead received %d arguments\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [27 x i8] c"Max is arg 1 with value %d\00"
@.str.2 = [27 x i8] c"Max is arg 2 with value %d\00"
@.str.3 = [27 x i8] c"Max is arg 3 with value %d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 4
br i1 %10, label %11, label %21
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 1
%18 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8* %15, i32 %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %6
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %7
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %8
%34 = load i32, i32* %6
%35 = load i32, i32* %7
%36 = icmp sge i32 %34, %35
br i1 %36, label %37, label %44
37: ; preds = %21
%38 = load i32, i32* %6
%39 = load i32, i32* %8
%40 = icmp sge i32 %38, %39
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i32, i32* %6
%43 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %42)
br label %59
44: ; preds = %37, %21
%45 = load i32, i32* %7
%46 = load i32, i32* %6
%47 = icmp sge i32 %45, %46
br i1 %47, label %48, label %55
48: ; preds = %44
%49 = load i32, i32* %7
%50 = load i32, i32* %8
%51 = icmp sge i32 %49, %50
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = load i32, i32* %7
%54 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %53)
br label %58
55: ; preds = %48, %44
%56 = load i32, i32* %8
%57 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %55, %52
br label %59
59: ; preds = %58, %41
%60 = load i32, i32* @EXIT_SUCCESS
%61 = call i32 @exit(i32 %60)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [60 x i8] c"%s Expected 3 arguments, but instead received %d arguments\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [27 x i8] c"Max is arg 1 with value %d\00"
@.str.2 = [27 x i8] c"Max is arg 2 with value %d\00"
@.str.3 = [27 x i8] c"Max is arg 3 with value %d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = add nsw i32 %0, -1
%8 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8* %6, i32 %7)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 3
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
%21 = icmp slt i32 %14, %17
%22 = icmp slt i32 %14, %20
%23 = select i1 %21, i1 true, i1 %22
br i1 %23, label %24, label %30
24: ; preds = %11
%25 = icmp slt i32 %17, %14
%26 = icmp slt i32 %17, %20
%27 = select i1 %25, i1 true, i1 %26
%28 = select i1 %27, i32 %20, i32 %17
%29 = select i1 %27, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0)
br label %30
30: ; preds = %24, %11
%31 = phi i32 [ %14, %11 ], [ %28, %24 ]
%32 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), %11 ], [ %29, %24 ]
%33 = tail call i32 @printf(i8* %32, i32 %31)
%34 = load i32, i32* @EXIT_SUCCESS
%35 = tail call i32 @exit(i32 %34)
unreachable
}