#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 */
struct stat {
  int st_size;
};

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ R_OK;
scalar_t__ access(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
unsigned int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
scalar_t__ fstat(int, struct stat *);
char *malloc(int);
int open(char const *, int /*<<< orphan*/);
int read(int, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(unsigned int);
char *cfg_read_file(const char *path, unsigned *len) {
  int fd, rd = 0, total = 0;
  struct stat st;
  char *buf = NULL;
  if (access(path, R_OK) < 0) {
    *len = -errno;
    fprintf(stderr, "Failed to access '%s': %s\n", path, strerror(errno));
    return NULL;
  }
  fd = open(path, O_RDONLY);
  if (fd < 0) {
    *len = -errno;
    fprintf(stderr, "Failed to open '%s': %s\n", path, strerror(errno));
    return NULL;
  }
  if (fstat(fd, &st) < 0) {
    *len = -errno;
    fprintf(stderr, "Failed to stat '%s': %s\n", path, strerror(errno));
    close(fd);
    return NULL;
  }
  buf = malloc(st.st_size + 3);
  if (!buf) {
    *len = -errno;
    fprintf(stderr, "Failed to allocate %lld bytes of memory for '%s'\n",
            (long long)st.st_size, path);
    close(fd);
    return NULL;
  }
  do {
    rd = read(fd, buf + rd, st.st_size - rd);
    total += rd;
  } while (total < st.st_size && rd > 0);
  *len = errno;
  close(fd);
  if (rd < 0 || total != st.st_size) {
    fprintf(stderr, "Reading from '%s' failed: %s\n", path, strerror(*len));
    free(buf);
    return NULL;
  }
  buf[st.st_size] = '\n';
  buf[st.st_size + 1] = '\0';
  *len = st.st_size;
  return buf;
}


x86 assembly (clang, -O0):
<cfg_read_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
call   1090 <access@plt>
cmp    $0x0,%rax
jge    122a <cfg_read_file+0x9a>
xor    %ecx,%ecx
mov    0x2df5(%rip),%rax
sub    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2dee(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    %rax,%rcx
lea    0xdea(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    146e <cfg_read_file+0x2de>
mov    -0x10(%rbp),%rdi
mov    0x2db3(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    12a1 <cfg_read_file+0x111>
xor    %ecx,%ecx
mov    0x2d7e(%rip),%rax
sub    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2d77(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xd8e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    146e <cfg_read_file+0x2de>
mov    -0x1c(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   10b0 <fstat@plt>
cmp    $0x0,%rax
jge    1317 <cfg_read_file+0x187>
xor    %ecx,%ecx
mov    0x2d10(%rip),%rax
sub    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2d09(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2ced(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rdx
mov    %rax,%rcx
lea    0xd39(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
movq   $0x0,-0x8(%rbp)
jmp    146e <cfg_read_file+0x2de>
mov    -0x28(%rbp),%edi
add    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1376 <cfg_read_file+0x1e6>
xor    %ecx,%ecx
mov    0x2c96(%rip),%rax
sub    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
movslq -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xcf3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
movq   $0x0,-0x8(%rbp)
jmp    146e <cfg_read_file+0x2de>
jmp    137b <cfg_read_file+0x1eb>
mov    -0x1c(%rbp),%edi
mov    -0x30(%rbp),%rsi
movslq -0x20(%rbp),%rax
add    %rax,%rsi
mov    -0x28(%rbp),%edx
sub    -0x20(%rbp),%edx
call   1050 <read@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
xor    %eax,%eax
cmp    -0x28(%rbp),%ecx
mov    %al,-0x5d(%rbp)
jge    13bb <cfg_read_file+0x22b>
cmpl   $0x0,-0x20(%rbp)
setg   %al
mov    %al,-0x5d(%rbp)
mov    -0x5d(%rbp),%al
test   $0x1,%al
jne    137b <cfg_read_file+0x1eb>
mov    0x2c03(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
cmpl   $0x0,-0x20(%rbp)
jl     13f3 <cfg_read_file+0x263>
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
je     1440 <cfg_read_file+0x2b0>
mov    0x2bde(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x6c(%rbp),%edi
mov    -0x68(%rbp),%rdx
mov    %rax,%rcx
lea    0xc5c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    146e <cfg_read_file+0x2de>
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
movb   $0xa,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfg_read_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x2e1d(%rip),%rax
mov    (%rax),%esi
call   1090 <access@plt>
test   %rax,%rax
js     1283 <cfg_read_file+0xf3>
mov    0x2e26(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1080 <open@plt>
test   %eax,%eax
js     12ac <cfg_read_file+0x11c>
mov    %eax,%ebp
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   10b0 <fstat@plt>
test   %rax,%rax
js     12e7 <cfg_read_file+0x157>
mov    0x8(%rsp),%r12d
movslq %r12d,%r15
lea    0x3(%r15),%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     1318 <cfg_read_file+0x188>
mov    %rax,%r13
mov    %r15,0x10(%rsp)
mov    %rbx,(%rsp)
xor    %ebx,%ebx
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%esi
add    %r13,%rsi
mov    %r12d,%edx
sub    %ebx,%edx
mov    %ebp,%edi
call   1050 <read@plt>
mov    %eax,%ebx
add    %eax,%r15d
test   %eax,%eax
jle    123f <cfg_read_file+0xaf>
cmp    %r12d,%r15d
jl     1220 <cfg_read_file+0x90>
mov    0x2d8a(%rip),%rax
mov    (%rax),%eax
mov    (%rsp),%rcx
mov    %eax,(%rcx)
mov    %ebp,%edi
call   1040 <close@plt>
test   %ebx,%ebx
js     134e <cfg_read_file+0x1be>
cmp    %r12d,%r15d
jne    134e <cfg_read_file+0x1be>
mov    0x10(%rsp),%rax
movb   $0xa,0x0(%r13,%rax,1)
movb   $0x0,0x1(%rax,%r13,1)
mov    (%rsp),%rax
mov    %r12d,(%rax)
jmp    1383 <cfg_read_file+0x1f3>
mov    0x2d46(%rip),%rax
xor    %r13d,%r13d
xor    %ecx,%ecx
sub    (%rax),%ecx
mov    %ecx,(%rbx)
mov    0x2d3e(%rip),%rcx
mov    (%rcx),%ebx
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd56(%rip),%rsi
jmp    12d3 <cfg_read_file+0x143>
mov    0x2d1d(%rip),%rax
xor    %r13d,%r13d
xor    %ecx,%ecx
sub    (%rax),%ecx
mov    %ecx,(%rbx)
mov    0x2d15(%rip),%rcx
mov    (%rcx),%ebx
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd48(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1383 <cfg_read_file+0x1f3>
mov    0x2ce2(%rip),%rax
xor    %r13d,%r13d
xor    %ecx,%ecx
sub    (%rax),%ecx
mov    %ecx,(%rbx)
mov    0x2cda(%rip),%rcx
mov    (%rcx),%ebx
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd26(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
jmp    133e <cfg_read_file+0x1ae>
mov    0x2cb1(%rip),%rax
xor    %ecx,%ecx
sub    (%rax),%ecx
xor    %r13d,%r13d
mov    %ecx,(%rbx)
mov    0x2ca9(%rip),%rax
mov    (%rax),%edi
lea    0xd15(%rip),%rsi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %ebp,%edi
call   1040 <close@plt>
jmp    1383 <cfg_read_file+0x1f3>
mov    0x2c83(%rip),%rax
mov    (%rax),%ebx
mov    (%rsp),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd16(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %r13d,%r13d
mov    %r13,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@R_OK = global i32 0
@errno = global i32 0
@stderr = global i32 0
@.str = [27 x i8] c"Failed to access '%s': %s\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [25 x i8] c"Failed to open '%s': %s\0A\00"
@.str.2 = [25 x i8] c"Failed to stat '%s': %s\0A\00"
@.str.3 = [50 x i8] c"Failed to allocate %lld bytes of memory for '%s'\0A\00"
@.str.4 = [30 x i8] c"Reading from '%s' failed: %s\0A\00"
define i8* @cfg_read_file(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.stat
%10 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 0, i32* %7
store i32 0, i32* %8
store i8* null, i8** %10
%11 = load i8*, i8** %4
%12 = load i32, i32* @R_OK
%13 = call i64 @access(i8* %11, i32 %12)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %2
%16 = load i32, i32* @errno
%17 = sub i32 0, %16
%18 = load i32*, i32** %5
store i32 %17, i32* %18
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %4
%21 = load i32, i32* @errno
%22 = call i8* @strerror(i32 %21)
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %20, i8* %22)
store i8* null, i8** %3
br label %135
24: ; preds = %2
%25 = load i8*, i8** %4
%26 = load i32, i32* @O_RDONLY
%27 = call i32 @open(i8* %25, i32 %26)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %39
30: ; preds = %24
%31 = load i32, i32* @errno
%32 = sub i32 0, %31
%33 = load i32*, i32** %5
store i32 %32, i32* %33
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %4
%36 = load i32, i32* @errno
%37 = call i8* @strerror(i32 %36)
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %35, i8* %37)
store i8* null, i8** %3
br label %135
39: ; preds = %24
%40 = load i32, i32* %6
%41 = call i64 @fstat(i32 %40, %struct.stat* %9)
%42 = icmp slt i64 %41, 0
br i1 %42, label %43, label %54
43: ; preds = %39
%44 = load i32, i32* @errno
%45 = sub i32 0, %44
%46 = load i32*, i32** %5
store i32 %45, i32* %46
%47 = load i32, i32* @stderr
%48 = load i8*, i8** %4
%49 = load i32, i32* @errno
%50 = call i8* @strerror(i32 %49)
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %48, i8* %50)
%52 = load i32, i32* %6
%53 = call i32 @close(i32 %52)
store i8* null, i8** %3
br label %135
54: ; preds = %39
%55 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%56 = load i32, i32* %55
%57 = add nsw i32 %56, 3
%58 = call i8* @malloc(i32 %57)
store i8* %58, i8** %10
%59 = load i8*, i8** %10
%60 = icmp ne i8* %59, null
br i1 %60, label %73, label %61
61: ; preds = %54
%62 = load i32, i32* @errno
%63 = sub i32 0, %62
%64 = load i32*, i32** %5
store i32 %63, i32* %64
%65 = load i32, i32* @stderr
%66 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%67 = load i32, i32* %66
%68 = sext i32 %67 to i64
%69 = load i8*, i8** %4
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i64 %68, i8* %69)
%71 = load i32, i32* %6
%72 = call i32 @close(i32 %71)
store i8* null, i8** %3
br label %135
73: ; preds = %54
br label %74
74: ; preds = %96, %73
%75 = load i32, i32* %6
%76 = load i8*, i8** %10
%77 = load i32, i32* %7
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %76, i64 %78
%80 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%81 = load i32, i32* %80
%82 = load i32, i32* %7
%83 = sub nsw i32 %81, %82
%84 = call i32 @read(i32 %75, i8* %79, i32 %83)
store i32 %84, i32* %7
%85 = load i32, i32* %7
%86 = load i32, i32* %8
%87 = add nsw i32 %86, %85
store i32 %87, i32* %8
br label %88
88: ; preds = %74
%89 = load i32, i32* %8
%90 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%91 = load i32, i32* %90
%92 = icmp slt i32 %89, %91
br i1 %92, label %93, label %96
93: ; preds = %88
%94 = load i32, i32* %7
%95 = icmp sgt i32 %94, 0
br label %96
96: ; preds = %93, %88
%97 = phi i1 [ false, %88 ], [ %95, %93 ]
br i1 %97, label %74, label %98
98: ; preds = %96
%99 = load i32, i32* @errno
%100 = load i32*, i32** %5
store i32 %99, i32* %100
%101 = load i32, i32* %6
%102 = call i32 @close(i32 %101)
%103 = load i32, i32* %7
%104 = icmp slt i32 %103, 0
br i1 %104, label %110, label %105
105: ; preds = %98
%106 = load i32, i32* %8
%107 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%108 = load i32, i32* %107
%109 = icmp ne i32 %106, %108
br i1 %109, label %110, label %119
110: ; preds = %105, %98
%111 = load i32, i32* @stderr
%112 = load i8*, i8** %4
%113 = load i32*, i32** %5
%114 = load i32, i32* %113
%115 = call i8* @strerror(i32 %114)
%116 = call i32 (i32, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %112, i8* %115)
%117 = load i8*, i8** %10
%118 = call i32 @free(i8* %117)
store i8* null, i8** %3
br label %135
119: ; preds = %105
%120 = load i8*, i8** %10
%121 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%122 = load i32, i32* %121
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i8, i8* %120, i64 %123
store i8 10, i8* %124
%125 = load i8*, i8** %10
%126 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%127 = load i32, i32* %126
%128 = add nsw i32 %127, 1
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i8, i8* %125, i64 %129
store i8 0, i8* %130
%131 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%132 = load i32, i32* %131
%133 = load i32*, i32** %5
store i32 %132, i32* %133
%134 = load i8*, i8** %10
store i8* %134, i8** %3
br label %135
135: ; preds = %119, %110, %61, %43, %30, %15
%136 = load i8*, i8** %3
ret i8* %136
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@R_OK = global i32 0
@errno = global i32 0
@stderr = global i32 0
@.str = [27 x i8] c"Failed to access '%s': %s\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [25 x i8] c"Failed to open '%s': %s\0A\00"
@.str.2 = [25 x i8] c"Failed to stat '%s': %s\0A\00"
@.str.3 = [50 x i8] c"Failed to allocate %lld bytes of memory for '%s'\0A\00"
@.str.4 = [30 x i8] c"Reading from '%s' failed: %s\0A\00"
define noalias i8* @cfg_read_file(i8* %0, i32* nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = load i32, i32* @R_OK
%6 = tail call i64 @access(i8* %0, i32 %5)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = load i32, i32* @errno
%10 = sub i32 0, %9
store i32 %10, i32* %1
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = tail call i8* @strerror(i32 %12)
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %13)
br label %79
15: ; preds = %2
%16 = load i32, i32* @O_RDONLY
%17 = tail call i32 @open(i8* %0, i32 %16)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %15
%20 = load i32, i32* @errno
%21 = sub i32 0, %20
store i32 %21, i32* %1
%22 = load i32, i32* @stderr
%23 = load i32, i32* @errno
%24 = tail call i8* @strerror(i32 %23)
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %24)
br label %79
26: ; preds = %15
%27 = call i64 @fstat(i32 %17, %struct.stat* %3)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %37
29: ; preds = %26
%30 = load i32, i32* @errno
%31 = sub i32 0, %30
store i32 %31, i32* %1
%32 = load i32, i32* @stderr
%33 = load i32, i32* @errno
%34 = tail call i8* @strerror(i32 %33)
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %34)
%36 = tail call i32 @close(i32 %17)
br label %79
37: ; preds = %26
%38 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 3
%41 = tail call i8* @malloc(i32 %40)
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %50
43: ; preds = %37
%44 = load i32, i32* @errno
%45 = sub i32 0, %44
store i32 %45, i32* %1
%46 = load i32, i32* @stderr
%47 = sext i32 %39 to i64
%48 = tail call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i64 %47, i8* %0)
%49 = tail call i32 @close(i32 %17)
br label %79
50: ; preds = %37, %50
%51 = phi i32 [ %56, %50 ], [ 0, %37 ]
%52 = phi i32 [ %57, %50 ], [ 0, %37 ]
%53 = zext i32 %51 to i64
%54 = getelementptr inbounds i8, i8* %41, i64 %53
%55 = sub nsw i32 %39, %51
%56 = tail call i32 @read(i32 %17, i8* %54, i32 %55)
%57 = add nsw i32 %56, %52
%58 = icmp slt i32 %57, %39
%59 = icmp sgt i32 %56, 0
%60 = and i1 %59, %58
br i1 %60, label %50, label %61
61: ; preds = %50
%62 = load i32, i32* @errno
store i32 %62, i32* %1
%63 = tail call i32 @close(i32 %17)
%64 = icmp sgt i32 %56, -1
%65 = icmp eq i32 %57, %39
%66 = select i1 %64, i1 %65, i1 false
br i1 %66, label %73, label %67
67: ; preds = %61
%68 = load i32, i32* @stderr
%69 = load i32, i32* %1
%70 = tail call i8* @strerror(i32 %69)
%71 = tail call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* %70)
%72 = tail call i32 @free(i8* %41)
br label %79
73: ; preds = %61
%74 = sext i32 %39 to i64
%75 = getelementptr inbounds i8, i8* %41, i64 %74
store i8 10, i8* %75
%76 = add nsw i32 %39, 1
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8, i8* %41, i64 %77
store i8 0, i8* %78
store i32 %39, i32* %1
br label %79
79: ; preds = %73, %67, %43, %29, %19, %8
%80 = phi i8* [ null, %8 ], [ null, %19 ], [ null, %29 ], [ null, %67 ], [ %41, %73 ], [ null, %43 ]
ret i8* %80
}