#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
FILE *open_file_wgs84(int file_no) {
  char path[1024];
  FILE *out = NULL;
  sprintf(path, "epsg_inlined_wgs84_%02d.c", file_no);
  out = fopen(path, "wb");
  if (out == NULL) {
    fprintf(stderr, "ERROR: unable to open the \"%s\" output file\n", path);
    return NULL;
  }
  return out;
}


x86 assembly (clang, -O0):
<open_file_wgs84>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0xc(%rbp)
movq   $0x0,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xea6(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x410(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0x0,-0x418(%rbp)
jne    11b0 <open_file_wgs84+0x80>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rdx
lea    0xe7f(%rip),%rsi
call   1030 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11bb <open_file_wgs84+0x8b>
mov    -0x418(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_file_wgs84>:
push   %rbx
sub    $0x400,%rsp
mov    %edi,%edx
lea    0xebf(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <sprintf@plt>
lea    0xec7(%rip),%rsi
mov    %rbx,%rdi
call   1040 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    117b <open_file_wgs84+0x4b>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
mov    %rsp,%rdx
call   1030 <fprintf@plt>
mov    %rbx,%rax
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"epsg_inlined_wgs84_%02d.c\00"
@.str.1 = [3 x i8] c"wb\00"
@stderr = global i32 0
@.str.2 = [44 x i8] c"ERROR: unable to open the \22%s\22 output file\0A\00"
define i32* @open_file_wgs84(i32 %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca [1024 x i8]
%5 = alloca i32*
store i32 %0, i32* %3
store i32* null, i32** %5
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* %3
%8 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %5
%11 = load i32*, i32** %5
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%16 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %15)
store i32* null, i32** %2
br label %19
17: ; preds = %1
%18 = load i32*, i32** %5
store i32* %18, i32** %2
br label %19
19: ; preds = %17, %13
%20 = load i32*, i32** %2
ret i32* %20
}

LLVM IR (-O2):
@.str = [26 x i8] c"epsg_inlined_wgs84_%02d.c\00"
@.str.1 = [3 x i8] c"wb\00"
@stderr = global i32 0
@.str.2 = [44 x i8] c"ERROR: unable to open the \22%s\22 output file\0A\00"
define noalias i32* @open_file_wgs84(i32 %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %0)
%5 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %10
10: ; preds = %1, %7
ret i32* %5
}