#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*/ *safe_fopen(char const *, char *);
int /*<<< orphan*/ write_cells(int /*<<< orphan*/ *);
int /*<<< orphan*/ write_cells_attributes(int /*<<< orphan*/ *);
int /*<<< orphan*/ write_file_version(int /*<<< orphan*/ *);
int /*<<< orphan*/ write_format(int /*<<< orphan*/ *);
int /*<<< orphan*/ write_header(int /*<<< orphan*/ *);
int /*<<< orphan*/ write_vertices(int /*<<< orphan*/ *);
void write_file(const char *fn) {
  FILE *fd = safe_fopen(fn, "w");
  write_file_version(fd);
  write_header(fd);
  write_format(fd);
  write_vertices(fd);
  write_cells(fd);
  write_cells_attributes(fd);
  fclose(fd);
}


x86 assembly (clang, -O0):
<write_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   10a0 <safe_fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <write_file_version@plt>
mov    -0x10(%rbp),%rdi
call   1090 <write_header@plt>
mov    -0x10(%rbp),%rdi
call   1060 <write_format@plt>
mov    -0x10(%rbp),%rdi
call   1080 <write_vertices@plt>
mov    -0x10(%rbp),%rdi
call   1070 <write_cells@plt>
mov    -0x10(%rbp),%rdi
call   1040 <write_cells_attributes@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_file>:
push   %rbx
lea    0xe78(%rip),%rsi
call   10a0 <safe_fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <write_file_version@plt>
mov    %rbx,%rdi
call   1090 <write_header@plt>
mov    %rbx,%rdi
call   1060 <write_format@plt>
mov    %rbx,%rdi
call   1080 <write_vertices@plt>
mov    %rbx,%rdi
call   1070 <write_cells@plt>
mov    %rbx,%rdi
call   1040 <write_cells_attributes@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
define void @write_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32* @safe_fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = call i32 @write_file_version(i32* %6)
%8 = load i32*, i32** %3
%9 = call i32 @write_header(i32* %8)
%10 = load i32*, i32** %3
%11 = call i32 @write_format(i32* %10)
%12 = load i32*, i32** %3
%13 = call i32 @write_vertices(i32* %12)
%14 = load i32*, i32** %3
%15 = call i32 @write_cells(i32* %14)
%16 = load i32*, i32** %3
%17 = call i32 @write_cells_attributes(i32* %16)
%18 = load i32*, i32** %3
%19 = call i32 @fclose(i32* %18)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
define void @write_file(i8* %0) {
%2 = tail call i32* @safe_fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @write_file_version(i32* %2)
%4 = tail call i32 @write_header(i32* %2)
%5 = tail call i32 @write_format(i32* %2)
%6 = tail call i32 @write_vertices(i32* %2)
%7 = tail call i32 @write_cells(i32* %2)
%8 = tail call i32 @write_cells_attributes(i32* %2)
%9 = tail call i32 @fclose(i32* %2)
ret void
}