#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*/ history_add(char *);
int /*<<< orphan*/ history_dump();
int /*<<< orphan*/ run(char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int builtin(char *command) {
  if (strlen(command) < 1) {
    return 0;
  } else if (strcmp(command, "exit") == 0) {
    return -1;
  } else if (strcmp(command, "history") == 0) {
    history_dump();
    return 0;
  } else {
    run(command);
    history_add(command);
    return 0;
  }
}


x86 assembly (clang, -O0):
<builtin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x1,%eax
jge    117a <builtin+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11e6 <builtin+0x96>
mov    -0x10(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11a0 <builtin+0x50>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e6 <builtin+0x96>
mov    -0x10(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11cd <builtin+0x7d>
mov    $0x0,%al
call   1030 <history_dump@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e6 <builtin+0x96>
mov    -0x10(%rbp),%rdi
call   1040 <run@plt>
mov    -0x10(%rbp),%rdi
call   1070 <history_add@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<builtin>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <strlen@plt>
xor    %ebp,%ebp
test   %eax,%eax
jle    11ab <builtin+0x5b>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     119b <builtin+0x4b>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11a2 <builtin+0x52>
mov    %rbx,%rdi
call   1040 <run@plt>
mov    %rbx,%rdi
call   1070 <history_add@plt>
jmp    11ab <builtin+0x5b>
mov    $0xffffffff,%ebp
jmp    11ab <builtin+0x5b>
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <history_dump@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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