#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, int *);
int main(int argc, char *argv[]) {
  int exitStatus = 0;
  if (argc < 2 || sscanf(argv[1], "%d\n", &exitStatus) != 1) {
    printf("Usage: %s exitStatus    - where exitStatus is an integer\n",
           argv[0]);
    printf("Returning %d\n", 1);
    return 1;
  }
  printf("EXIT_SUCCESS is %d\n", EXIT_SUCCESS);
  printf("EXIT_FAILURE is %d\n", EXIT_FAILURE);
  printf("Returning %d\n", exitStatus);
  printf(
      "If you are using a bash-like shell, try running 'echo $?' immediately "
      "after you run this program to see the actual return value.\n");
  return exitStatus;
}


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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1168 <main+0x48>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeee(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     119c <main+0x7c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ef <main+0xcf>
mov    0x2e35(%rip),%rax
mov    (%rax),%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
movl   $0x0,0xc(%rsp)
cmp    $0x2,%edi
jl     11b1 <main+0x81>
mov    0x8(%rbx),%rdi
lea    0xef4(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    11b1 <main+0x81>
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
lea    0xed9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
lea    0xed6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%ebx
jmp    11da <main+0xaa>
mov    (%rbx),%rsi
lea    0xe45(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe71(%rip),%rdi
mov    $0x1,%ebx
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [58 x i8] c"Usage: %s exitStatus - where exitStatus is an integer\0A\00"
@.str.2 = [14 x i8] c"Returning %d\0A\00"
@.str.3 = [20 x i8] c"EXIT_SUCCESS is %d\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.4 = [20 x i8] c"EXIT_FAILURE is %d\0A\00"
@EXIT_FAILURE = global i32 0
@.str.5 = [130 x i8] c"If you are using a bash-like shell, try running 'echo $?' immediately after you run this program to see the actual return value.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %15, label %9
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %6)
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %21
15: ; preds = %9, %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 1)
store i32 1, i32* %3
br label %30
21: ; preds = %9
%22 = load i32, i32* @EXIT_SUCCESS
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %6
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.5, i64 0, i64 0))
%29 = load i32, i32* %6
store i32 %29, i32* %3
br label %30
30: ; preds = %21, %15
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [58 x i8] c"Usage: %s exitStatus - where exitStatus is an integer\0A\00"
@.str.2 = [14 x i8] c"Returning %d\0A\00"
@.str.3 = [20 x i8] c"EXIT_SUCCESS is %d\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.4 = [20 x i8] c"EXIT_FAILURE is %d\0A\00"
@EXIT_FAILURE = global i32 0
@str = [129 x i8] c"If you are using a bash-like shell, try running 'echo $?' immediately after you run this program to see the actual return value.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = icmp slt i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = icmp eq i32 %9, 1
br i1 %10, label %15, label %11
11: ; preds = %6, %2
%12 = load i8*, i8** %1
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %24
15: ; preds = %6
%16 = load i32, i32* @EXIT_SUCCESS
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %3
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([129 x i8], [129 x i8]* @str, i64 0, i64 0))
%23 = load i32, i32* %3
br label %24
24: ; preds = %15, %11
%25 = phi i32 [ 1, %11 ], [ %23, %15 ]
ret i32 %25
}