#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*/ *fopen(char *, char *);
int initialize(int argc, char **argv, void **pctx) {
  FILE *fp;
  if (argc != 1)
    return -1;
  fp = fopen(argv[0], "w");
  if (fp == NULL)
    return -1;
  *pctx = fp;
  return 0;
}


x86 assembly (clang, -O0):
<initialize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     1139 <initialize+0x29>
movl   $0xffffffff,-0x4(%rbp)
jmp    1179 <initialize+0x69>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xeb9(%rip),%rsi
call   1030 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1167 <initialize+0x57>
movl   $0xffffffff,-0x4(%rbp)
jmp    1179 <initialize+0x69>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initialize>:
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%ebx
cmp    $0x1,%edi
jne    113a <initialize+0x2a>
mov    %rdx,%r14
mov    (%rsi),%rdi
lea    0xed5(%rip),%rsi
call   1030 <fopen@plt>
test   %rax,%rax
je     113a <initialize+0x2a>
mov    %rax,(%r14)
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
define i32 @initialize(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* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%9 = load i32, i32* %5
%10 = icmp ne i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %3
store i32 -1, i32* %4
br label %24
12: ; preds = %3
%13 = load i8**, i8*** %6
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %8
%17 = load i32*, i32** %8
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %20
19: ; preds = %12
store i32 -1, i32* %4
br label %24
20: ; preds = %12
%21 = load i32*, i32** %8
%22 = bitcast i32* %21 to i8*
%23 = load i8**, i8*** %7
store i8* %22, i8** %23
store i32 0, i32* %4
br label %24
24: ; preds = %20, %19, %11
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
define i32 @initialize(i32 %0, i8** nocapture %1, i8** nocapture writeonly %2) {
%4 = icmp eq i32 %0, 1
br i1 %4, label %5, label %11
5: ; preds = %3
%6 = load i8*, i8** %1
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = bitcast i8** %2 to i32**
store i32* %7, i32** %10
br label %11
11: ; preds = %5, %3, %9
%12 = phi i32 [ 0, %9 ], [ -1, %3 ], [ -1, %5 ]
ret i32 %12
}