#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 ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EIO;
int ENOMEM;
int PATH_MAX;
char *calloc(int, int);
int errno;
int fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int simple_io_read_whole_file_zt(char *, char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ strncmp(char const *, char *, int);
int zsnprintf(char *, int, char *, char const *, int);
int read_then_write_file(const char *tempdir, int *next_id,
                         const char *contents, int buf_sz) {
  ssize_t res;
  FILE *fp;
  char *buf, file_name[PATH_MAX];
  do {
    int __my_ret__ =
        zsnprintf(file_name, PATH_MAX, "%s/outfile.%d", tempdir, *next_id);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 37,
              "zsnprintf(file_name, PATH_MAX,\"%s/outfile.%d\", tempdir, "
              "*next_id)");
      return __my_ret__;
    }
  } while (0);
  ;
  *next_id = *next_id + 1;
  fp = fopen(file_name, "w");
  if (!fp) {
    int ret = errno;
    fprintf(stderr, "failed to open '%s': error %d\n", file_name, ret);
    return ret;
  }
  if (fprintf(fp, "%s", contents) < 0) {
    int ret = errno;
    fprintf(stderr, "failed to write to '%s': error %d\n", file_name, ret);
    return ret;
  }
  do {
    int __my_ret__ = fclose(fp);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 54, "fclose(fp)");
      return __my_ret__;
    }
  } while (0);
  ;
  buf = calloc(1, buf_sz);
  if (!buf) {
    return -ENOMEM;
  }
  res = simple_io_read_whole_file_zt(file_name, buf, buf_sz);
  if (res < 0) {
    free(buf);
    fprintf(stderr,
            "simple_io_read_whole_file_zt failed with "
            "error %Zd\n",
            res);
    return res;
  }
  if ((buf_sz > 0) && (strncmp(contents, buf, buf_sz - 1))) {
    fprintf(stderr,
            "got contents: '%s'; expected first "
            "%d characters of: '%s' \n",
            buf, buf_sz - 1, contents);
    free(buf);
    return -EIO;
  }
  free(buf);
  return 0;
}


