#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 {
  scalar_t__ st_size;
};
typedef int /*<<< orphan*/ inc;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ logger(int, int /*<<< orphan*/, char *, ...);
char *malloc(scalar_t__);
int open(char const *, int /*<<< orphan*/);
int read(int, char *, scalar_t__);
char *realloc(char *, scalar_t__);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
scalar_t__ stat(char const *, struct stat *);
scalar_t__ stat_file(char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char const *);
char *strrchr(char const *, char);
int read_script(const char *fname, char *include, char **buf) {
  struct stat st;
  char *tmp, *p = NULL;
  int fd, len = 0;
  char *inc;
  if (!fname) {
    logger(-1, 0, "read_script: file name not specified");
    return -1;
  }
  if (include != NULL) {
    inc = malloc(strlen(fname) + strlen(include) + 1);
    if ((p = strrchr(fname, '/')) != NULL) {
      snprintf(inc, p - fname + 2, "%s", fname);
      strcat(inc, include);
    } else {
      snprintf(inc, sizeof(inc), "%s", include);
    }
    if (stat_file(inc))
      len = read_script(inc, NULL, buf);
    if (inc != NULL)
      free(inc);
    if (len < 0)
      return -1;
  }
  if (stat(fname, &st)) {
    logger(-1, 0, "file %s not found", fname);
    return -1;
  }
  if ((fd = open(fname, O_RDONLY)) < 0) {
    logger(-1, errno, "Unable to open %s", fname);
    goto err;
  }
  if (*buf != NULL) {
    tmp = realloc(*buf, st.st_size + len + 2);
    if (tmp == NULL)
      goto err;
    *buf = tmp;
    p = *buf + len;
  } else {
    *buf = malloc(st.st_size + 2);
    if (*buf == NULL)
      goto err;
    p = *buf;
  }
  if ((len = read(fd, p, st.st_size)) < 0) {
    logger(-1, errno, "Error reading %s", fname);
    goto err;
  }
  p += len;
  p[0] = '\n';
  p[1] = 0;
  close(fd);
  return len;
err:
  if (fd > 0)
    close(fd);
  if (*buf != NULL)
    free(*buf);
  return -1;
}


