#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ run_child(char **);
int /*<<< orphan*/ strcmp(char *, char *);
int builtin_cmd(char **argv) {
  if (!strcmp(argv[0], "quit")) {
    exit(0);
  }
  if (!strcmp(argv[0], "world")) {
    run_child(argv);
    return 1;
  }
  if (!strcmp(argv[0], "mars")) {
    run_child(argv);
    return 1;
  }
  if (!strcmp(argv[0], "newcat")) {
    run_child(argv);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<builtin_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xeb6(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    115f <builtin_cmd+0x2f>
xor    %edi,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe98(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1190 <builtin_cmd+0x60>
mov    -0x10(%rbp),%rdi
call   1040 <run_child@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f9 <builtin_cmd+0xc9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe6d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11c1 <builtin_cmd+0x91>
mov    -0x10(%rbp),%rdi
call   1040 <run_child@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f9 <builtin_cmd+0xc9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe41(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11f2 <builtin_cmd+0xc2>
mov    -0x10(%rbp),%rdi
call   1040 <run_child@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f9 <builtin_cmd+0xc9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<builtin_cmd>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%rbx
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     119f <builtin_cmd+0x6f>
lea    0xeb1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     118a <builtin_cmd+0x5a>
lea    0xea4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     118a <builtin_cmd+0x5a>
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    1197 <builtin_cmd+0x67>
mov    %r14,%rdi
call   1040 <run_child@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"quit\00"
@.str.1 = [6 x i8] c"world\00"
@.str.2 = [5 x i8] c"mars\00"
@.str.3 = [7 x i8] c"newcat\00"
define i32 @builtin_cmd(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
store i8** %0, i8*** %3
%4 = load i8**, i8*** %3
%5 = getelementptr inbounds i8*, i8** %4, i64 0
%6 = load i8*, i8** %5
%7 = call i32 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = call i32 @exit(i32 0)
unreachable
11: ; preds = %1
%12 = load i8**, i8*** %3
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %11
%18 = load i8**, i8*** %3
%19 = call i32 @run_child(i8** %18)
store i32 1, i32* %2
br label %39
20: ; preds = %11
%21 = load i8**, i8*** %3
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %20
%27 = load i8**, i8*** %3
%28 = call i32 @run_child(i8** %27)
store i32 1, i32* %2
br label %39
29: ; preds = %20
%30 = load i8**, i8*** %3
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %29
%36 = load i8**, i8*** %3
%37 = call i32 @run_child(i8** %36)
store i32 1, i32* %2
br label %39
38: ; preds = %29
store i32 0, i32* %2
br label %39
39: ; preds = %38, %35, %26, %17
%40 = load i32, i32* %2
ret i32 %40
}

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