#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*/ SIGINT;
int /*<<< orphan*/ change_directory(char *);
int /*<<< orphan*/ current_working_directory();
int /*<<< orphan*/ execute_command(char *, char *);
int /*<<< orphan*/ kill(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
void handle_command(char *command, char *arguments, char *buffer, char *ret) {
  if (strcmp(command, "q") == 0 || strcmp(command, "quit") == 0)
    kill(0, SIGINT);
  else if (strcmp(command, "cd") == 0)
    change_directory(buffer);
  else if (strcmp(command, "cwd") == 0)
    current_working_directory();
  else if (!ret)
    execute_command(command, arguments);
}


x86 assembly (clang, -O0):
<handle_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     119c <handle_command+0x4c>
mov    -0x8(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11b1 <handle_command+0x61>
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
call   1040 <kill@plt>
jmp    1226 <handle_command+0xd6>
mov    -0x8(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11d9 <handle_command+0x89>
mov    -0x18(%rbp),%rdi
call   1050 <change_directory@plt>
jmp    1221 <handle_command+0xd1>
mov    -0x8(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ff <handle_command+0xaf>
mov    $0x0,%al
call   1070 <current_working_directory@plt>
jmp    121c <handle_command+0xcc>
cmpq   $0x0,-0x20(%rbp)
jne    1217 <handle_command+0xc7>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <execute_command@plt>
jmp    121c <handle_command+0xcc>
jmp    1221 <handle_command+0xd1>
jmp    1226 <handle_command+0xd6>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_command>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe95(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11c2 <handle_command+0x72>
lea    0xe86(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11c2 <handle_command+0x72>
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11dd <handle_command+0x8d>
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11f0 <handle_command+0xa0>
test   %r15,%r15
je     1202 <handle_command+0xb2>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2e1f(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <kill@plt>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <change_directory@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1070 <current_working_directory@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <execute_command@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"q\00"
@.str.1 = [5 x i8] c"quit\00"
@SIGINT = global i32 0
@.str.2 = [3 x i8] c"cd\00"
@.str.3 = [4 x i8] c"cwd\00"
define void @handle_command(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%9 = load i8*, i8** %5
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %4
%13 = load i8*, i8** %5
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12, %4
%17 = load i32, i32* @SIGINT
%18 = call i32 @kill(i32 0, i32 %17)
br label %42
19: ; preds = %12
%20 = load i8*, i8** %5
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i8*, i8** %7
%25 = call i32 @change_directory(i8* %24)
br label %41
26: ; preds = %19
%27 = load i8*, i8** %5
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 (...) @current_working_directory()
br label %40
32: ; preds = %26
%33 = load i8*, i8** %8
%34 = icmp ne i8* %33, null
br i1 %34, label %39, label %35
35: ; preds = %32
%36 = load i8*, i8** %5
%37 = load i8*, i8** %6
%38 = call i32 @execute_command(i8* %36, i8* %37)
br label %39
39: ; preds = %35, %32
br label %40
40: ; preds = %39, %30
br label %41
41: ; preds = %40, %23
br label %42
42: ; preds = %41, %16
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"q\00"
@.str.1 = [5 x i8] c"quit\00"
@SIGINT = global i32 0
@.str.2 = [3 x i8] c"cd\00"
@.str.3 = [4 x i8] c"cwd\00"
define void @handle_command(i8* %0, i8* %1, i8* %2, i8* readnone %3) {
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7, %4
%11 = load i32, i32* @SIGINT
%12 = tail call i32 @kill(i32 0, i32 %11)
br label %27
13: ; preds = %7
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @change_directory(i8* %2)
br label %27
18: ; preds = %13
%19 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 (...) @current_working_directory()
br label %27
23: ; preds = %18
%24 = icmp eq i8* %3, null
br i1 %24, label %25, label %27
25: ; preds = %23
%26 = tail call i32 @execute_command(i8* %0, i8* %1)
br label %27
27: ; preds = %16, %23, %25, %21, %10
ret void
}