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

/* Variables and functions */
int EOF;
char *calloc(int, int);
int /*<<< orphan*/ chdir(char *);
int error_code(int, char *, ...);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *get_conf_line(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ getcwd(char *, int);
char *getenv(char *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
char *realloc(char *, size_t);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ unquote_str(char *);
int mod_find_p(char *mod, char *script, char *args, char **ret) {
  char *home_dir;
  char *str, *s;
  char pwd[2048];
  size_t n = 256;
  FILE *pipe;
  int c, p = 0;
  if (!(home_dir = getenv("mod_root")))
    return error_code(-1, "Missing environment variable $mod_root.");
  str = calloc(256 + n, sizeof(char));
  snprintf(str, (256 + n), "%s/%s/info.txt", home_dir, mod);
  if ((s = get_conf_line(str, script))) {
    unquote_str(script = s);
    getcwd(pwd, sizeof(pwd));
    sprintf(str, "%s/%s", home_dir, mod);
    if (chdir(str))
      return error_code(1, "Module missing. (%s)", mod);
    sprintf(str, "./%s %s", script, args ? args : "");
    if ((pipe = popen(str, "r"))) {
      while ((c = getc(pipe)) != EOF) {
        if (ret) {
          if (p > n) {
            n += 256;
            str = realloc(str, n * sizeof(char));
          }
          str[p++] = c;
        } else
          fputc(c, stdout);
      }
      str[p] = 0;
      pclose(pipe);
    }
    chdir(pwd);
    if (!ret)
      (free(str), (str) = NULL);
    else
      *ret = str;
  } else
    return error_code(1, "No script found. (%s:%s)", mod, script);
  return 0;
}


x86 assembly (clang, -O0):
<mod_find_p>:
push   %rbp
mov    %rsp,%rbp
sub    $0x870,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movq   $0x100,-0x848(%rbp)
movl   $0x0,-0x858(%rbp)
lea    0xdd9(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1255 <mod_find_p+0x65>
mov    $0xffffffff,%edi
lea    0xdc3(%rip),%rsi
mov    $0x0,%al
call   10c0 <error_code@plt>
mov    %eax,-0x4(%rbp)
jmp    14d5 <mod_find_p+0x2e5>
mov    -0x848(%rbp),%rax
add    $0x100,%rax
mov    %eax,%edi
mov    $0x1,%esi
call   10b0 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x848(%rbp),%rax
add    $0x100,%rax
mov    %eax,%esi
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xd9d(%rip),%rdx
call   1080 <snprintf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <get_conf_line@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
je     14ab <mod_find_p+0x2bb>
mov    -0x40(%rbp),%rdi
mov    %rdi,-0x18(%rbp)
call   10d0 <unquote_str@plt>
lea    -0x840(%rbp),%rdi
mov    $0x800,%esi
call   1090 <getcwd@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xd5b(%rip),%rsi
call   1100 <sprintf@plt>
mov    -0x38(%rbp),%rdi
call   1060 <chdir@plt>
cmp    $0x0,%eax
je     131b <mod_find_p+0x12b>
mov    -0x10(%rbp),%rdx
mov    $0x1,%edi
lea    0xd3a(%rip),%rsi
mov    $0x0,%al
call   10c0 <error_code@plt>
mov    %eax,-0x4(%rbp)
jmp    14d5 <mod_find_p+0x2e5>
mov    -0x38(%rbp),%rax
mov    %rax,-0x868(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x860(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     134c <mod_find_p+0x15c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x870(%rbp)
jmp    135f <mod_find_p+0x16f>
lea    0xd07(%rip),%rax
mov    %rax,-0x870(%rbp)
jmp    135f <mod_find_p+0x16f>
mov    -0x860(%rbp),%rdx
mov    -0x868(%rbp),%rdi
mov    -0x870(%rbp),%rcx
lea    0xce0(%rip),%rsi
call   1100 <sprintf@plt>
mov    -0x38(%rbp),%rdi
lea    0xcd8(%rip),%rsi
call   10f0 <popen@plt>
mov    %rax,-0x850(%rbp)
cmp    $0x0,%rax
je     146e <mod_find_p+0x27e>
jmp    13a6 <mod_find_p+0x1b6>
mov    -0x850(%rbp),%rdi
call   1110 <getc@plt>
mov    %eax,-0x854(%rbp)
mov    0x2c29(%rip),%rcx
cmp    (%rcx),%eax
je     1453 <mod_find_p+0x263>
cmpq   $0x0,-0x28(%rbp)
je     143a <mod_find_p+0x24a>
movslq -0x858(%rbp),%rax
cmp    -0x848(%rbp),%rax
jbe    1412 <mod_find_p+0x222>
mov    -0x848(%rbp),%rax
add    $0x100,%rax
mov    %rax,-0x848(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x848(%rbp),%rsi
shl    $0x0,%rsi
call   10e0 <realloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x854(%rbp),%eax
mov    %al,%dl
mov    -0x38(%rbp),%rax
mov    -0x858(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x858(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    144e <mod_find_p+0x25e>
mov    -0x854(%rbp),%edi
mov    0x2b91(%rip),%rax
mov    (%rax),%esi
call   10a0 <fputc@plt>
jmp    13a6 <mod_find_p+0x1b6>
mov    -0x38(%rbp),%rax
movslq -0x858(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x850(%rbp),%rdi
call   1070 <pclose@plt>
lea    -0x840(%rbp),%rdi
call   1060 <chdir@plt>
cmpq   $0x0,-0x28(%rbp)
jne    149b <mod_find_p+0x2ab>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x38(%rbp)
jmp    14a6 <mod_find_p+0x2b6>
mov    -0x38(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
jmp    14ce <mod_find_p+0x2de>
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%edi
lea    0xba6(%rip),%rsi
mov    $0x0,%al
call   10c0 <error_code@plt>
mov    %eax,-0x4(%rbp)
jmp    14d5 <mod_find_p+0x2e5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x870,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod_find_p>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
mov    %rcx,0x8(%rsp)
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xdea(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     12b9 <mod_find_p+0xc9>
mov    %rax,%rbp
mov    $0x200,%edi
mov    $0x1,%esi
call   10b0 <calloc@plt>
mov    %rax,%r13
lea    0xdf1(%rip),%rdx
mov    %rax,%rdi
mov    $0x200,%esi
mov    %rbp,%rcx
mov    %r15,%r8
call   1080 <snprintf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <get_conf_line@plt>
test   %rax,%rax
je     12dd <mod_find_p+0xed>
mov    %rax,%r14
mov    %rax,%rdi
call   10d0 <unquote_str@plt>
lea    0x10(%rsp),%rdi
mov    $0x800,%esi
call   1090 <getcwd@plt>
lea    0xdbc(%rip),%rsi
mov    %r13,%rdi
mov    %rbp,%rdx
mov    %r15,%rcx
call   1100 <sprintf@plt>
mov    %r13,%rdi
call   1060 <chdir@plt>
test   %eax,%eax
je     1307 <mod_find_p+0x117>
lea    0xda1(%rip),%rsi
mov    $0x1,%edi
mov    %r15,%rdx
xor    %eax,%eax
call   10c0 <error_code@plt>
jmp    1391 <mod_find_p+0x1a1>
lea    0xd49(%rip),%rsi
mov    $0xffffffff,%edi
xor    %eax,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10c0 <error_code@plt>
lea    0xd81(%rip),%rsi
mov    $0x1,%edi
mov    %r15,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10c0 <error_code@plt>
test   %r12,%r12
lea    0xd49(%rip),%rcx
cmovne %r12,%rcx
lea    0xd3f(%rip),%rsi
mov    %r13,%rdi
mov    %r14,%rdx
call   1100 <sprintf@plt>
lea    0xd35(%rip),%rsi
mov    %r13,%rdi
call   10f0 <popen@plt>
test   %rax,%rax
je     136e <mod_find_p+0x17e>
mov    %rax,%r15
mov    %rax,%rdi
call   1110 <getc@plt>
mov    %eax,%ebp
mov    0x2c99(%rip),%rax
xor    %r14d,%r14d
cmp    (%rax),%ebp
mov    0x8(%rsp),%rbx
jne    13a3 <mod_find_p+0x1b3>
movslq %r14d,%rax
movb   $0x0,0x0(%r13,%rax,1)
mov    %r15,%rdi
call   1070 <pclose@plt>
jmp    1373 <mod_find_p+0x183>
mov    0x8(%rsp),%rbx
lea    0x10(%rsp),%rdi
call   1060 <chdir@plt>
test   %rbx,%rbx
je     1387 <mod_find_p+0x197>
mov    %r13,(%rbx)
jmp    138f <mod_find_p+0x19f>
mov    %r13,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x100,%r12d
xor    %r14d,%r14d
jmp    13d9 <mod_find_p+0x1e9>
xchg   %ax,%ax
mov    0x2c21(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   10a0 <fputc@plt>
mov    %r15,%rdi
call   1110 <getc@plt>
mov    %eax,%ebp
mov    0x2c17(%rip),%rax
cmp    (%rax),%ebp
je     135b <mod_find_p+0x16b>
test   %rbx,%rbx
je     13b0 <mod_find_p+0x1c0>
movslq %r14d,%rbx
cmp    %rbx,%r12
jae    13fb <mod_find_p+0x20b>
add    $0x100,%r12
mov    %r13,%rdi
mov    %r12,%rsi
call   10e0 <realloc@plt>
mov    %rax,%r13
lea    0x1(%rbx),%r14d
mov    %bpl,0x0(%r13,%rbx,1)
mov    0x8(%rsp),%rbx
jmp    13c0 <mod_find_p+0x1d0>

LLVM IR (-O0):
@.str = [9 x i8] c"mod_root\00"
@.str.1 = [40 x i8] c"Missing environment variable $mod_root.\00"
@.str.2 = [15 x i8] c"%s/%s/info.txt\00"
@.str.3 = [6 x i8] c"%s/%s\00"
@.str.4 = [21 x i8] c"Module missing. (%s)\00"
@.str.5 = [8 x i8] c"./%s %s\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [2 x i8] c"r\00"
@EOF = global i32 0
@stdout = global i32 0
@.str.8 = [25 x i8] c"No script found. (%s:%s)\00"
define i32 @mod_find_p(i8* %0, i8* %1, i8* %2, i8** %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8**
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca [2048 x i8]
%14 = alloca i64
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8** %3, i8*** %9
store i64 256, i64* %14
store i32 0, i32* %17
%18 = call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i8* %18, i8** %10
%19 = icmp ne i8* %18, null
br i1 %19, label %22, label %20
20: ; preds = %4
%21 = call i32 (i32, i8*, ...) @error_code(i32 -1, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
store i32 %21, i32* %5
br label %125
22: ; preds = %4
%23 = load i64, i64* %14
%24 = add i64 256, %23
%25 = trunc i64 %24 to i32
%26 = call i8* @calloc(i32 %25, i32 1)
store i8* %26, i8** %11
%27 = load i8*, i8** %11
%28 = load i64, i64* %14
%29 = add i64 256, %28
%30 = trunc i64 %29 to i32
%31 = load i8*, i8** %10
%32 = load i8*, i8** %6
%33 = call i32 @snprintf(i8* %27, i32 %30, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %32)
%34 = load i8*, i8** %11
%35 = load i8*, i8** %7
%36 = call i8* @get_conf_line(i8* %34, i8* %35)
store i8* %36, i8** %12
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %120
38: ; preds = %22
%39 = load i8*, i8** %12
store i8* %39, i8** %7
%40 = call i32 @unquote_str(i8* %39)
%41 = getelementptr inbounds [2048 x i8], [2048 x i8]* %13, i64 0, i64 0
%42 = call i32 @getcwd(i8* %41, i32 2048)
%43 = load i8*, i8** %11
%44 = load i8*, i8** %10
%45 = load i8*, i8** %6
%46 = call i32 @sprintf(i8* %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %44, i8* %45)
%47 = load i8*, i8** %11
%48 = call i32 @chdir(i8* %47)
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %38
%51 = load i8*, i8** %6
%52 = call i32 (i32, i8*, ...) @error_code(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %51)
store i32 %52, i32* %5
br label %125
53: ; preds = %38
%54 = load i8*, i8** %11
%55 = load i8*, i8** %7
%56 = load i8*, i8** %8
%57 = icmp ne i8* %56, null
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = load i8*, i8** %8
br label %61
60: ; preds = %53
br label %61
61: ; preds = %60, %58
%62 = phi i8* [ %59, %58 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), %60 ]
%63 = call i32 @sprintf(i8* %54, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %55, i8* %62)
%64 = load i8*, i8** %11
%65 = call i32* @popen(i8* %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %65, i32** %15
%66 = icmp ne i32* %65, null
br i1 %66, label %67, label %108
67: ; preds = %61
br label %68
68: ; preds = %100, %67
%69 = load i32*, i32** %15
%70 = call i32 @getc(i32* %69)
store i32 %70, i32* %16
%71 = load i32, i32* @EOF
%72 = icmp ne i32 %70, %71
br i1 %72, label %73, label %101
73: ; preds = %68
%74 = load i8**, i8*** %9
%75 = icmp ne i8** %74, null
br i1 %75, label %76, label %96
76: ; preds = %73
%77 = load i32, i32* %17
%78 = sext i32 %77 to i64
%79 = load i64, i64* %14
%80 = icmp ugt i64 %78, %79
br i1 %80, label %81, label %88
81: ; preds = %76
%82 = load i64, i64* %14
%83 = add i64 %82, 256
store i64 %83, i64* %14
%84 = load i8*, i8** %11
%85 = load i64, i64* %14
%86 = mul i64 %85, 1
%87 = call i8* @realloc(i8* %84, i64 %86)
store i8* %87, i8** %11
br label %88
88: ; preds = %81, %76
%89 = load i32, i32* %16
%90 = trunc i32 %89 to i8
%91 = load i8*, i8** %11
%92 = load i32, i32* %17
%93 = add nsw i32 %92, 1
store i32 %93, i32* %17
%94 = sext i32 %92 to i64
%95 = getelementptr inbounds i8, i8* %91, i64 %94
store i8 %90, i8* %95
br label %100
96: ; preds = %73
%97 = load i32, i32* %16
%98 = load i32, i32* @stdout
%99 = call i32 @fputc(i32 %97, i32 %98)
br label %100
100: ; preds = %96, %88
br label %68
101: ; preds = %68
%102 = load i8*, i8** %11
%103 = load i32, i32* %17
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i8, i8* %102, i64 %104
store i8 0, i8* %105
%106 = load i32*, i32** %15
%107 = call i32 @pclose(i32* %106)
br label %108
108: ; preds = %101, %61
%109 = getelementptr inbounds [2048 x i8], [2048 x i8]* %13, i64 0, i64 0
%110 = call i32 @chdir(i8* %109)
%111 = load i8**, i8*** %9
%112 = icmp ne i8** %111, null
br i1 %112, label %116, label %113
113: ; preds = %108
%114 = load i8*, i8** %11
%115 = call i32 @free(i8* %114)
store i8* null, i8** %11
br label %119
116: ; preds = %108
%117 = load i8*, i8** %11
%118 = load i8**, i8*** %9
store i8* %117, i8** %118
br label %119
119: ; preds = %116, %113
br label %124
120: ; preds = %22
%121 = load i8*, i8** %6
%122 = load i8*, i8** %7
%123 = call i32 (i32, i8*, ...) @error_code(i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %121, i8* %122)
store i32 %123, i32* %5
br label %125
124: ; preds = %119
store i32 0, i32* %5
br label %125
125: ; preds = %124, %120, %50, %20
%126 = load i32, i32* %5
ret i32 %126
}

LLVM IR (-O2):
@.str = [9 x i8] c"mod_root\00"
@.str.1 = [40 x i8] c"Missing environment variable $mod_root.\00"
@.str.2 = [15 x i8] c"%s/%s/info.txt\00"
@.str.3 = [6 x i8] c"%s/%s\00"
@.str.4 = [21 x i8] c"Module missing. (%s)\00"
@.str.5 = [8 x i8] c"./%s %s\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [2 x i8] c"r\00"
@EOF = global i32 0
@stdout = global i32 0
@.str.8 = [25 x i8] c"No script found. (%s:%s)\00"
define i32 @mod_find_p(i8* %0, i8* %1, i8* %2, i8** writeonly %3) {
%5 = alloca [2048 x i8]
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%7 = tail call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 (i32, i8*, ...) @error_code(i32 -1, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %78
11: ; preds = %4
%12 = tail call dereferenceable_or_null(512) i8* @calloc(i32 512, i32 1)
%13 = tail call i32 @snprintf(i8* %12, i32 512, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %7, i8* %0)
%14 = tail call i8* @get_conf_line(i8* %12, i8* %1)
%15 = icmp eq i8* %14, null
br i1 %15, label %76, label %16
16: ; preds = %11
%17 = tail call i32 @unquote_str(i8* %14)
%18 = call i32 @getcwd(i8* %6, i32 2048)
%19 = call i32 @sprintf(i8* dereferenceable(1) %12, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %7, i8* %0)
%20 = call i32 @chdir(i8* %12)
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %16
%23 = call i32 (i32, i8*, ...) @error_code(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %78
24: ; preds = %16
%25 = icmp eq i8* %2, null
%26 = select i1 %25, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* %2
%27 = call i32 @sprintf(i8* dereferenceable(1) %12, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %14, i8* %26)
%28 = call i32* @popen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %69, label %30
30: ; preds = %24
%31 = call i32 @getc(i32* %28)
%32 = load i32, i32* @EOF
%33 = icmp eq i32 %31, %32
br i1 %33, label %63, label %34
34: ; preds = %30
%35 = icmp eq i8** %3, null
br label %36
36: ; preds = %34, %56
%37 = phi i32 [ %31, %34 ], [ %60, %56 ]
%38 = phi i32 [ 0, %34 ], [ %59, %56 ]
%39 = phi i64 [ 256, %34 ], [ %58, %56 ]
%40 = phi i8* [ %12, %34 ], [ %57, %56 ]
br i1 %35, label %53, label %41
41: ; preds = %36
%42 = sext i32 %38 to i64
%43 = icmp ult i64 %39, %42
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = add i64 %39, 256
%46 = call i8* @realloc(i8* %40, i64 %45)
br label %47
47: ; preds = %44, %41
%48 = phi i8* [ %46, %44 ], [ %40, %41 ]
%49 = phi i64 [ %45, %44 ], [ %39, %41 ]
%50 = trunc i32 %37 to i8
%51 = add nsw i32 %38, 1
%52 = getelementptr inbounds i8, i8* %48, i64 %42
store i8 %50, i8* %52
br label %56
53: ; preds = %36
%54 = load i32, i32* @stdout
%55 = call i32 @fputc(i32 %37, i32 %54)
br label %56
56: ; preds = %53, %47
%57 = phi i8* [ %48, %47 ], [ %40, %53 ]
%58 = phi i64 [ %49, %47 ], [ %39, %53 ]
%59 = phi i32 [ %51, %47 ], [ %38, %53 ]
%60 = call i32 @getc(i32* %28)
%61 = load i32, i32* @EOF
%62 = icmp eq i32 %60, %61
br i1 %62, label %63, label %36
63: ; preds = %56, %30
%64 = phi i8* [ %12, %30 ], [ %57, %56 ]
%65 = phi i32 [ 0, %30 ], [ %59, %56 ]
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %64, i64 %66
store i8 0, i8* %67
%68 = call i32 @pclose(i32* %28)
br label %69
69: ; preds = %63, %24
%70 = phi i8* [ %64, %63 ], [ %12, %24 ]
%71 = call i32 @chdir(i8* %6)
%72 = icmp eq i8** %3, null
br i1 %72, label %73, label %75
73: ; preds = %69
%74 = call i32 @free(i8* %70)
br label %78
75: ; preds = %69
store i8* %70, i8** %3
br label %78
76: ; preds = %11
%77 = tail call i32 (i32, i8*, ...) @error_code(i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %0, i8* %1)
br label %78
78: ; preds = %75, %73, %76, %22, %9
%79 = phi i32 [ %23, %22 ], [ %77, %76 ], [ %10, %9 ], [ 0, %73 ], [ 0, %75 ]
ret i32 %79
}