#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*/ chdir(char *);
int execl(char *, char *, char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void executeMole(int i, char dir[]) {
  int status;
  chdir(dir);
  if (i == 1) {
    status = execl("mole", "mole1", dir, (char *)NULL);
    if (status == -1)
      fprintf(stderr, "Exec: mole1 Failed\n");
  }
  if (i == 2) {
    status = execl("mole", "mole2", dir, (char *)NULL);
    if (status == -1)
      fprintf(stderr, "Exec: mole2 Failed\n");
  }
}


x86 assembly (clang, -O0):
<executeMole>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <chdir@plt>
cmpl   $0x1,-0x4(%rbp)
jne    1194 <executeMole+0x64>
mov    -0x10(%rbp),%rdx
lea    0xea3(%rip),%rdi
lea    0xea1(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <execl@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    118f <executeMole+0x5f>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1194 <executeMole+0x64>
cmpl   $0x2,-0x4(%rbp)
jne    11e0 <executeMole+0xb0>
mov    -0x10(%rbp),%rdx
lea    0xe57(%rip),%rdi
lea    0xe6f(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <execl@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11db <executeMole+0xab>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    0xe4f(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11e0 <executeMole+0xb0>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<executeMole>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1030 <chdir@plt>
cmp    $0x2,%ebp
je     1170 <executeMole+0x40>
cmp    $0x1,%ebp
jne    118d <executeMole+0x5d>
lea    0xeaf(%rip),%rdi
lea    0xead(%rip),%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1050 <execl@plt>
cmp    $0xffffffff,%eax
jne    118d <executeMole+0x5d>
lea    0xe9d(%rip),%rsi
jmp    119b <executeMole+0x6b>
lea    0xe89(%rip),%rdi
lea    0xea1(%rip),%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1050 <execl@plt>
cmp    $0xffffffff,%eax
je     1194 <executeMole+0x64>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe8a(%rip),%rsi
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"mole\00"
@.str.1 = [6 x i8] c"mole1\00"
@stderr = global i32 0
@.str.2 = [20 x i8] c"Exec: mole1 Failed\0A\00"
@.str.3 = [6 x i8] c"mole2\00"
@.str.4 = [20 x i8] c"Exec: mole2 Failed\0A\00"
define void @executeMole(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i32 @chdir(i8* %6)
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %19
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i32 @execl(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8* null)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %15, %10
br label %19
19: ; preds = %18, %2
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = load i8*, i8** %4
%24 = call i32 @execl(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %23, i8* null)
store i32 %24, i32* %5
%25 = load i32, i32* %5
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %30
30: ; preds = %27, %22
br label %31
31: ; preds = %30, %19
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"mole\00"
@.str.1 = [6 x i8] c"mole1\00"
@stderr = global i32 0
@.str.2 = [20 x i8] c"Exec: mole1 Failed\0A\00"
@.str.3 = [6 x i8] c"mole2\00"
@.str.4 = [20 x i8] c"Exec: mole2 Failed\0A\00"
define void @executeMole(i32 %0, i8* %1) {
%3 = tail call i32 @chdir(i8* %1)
switch i32 %0, label %14 [
i32 1, label %4
i32 2, label %7
]
4: ; preds = %2
%5 = tail call i32 @execl(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* null)
%6 = icmp eq i32 %5, -1
br i1 %6, label %10, label %14
7: ; preds = %2
%8 = tail call i32 @execl(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* null)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %7, %4
%11 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), %7 ]
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* %11)
br label %14
14: ; preds = %10, %4, %2, %7
ret void
}