#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*/ call_exit(char **);
int /*<<< orphan*/ call_history(char **);
scalar_t__ strcmp(char *, char *);
int do_builtin(char **shArgs) {
  int isBuiltIn = 0;
  if (strcmp("exit", shArgs[0]) == 0) {
    isBuiltIn = 1;
    call_exit(shArgs);
  } else if (strcmp("history", shArgs[0]) == 0) {
    isBuiltIn = 1;
    call_history(shArgs);
  }
  return isBuiltIn;
}


x86 assembly (clang, -O0):
<do_builtin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xeaf(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1175 <do_builtin+0x45>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <call_exit@plt>
jmp    11a7 <do_builtin+0x77>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xe82(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a2 <do_builtin+0x72>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <call_history@plt>
jmp    11a7 <do_builtin+0x77>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_builtin>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rsi
lea    0xec2(%rip),%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1163 <do_builtin+0x33>
mov    (%rbx),%rsi
lea    0xeb3(%rip),%rdi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     116d <do_builtin+0x3d>
pop    %rbx
ret
mov    %rbx,%rdi
call   1050 <call_exit@plt>
jmp    1175 <do_builtin+0x45>
mov    %rbx,%rdi
call   1040 <call_history@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"exit\00"
@.str.1 = [8 x i8] c"history\00"
define i32 @do_builtin(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
store i8** %0, i8*** %2
store i32 0, i32* %3
%4 = load i8**, i8*** %2
%5 = getelementptr inbounds i8*, i8** %4, i64 0
%6 = load i8*, i8** %5
%7 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
store i32 1, i32* %3
%10 = load i8**, i8*** %2
%11 = call i32 @call_exit(i8** %10)
br label %22
12: ; preds = %1
%13 = load i8**, i8*** %2
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %12
store i32 1, i32* %3
%19 = load i8**, i8*** %2
%20 = call i32 @call_history(i8** %19)
br label %21
21: ; preds = %18, %12
br label %22
22: ; preds = %21, %9
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str = [5 x i8] c"exit\00"
@.str.1 = [8 x i8] c"history\00"
define i32 @do_builtin(i8** %0) {
%2 = load i8*, i8** %0
%3 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @call_exit(i8** %0)
br label %13
7: ; preds = %1
%8 = load i8*, i8** %0
%9 = tail call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @call_history(i8** %0)
br label %13
13: ; preds = %7, %11, %5
%14 = phi i32 [ 1, %5 ], [ 1, %11 ], [ 0, %7 ]
ret i32 %14
}