#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 */
char *concat(char *, char *);
scalar_t__ strcmp(char *, char *);
char *getCommand(char *command, char *file) {
  char *s;
  if (strcmp(command, "-r") == 0) {
    s = concat(concat("if [ -r \"", file),
               "\" ]; then echo can read; else echo cannot read; fi");
  } else if (strcmp(command, "-w") == 0) {
    s = concat(concat("if [ -w \"", file),
               "\" ]; then echo can write; else echo cannot write; fi");
  } else if (strcmp(command, "-f") == 0) {
    s = concat(
        concat("if [ -f \"", file),
        "\" ]; then echo file exists; else echo file does not exist; fi");
  }
  return s;
}


x86 assembly (clang, -O0):
<getCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1172 <getCommand+0x52>
mov    -0x10(%rbp),%rsi
lea    0xeae(%rip),%rdi
call   1030 <concat@plt>
mov    %rax,%rdi
lea    0xea9(%rip),%rsi
call   1030 <concat@plt>
mov    %rax,-0x18(%rbp)
jmp    11fb <getCommand+0xdb>
mov    -0x8(%rbp),%rdi
lea    0xec3(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b4 <getCommand+0x94>
mov    -0x10(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1030 <concat@plt>
mov    %rax,%rdi
lea    0xea7(%rip),%rsi
call   1030 <concat@plt>
mov    %rax,-0x18(%rbp)
jmp    11f6 <getCommand+0xd6>
mov    -0x8(%rbp),%rdi
lea    0xec3(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f1 <getCommand+0xd1>
mov    -0x10(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1030 <concat@plt>
mov    %rax,%rdi
lea    0xea7(%rip),%rsi
call   1030 <concat@plt>
mov    %rax,-0x18(%rbp)
jmp    11f6 <getCommand+0xd6>
jmp    11fb <getCommand+0xdb>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCommand>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecf(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     116b <getCommand+0x4b>
lea    0xefe(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     117b <getCommand+0x5b>
lea    0xf2c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     118b <getCommand+0x6b>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe9b(%rip),%rbx
lea    0xe8a(%rip),%rdi
jmp    1199 <getCommand+0x79>
lea    0xecb(%rip),%rbx
lea    0xeba(%rip),%rdi
jmp    1199 <getCommand+0x79>
lea    0xefd(%rip),%rbx
lea    0xeec(%rip),%rdi
mov    %r14,%rsi
call   1030 <concat@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <concat@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-r\00"
@.str.1 = [10 x i8] c"if [ -r \22\00"
@.str.2 = [51 x i8] c"\22 ]; then echo can read; else echo cannot read; fi\00"
@.str.3 = [3 x i8] c"-w\00"
@.str.4 = [10 x i8] c"if [ -w \22\00"
@.str.5 = [53 x i8] c"\22 ]; then echo can write; else echo cannot write; fi\00"
@.str.6 = [3 x i8] c"-f\00"
@.str.7 = [10 x i8] c"if [ -f \22\00"
@.str.8 = [62 x i8] c"\22 ]; then echo file exists; else echo file does not exist; fi\00"
define i8* @getCommand(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%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 %13
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = call i8* @concat(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i8* @concat(i8* %11, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
store i8* %12, i8** %5
br label %31
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i8*, i8** %4
%19 = call i8* @concat(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %18)
%20 = call i8* @concat(i8* %19, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0))
store i8* %20, i8** %5
br label %30
21: ; preds = %13
%22 = load i8*, i8** %3
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i8*, i8** %4
%27 = call i8* @concat(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %26)
%28 = call i8* @concat(i8* %27, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.8, i64 0, i64 0))
store i8* %28, i8** %5
br label %29
29: ; preds = %25, %21
br label %30
30: ; preds = %29, %17
br label %31
31: ; preds = %30, %9
%32 = load i8*, i8** %5
ret i8* %32
}

LLVM IR (-O2):
@.str = [3 x i8] c"-r\00"
@.str.1 = [10 x i8] c"if [ -r \22\00"
@.str.2 = [51 x i8] c"\22 ]; then echo can read; else echo cannot read; fi\00"
@.str.3 = [3 x i8] c"-w\00"
@.str.4 = [10 x i8] c"if [ -w \22\00"
@.str.5 = [53 x i8] c"\22 ]; then echo can write; else echo cannot write; fi\00"
@.str.6 = [3 x i8] c"-f\00"
@.str.7 = [10 x i8] c"if [ -f \22\00"
@.str.8 = [62 x i8] c"\22 ]; then echo file exists; else echo file does not exist; fi\00"
define i8* @getCommand(i8* %0, i8* %1) {
%3 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %8, %5, %2
%12 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), %8 ]
%13 = phi i8* [ getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), %2 ], [ getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0), %5 ], [ getelementptr inbounds ([62 x i8], [62 x i8]* @.str.8, i64 0, i64 0), %8 ]
%14 = tail call i8* @concat(i8* %12, i8* %1)
%15 = tail call i8* @concat(i8* %14, i8* %13)
br label %16
16: ; preds = %11, %8
%17 = phi i8* [ undef, %8 ], [ %15, %11 ]
ret i8* %17
}