#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_usage();
int /*<<< orphan*/ exit(int);
int strtol(char *, char **, int);
int builtin_exit(int argc, char *argv[]) {
  int status = 0;
  char *p;
  if (argc > 2)
    return _exit_usage();
  if (argc == 2) {
    status = strtol(argv[1], &p, 10);
    if (*(argv[1]) == '\0' || *p != '\0' || status < 0 || status > 255)
      return _exit_usage();
  }
  exit(status);
  return 0;
}


x86 assembly (clang, -O0):
<builtin_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    115f <builtin_exit+0x2f>
mov    $0x0,%al
call   1030 <_exit_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    11d9 <builtin_exit+0xa9>
cmpl   $0x2,-0x8(%rbp)
jne    11d1 <builtin_exit+0xa1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11bd <builtin_exit+0x8d>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11bd <builtin_exit+0x8d>
cmpl   $0x0,-0x14(%rbp)
jl     11bd <builtin_exit+0x8d>
cmpl   $0xff,-0x14(%rbp)
jle    11cc <builtin_exit+0x9c>
mov    $0x0,%al
call   1030 <_exit_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    11d9 <builtin_exit+0xa9>
jmp    11d1 <builtin_exit+0xa1>
mov    -0x14(%rbp),%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<builtin_exit>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jg     1170 <builtin_exit+0x40>
jne    117c <builtin_exit+0x4c>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    0x8(%rbx),%rcx
cmpb   $0x0,(%rcx)
je     1170 <builtin_exit+0x40>
mov    0x8(%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    1170 <builtin_exit+0x40>
test   %eax,%eax
js     1170 <builtin_exit+0x40>
cmp    $0xff,%eax
jle    1183 <builtin_exit+0x53>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
jmp    1030 <_exit_usage@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    %eax,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
define i32 @builtin_exit(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (...) @_exit_usage()
store i32 %11, i32* %3
br label %43
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %40
15: ; preds = %12
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strtol(i8* %18, i8** %7, i32 10)
store i32 %19, i32* %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 0
br i1 %25, label %37, label %26
26: ; preds = %15
%27 = load i8*, i8** %7
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %37, label %31
31: ; preds = %26
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = load i32, i32* %6
%36 = icmp sgt i32 %35, 255
br i1 %36, label %37, label %39
37: ; preds = %34, %31, %26, %15
%38 = call i32 (...) @_exit_usage()
store i32 %38, i32* %3
br label %43
39: ; preds = %34
br label %40
40: ; preds = %39, %12
%41 = load i32, i32* %6
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %37, %10
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
define i32 @builtin_exit(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp sgt i32 %0, 2
br i1 %5, label %26, label %6
6: ; preds = %2
%7 = icmp eq i32 %0, 2
br i1 %7, label %8, label %23
8: ; preds = %6
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @strtol(i8* %10, i8** %3, i32 10)
%12 = load i8*, i8** %9
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %26, label %15
15: ; preds = %8
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
%19 = icmp slt i32 %11, 0
%20 = select i1 %18, i1 true, i1 %19
%21 = icmp sgt i32 %11, 255
%22 = select i1 %20, i1 true, i1 %21
br i1 %22, label %26, label %23
23: ; preds = %15, %6
%24 = phi i32 [ %11, %15 ], [ 0, %6 ]
%25 = tail call i32 @exit(i32 %24)
unreachable
26: ; preds = %8, %15, %2
%27 = tail call i32 (...) @_exit_usage()
ret i32 %27
}