#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 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_testExe3() { return 0; }\n");
      fclose(f);
    } else {
      fprintf(stderr, "Error writing to %s\n", argv[1]);
      return 1;
    }
  }
  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)
cmpl   $0x2,-0x8(%rbp)
jge    1173 <main+0x43>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ea <main+0xba>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe99(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b8 <main+0x88>
mov    -0x18(%rbp),%rax
mov    %eax,%edi
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11e3 <main+0xb3>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe78(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ea <main+0xba>
movl   $0x0,-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     1152 <main+0x22>
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
lea    0xeb7(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11a5 <main+0x75>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xebb(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     118a <main+0x5a>
mov    %rax,%r14
lea    0xea9(%rip),%rsi
xor    %ebx,%ebx
mov    %r14d,%edi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
jmp    11aa <main+0x7a>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xeaa(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%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_testExe3() { 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 %32
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 %32
31: ; preds = %19
store i32 0, i32* %3
br label %32
32: ; preds = %31, %25, %9
%33 = load i32, i32* %3
ret i32 %33
}

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_testExe3() { 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 %21
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 %17, label %12
12: ; preds = %7
%13 = ptrtoint i32* %10 to i64
%14 = trunc i64 %13 to i32
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 @fclose(i32* %10)
br label %21
17: ; preds = %7
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %8
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %17, %12, %4
%22 = phi i32 [ 1, %4 ], [ 0, %12 ], [ 1, %17 ]
ret i32 %22
}