#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 */
typedef int /*<<< orphan*/ time_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ ftsh_error(int, int, char *, int);
int sscanf(char *, char *, int *);
int builtin_exit(int line, int argc, char **argv, time_t stoptime) {
  int value;
  if (argc < 2) {
    value = 0;
  } else {
    if (sscanf(argv[1], "%d", &value) != 1) {
      value = 1;
    }
  }
  ftsh_error(30, line, "exit: exiting with status %d", value);
  exit(value);
}


x86 assembly (clang, -O0):
<builtin_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    115b <builtin_exit+0x2b>
movl   $0x0,-0x18(%rbp)
jmp    1188 <builtin_exit+0x58>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeb0(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <sscanf@plt>
cmp    $0x1,%eax
je     1183 <builtin_exit+0x53>
movl   $0x1,-0x18(%rbp)
jmp    1188 <builtin_exit+0x58>
mov    -0x4(%rbp),%esi
mov    -0x18(%rbp),%ecx
mov    $0x1e,%edi
lea    0xe66(%rip),%rdx
call   1040 <ftsh_error@plt>
mov    -0x18(%rbp),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<builtin_exit>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
cmp    $0x1,%esi
jg     1148 <builtin_exit+0x18>
movl   $0x0,0xc(%rsp)
xor    %ecx,%ecx
jmp    1175 <builtin_exit+0x45>
mov    0x8(%rdx),%rdi
lea    0xec7(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1030 <sscanf@plt>
cmp    $0x1,%eax
jne    1168 <builtin_exit+0x38>
mov    0xc(%rsp),%ecx
jmp    1175 <builtin_exit+0x45>
movl   $0x1,0xc(%rsp)
mov    $0x1,%ecx
lea    0xe84(%rip),%rdx
mov    $0x1e,%edi
mov    %ebx,%esi
call   1040 <ftsh_error@plt>
mov    0xc(%rsp),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [29 x i8] c"exit: exiting with status %d\00"
define i32 @builtin_exit(i32 %0, i32 %1, i8** %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i32 %3, i32* %8
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %4
store i32 0, i32* %9
br label %21
13: ; preds = %4
%14 = load i8**, i8*** %7
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%18 = icmp ne i32 %17, 1
br i1 %18, label %19, label %20
19: ; preds = %13
store i32 1, i32* %9
br label %20
20: ; preds = %19, %13
br label %21
21: ; preds = %20, %12
%22 = load i32, i32* %5
%23 = load i32, i32* %9
%24 = call i32 @ftsh_error(i32 30, i32 %22, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %9
%26 = call i32 @exit(i32 %25)
unreachable
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [29 x i8] c"exit: exiting with status %d\00"
define i32 @builtin_exit(i32 %0, i32 %1, i8** nocapture %2, i32 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = icmp slt i32 %1, 2
br i1 %7, label %8, label %9
8: ; preds = %4
store i32 0, i32* %5
br label %17
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %2, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = load i32, i32* %5
br label %17
16: ; preds = %9
store i32 1, i32* %5
br label %17
17: ; preds = %14, %16, %8
%18 = phi i32 [ %15, %14 ], [ 1, %16 ], [ 0, %8 ]
%19 = call i32 @ftsh_error(i32 30, i32 %0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %5
%21 = call i32 @exit(i32 %20)
unreachable
}