#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*/ cd(char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char *get_current_dir_name();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
void runBuiltin(char **args) {
  if (!strcmp(args[0], "cd"))
    cd(args);
  if (!strcmp(args[0], "exit"))
    exit(0);
  if (!strcmp(args[0], "pwd"))
    printf("%s\n", get_current_dir_name());
}


x86 assembly (clang, -O0):
<runBuiltin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    0xe96(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1181 <runBuiltin+0x31>
mov    -0x8(%rbp),%rdi
call   1030 <cd@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    0xe74(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11a4 <runBuiltin+0x54>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    0xe56(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11d6 <runBuiltin+0x86>
mov    $0x0,%al
call   1060 <get_current_dir_name@plt>
mov    %rax,%rsi
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runBuiltin>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%rbx
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    1178 <runBuiltin+0x28>
mov    %r14,%rdi
call   1030 <cd@plt>
mov    (%r14),%rbx
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11c3 <runBuiltin+0x73>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11a6 <runBuiltin+0x56>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
call   1060 <get_current_dir_name@plt>
lea    0xe58(%rip),%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"cd\00"
@.str.1 = [5 x i8] c"exit\00"
@.str.2 = [4 x i8] c"pwd\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define void @runBuiltin(i8** %0) {
%2 = load i8*, i8** %0
%3 = tail call i32 @strcmp(i8* dereferenceable(1) %2, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i32 @cd(i8** %0)
%7 = load i8*, i8** %0
br label %8
8: ; preds = %5, %1
%9 = phi i8* [ %7, %5 ], [ %2, %1 ]
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32 @exit(i32 0)
unreachable
14: ; preds = %8
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = tail call i8* (...) @get_current_dir_name()
%19 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %17, %14
ret void
}