#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 */

/* Variables and functions */
int /*<<< orphan*/ def_dims(int);
int /*<<< orphan*/ def_vars(int);
int /*<<< orphan*/ error(char *, int /*<<< orphan*/);
scalar_t__ ifFail(int, int, char *);
int nc_close(int);
int nc_create(char *, int /*<<< orphan*/, int *);
int nc_enddef(int);
int /*<<< orphan*/ nc_strerror(int);
int /*<<< orphan*/ put_atts(int);
int /*<<< orphan*/ put_vars(int);
void write_file(char *filename) {
  int ncid;
  int err;
  err = nc_create(filename, 0, &ncid);
  if (ifFail(err, 650,
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/borismarin/genesis2.4gamma/refs/heads/"
             "master/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/"
             "nc_test/util.c"))
    error("nc_create: %s", nc_strerror(err));
  def_dims(ncid);
  def_vars(ncid);
  put_atts(ncid);
  err = nc_enddef(ncid);
  if (ifFail(err, 657,
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/borismarin/genesis2.4gamma/refs/heads/"
             "master/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/"
             "nc_test/util.c"))
    error("nc_enddef: %s", nc_strerror(err));
  put_vars(ncid);
  err = nc_close(ncid);
  if (ifFail(err, 662,
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/borismarin/genesis2.4gamma/refs/heads/"
             "master/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/"
             "nc_test/util.c"))
    error("nc_close: %s", nc_strerror(err));
}


