#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 */
struct exitinfo {
  int dummy;
};

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ exitinfo_exit(struct exitinfo *, int);
int /*<<< orphan*/ printf(char *);
void cmd_exit(int ac, char *av[], struct exitinfo *ei) {
  int code;
  if (ac == 1) {
    code = 0;
  } else if (ac == 2) {
    code = atoi(av[1]);
  } else {
    printf("Usage: exit [code]\n");
    exitinfo_exit(ei, 1);
    return;
  }
  exit(code);
}


x86 assembly (clang, -O0):
<cmd_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1169 <cmd_exit+0x29>
movl   $0x0,-0x1c(%rbp)
jmp    11ad <cmd_exit+0x6d>
cmpl   $0x2,-0x4(%rbp)
jne    1188 <cmd_exit+0x48>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    11a8 <cmd_exit+0x68>
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   1040 <exitinfo_exit@plt>
add    $0x20,%rsp
pop    %rbp
ret
jmp    11ad <cmd_exit+0x6d>
mov    -0x1c(%rbp),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<cmd_exit>:
push   %rbx
cmp    $0x1,%edi
je     1168 <cmd_exit+0x28>
cmp    $0x2,%edi
je     116f <cmd_exit+0x2f>
mov    %rdx,%rbx
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
pop    %rbx
jmp    1040 <exitinfo_exit@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.exitinfo = type { i32 }
@.str = [20 x i8] c"Usage: exit [code]\0A\00"
define void @cmd_exit(i32 %0, i8** %1, %struct.exitinfo* %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.exitinfo*
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.exitinfo* %2, %struct.exitinfo** %6
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %11
10: ; preds = %3
store i32 0, i32* %7
br label %24
11: ; preds = %3
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %7
br label %23
19: ; preds = %11
%20 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%21 = load %struct.exitinfo*, %struct.exitinfo** %6
%22 = call i32 @exitinfo_exit(%struct.exitinfo* %21, i32 1)
ret void
23: ; preds = %14
br label %24
24: ; preds = %23, %10
%25 = load i32, i32* %7
%26 = call i32 @exit(i32 %25)
unreachable
}

LLVM IR (-O2):
%struct.exitinfo = type { i32 }
@str = [19 x i8] c"Usage: exit [code]\00"
define void @cmd_exit(i32 %0, i8** nocapture %1, %struct.exitinfo* %2) {
switch i32 %0, label %8 [
i32 1, label %11
i32 2, label %4
]
4: ; preds = %3
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
br label %11
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @exitinfo_exit(%struct.exitinfo* %2, i32 1)
ret void
11: ; preds = %3, %4
%12 = phi i32 [ %7, %4 ], [ 0, %3 ]
%13 = tail call i32 @exit(i32 %12)
unreachable
}