x86 assembly (clang, -O0):
<read_script>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x40(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    122f <read_script+0x4f>
mov    $0xffffffff,%edi
xor    %esi,%esi
lea    0xde4(%rip),%rdx
mov    $0x0,%al
call   10b0 <logger@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e0 <read_script+0x300>
cmpq   $0x0,-0x18(%rbp)
je     1326 <read_script+0x146>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x50(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   10c0 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     12b7 <read_script+0xd7>
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x2,%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rcx
lea    0xdb7(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10f0 <strcat@plt>
jmp    12d0 <read_script+0xf0>
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x8,%esi
lea    0xd8c(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x48(%rbp),%rdi
call   1090 <stat_file@plt>
cmp    $0x0,%rax
je     12f7 <read_script+0x117>
mov    -0x48(%rbp),%rdi
mov    -0x20(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%esi
call   1100 <read_script@plt>
mov    %eax,-0x40(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     130b <read_script+0x12b>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x40(%rbp)
jge    1321 <read_script+0x141>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e0 <read_script+0x300>
jmp    1326 <read_script+0x146>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   10a0 <stat@plt>
cmp    $0x0,%rax
je     1362 <read_script+0x182>
mov    -0x10(%rbp),%rcx
mov    $0xffffffff,%edi
xor    %esi,%esi
lea    0xcd6(%rip),%rdx
mov    $0x0,%al
call   10b0 <logger@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e0 <read_script+0x300>
mov    -0x10(%rbp),%rdi
mov    0x2c7b(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0x0,%eax
jge    13a5 <read_script+0x1c5>
mov    0x2c51(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rcx
mov    $0xffffffff,%edi
lea    0xc9e(%rip),%rdx
mov    $0x0,%al
call   10b0 <logger@plt>
jmp    14ad <read_script+0x2cd>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     1404 <read_script+0x224>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x40(%rbp),%rax
add    %rax,%rsi
add    $0x2,%rsi
call   10d0 <realloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    13e2 <read_script+0x202>
jmp    14ad <read_script+0x2cd>
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movslq -0x40(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
jmp    1439 <read_script+0x259>
mov    -0x28(%rbp),%rdi
add    $0x2,%rdi
call   10c0 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    142e <read_script+0x24e>
jmp    14ad <read_script+0x2cd>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1080 <read@plt>
mov    %eax,-0x40(%rbp)
cmp    $0x0,%eax
jge    147a <read_script+0x29a>
mov    0x2b7c(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rcx
mov    $0xffffffff,%edi
lea    0xbdb(%rip),%rdx
mov    $0x0,%al
call   10b0 <logger@plt>
jmp    14ad <read_script+0x2cd>
mov    -0x40(%rbp),%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movb   $0xa,(%rax)
mov    -0x38(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x3c(%rbp),%edi
call   1070 <close@plt>
mov    -0x40(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14e0 <read_script+0x300>
cmpl   $0x0,-0x3c(%rbp)
jle    14bf <read_script+0x2df>
mov    -0x3c(%rbp),%edi
call   1070 <close@plt>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     14d9 <read_script+0x2f9>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_script>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     125a <read_script+0x7a>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
test   %rsi,%rsi
je     1279 <read_script+0x99>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    (%rax,%rbp,1),%rdi
add    $0x1,%rdi
call   10c0 <malloc@plt>
mov    %rax,%rbp
mov    %r15,%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
test   %rax,%rax
je     127d <read_script+0x9d>
sub    %r15d,%eax
add    $0x2,%eax
lea    0xe17(%rip),%rdx
mov    %rbp,%rdi
mov    %eax,%esi
mov    %r15,%rcx
call   1050 <snprintf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10f0 <strcat@plt>
jmp    1294 <read_script+0xb4>
lea    0xd9f(%rip),%rdx
mov    $0xffffffff,%ebx
mov    $0xffffffff,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10b0 <logger@plt>
jmp    13fa <read_script+0x21a>
xor    %ebx,%ebx
jmp    12c9 <read_script+0xe9>
lea    0xdd3(%rip),%rdx
mov    %rbp,%rdi
mov    $0x8,%esi
mov    %rbx,%rcx
call   1050 <snprintf@plt>
mov    %rbp,%rdi
call   1090 <stat_file@plt>
test   %rax,%rax
je     1346 <read_script+0x166>
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1100 <read_script@plt>
mov    %eax,%ebx
test   %rbp,%rbp
je     12c1 <read_script+0xe1>
mov    %rbp,%rdi
call   1030 <free@plt>
test   %ebx,%ebx
js     1356 <read_script+0x176>
mov    %rsp,%rsi
mov    %r15,%rdi
call   10a0 <stat@plt>
test   %rax,%rax
je     12fb <read_script+0x11b>
lea    0xd45(%rip),%rdx
mov    $0xffffffff,%ebx
mov    $0xffffffff,%edi
xor    %esi,%esi
mov    %r15,%rcx
xor    %eax,%eax
call   10b0 <logger@plt>
jmp    13fa <read_script+0x21a>
mov    0x2ce6(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   10e0 <open@plt>
test   %eax,%eax
js     1360 <read_script+0x180>
mov    %eax,%r12d
mov    (%r14),%rdi
mov    (%rsp),%r13
test   %rdi,%rdi
je     1381 <read_script+0x1a1>
mov    %ebx,%ebp
lea    0x2(,%r13,1),%rsi
add    %rbp,%rsi
call   10d0 <realloc@plt>
test   %rax,%rax
je     13db <read_script+0x1fb>
mov    %rax,(%r14)
add    %rax,%rbp
mov    (%rsp),%r13
jmp    1395 <read_script+0x1b5>
xor    %ebx,%ebx
test   %rbp,%rbp
jne    12b9 <read_script+0xd9>
jmp    12c1 <read_script+0xe1>
mov    $0xffffffff,%ebx
jmp    13fa <read_script+0x21a>
mov    0x2c71(%rip),%rax
mov    (%rax),%esi
lea    0xcc7(%rip),%rdx
mov    $0xffffffff,%edi
mov    %r15,%rcx
xor    %eax,%eax
call   10b0 <logger@plt>
jmp    13e8 <read_script+0x208>
lea    0x2(%r13),%rdi
call   10c0 <malloc@plt>
mov    %rax,%rbp
mov    %rax,(%r14)
test   %rax,%rax
je     13db <read_script+0x1fb>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    %r13,%rdx
call   1080 <read@plt>
test   %eax,%eax
js     13bc <read_script+0x1dc>
mov    %eax,%ebx
mov    %eax,%eax
movw   $0xa,0x0(%rbp,%rax,1)
mov    %r12d,%edi
call   1070 <close@plt>
jmp    13fa <read_script+0x21a>
mov    0x2c15(%rip),%rax
mov    (%rax),%esi
lea    0xc7d(%rip),%rdx
mov    $0xffffffff,%edi
mov    %r15,%rcx
xor    %eax,%eax
call   10b0 <logger@plt>
test   %r12d,%r12d
je     13e8 <read_script+0x208>
mov    %r12d,%edi
call   1070 <close@plt>
mov    (%r14),%rdi
mov    $0xffffffff,%ebx
test   %rdi,%rdi
je     13fa <read_script+0x21a>
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
@.str = [37 x i8] c"read_script: file name not specified\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [18 x i8] c"file %s not found\00"
@O_RDONLY = global i32 0
@errno = global i32 0
@.str.3 = [18 x i8] c"Unable to open %s\00"
@.str.4 = [17 x i8] c"Error reading %s\00"
define i32 @read_script(i8* %0, i8* %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca %struct.stat
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8** %2, i8*** %7
store i8* null, i8** %10
store i32 0, i32* %12
%14 = load i8*, i8** %5
%15 = icmp ne i8* %14, null
br i1 %15, label %18, label %16
16: ; preds = %3
%17 = call i32 (i32, i32, i8*, ...) @logger(i32 -1, i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %161
18: ; preds = %3
%19 = load i8*, i8** %6
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %69
21: ; preds = %18
%22 = load i8*, i8** %5
%23 = call i64 @strlen(i8* %22)
%24 = load i8*, i8** %6
%25 = call i64 @strlen(i8* %24)
%26 = add nsw i64 %23, %25
%27 = add nsw i64 %26, 1
%28 = call i8* @malloc(i64 %27)
store i8* %28, i8** %13
%29 = load i8*, i8** %5
%30 = call i8* @strrchr(i8* %29, i8 signext 47)
store i8* %30, i8** %10
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %46
32: ; preds = %21
%33 = load i8*, i8** %13
%34 = load i8*, i8** %10
%35 = load i8*, i8** %5
%36 = ptrtoint i8* %34 to i64
%37 = ptrtoint i8* %35 to i64
%38 = sub i64 %36, %37
%39 = add nsw i64 %38, 2
%40 = trunc i64 %39 to i32
%41 = load i8*, i8** %5
%42 = call i32 @snprintf(i8* %33, i32 %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %41)
%43 = load i8*, i8** %13
%44 = load i8*, i8** %6
%45 = call i32 @strcat(i8* %43, i8* %44)
br label %50
46: ; preds = %21
%47 = load i8*, i8** %13
%48 = load i8*, i8** %6
%49 = call i32 @snprintf(i8* %47, i32 8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %46, %32
%51 = load i8*, i8** %13
%52 = call i64 @stat_file(i8* %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %50
%55 = load i8*, i8** %13
%56 = load i8**, i8*** %7
%57 = call i32 @read_script(i8* %55, i8* null, i8** %56)
store i32 %57, i32* %12
br label %58
58: ; preds = %54, %50
%59 = load i8*, i8** %13
%60 = icmp ne i8* %59, null
br i1 %60, label %61, label %64
61: ; preds = %58
%62 = load i8*, i8** %13
%63 = call i32 @free(i8* %62)
br label %64
64: ; preds = %61, %58
%65 = load i32, i32* %12
%66 = icmp slt i32 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %64
store i32 -1, i32* %4
br label %161
68: ; preds = %64
br label %69
69: ; preds = %68, %18
%70 = load i8*, i8** %5
%71 = call i64 @stat(i8* %70, %struct.stat* %8)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %69
%74 = load i8*, i8** %5
%75 = call i32 (i32, i32, i8*, ...) @logger(i32 -1, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %74)
store i32 -1, i32* %4
br label %161
76: ; preds = %69
%77 = load i8*, i8** %5
%78 = load i32, i32* @O_RDONLY
%79 = call i32 @open(i8* %77, i32 %78)
store i32 %79, i32* %11
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %85
81: ; preds = %76
%82 = load i32, i32* @errno
%83 = load i8*, i8** %5
%84 = call i32 (i32, i32, i8*, ...) @logger(i32 -1, i32 %82, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %83)
br label %146
85: ; preds = %76
%86 = load i8**, i8*** %7
%87 = load i8*, i8** %86
%88 = icmp ne i8* %87, null
br i1 %88, label %89, label %110
89: ; preds = %85
%90 = load i8**, i8*** %7
%91 = load i8*, i8** %90
%92 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%93 = load i64, i64* %92
%94 = load i32, i32* %12
%95 = sext i32 %94 to i64
%96 = add nsw i64 %93, %95
%97 = add nsw i64 %96, 2
%98 = call i8* @realloc(i8* %91, i64 %97)
store i8* %98, i8** %9
%99 = load i8*, i8** %9
%100 = icmp eq i8* %99, null
br i1 %100, label %101, label %102
101: ; preds = %89
br label %146
102: ; preds = %89
%103 = load i8*, i8** %9
%104 = load i8**, i8*** %7
store i8* %103, i8** %104
%105 = load i8**, i8*** %7
%106 = load i8*, i8** %105
%107 = load i32, i32* %12
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %106, i64 %108
store i8* %109, i8** %10
br label %123
110: ; preds = %85
%111 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%112 = load i64, i64* %111
%113 = add nsw i64 %112, 2
%114 = call i8* @malloc(i64 %113)
%115 = load i8**, i8*** %7
store i8* %114, i8** %115
%116 = load i8**, i8*** %7
%117 = load i8*, i8** %116
%118 = icmp eq i8* %117, null
br i1 %118, label %119, label %120
119: ; preds = %110
br label %146
120: ; preds = %110
%121 = load i8**, i8*** %7
%122 = load i8*, i8** %121
store i8* %122, i8** %10
br label %123
123: ; preds = %120, %102
%124 = load i32, i32* %11
%125 = load i8*, i8** %10
%126 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%127 = load i64, i64* %126
%128 = call i32 @read(i32 %124, i8* %125, i64 %127)
store i32 %128, i32* %12
%129 = icmp slt i32 %128, 0
br i1 %129, label %130, label %134
130: ; preds = %123
%131 = load i32, i32* @errno
%132 = load i8*, i8** %5
%133 = call i32 (i32, i32, i8*, ...) @logger(i32 -1, i32 %131, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %132)
br label %146
134: ; preds = %123
%135 = load i32, i32* %12
%136 = load i8*, i8** %10
%137 = sext i32 %135 to i64
%138 = getelementptr inbounds i8, i8* %136, i64 %137
store i8* %138, i8** %10
%139 = load i8*, i8** %10
%140 = getelementptr inbounds i8, i8* %139, i64 0
store i8 10, i8* %140
%141 = load i8*, i8** %10
%142 = getelementptr inbounds i8, i8* %141, i64 1
store i8 0, i8* %142
%143 = load i32, i32* %11
%144 = call i32 @close(i32 %143)
%145 = load i32, i32* %12
store i32 %145, i32* %4
br label %161
146: ; preds = %130, %119, %101, %81
%147 = load i32, i32* %11
%148 = icmp sgt i32 %147, 0
br i1 %148, label %149, label %152
149: ; preds = %146
%150 = load i32, i32* %11
%151 = call i32 @close(i32 %150)
br label %152
152: ; preds = %149, %146
%153 = load i8**, i8*** %7
%154 = load i8*, i8** %153
%155 = icmp ne i8* %154, null
br i1 %155, label %156, label %160
156: ; preds = %152
%157 = load i8**, i8*** %7
%158 = load i8*, i8** %157
%159 = call i32 @free(i8* %158)
br label %160
160: ; preds = %156, %152
store i32 -1, i32* %4
br label %161
161: ; preds = %160, %134, %73, %67, %16
%162 = load i32, i32* %4
ret i32 %162
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@.str = [37 x i8] c"read_script: file name not specified\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [18 x i8] c"file %s not found\00"
@O_RDONLY = global i32 0
@errno = global i32 0
@.str.3 = [18 x i8] c"Unable to open %s\00"
@.str.4 = [17 x i8] c"Error reading %s\00"
define i32 @read_script(i8* %0, i8* %1, i8** nocapture %2) {
%4 = alloca %struct.stat
%5 = bitcast %struct.stat* %4 to i8*
%6 = icmp eq i8* %0, null
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 (i32, i32, i8*, ...) @logger(i32 -1, i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %94
9: ; preds = %3
%10 = icmp eq i8* %1, null
br i1 %10, label %41, label %11
11: ; preds = %9
%12 = tail call i64 @strlen(i8* %0)
%13 = tail call i64 @strlen(i8* %1)
%14 = add i64 %12, 1
%15 = add i64 %14, %13
%16 = tail call i8* @malloc(i64 %15)
%17 = tail call i8* @strrchr(i8* %0, i8 signext 47)
%18 = icmp eq i8* %17, null
br i1 %18, label %27, label %19
19: ; preds = %11
%20 = ptrtoint i8* %17 to i64
%21 = ptrtoint i8* %0 to i64
%22 = sub i64 %20, %21
%23 = trunc i64 %22 to i32
%24 = add i32 %23, 2
%25 = tail call i32 @snprintf(i8* %16, i32 %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%26 = tail call i32 @strcat(i8* %16, i8* %1)
br label %29
27: ; preds = %11
%28 = tail call i32 @snprintf(i8* %16, i32 8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %29
29: ; preds = %27, %19
%30 = tail call i64 @stat_file(i8* %16)
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = tail call i32 @read_script(i8* %16, i8* null, i8** %2)
br label %34
34: ; preds = %32, %29
%35 = phi i32 [ %33, %32 ], [ 0, %29 ]
%36 = icmp eq i8* %16, null
br i1 %36, label %39, label %37
37: ; preds = %34
%38 = tail call i32 @free(i8* %16)
br label %39
39: ; preds = %37, %34
%40 = icmp slt i32 %35, 0
br i1 %40, label %94, label %41
41: ; preds = %39, %9
%42 = phi i32 [ %35, %39 ], [ 0, %9 ]
%43 = call i64 @stat(i8* %0, %struct.stat* %4)
%44 = icmp eq i64 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %41
%46 = call i32 (i32, i32, i8*, ...) @logger(i32 -1, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %94
47: ; preds = %41
%48 = load i32, i32* @O_RDONLY
%49 = call i32 @open(i8* %0, i32 %48)
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = load i32, i32* @errno
%53 = call i32 (i32, i32, i8*, ...) @logger(i32 -1, i32 %52, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %89
54: ; preds = %47
%55 = load i8*, i8** %2
%56 = icmp eq i8* %55, null
%57 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%58 = load i64, i64* %57
br i1 %56, label %68, label %59
59: ; preds = %54
%60 = zext i32 %42 to i64
%61 = add nuw nsw i64 %60, 2
%62 = add i64 %61, %58
%63 = call i8* @realloc(i8* %55, i64 %62)
%64 = icmp eq i8* %63, null
br i1 %64, label %85, label %65
65: ; preds = %59
store i8* %63, i8** %2
%66 = getelementptr inbounds i8, i8* %63, i64 %60
%67 = load i64, i64* %57
br label %72
68: ; preds = %54
%69 = add nsw i64 %58, 2
%70 = call i8* @malloc(i64 %69)
store i8* %70, i8** %2
%71 = icmp eq i8* %70, null
br i1 %71, label %85, label %72
72: ; preds = %68, %65
%73 = phi i64 [ %67, %65 ], [ %58, %68 ]
%74 = phi i8* [ %66, %65 ], [ %70, %68 ]
%75 = call i32 @read(i32 %49, i8* %74, i64 %73)
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %80
77: ; preds = %72
%78 = load i32, i32* @errno
%79 = call i32 (i32, i32, i8*, ...) @logger(i32 -1, i32 %78, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %85
80: ; preds = %72
%81 = zext i32 %75 to i64
%82 = getelementptr inbounds i8, i8* %74, i64 %81
store i8 10, i8* %82
%83 = getelementptr inbounds i8, i8* %82, i64 1
store i8 0, i8* %83
%84 = call i32 @close(i32 %49)
br label %94
85: ; preds = %68, %59, %77
%86 = icmp eq i32 %49, 0
br i1 %86, label %89, label %87
87: ; preds = %85
%88 = call i32 @close(i32 %49)
br label %89
89: ; preds = %51, %87, %85
%90 = load i8*, i8** %2
%91 = icmp eq i8* %90, null
br i1 %91, label %94, label %92
92: ; preds = %89
%93 = call i32 @free(i8* %90)
br label %94
94: ; preds = %89, %92, %39, %80, %45, %7
%95 = phi i32 [ -1, %45 ], [ %75, %80 ], [ -1, %7 ], [ -1, %39 ], [ -1, %92 ], [ -1, %89 ]
ret i32 %95
}