#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*/ bi_cd(char *);
int /*<<< orphan*/ bi_exit(char *);
int /*<<< orphan*/ bi_fg(char *);
int /*<<< orphan*/ bi_jobs();
int /*<<< orphan*/ bi_pwd();
scalar_t__ strcmp(char *, char *);
int builtIn(char *args[]) {
  int result = 1;
  if (strcmp(args[1], "cd") == 0)
    bi_cd(args[2]);
  else if (strcmp(args[1], "pwd") == 0)
    bi_pwd();
  else if (strcmp(args[1], "exit") == 0)
    bi_exit(args[0]);
  else if (strcmp(args[1], "fg") == 0)
    bi_fg(args[2]);
  else if (strcmp(args[1], "jobs") == 0)
    bi_jobs();
  else
    result = 0;
  return result;
}


x86 assembly (clang, -O0):
<builtIn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7e(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11a3 <builtIn+0x43>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <bi_cd@plt>
jmp    1271 <builtIn+0x111>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe51(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11cd <builtIn+0x6d>
mov    $0x0,%al
call   1060 <bi_pwd@plt>
jmp    126c <builtIn+0x10c>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11fc <builtIn+0x9c>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <bi_exit@plt>
jmp    1267 <builtIn+0x107>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe01(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    122c <builtIn+0xcc>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <bi_fg@plt>
jmp    1262 <builtIn+0x102>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd4(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1256 <builtIn+0xf6>
mov    $0x0,%al
call   1050 <bi_jobs@plt>
jmp    125d <builtIn+0xfd>
movl   $0x0,-0xc(%rbp)
jmp    1262 <builtIn+0x102>
jmp    1267 <builtIn+0x107>
jmp    126c <builtIn+0x10c>
jmp    1271 <builtIn+0x111>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<builtIn>:
push   %rbx
mov    %rdi,%rbx
mov    0x8(%rdi),%rdi
lea    0xe91(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11d4 <builtIn+0x74>
mov    0x8(%rbx),%rdi
lea    0xe7f(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11df <builtIn+0x7f>
mov    0x8(%rbx),%rdi
lea    0xe6e(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11e8 <builtIn+0x88>
mov    0x8(%rbx),%rdi
lea    0xe5e(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11f2 <builtIn+0x92>
mov    0x8(%rbx),%rdi
lea    0xe4c(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     11fd <builtIn+0x9d>
pop    %rbx
ret
mov    0x10(%rbx),%rdi
call   1030 <bi_cd@plt>
jmp    1204 <builtIn+0xa4>
xor    %eax,%eax
call   1060 <bi_pwd@plt>
jmp    1204 <builtIn+0xa4>
mov    (%rbx),%rdi
call   1040 <bi_exit@plt>
jmp    1204 <builtIn+0xa4>
mov    0x10(%rbx),%rdi
call   1080 <bi_fg@plt>
jmp    1204 <builtIn+0xa4>
xor    %eax,%eax
call   1050 <bi_jobs@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"cd\00"
@.str.1 = [4 x i8] c"pwd\00"
@.str.2 = [5 x i8] c"exit\00"
@.str.3 = [3 x i8] c"fg\00"
@.str.4 = [5 x i8] c"jobs\00"
define i32 @builtIn(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
store i8** %0, i8*** %2
store i32 1, i32* %3
%4 = load i8**, i8*** %2
%5 = getelementptr inbounds i8*, i8** %4, i64 1
%6 = load i8*, i8** %5
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = load i8**, i8*** %2
%11 = getelementptr inbounds i8*, i8** %10, i64 2
%12 = load i8*, i8** %11
%13 = call i32 @bi_cd(i8* %12)
br label %57
14: ; preds = %1
%15 = load i8**, i8*** %2
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = call i32 (...) @bi_pwd()
br label %56
22: ; preds = %14
%23 = load i8**, i8*** %2
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %22
%29 = load i8**, i8*** %2
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = call i32 @bi_exit(i8* %31)
br label %55
33: ; preds = %22
%34 = load i8**, i8*** %2
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %33
%40 = load i8**, i8*** %2
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32 @bi_fg(i8* %42)
br label %54
44: ; preds = %33
%45 = load i8**, i8*** %2
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %44
%51 = call i32 (...) @bi_jobs()
br label %53
52: ; preds = %44
store i32 0, i32* %3
br label %53
53: ; preds = %52, %50
br label %54
54: ; preds = %53, %39
br label %55
55: ; preds = %54, %28
br label %56
56: ; preds = %55, %20
br label %57
57: ; preds = %56, %9
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@.str = [3 x i8] c"cd\00"
@.str.1 = [4 x i8] c"pwd\00"
@.str.2 = [5 x i8] c"exit\00"
@.str.3 = [3 x i8] c"fg\00"
@.str.4 = [5 x i8] c"jobs\00"
define i32 @builtIn(i8** nocapture %0) {
%2 = getelementptr inbounds i8*, i8** %0, i64 1
%3 = load i8*, i8** %2
%4 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = getelementptr inbounds i8*, i8** %0, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32 @bi_cd(i8* %8)
br label %37
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 (...) @bi_pwd()
br label %37
16: ; preds = %10
%17 = load i8*, i8** %2
%18 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i8*, i8** %0
%22 = tail call i32 @bi_exit(i8* %21)
br label %37
23: ; preds = %16
%24 = load i8*, i8** %2
%25 = tail call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = getelementptr inbounds i8*, i8** %0, i64 2
%29 = load i8*, i8** %28
%30 = tail call i32 @bi_fg(i8* %29)
br label %37
31: ; preds = %23
%32 = load i8*, i8** %2
%33 = tail call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = tail call i32 (...) @bi_jobs()
br label %37
37: ; preds = %31, %14, %27, %35, %20, %6
%38 = phi i32 [ 1, %6 ], [ 1, %14 ], [ 1, %20 ], [ 1, %27 ], [ 1, %35 ], [ 0, %31 ]
ret i32 %38
}