#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ test_allexec(char *);
int main(int argc, char **argv, char **envp) {
  if ((argc == 2) && (strcmp(argv[1], "exec") == 0)) {
    (fprintf(stdout, "%s will exec ./allexec32\n", argv[0]), fflush(stdout));
    test_allexec("./allexec32");
    (fprintf(stdout, "%s will exec ./allexec64\n", argv[0]), fflush(stdout));
    test_allexec("./allexec64");
  } else {
    int i;
    (fprintf(stdout, "program exec-ed:"), fflush(stdout));
    for (i = 0; i < argc; i++)
      (fprintf(stdout, " %s", argv[i]), fflush(stdout));
    (fprintf(stdout, "\n"), fflush(stdout));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11f7 <main+0xb7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11f7 <main+0xb7>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    0xe6a(%rip),%rdi
call   1050 <test_allexec@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe5a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    0xe58(%rip),%rdi
call   1050 <test_allexec@plt>
jmp    1293 <main+0x153>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    126e <main+0x12e>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe17(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1223 <main+0xe3>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
lea    0xd9f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
cmp    $0x2,%edi
jne    1167 <main+0x27>
mov    0x8(%r14),%rdi
lea    0xea3(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e1 <main+0xa1>
mov    0x2e72(%rip),%r12
mov    (%r12),%edi
lea    0xed8(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r12),%edi
call   1060 <fflush@plt>
test   %ebp,%ebp
jle    11c4 <main+0x84>
mov    %ebp,%ebp
lea    0xecc(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r12),%edi
mov    (%r14,%rbx,8),%rdx
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r12),%edi
call   1060 <fflush@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11a0 <main+0x60>
mov    (%r12),%edi
lea    0xe4e(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r12),%edi
call   1060 <fflush@plt>
jmp    1234 <main+0xf4>
mov    0x2df8(%rip),%rbx
mov    (%rbx),%edi
mov    (%r14),%rdx
lea    0xe11(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
call   1060 <fflush@plt>
lea    0xe16(%rip),%rdi
call   1050 <test_allexec@plt>
mov    (%rbx),%edi
mov    (%r14),%rdx
lea    0xe11(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
call   1060 <fflush@plt>
lea    0xe16(%rip),%rdi
call   1050 <test_allexec@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"exec\00"
@stdout = global i32 0
@.str.1 = [26 x i8] c"%s will exec ./allexec32\0A\00"
@.str.2 = [12 x i8] c"./allexec32\00"
@.str.3 = [26 x i8] c"%s will exec ./allexec64\0A\00"
@.str.4 = [12 x i8] c"./allexec64\00"
@.str.5 = [17 x i8] c"program exec-ed:\00"
@.str.6 = [4 x i8] c" %s\00"
@.str.7 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %34
11: ; preds = %3
%12 = load i8**, i8*** %6
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %34
17: ; preds = %11
%18 = load i32, i32* @stdout
%19 = load i8**, i8*** %6
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i32, i32* @stdout
%24 = call i32 @fflush(i32 %23)
%25 = call i32 @test_allexec(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* @stdout
%27 = load i8**, i8*** %6
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @stdout
%32 = call i32 @fflush(i32 %31)
%33 = call i32 @test_allexec(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %61
34: ; preds = %11, %3
%35 = load i32, i32* @stdout
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%37 = load i32, i32* @stdout
%38 = call i32 @fflush(i32 %37)
store i32 0, i32* %8
br label %39
39: ; preds = %53, %34
%40 = load i32, i32* %8
%41 = load i32, i32* %5
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %56
43: ; preds = %39
%44 = load i32, i32* @stdout
%45 = load i8**, i8*** %6
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %49)
%51 = load i32, i32* @stdout
%52 = call i32 @fflush(i32 %51)
br label %53
53: ; preds = %43
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
store i32 %55, i32* %8
br label %39
56: ; preds = %39
%57 = load i32, i32* @stdout
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%59 = load i32, i32* @stdout
%60 = call i32 @fflush(i32 %59)
br label %61
61: ; preds = %56, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"exec\00"
@stdout = global i32 0
@.str.1 = [26 x i8] c"%s will exec ./allexec32\0A\00"
@.str.2 = [12 x i8] c"./allexec32\00"
@.str.3 = [26 x i8] c"%s will exec ./allexec64\0A\00"
@.str.4 = [12 x i8] c"./allexec64\00"
@.str.5 = [17 x i8] c"program exec-ed:\00"
@.str.6 = [4 x i8] c" %s\00"
@.str.7 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = icmp eq i32 %0, 2
br i1 %4, label %5, label %23
5: ; preds = %3
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %5
%11 = load i32, i32* @stdout
%12 = load i8*, i8** %1
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @stdout
%15 = tail call i32 @fflush(i32 %14)
%16 = tail call i32 @test_allexec(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32, i32* @stdout
%18 = load i8*, i8** %1
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @stdout
%21 = tail call i32 @fflush(i32 %20)
%22 = tail call i32 @test_allexec(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %46
23: ; preds = %5, %3
%24 = load i32, i32* @stdout
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%26 = load i32, i32* @stdout
%27 = tail call i32 @fflush(i32 %26)
%28 = icmp sgt i32 %0, 0
br i1 %28, label %29, label %41
29: ; preds = %23
%30 = zext i32 %0 to i64
br label %31
31: ; preds = %29, %31
%32 = phi i64 [ 0, %29 ], [ %39, %31 ]
%33 = load i32, i32* @stdout
%34 = getelementptr inbounds i8*, i8** %1, i64 %32
%35 = load i8*, i8** %34
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %35)
%37 = load i32, i32* @stdout
%38 = tail call i32 @fflush(i32 %37)
%39 = add nuw nsw i64 %32, 1
%40 = icmp eq i64 %39, %30
br i1 %40, label %41, label %31
41: ; preds = %31, %23
%42 = load i32, i32* @stdout
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%44 = load i32, i32* @stdout
%45 = tail call i32 @fflush(i32 %44)
br label %46
46: ; preds = %41, %10
ret i32 0
}