x86 assembly (clang, -O0):
<read_then_write_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
mov    -0x68(%rbp),%rdi
mov    0x2e22(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    (%rax),%r8d
lea    0xe1e(%rip),%rdx
call   1090 <zsnprintf@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     1229 <read_then_write_file+0xa9>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
lea    0xe0a(%rip),%rsi
mov    $0x25,%edx
lea    0xe15(%rip),%rcx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x50(%rbp)
jmp    1463 <read_then_write_file+0x2e3>
jmp    122e <read_then_write_file+0xae>
jmp    1233 <read_then_write_file+0xb3>
mov    -0x68(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
lea    0xe1a(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    129d <read_then_write_file+0x11d>
mov    -0x68(%rbp),%rdx
mov    0x2d54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
mov    -0x54(%rbp),%ecx
lea    0xde5(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x54(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x50(%rbp)
jmp    1463 <read_then_write_file+0x2e3>
mov    -0x30(%rbp),%rax
mov    %eax,%edi
mov    -0x20(%rbp),%rdx
lea    0xdda(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
cmp    $0x0,%rax
jge    12fb <read_then_write_file+0x17b>
mov    -0x68(%rbp),%rdx
mov    0x2cf6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    0x2cf2(%rip),%rax
mov    (%rax),%edi
mov    -0x58(%rbp),%ecx
lea    0xda9(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x58(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x50(%rbp)
jmp    1463 <read_then_write_file+0x2e3>
jmp    1300 <read_then_write_file+0x180>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
je     134b <read_then_write_file+0x1cb>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
lea    0xce8(%rip),%rsi
mov    $0x36,%edx
lea    0xd7c(%rip),%rcx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x50(%rbp)
jmp    1463 <read_then_write_file+0x2e3>
jmp    1350 <read_then_write_file+0x1d0>
jmp    1355 <read_then_write_file+0x1d5>
mov    -0x24(%rbp),%esi
mov    $0x1,%edi
call   1070 <calloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    138b <read_then_write_file+0x20b>
xor    %eax,%eax
mov    0x2c56(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x50(%rbp)
jmp    1463 <read_then_write_file+0x2e3>
mov    -0x68(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1060 <simple_io_read_whole_file_zt@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    13dd <read_then_write_file+0x25d>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    0x2c10(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%edx
lea    0xcf5(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x50(%rbp)
jmp    1463 <read_then_write_file+0x2e3>
cmpl   $0x0,-0x24(%rbp)
jle    144c <read_then_write_file+0x2cc>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x24(%rbp),%edx
sub    $0x1,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     144c <read_then_write_file+0x2cc>
mov    0x2bbd(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x20(%rbp),%r8
lea    0xccb(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
mov    0x2b9d(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x50(%rbp)
jmp    1463 <read_then_write_file+0x2e3>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x50(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_then_write_file>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%rcx
mov    0x2e4f(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x0(%r13),%r8d
lea    0xe3e(%rip),%rdx
mov    %rbx,%rdi
call   1090 <zsnprintf@plt>
test   %eax,%eax
je     11f9 <read_then_write_file+0x79>
mov    %eax,%r12d
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
lea    0xe3d(%rip),%rcx
mov    $0x25,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    129e <read_then_write_file+0x11e>
addl   $0x1,0x0(%r13)
lea    0xe62(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     125b <read_then_write_file+0xdb>
mov    %rax,%r12
lea    0xe6c(%rip),%rsi
mov    %r12d,%edi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
test   %rax,%rax
js     1277 <read_then_write_file+0xf7>
mov    %r12,%rdi
call   1050 <fclose@plt>
test   %eax,%eax
je     12b0 <read_then_write_file+0x130>
mov    %eax,%r12d
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
lea    0xdc1(%rip),%rsi
lea    0xe5a(%rip),%rcx
mov    $0x36,%edx
jmp    11ed <read_then_write_file+0x6d>
mov    0x2d5e(%rip),%rax
mov    (%rax),%r12d
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
lea    0xdf4(%rip),%rsi
jmp    1291 <read_then_write_file+0x111>
mov    0x2d42(%rip),%rax
mov    (%rax),%r12d
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
lea    0xdfa(%rip),%rsi
mov    %rbx,%rdx
mov    %r12d,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r12d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
mov    %r15d,%esi
call   1070 <calloc@plt>
test   %rax,%rax
je     1331 <read_then_write_file+0x1b1>
mov    %rax,%r13
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r15d,%edx
call   1060 <simple_io_read_whole_file_zt@plt>
test   %eax,%eax
js     1343 <read_then_write_file+0x1c3>
test   %r15d,%r15d
jle    136d <read_then_write_file+0x1ed>
add    $0xffffffff,%r15d
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15d,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     136d <read_then_write_file+0x1ed>
mov    0x2cca(%rip),%rax
mov    (%rax),%edi
lea    0xde6(%rip),%rsi
xor    %r12d,%r12d
mov    %r13,%rdx
mov    %r15d,%ecx
mov    %r14,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    0x2caf(%rip),%rax
sub    (%rax),%r12d
jmp    129e <read_then_write_file+0x11e>
mov    0x2c98(%rip),%rax
xor    %r12d,%r12d
sub    (%rax),%r12d
jmp    129e <read_then_write_file+0x11e>
mov    %eax,%r12d
mov    %r13,%rdi
call   1030 <free@plt>
mov    0x2c73(%rip),%rax
mov    (%rax),%edi
lea    0xd5b(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    129e <read_then_write_file+0x11e>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %r12d,%r12d
jmp    129e <read_then_write_file+0x11e>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [14 x i8] c"%s/outfile.%d\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"failed on line %d: %s\0A\00"
@.str.2 = [66 x i8] c"zsnprintf(file_name, PATH_MAX,\22%s/outfile.%d\22, tempdir, *next_id)\00"
@.str.3 = [2 x i8] c"w\00"
@errno = global i32 0
@.str.4 = [31 x i8] c"failed to open '%s': error %d\0A\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [35 x i8] c"failed to write to '%s': error %d\0A\00"
@.str.7 = [11 x i8] c"fclose(fp)\00"
@ENOMEM = global i32 0
@.str.8 = [52 x i8] c"simple_io_read_whole_file_zt failed with error %Zd\0A\00"
@.str.9 = [60 x i8] c"got contents: '%s'; expected first %d characters of: '%s' \0A\00"
@EIO = global i32 0
define i32 @read_then_write_file(i8* %0, i32* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i8* %0, i8** %6
store i32* %1, i32** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%20 = load i32, i32* @PATH_MAX
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %13
%23 = alloca i8, i64 %21
store i64 %21, i64* %14
br label %24
24: ; preds = %4
%25 = load i32, i32* @PATH_MAX
%26 = load i8*, i8** %6
%27 = load i32*, i32** %7
%28 = load i32, i32* %27
%29 = call i32 @zsnprintf(i8* %23, i32 %25, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %26, i32 %28)
store i32 %29, i32* %15
%30 = load i32, i32* %15
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %24
%33 = load i32, i32* @stderr
%34 = call i64 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 37, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32, i32* %15
store i32 %35, i32* %5
store i32 1, i32* %16
br label %121
36: ; preds = %24
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37
%39 = load i32*, i32** %7
%40 = load i32, i32* %39
%41 = add nsw i32 %40, 1
%42 = load i32*, i32** %7
store i32 %41, i32* %42
%43 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %43, i32** %11
%44 = load i32*, i32** %11
%45 = icmp ne i32* %44, null
br i1 %45, label %52, label %46
46: ; preds = %38
%47 = load i32, i32* @errno
store i32 %47, i32* %17
%48 = load i32, i32* @stderr
%49 = load i32, i32* %17
%50 = call i64 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %23, i32 %49)
%51 = load i32, i32* %17
store i32 %51, i32* %5
store i32 1, i32* %16
br label %121
52: ; preds = %38
%53 = load i32*, i32** %11
%54 = ptrtoint i32* %53 to i32
%55 = load i8*, i8** %8
%56 = call i64 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %55)
%57 = icmp slt i64 %56, 0
br i1 %57, label %58, label %64
58: ; preds = %52
%59 = load i32, i32* @errno
store i32 %59, i32* %18
%60 = load i32, i32* @stderr
%61 = load i32, i32* %18
%62 = call i64 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i8* %23, i32 %61)
%63 = load i32, i32* %18
store i32 %63, i32* %5
store i32 1, i32* %16
br label %121
64: ; preds = %52
br label %65
65: ; preds = %64
%66 = load i32*, i32** %11
%67 = call i32 @fclose(i32* %66)
store i32 %67, i32* %19
%68 = load i32, i32* %19
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %65
%71 = load i32, i32* @stderr
%72 = call i64 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 54, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%73 = load i32, i32* %19
store i32 %73, i32* %5
store i32 1, i32* %16
br label %121
74: ; preds = %65
br label %75
75: ; preds = %74
br label %76
76: ; preds = %75
%77 = load i32, i32* %9
%78 = call i8* @calloc(i32 1, i32 %77)
store i8* %78, i8** %12
%79 = load i8*, i8** %12
%80 = icmp ne i8* %79, null
br i1 %80, label %84, label %81
81: ; preds = %76
%82 = load i32, i32* @ENOMEM
%83 = sub nsw i32 0, %82
store i32 %83, i32* %5
store i32 1, i32* %16
br label %121
84: ; preds = %76
%85 = load i8*, i8** %12
%86 = load i32, i32* %9
%87 = call i32 @simple_io_read_whole_file_zt(i8* %23, i8* %85, i32 %86)
store i32 %87, i32* %10
%88 = load i32, i32* %10
%89 = icmp slt i32 %88, 0
br i1 %89, label %90, label %97
90: ; preds = %84
%91 = load i8*, i8** %12
%92 = call i32 @free(i8* %91)
%93 = load i32, i32* @stderr
%94 = load i32, i32* %10
%95 = call i64 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0), i32 %94)
%96 = load i32, i32* %10
store i32 %96, i32* %5
store i32 1, i32* %16
br label %121
97: ; preds = %84
%98 = load i32, i32* %9
%99 = icmp sgt i32 %98, 0
br i1 %99, label %100, label %118
100: ; preds = %97
%101 = load i8*, i8** %8
%102 = load i8*, i8** %12
%103 = load i32, i32* %9
%104 = sub nsw i32 %103, 1
%105 = call i64 @strncmp(i8* %101, i8* %102, i32 %104)
%106 = icmp ne i64 %105, 0
br i1 %106, label %107, label %118
107: ; preds = %100
%108 = load i32, i32* @stderr
%109 = load i8*, i8** %12
%110 = load i32, i32* %9
%111 = sub nsw i32 %110, 1
%112 = load i8*, i8** %8
%113 = call i64 (i32, i8*, ...) @fprintf(i32 %108, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.9, i64 0, i64 0), i8* %109, i32 %111, i8* %112)
%114 = load i8*, i8** %12
%115 = call i32 @free(i8* %114)
%116 = load i32, i32* @EIO
%117 = sub nsw i32 0, %116
store i32 %117, i32* %5
store i32 1, i32* %16
br label %121
118: ; preds = %100, %97
%119 = load i8*, i8** %12
%120 = call i32 @free(i8* %119)
store i32 0, i32* %5
store i32 1, i32* %16
br label %121
121: ; preds = %118, %107, %90, %81, %70, %58, %46, %32
%122 = load i8*, i8** %13
%123 = load i32, i32* %5
ret i32 %123
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [14 x i8] c"%s/outfile.%d\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"failed on line %d: %s\0A\00"
@.str.2 = [66 x i8] c"zsnprintf(file_name, PATH_MAX,\22%s/outfile.%d\22, tempdir, *next_id)\00"
@.str.3 = [2 x i8] c"w\00"
@errno = global i32 0
@.str.4 = [31 x i8] c"failed to open '%s': error %d\0A\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [35 x i8] c"failed to write to '%s': error %d\0A\00"
@.str.7 = [11 x i8] c"fclose(fp)\00"
@ENOMEM = global i32 0
@.str.8 = [52 x i8] c"simple_io_read_whole_file_zt failed with error %Zd\0A\00"
@.str.9 = [60 x i8] c"got contents: '%s'; expected first %d characters of: '%s' \0A\00"
@EIO = global i32 0
define i32 @read_then_write_file(i8* %0, i32* nocapture %1, i8* %2, i32 %3) {
%5 = load i32, i32* @PATH_MAX
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = load i32, i32* %1
%9 = call i32 @zsnprintf(i8* %7, i32 %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %4
%12 = load i32, i32* @stderr
%13 = call i64 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 37, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0))
br label %65
14: ; preds = %4
%15 = load i32, i32* %1
%16 = add nsw i32 %15, 1
store i32 %16, i32* %1
%17 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = load i32, i32* @errno
%21 = load i32, i32* @stderr
%22 = call i64 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %7, i32 %20)
br label %65
23: ; preds = %14
%24 = ptrtoint i32* %17 to i64
%25 = trunc i64 %24 to i32
%26 = call i64 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %2)
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i32, i32* @errno
%30 = load i32, i32* @stderr
%31 = call i64 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i8* %7, i32 %29)
br label %65
32: ; preds = %23
%33 = call i32 @fclose(i32* %17)
%34 = icmp eq i32 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = load i32, i32* @stderr
%37 = call i64 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 54, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
br label %65
38: ; preds = %32
%39 = call i8* @calloc(i32 1, i32 %3)
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* @ENOMEM
%43 = sub nsw i32 0, %42
br label %65
44: ; preds = %38
%45 = call i32 @simple_io_read_whole_file_zt(i8* %7, i8* %39, i32 %3)
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = call i32 @free(i8* %39)
%49 = load i32, i32* @stderr
%50 = call i64 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0), i32 %45)
br label %65
51: ; preds = %44
%52 = icmp sgt i32 %3, 0
br i1 %52, label %53, label %63
53: ; preds = %51
%54 = add nsw i32 %3, -1
%55 = call i64 @strncmp(i8* %2, i8* %39, i32 %54)
%56 = icmp eq i64 %55, 0
br i1 %56, label %63, label %57
57: ; preds = %53
%58 = load i32, i32* @stderr
%59 = call i64 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.9, i64 0, i64 0), i8* %39, i32 %54, i8* %2)
%60 = call i32 @free(i8* %39)
%61 = load i32, i32* @EIO
%62 = sub nsw i32 0, %61
br label %65
63: ; preds = %53, %51
%64 = call i32 @free(i8* %39)
br label %65
65: ; preds = %35, %11, %63, %57, %47, %41, %28, %19
%66 = phi i32 [ %29, %28 ], [ %45, %47 ], [ %62, %57 ], [ 0, %63 ], [ %43, %41 ], [ %33, %35 ], [ %20, %19 ], [ %9, %11 ]
ret i32 %66
}