#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*/ b_cd(char *);
int /*<<< orphan*/ b_clr();
int /*<<< orphan*/ b_dir(char *);
int /*<<< orphan*/ b_echo(int, char **);
int /*<<< orphan*/ b_env();
int /*<<< orphan*/ b_help();
int /*<<< orphan*/ b_pwd();
int /*<<< orphan*/ b_quit();
int /*<<< orphan*/ strcmp(char *, char *);
int buildin(int arg_c, char arg[][100 + 1]) {
  if (!strcmp(arg[0], "cd")) {
    if (arg_c)
      b_cd(arg[1]);
    else
      b_pwd();
    return 1;
  }
  if (!strcmp(arg[0], "pwd")) {
    b_pwd();
    return 1;
  }
  if (!strcmp(arg[0], "clr")) {
    b_clr();
    return 1;
  }
  if (!strcmp(arg[0], "dir")) {
    if (arg_c > 0)
      b_dir(arg[1]);
    else
      b_dir(".");
    return 1;
  }
  if (!strcmp(arg[0], "echo")) {
    b_echo(arg_c, arg);
    return 1;
  }
  if (!strcmp(arg[0], "help")) {
    b_help();
    return 1;
  }
  if (!strcmp(arg[0], "quit")) {
    b_quit();
    return 1;
  }
  if (!strcmp(arg[0], "environ")) {
    b_env();
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<buildin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    11e7 <buildin+0x57>
cmpl   $0x0,-0x8(%rbp)
je     11d4 <buildin+0x44>
mov    -0x10(%rbp),%rdi
add    $0x65,%rdi
call   1090 <b_cd@plt>
jmp    11db <buildin+0x4b>
mov    $0x0,%al
call   1050 <b_pwd@plt>
movl   $0x1,-0x4(%rbp)
jmp    1348 <buildin+0x1b8>
mov    -0x10(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1213 <buildin+0x83>
mov    $0x0,%al
call   1050 <b_pwd@plt>
movl   $0x1,-0x4(%rbp)
jmp    1348 <buildin+0x1b8>
mov    -0x10(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    123f <buildin+0xaf>
mov    $0x0,%al
call   10b0 <b_clr@plt>
movl   $0x1,-0x4(%rbp)
jmp    1348 <buildin+0x1b8>
mov    -0x10(%rbp),%rdi
lea    0xdc1(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    128c <buildin+0xfc>
cmpl   $0x0,-0x8(%rbp)
jle    1274 <buildin+0xe4>
mov    -0x10(%rbp),%rdi
add    $0x65,%rdi
call   10a0 <b_dir@plt>
jmp    1280 <buildin+0xf0>
lea    0xd94(%rip),%rdi
call   10a0 <b_dir@plt>
movl   $0x1,-0x4(%rbp)
jmp    1348 <buildin+0x1b8>
mov    -0x10(%rbp),%rdi
lea    0xd7a(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    12bd <buildin+0x12d>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <b_echo@plt>
movl   $0x1,-0x4(%rbp)
jmp    1348 <buildin+0x1b8>
mov    -0x10(%rbp),%rdi
lea    0xd4e(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    12e9 <buildin+0x159>
mov    $0x0,%al
call   1060 <b_help@plt>
movl   $0x1,-0x4(%rbp)
jmp    1348 <buildin+0x1b8>
mov    -0x10(%rbp),%rdi
lea    0xd27(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1315 <buildin+0x185>
mov    $0x0,%al
call   1070 <b_quit@plt>
movl   $0x1,-0x4(%rbp)
jmp    1348 <buildin+0x1b8>
mov    -0x10(%rbp),%rdi
lea    0xd00(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1341 <buildin+0x1b1>
mov    $0x0,%al
call   1030 <b_env@plt>
movl   $0x1,-0x4(%rbp)
jmp    1348 <buildin+0x1b8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buildin>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe61(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1249 <buildin+0xb9>
lea    0xe4d(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     125b <buildin+0xcb>
lea    0xe3a(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1264 <buildin+0xd4>
lea    0xe27(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     126d <buildin+0xdd>
lea    0xe1a(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     127f <buildin+0xef>
lea    0xe0c(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     128b <buildin+0xfb>
lea    0xdfe(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     12a2 <buildin+0x112>
lea    0xdf0(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    12ae <buildin+0x11e>
xor    %eax,%eax
call   1030 <b_env@plt>
jmp    12a9 <buildin+0x119>
test   %ebp,%ebp
je     125b <buildin+0xcb>
add    $0x65,%rbx
mov    %rbx,%rdi
call   1090 <b_cd@plt>
jmp    12a9 <buildin+0x119>
xor    %eax,%eax
call   1050 <b_pwd@plt>
jmp    12a9 <buildin+0x119>
xor    %eax,%eax
call   10b0 <b_clr@plt>
jmp    12a9 <buildin+0x119>
test   %ebp,%ebp
jle    1294 <buildin+0x104>
add    $0x65,%rbx
mov    %rbx,%rdi
call   10a0 <b_dir@plt>
jmp    12a9 <buildin+0x119>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <b_echo@plt>
jmp    12a9 <buildin+0x119>
xor    %eax,%eax
call   1060 <b_help@plt>
jmp    12a9 <buildin+0x119>
lea    0xd74(%rip),%rdi
call   10a0 <b_dir@plt>
jmp    12a9 <buildin+0x119>
xor    %eax,%eax
call   1070 <b_quit@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"cd\00"
@.str.1 = [4 x i8] c"pwd\00"
@.str.2 = [4 x i8] c"clr\00"
@.str.3 = [4 x i8] c"dir\00"
@.str.4 = [2 x i8] c".\00"
@.str.5 = [5 x i8] c"echo\00"
@.str.6 = [5 x i8] c"help\00"
@.str.7 = [5 x i8] c"quit\00"
@.str.8 = [8 x i8] c"environ\00"
define i32 @buildin(i32 %0, [101 x i8]* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [101 x i8]*
store i32 %0, i32* %4
store [101 x i8]* %1, [101 x i8]** %5
%6 = load [101 x i8]*, [101 x i8]** %5
%7 = getelementptr inbounds [101 x i8], [101 x i8]* %6, i64 0
%8 = getelementptr inbounds [101 x i8], [101 x i8]* %7, i64 0, i64 0
%9 = call i32 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i32 %9, 0
br i1 %10, label %22, label %11
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load [101 x i8]*, [101 x i8]** %5
%16 = getelementptr inbounds [101 x i8], [101 x i8]* %15, i64 1
%17 = getelementptr inbounds [101 x i8], [101 x i8]* %16, i64 0, i64 0
%18 = call i32 @b_cd(i8* %17)
br label %21
19: ; preds = %11
%20 = call i32 (...) @b_pwd()
br label %21
21: ; preds = %19, %14
store i32 1, i32* %3
br label %91
22: ; preds = %2
%23 = load [101 x i8]*, [101 x i8]** %5
%24 = getelementptr inbounds [101 x i8], [101 x i8]* %23, i64 0
%25 = getelementptr inbounds [101 x i8], [101 x i8]* %24, i64 0, i64 0
%26 = call i32 @strcmp(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp ne i32 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %22
%29 = call i32 (...) @b_pwd()
store i32 1, i32* %3
br label %91
30: ; preds = %22
%31 = load [101 x i8]*, [101 x i8]** %5
%32 = getelementptr inbounds [101 x i8], [101 x i8]* %31, i64 0
%33 = getelementptr inbounds [101 x i8], [101 x i8]* %32, i64 0, i64 0
%34 = call i32 @strcmp(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%35 = icmp ne i32 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %30
%37 = call i32 (...) @b_clr()
store i32 1, i32* %3
br label %91
38: ; preds = %30
%39 = load [101 x i8]*, [101 x i8]** %5
%40 = getelementptr inbounds [101 x i8], [101 x i8]* %39, i64 0
%41 = getelementptr inbounds [101 x i8], [101 x i8]* %40, i64 0, i64 0
%42 = call i32 @strcmp(i8* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %55, label %44
44: ; preds = %38
%45 = load i32, i32* %4
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %52
47: ; preds = %44
%48 = load [101 x i8]*, [101 x i8]** %5
%49 = getelementptr inbounds [101 x i8], [101 x i8]* %48, i64 1
%50 = getelementptr inbounds [101 x i8], [101 x i8]* %49, i64 0, i64 0
%51 = call i32 @b_dir(i8* %50)
br label %54
52: ; preds = %44
%53 = call i32 @b_dir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %54
54: ; preds = %52, %47
store i32 1, i32* %3
br label %91
55: ; preds = %38
%56 = load [101 x i8]*, [101 x i8]** %5
%57 = getelementptr inbounds [101 x i8], [101 x i8]* %56, i64 0
%58 = getelementptr inbounds [101 x i8], [101 x i8]* %57, i64 0, i64 0
%59 = call i32 @strcmp(i8* %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%60 = icmp ne i32 %59, 0
br i1 %60, label %66, label %61
61: ; preds = %55
%62 = load i32, i32* %4
%63 = load [101 x i8]*, [101 x i8]** %5
%64 = bitcast [101 x i8]* %63 to i8**
%65 = call i32 @b_echo(i32 %62, i8** %64)
store i32 1, i32* %3
br label %91
66: ; preds = %55
%67 = load [101 x i8]*, [101 x i8]** %5
%68 = getelementptr inbounds [101 x i8], [101 x i8]* %67, i64 0
%69 = getelementptr inbounds [101 x i8], [101 x i8]* %68, i64 0, i64 0
%70 = call i32 @strcmp(i8* %69, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%71 = icmp ne i32 %70, 0
br i1 %71, label %74, label %72
72: ; preds = %66
%73 = call i32 (...) @b_help()
store i32 1, i32* %3
br label %91
74: ; preds = %66
%75 = load [101 x i8]*, [101 x i8]** %5
%76 = getelementptr inbounds [101 x i8], [101 x i8]* %75, i64 0
%77 = getelementptr inbounds [101 x i8], [101 x i8]* %76, i64 0, i64 0
%78 = call i32 @strcmp(i8* %77, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%79 = icmp ne i32 %78, 0
br i1 %79, label %82, label %80
80: ; preds = %74
%81 = call i32 (...) @b_quit()
store i32 1, i32* %3
br label %91
82: ; preds = %74
%83 = load [101 x i8]*, [101 x i8]** %5
%84 = getelementptr inbounds [101 x i8], [101 x i8]* %83, i64 0
%85 = getelementptr inbounds [101 x i8], [101 x i8]* %84, i64 0, i64 0
%86 = call i32 @strcmp(i8* %85, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%87 = icmp ne i32 %86, 0
br i1 %87, label %90, label %88
88: ; preds = %82
%89 = call i32 (...) @b_env()
store i32 1, i32* %3
br label %91
90: ; preds = %82
store i32 0, i32* %3
br label %91
91: ; preds = %90, %88, %80, %72, %61, %54, %36, %28, %21
%92 = load i32, i32* %3
ret i32 %92
}

LLVM IR (-O2):
@.str = [3 x i8] c"cd\00"
@.str.1 = [4 x i8] c"pwd\00"
@.str.2 = [4 x i8] c"clr\00"
@.str.3 = [4 x i8] c"dir\00"
@.str.4 = [2 x i8] c".\00"
@.str.5 = [5 x i8] c"echo\00"
@.str.6 = [5 x i8] c"help\00"
@.str.7 = [5 x i8] c"quit\00"
@.str.8 = [8 x i8] c"environ\00"
define i32 @buildin(i32 %0, [101 x i8]* %1) {
%3 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 0
%4 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = icmp eq i32 %0, 0
br i1 %7, label %11, label %8
8: ; preds = %6
%9 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 1, i64 0
%10 = tail call i32 @b_cd(i8* %9)
br label %54
11: ; preds = %6
%12 = tail call i32 (...) @b_pwd()
br label %54
13: ; preds = %2
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 (...) @b_pwd()
br label %54
18: ; preds = %13
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 (...) @b_clr()
br label %54
23: ; preds = %18
%24 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = icmp sgt i32 %0, 0
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 1, i64 0
%30 = tail call i32 @b_dir(i8* %29)
br label %54
31: ; preds = %26
%32 = tail call i32 @b_dir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %54
33: ; preds = %23
%34 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = bitcast [101 x i8]* %1 to i8**
%38 = tail call i32 @b_echo(i32 %0, i8** %37)
br label %54
39: ; preds = %33
%40 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = tail call i32 (...) @b_help()
br label %54
44: ; preds = %39
%45 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = tail call i32 (...) @b_quit()
br label %54
49: ; preds = %44
%50 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = tail call i32 (...) @b_env()
br label %54
54: ; preds = %49, %28, %31, %8, %11, %52, %47, %42, %36, %21, %16
%55 = phi i32 [ 1, %52 ], [ 1, %47 ], [ 1, %42 ], [ 1, %36 ], [ 1, %21 ], [ 1, %16 ], [ 1, %11 ], [ 1, %8 ], [ 1, %31 ], [ 1, %28 ], [ 0, %49 ]
ret i32 %55
}