#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int testExe1lib();
int main(int argc, const char *argv[]) {
  if (argc < 2) {
    fprintf(stderr, "Must specify output file.\n");
    return 1;
  }
  {
    FILE *f = fopen(argv[1], "w");
    if (f) {
      fprintf(f, "int generated_by_testExe1() { return 0; }\n");
      fclose(f);
    } else {
      fprintf(stderr, "Error writing to %s\n", argv[1]);
      return 1;
    }
  }
  return testExe1lib();
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    1183 <main+0x43>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fd <main+0xbd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe89(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c8 <main+0x88>
mov    -0x18(%rbp),%rax
mov    %eax,%edi
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11f3 <main+0xb3>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe68(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fd <main+0xbd>
mov    $0x0,%al
call   1060 <testExe1lib@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     1162 <main+0x22>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
lea    0xea7(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11be <main+0x7e>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xeab(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11a3 <main+0x63>
mov    %rax,%rbx
lea    0xe99(%rip),%rsi
mov    %ebx,%edi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <testExe1lib@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xe91(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"Must specify output file.\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [43 x i8] c"int generated_by_testExe1() { return 0; }\0A\00"
@.str.3 = [21 x i8] c"Error writing to %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %33
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %25
19: ; preds = %12
%20 = load i32*, i32** %6
%21 = ptrtoint i32* %20 to i32
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32*, i32** %6
%24 = call i32 @fclose(i32* %23)
br label %31
25: ; preds = %12
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %29)
store i32 1, i32* %3
br label %33
31: ; preds = %19
%32 = call i32 (...) @testExe1lib()
store i32 %32, i32* %3
br label %33
33: ; preds = %31, %25, %9
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"Must specify output file.\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [43 x i8] c"int generated_by_testExe1() { return 0; }\0A\00"
@.str.3 = [21 x i8] c"Error writing to %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %22
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %8
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %14)
br label %22
16: ; preds = %7
%17 = ptrtoint i32* %10 to i64
%18 = trunc i64 %17 to i32
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%20 = tail call i32 @fclose(i32* %10)
%21 = tail call i32 (...) @testExe1lib()
br label %22
22: ; preds = %12, %16, %4
%23 = phi i32 [ 1, %4 ], [ 1, %12 ], [ %21, %16 ]
ret i32 %23
}