#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*/ execl(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ puts(char *);
scalar_t__ strcmp(char *, char const *);
int main(int argc, char const *argv[]) {
  if (strcmp("ls", argv[1]) == 0) {
    execl("/bin/ls", "ls", NULL);
    perror("Error!");
  } else if (strcmp("pwd", argv[1]) == 0) {
    execl("/bin/pwd", "pwd", NULL);
    perror("Error!");
  } else if (strcmp("ls", argv[1]) == 0) {
    execl("/bin/ls", "ls", NULL);
    perror("Error!");
  } else
    puts("Unknown command.");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xea0(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    119c <main+0x5c>
lea    0xe85(%rip),%rdi
lea    0xe83(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <execl@plt>
lea    0xe76(%rip),%rdi
call   1050 <perror@plt>
jmp    123e <main+0xfe>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe69(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11e2 <main+0xa2>
lea    0xe4e(%rip),%rdi
lea    0xe4c(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <execl@plt>
lea    0xe30(%rip),%rdi
call   1050 <perror@plt>
jmp    1239 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe14(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1228 <main+0xe8>
lea    0xdf9(%rip),%rdi
lea    0xdf7(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <execl@plt>
lea    0xdea(%rip),%rdi
call   1050 <perror@plt>
jmp    1234 <main+0xf4>
lea    0xde9(%rip),%rdi
call   1030 <puts@plt>
jmp    1239 <main+0xf9>
jmp    123e <main+0xfe>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0xeb6(%rip),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1193 <main+0x53>
mov    0x8(%rbx),%rsi
lea    0xeb0(%rip),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11a3 <main+0x63>
mov    0x8(%rbx),%rsi
lea    0xe8c(%rip),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1193 <main+0x53>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe66(%rip),%rdi
lea    0xe64(%rip),%rsi
jmp    11b1 <main+0x71>
lea    0xe65(%rip),%rdi
lea    0xe63(%rip),%rsi
xor    %edx,%edx
call   1060 <execl@plt>
lea    0xe49(%rip),%rdi
call   1050 <perror@plt>
jmp    118f <main+0x4f>

LLVM IR (-O0):
@.str = [3 x i8] c"ls\00"
@.str.1 = [8 x i8] c"/bin/ls\00"
@.str.2 = [7 x i8] c"Error!\00"
@.str.3 = [4 x i8] c"pwd\00"
@.str.4 = [9 x i8] c"/bin/pwd\00"
@.str.5 = [17 x i8] c"Unknown command.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i8**, i8*** %5
%7 = getelementptr inbounds i8*, i8** %6, i64 1
%8 = load i8*, i8** %7
%9 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null)
%13 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %36
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = call i32 @execl(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* null)
%22 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %35
23: ; preds = %14
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null)
%31 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %34
32: ; preds = %23
%33 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %34
34: ; preds = %32, %29
br label %35
35: ; preds = %34, %20
br label %36
36: ; preds = %35, %11
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [3 x i8] c"ls\00"
@.str.1 = [8 x i8] c"/bin/ls\00"
@.str.2 = [7 x i8] c"Error!\00"
@.str.3 = [4 x i8] c"pwd\00"
@.str.4 = [9 x i8] c"/bin/pwd\00"
@.str.5 = [17 x i8] c"Unknown command.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null)
%9 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %26
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = tail call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = tail call i32 @execl(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* null)
%16 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %26
17: ; preds = %10
%18 = load i8*, i8** %3
%19 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = tail call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null)
%23 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %26
24: ; preds = %17
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %26
26: ; preds = %14, %24, %21, %7
ret i32 0
}