x86 assembly (clang, -O0):
<write_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
lea    -0xc(%rbp),%rdx
call   1090 <nc_create@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    $0x28a,%esi
lea    0xe33(%rip),%rdx
call   1080 <ifFail@plt>
cmp    $0x0,%rax
je     11f2 <write_file+0x52>
mov    -0x10(%rbp),%edi
call   10c0 <nc_strerror@plt>
mov    %eax,%esi
lea    0xedc(%rip),%rdi
call   10b0 <error@plt>
mov    -0xc(%rbp),%edi
call   1040 <def_dims@plt>
mov    -0xc(%rbp),%edi
call   10a0 <def_vars@plt>
mov    -0xc(%rbp),%edi
call   1060 <put_atts@plt>
mov    -0xc(%rbp),%edi
call   1070 <nc_enddef@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    $0x291,%esi
lea    0xddc(%rip),%rdx
call   1080 <ifFail@plt>
cmp    $0x0,%rax
je     1249 <write_file+0xa9>
mov    -0x10(%rbp),%edi
call   10c0 <nc_strerror@plt>
mov    %eax,%esi
lea    0xe93(%rip),%rdi
call   10b0 <error@plt>
mov    -0xc(%rbp),%edi
call   1030 <put_vars@plt>
mov    -0xc(%rbp),%edi
call   1050 <nc_close@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    $0x296,%esi
lea    0xd95(%rip),%rdx
call   1080 <ifFail@plt>
cmp    $0x0,%rax
je     1290 <write_file+0xf0>
mov    -0x10(%rbp),%edi
call   10c0 <nc_strerror@plt>
mov    %eax,%esi
lea    0xe5a(%rip),%rdi
call   10b0 <error@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_file>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdx
xor    %esi,%esi
call   1090 <nc_create@plt>
mov    %eax,%ebx
lea    0xe46(%rip),%rdx
mov    %eax,%edi
mov    $0x28a,%esi
call   1080 <ifFail@plt>
test   %rax,%rax
je     11e0 <write_file+0x40>
mov    %ebx,%edi
call   10c0 <nc_strerror@plt>
lea    0xef0(%rip),%rdi
mov    %eax,%esi
call   10b0 <error@plt>
mov    0xc(%rsp),%edi
call   1040 <def_dims@plt>
mov    0xc(%rsp),%edi
call   10a0 <def_vars@plt>
mov    0xc(%rsp),%edi
call   1060 <put_atts@plt>
mov    0xc(%rsp),%edi
call   1070 <nc_enddef@plt>
mov    %eax,%ebx
lea    0xdf3(%rip),%rdx
mov    %eax,%edi
mov    $0x291,%esi
call   1080 <ifFail@plt>
test   %rax,%rax
je     1233 <write_file+0x93>
mov    %ebx,%edi
call   10c0 <nc_strerror@plt>
lea    0xeab(%rip),%rdi
mov    %eax,%esi
call   10b0 <error@plt>
mov    0xc(%rsp),%edi
call   1030 <put_vars@plt>
mov    0xc(%rsp),%edi
call   1050 <nc_close@plt>
mov    %eax,%ebx
lea    0xdb2(%rip),%rdx
mov    %eax,%edi
mov    $0x296,%esi
call   1080 <ifFail@plt>
test   %rax,%rax
je     1274 <write_file+0xd4>
mov    %ebx,%edi
call   10c0 <nc_strerror@plt>
lea    0xe78(%rip),%rdi
mov    %eax,%esi
call   10b0 <error@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [201 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/borismarin/genesis2.4gamma/refs/heads/master/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/util.c\00"
@.str.1 = [14 x i8] c"nc_create: %s\00"
@.str.2 = [14 x i8] c"nc_enddef: %s\00"
@.str.3 = [13 x i8] c"nc_close: %s\00"
define void @write_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @nc_create(i8* %5, i32 0, i32* %3)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = call i64 @ifFail(i32 %7, i32 650, i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* %4
%12 = call i32 @nc_strerror(i32 %11)
%13 = call i32 @error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %10, %1
%15 = load i32, i32* %3
%16 = call i32 @def_dims(i32 %15)
%17 = load i32, i32* %3
%18 = call i32 @def_vars(i32 %17)
%19 = load i32, i32* %3
%20 = call i32 @put_atts(i32 %19)
%21 = load i32, i32* %3
%22 = call i32 @nc_enddef(i32 %21)
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = call i64 @ifFail(i32 %23, i32 657, i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %14
%27 = load i32, i32* %4
%28 = call i32 @nc_strerror(i32 %27)
%29 = call i32 @error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %26, %14
%31 = load i32, i32* %3
%32 = call i32 @put_vars(i32 %31)
%33 = load i32, i32* %3
%34 = call i32 @nc_close(i32 %33)
store i32 %34, i32* %4
%35 = load i32, i32* %4
%36 = call i64 @ifFail(i32 %35, i32 662, i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str, i64 0, i64 0))
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %30
%39 = load i32, i32* %4
%40 = call i32 @nc_strerror(i32 %39)
%41 = call i32 @error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %38, %30
ret void
}

LLVM IR (-O2):
@.str = [201 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/borismarin/genesis2.4gamma/refs/heads/master/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/util.c\00"
@.str.1 = [14 x i8] c"nc_create: %s\00"
@.str.2 = [14 x i8] c"nc_enddef: %s\00"
@.str.3 = [13 x i8] c"nc_close: %s\00"
define void @write_file(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @nc_create(i8* %0, i32 0, i32* %2)
%5 = call i64 @ifFail(i32 %4, i32 650, i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = call i32 @nc_strerror(i32 %4)
%9 = call i32 @error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %7, %1
%11 = load i32, i32* %2
%12 = call i32 @def_dims(i32 %11)
%13 = load i32, i32* %2
%14 = call i32 @def_vars(i32 %13)
%15 = load i32, i32* %2
%16 = call i32 @put_atts(i32 %15)
%17 = load i32, i32* %2
%18 = call i32 @nc_enddef(i32 %17)
%19 = call i64 @ifFail(i32 %18, i32 657, i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %10
%22 = call i32 @nc_strerror(i32 %18)
%23 = call i32 @error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %21, %10
%25 = load i32, i32* %2
%26 = call i32 @put_vars(i32 %25)
%27 = load i32, i32* %2
%28 = call i32 @nc_close(i32 %27)
%29 = call i64 @ifFail(i32 %28, i32 662, i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %24
%32 = call i32 @nc_strerror(i32 %28)
%33 = call i32 @error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %31, %24
ret void
}