#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*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
char *get_parm(int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
FILE *open_proxy(void) {
  char filename[128 + 10];
  FILE *stream;
  snprintf(filename, 128 + 9, "PROXY_%s.c", get_parm(0));
  filename[128 + 9] = '\0';
  stream = fopen(filename, "w");
  if (stream == NULL) {
    fprintf(stderr, "Failed to open %s: %s\n", filename, strerror(errno));
    exit(10);
  }
  return stream;
}


x86 assembly (clang, -O0):
<open_proxy>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
lea    -0x90(%rbp),%rax
mov    %rax,-0xa0(%rbp)
xor    %edi,%edi
call   1030 <get_parm@plt>
mov    -0xa0(%rbp),%rdi
mov    %rax,%rcx
mov    $0x89,%esi
lea    0xe6a(%rip),%rdx
call   1040 <snprintf@plt>
movb   $0x0,-0x7(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
jne    1218 <open_proxy+0xb8>
mov    0x2e12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xac(%rbp)
lea    -0x90(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0xac(%rbp),%edi
mov    -0xa8(%rbp),%rdx
mov    %rax,%rcx
lea    0xe04(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xa,%edi
call   1070 <exit@plt>
mov    -0x98(%rbp),%rax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_proxy>:
push   %rbx
sub    $0x90,%rsp
xor    %edi,%edi
call   1030 <get_parm@plt>
lea    0xe8a(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x89,%esi
mov    %rax,%rcx
call   1040 <snprintf@plt>
movb   $0x0,0x89(%rsp)
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11ae <open_proxy+0x4e>
add    $0x90,%rsp
pop    %rbx
ret
mov    0x2e2b(%rip),%rax
mov    (%rax),%ebx
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe41(%rip),%rsi
mov    %rsp,%rdx
mov    %ebx,%edi
mov    %rax,%rcx
call   1050 <fprintf@plt>
mov    $0xa,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"PROXY_%s.c\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"Failed to open %s: %s\0A\00"
@errno = global i32 0
define i32* @open_proxy() {
%1 = alloca [138 x i8]
%2 = alloca i32*
%3 = getelementptr inbounds [138 x i8], [138 x i8]* %1, i64 0, i64 0
%4 = call i8* @get_parm(i32 0)
%5 = call i32 @snprintf(i8* %3, i32 137, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = getelementptr inbounds [138 x i8], [138 x i8]* %1, i64 0, i64 137
store i8 0, i8* %6
%7 = getelementptr inbounds [138 x i8], [138 x i8]* %1, i64 0, i64 0
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %18
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = getelementptr inbounds [138 x i8], [138 x i8]* %1, i64 0, i64 0
%14 = load i32, i32* @errno
%15 = call i8* @strerror(i32 %14)
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %13, i8* %15)
%17 = call i32 @exit(i32 10)
unreachable
18: ; preds = %0
%19 = load i32*, i32** %2
ret i32* %19
}

LLVM IR (-O2):
@.str = [11 x i8] c"PROXY_%s.c\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"Failed to open %s: %s\0A\00"
@errno = global i32 0
define noalias i32* @open_proxy() {
%1 = alloca [138 x i8]
%2 = getelementptr inbounds [138 x i8], [138 x i8]* %1, i64 0, i64 0
%3 = tail call i8* @get_parm(i32 0)
%4 = call i32 @snprintf(i8* %2, i32 137, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = getelementptr inbounds [138 x i8], [138 x i8]* %1, i64 0, i64 137
store i8 0, i8* %5
%6 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %14
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = load i32, i32* @errno
%11 = call i8* @strerror(i32 %10)
%12 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %2, i8* %11)
%13 = call i32 @exit(i32 10)
unreachable
14: ; preds = %0
ret i32* %6
}