#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(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int strtol(char *, char **, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int ecode = 0;
  if ((0 == strcmp(argv[0], "exit")) && argc != 1) {
    char *eptr;
    ecode = strtol(argv[1], &eptr, 0);
    if (*eptr != '\0') {
      ecode = 255;
      fprintf(stderr, "exit: exit code should be numerical value\n");
    }
  }
  exit(ecode);
}


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)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe95(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11cf <main+0x8f>
cmpl   $0x1,-0x8(%rbp)
je     11cf <main+0x8f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ca <main+0x8a>
movl   $0xff,-0x14(%rbp)
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11cf <main+0x8f>
mov    -0x14(%rbp),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rdi
lea    0xeae(%rip),%rsi
call   1030 <strcmp@plt>
xor    %edi,%edi
cmp    $0x1,%ebp
je     1196 <main+0x56>
test   %rax,%rax
jne    1196 <main+0x56>
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,%edi
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     1196 <main+0x56>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
lea    0xe79(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"exit\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"exit: exit code should be numerical value\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 0, %11
br i1 %12, label %13, label %29
13: ; preds = %2
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %29
16: ; preds = %13
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @strtol(i8* %19, i8** %7, i32 0)
store i32 %20, i32* %6
%21 = load i8*, i8** %7
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %16
store i32 255, i32* %6
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %25, %16
br label %29
29: ; preds = %28, %13, %2
%30 = load i32, i32* %6
%31 = call i32 @exit(i32 %30)
unreachable
}

LLVM IR (-O2):
@.str = [5 x i8] c"exit\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"exit: exit code should be numerical value\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = load i8*, i8** %1
%5 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
%7 = icmp ne i32 %0, 1
%8 = and i1 %7, %6
br i1 %8, label %9, label %22
9: ; preds = %2
%10 = bitcast i8** %3 to i8*
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @strtol(i8* %12, i8** %3, i32 0)
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %9
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %17, %9
%21 = phi i32 [ 255, %17 ], [ %13, %9 ]
br label %22
22: ; preds = %20, %2
%23 = phi i32 [ %21, %20 ], [ 0, %2 ]
%24 = tail call i32 @exit(i32 %23)
unreachable
}