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

/* Variables and functions */
int EMLINK;
int append_arg(char *, char ***, size_t *, size_t *);
int errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *, int, int);
int /*<<< orphan*/ free(void *);
int getpid();
char *merge(char *, char *);
int /*<<< orphan*/ stderr;
size_t strlen(char *);
int expand_arg(const char *fn, char ***arg, size_t *index, size_t *capacity,
               int level) {
  FILE *f;
  char line[4096];
  size_t len;
  char *cmd = NULL;
  char *save = NULL;
  unsigned long lineno = 0ul;
  if (level >= 32) {
    fprintf(stderr,
            "kickstart[%d]: %s[%d]: "
            "ERROR: Nesting too deep (%d levels), "
            "circuit breaker triggered!\n",
            getpid(),
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/pegasus-isi/pegasus/refs/heads/master/"
            "src/tools/pegasus-kickstart/invoke.c",
            103, level);
    errno = EMLINK;
    return -1;
  }
  if ((f = fopen(fn, "r")) == NULL) {
    return -1;
  }
  while (fgets(line, sizeof(line), f)) {
    ++lineno;
    if (line[0] == 0 || line[0] == '\r' || line[0] == '\n')
      continue;
    len = strlen(line);
    if (line[len - 1] != '\r' && line[len - 1] != '\n') {
      char *temp = merge(save, line);
      if (temp == NULL) {
        int saverr = errno;
        fclose(f);
        if (save != NULL)
          free((void *)save);
        errno = saverr;
        return -1;
      }
      if (save != NULL)
        free((void *)save);
      save = temp;
      lineno--;
      continue;
    } else {
      while (len > 0 && (line[len - 1] == '\r' || line[len - 1] == '\n')) {
        line[len - 1] = 0;
        len--;
      }
    }
    if (save != NULL) {
      cmd = merge(save, line);
      free((void *)save);
      save = NULL;
      if (cmd == NULL) {
        int saverr = errno;
        fclose(f);
        errno = saverr;
        return -1;
      }
    } else {
      cmd = line;
    }
    if ((len = strlen(cmd)) > 0) {
      int result = append_arg(cmd, arg, index, capacity);
      if (result == -1) {
        int saverr = errno;
        fclose(f);
        if (cmd != line)
          free((void *)cmd);
        errno = saverr;
        return -1;
      }
    }
    if (cmd != line)
      free((void *)cmd);
  }
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<expand_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1080,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
movq   $0x0,-0x1050(%rbp)
movq   $0x0,-0x1058(%rbp)
movq   $0x0,-0x1060(%rbp)
cmpl   $0x20,-0x2c(%rbp)
jl     1233 <expand_arg+0xa3>
mov    0x2df7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x107c(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x107c(%rbp),%edi
mov    %eax,%edx
mov    -0x2c(%rbp),%r9d
lea    0xdfd(%rip),%rsi
lea    0xe4e(%rip),%rcx
mov    $0x67,%r8d
call   1080 <fprintf@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%ecx
mov    0x2dab(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    15e1 <expand_arg+0x451>
mov    -0x10(%rbp),%rdi
lea    0xebf(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    125d <expand_arg+0xcd>
movl   $0xffffffff,-0x4(%rbp)
jmp    15e1 <expand_arg+0x451>
jmp    1262 <expand_arg+0xd2>
lea    -0x1040(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x1000,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     15d1 <expand_arg+0x441>
mov    -0x1060(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1060(%rbp)
movsbl -0x1040(%rbp),%eax
cmp    $0x0,%eax
je     12c3 <expand_arg+0x133>
movsbl -0x1040(%rbp),%eax
cmp    $0xd,%eax
je     12c3 <expand_arg+0x133>
movsbl -0x1040(%rbp),%eax
cmp    $0xa,%eax
jne    12c8 <expand_arg+0x138>
jmp    1262 <expand_arg+0xd2>
lea    -0x1040(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x1048(%rbp)
mov    -0x1048(%rbp),%rax
sub    $0x1,%rax
movsbl -0x1040(%rbp,%rax,1),%eax
ff
cmp    $0xd,%eax
je     13c7 <expand_arg+0x237>
mov    -0x1048(%rbp),%rax
sub    $0x1,%rax
movsbl -0x1040(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     13c7 <expand_arg+0x237>
mov    -0x1058(%rbp),%rdi
lea    -0x1040(%rbp),%rsi
call   1090 <merge@plt>
mov    %rax,-0x1068(%rbp)
cmpq   $0x0,-0x1068(%rbp)
jne    1388 <expand_arg+0x1f8>
mov    0x2c8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x106c(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x1058(%rbp)
je     136d <expand_arg+0x1dd>
mov    -0x1058(%rbp),%rdi
call   1030 <free@plt>
mov    -0x106c(%rbp),%ecx
mov    0x2c56(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    15e1 <expand_arg+0x451>
cmpq   $0x0,-0x1058(%rbp)
je     13a2 <expand_arg+0x212>
mov    -0x1058(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1068(%rbp),%rax
mov    %rax,-0x1058(%rbp)
mov    -0x1060(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x1060(%rbp)
jmp    1262 <expand_arg+0xd2>
jmp    13cc <expand_arg+0x23c>
xor    %eax,%eax
cmpq   $0x0,-0x1048(%rbp)
mov    %al,-0x107d(%rbp)
jbe    1431 <expand_arg+0x2a1>
mov    -0x1048(%rbp),%rax
sub    $0x1,%rax
movsbl -0x1040(%rbp,%rax,1),%ecx
ff
mov    $0x1,%al
cmp    $0xd,%ecx
mov    %al,-0x107e(%rbp)
je     1425 <expand_arg+0x295>
mov    -0x1048(%rbp),%rax
sub    $0x1,%rax
movsbl -0x1040(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
sete   %al
mov    %al,-0x107e(%rbp)
mov    -0x107e(%rbp),%al
mov    %al,-0x107d(%rbp)
mov    -0x107d(%rbp),%al
test   $0x1,%al
jne    1444 <expand_arg+0x2b4>
jmp    146e <expand_arg+0x2de>
mov    -0x1048(%rbp),%rax
sub    $0x1,%rax
movb   $0x0,-0x1040(%rbp,%rax,1)
mov    -0x1048(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x1048(%rbp)
jmp    13cc <expand_arg+0x23c>
jmp    1473 <expand_arg+0x2e3>
cmpq   $0x0,-0x1058(%rbp)
je     14f8 <expand_arg+0x368>
mov    -0x1058(%rbp),%rdi
lea    -0x1040(%rbp),%rsi
call   1090 <merge@plt>
mov    %rax,-0x1050(%rbp)
mov    -0x1058(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x1058(%rbp)
cmpq   $0x0,-0x1050(%rbp)
jne    14f3 <expand_arg+0x363>
mov    0x2b09(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1070(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x1070(%rbp),%ecx
mov    0x2aeb(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    15e1 <expand_arg+0x451>
jmp    1506 <expand_arg+0x376>
lea    -0x1040(%rbp),%rax
mov    %rax,-0x1050(%rbp)
mov    -0x1050(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x1048(%rbp)
cmp    $0x0,%rax
jbe    15a9 <expand_arg+0x419>
mov    -0x1050(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   10a0 <append_arg@plt>
mov    %eax,-0x1074(%rbp)
cmpl   $0xffffffff,-0x1074(%rbp)
jne    15a4 <expand_arg+0x414>
mov    0x2a7b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1078(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x1050(%rbp),%rax
lea    -0x1040(%rbp),%rcx
cmp    %rcx,%rax
je     1589 <expand_arg+0x3f9>
mov    -0x1050(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1078(%rbp),%ecx
mov    0x2a3a(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    15e1 <expand_arg+0x451>
jmp    15a9 <expand_arg+0x419>
mov    -0x1050(%rbp),%rax
lea    -0x1040(%rbp),%rcx
cmp    %rcx,%rax
je     15cc <expand_arg+0x43c>
mov    -0x1050(%rbp),%rdi
call   1030 <free@plt>
jmp    1262 <expand_arg+0xd2>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1080,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expand_arg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1028,%rsp
cmp    $0x20,%r8d
jl     11f7 <expand_arg+0x67>
mov    %r8d,%ebx
mov    0x2e27(%rip),%rax
mov    (%rax),%ebp
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe3f(%rip),%rsi
lea    0xe90(%rip),%rcx
mov    %ebp,%edi
mov    %eax,%edx
mov    $0x67,%r8d
mov    %ebx,%r9d
call   1080 <fprintf@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%eax
mov    0x2de6(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%r13d
jmp    1387 <expand_arg+0x1f7>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbp
lea    0xef6(%rip),%rsi
call   10b0 <fopen@plt>
mov    $0xffffffff,%r13d
test   %rax,%rax
je     1387 <expand_arg+0x1f7>
mov    %rax,%rbx
mov    %rbp,0x8(%rsp)
mov    %r15,0x10(%rsp)
mov    %r14,0x18(%rsp)
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    $0x1000,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     137c <expand_arg+0x1ec>
xor    %r14d,%r14d
mov    $0x2401,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl 0x20(%rsp),%eax
cmp    $0xd,%rax
ja     1290 <expand_arg+0x100>
bt     %rax,%r12
jae    1290 <expand_arg+0x100>
mov    %r15,%rdi
mov    $0x1000,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
jne    1260 <expand_arg+0xd0>
jmp    137c <expand_arg+0x1ec>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    -0x1(%rax,%r15,1),%cl
cmp    $0xa,%cl
je     12ab <expand_arg+0x11b>
cmp    $0xd,%cl
jne    133c <expand_arg+0x1ac>
test   %rax,%rax
jne    12cb <expand_arg+0x13b>
jmp    12da <expand_arg+0x14a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movb   $0x0,0x1f(%rsp,%rax,1)
add    $0xffffffffffffffff,%rax
je     12da <expand_arg+0x14a>
movzbl 0x1f(%rsp,%rax,1),%ecx
cmp    $0xd,%cl
je     12c0 <expand_arg+0x130>
cmp    $0xa,%cl
je     12c0 <expand_arg+0x130>
mov    %r15,%rbp
test   %r14,%r14
je     1301 <expand_arg+0x171>
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <merge@plt>
mov    %rax,%rbp
mov    %r14,%rdi
call   1030 <free@plt>
test   %rbp,%rbp
je     139c <expand_arg+0x20c>
cmpb   $0x0,0x0(%rbp)
je     1327 <expand_arg+0x197>
mov    %rbp,%rdi
mov    0x8(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    0x18(%rsp),%rcx
call   10a0 <append_arg@plt>
cmp    $0xffffffff,%eax
je     13b3 <expand_arg+0x223>
cmp    %r15,%rbp
je     1334 <expand_arg+0x1a4>
mov    %rbp,%rdi
call   1030 <free@plt>
xor    %r14d,%r14d
jmp    1271 <expand_arg+0xe1>
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <merge@plt>
test   %rax,%rax
je     13dc <expand_arg+0x24c>
mov    %rax,%rbp
test   %r14,%r14
je     1360 <expand_arg+0x1d0>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
mov    $0x1000,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
mov    %rbp,%r14
test   %rax,%rax
jne    1260 <expand_arg+0xd0>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %r13d,%r13d
mov    %r13d,%eax
add    $0x1028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c2d(%rip),%r14
mov    (%r14),%ebp
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %ebp,(%r14)
jmp    1387 <expand_arg+0x1f7>
mov    0x2c16(%rip),%r14
mov    (%r14),%r15d
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0x20(%rsp),%rax
cmp    %rax,%rbp
je     13d7 <expand_arg+0x247>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r15d,(%r14)
jmp    1387 <expand_arg+0x1f7>
mov    0x2bed(%rip),%r15
mov    (%r15),%ebp
mov    %rbx,%rdi
call   1050 <fclose@plt>
test   %r14,%r14
je     13fb <expand_arg+0x26b>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebp,(%r15)
jmp    1387 <expand_arg+0x1f7>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [88 x i8] c"kickstart[%d]: %s[%d]: ERROR: Nesting too deep (%d levels), circuit breaker triggered!\0A\00"
@.str.1 = [165 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pegasus-isi/pegasus/refs/heads/master/src/tools/pegasus-kickstart/invoke.c\00"
@EMLINK = global i32 0
@errno = global i32 0
@.str.2 = [2 x i8] c"r\00"
define i32 @expand_arg(i8* %0, i8*** %1, i64* %2, i64* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8***
%9 = alloca i64*
%10 = alloca i64*
%11 = alloca i32
%12 = alloca i32*
%13 = alloca [4096 x i8]
%14 = alloca i64
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i64
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
store i8* %0, i8** %7
store i8*** %1, i8**** %8
store i64* %2, i64** %9
store i64* %3, i64** %10
store i32 %4, i32* %11
store i8* null, i8** %15
store i8* null, i8** %16
store i64 0, i64* %17
%23 = load i32, i32* %11
%24 = icmp sge i32 %23, 32
br i1 %24, label %25, label %31
25: ; preds = %5
%26 = load i32, i32* @stderr
%27 = call i32 (...) @getpid()
%28 = load i32, i32* %11
%29 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str, i64 0, i64 0), i32 %27, i8* getelementptr inbounds ([165 x i8], [165 x i8]* @.str.1, i64 0, i64 0), i32 103, i32 %28)
%30 = load i32, i32* @EMLINK
store i32 %30, i32* @errno
store i32 -1, i32* %6
br label %187
31: ; preds = %5
%32 = load i8*, i8** %7
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %33, i32** %12
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %36
35: ; preds = %31
store i32 -1, i32* %6
br label %187
36: ; preds = %31
br label %37
37: ; preds = %183, %99, %59, %36
%38 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%39 = load i32*, i32** %12
%40 = call i64 @fgets(i8* %38, i32 4096, i32* %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %184
42: ; preds = %37
%43 = load i64, i64* %17
%44 = add i64 %43, 1
store i64 %44, i64* %17
%45 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 0
br i1 %48, label %59, label %49
49: ; preds = %42
%50 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 13
br i1 %53, label %59, label %54
54: ; preds = %49
%55 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 10
br i1 %58, label %59, label %60
59: ; preds = %54, %49, %42
br label %37
60: ; preds = %54
%61 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%62 = call i64 @strlen(i8* %61)
store i64 %62, i64* %14
%63 = load i64, i64* %14
%64 = sub i64 %63, 1
%65 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 %64
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp ne i32 %67, 13
br i1 %68, label %69, label %103
69: ; preds = %60
%70 = load i64, i64* %14
%71 = sub i64 %70, 1
%72 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 %71
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp ne i32 %74, 10
br i1 %75, label %76, label %103
76: ; preds = %69
%77 = load i8*, i8** %16
%78 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%79 = call i8* @merge(i8* %77, i8* %78)
store i8* %79, i8** %18
%80 = load i8*, i8** %18
%81 = icmp eq i8* %80, null
br i1 %81, label %82, label %93
82: ; preds = %76
%83 = load i32, i32* @errno
store i32 %83, i32* %19
%84 = load i32*, i32** %12
%85 = call i32 @fclose(i32* %84)
%86 = load i8*, i8** %16
%87 = icmp ne i8* %86, null
br i1 %87, label %88, label %91
88: ; preds = %82
%89 = load i8*, i8** %16
%90 = call i32 @free(i8* %89)
br label %91
91: ; preds = %88, %82
%92 = load i32, i32* %19
store i32 %92, i32* @errno
store i32 -1, i32* %6
br label %187
93: ; preds = %76
%94 = load i8*, i8** %16
%95 = icmp ne i8* %94, null
br i1 %95, label %96, label %99
96: ; preds = %93
%97 = load i8*, i8** %16
%98 = call i32 @free(i8* %97)
br label %99
99: ; preds = %96, %93
%100 = load i8*, i8** %18
store i8* %100, i8** %16
%101 = load i64, i64* %17
%102 = add i64 %101, -1
store i64 %102, i64* %17
br label %37
103: ; preds = %69, %60
br label %104
104: ; preds = %125, %103
%105 = load i64, i64* %14
%106 = icmp ugt i64 %105, 0
br i1 %106, label %107, label %123
107: ; preds = %104
%108 = load i64, i64* %14
%109 = sub i64 %108, 1
%110 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 %109
%111 = load i8, i8* %110
%112 = sext i8 %111 to i32
%113 = icmp eq i32 %112, 13
br i1 %113, label %121, label %114
114: ; preds = %107
%115 = load i64, i64* %14
%116 = sub i64 %115, 1
%117 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 %116
%118 = load i8, i8* %117
%119 = sext i8 %118 to i32
%120 = icmp eq i32 %119, 10
br label %121
121: ; preds = %114, %107
%122 = phi i1 [ true, %107 ], [ %120, %114 ]
br label %123
123: ; preds = %121, %104
%124 = phi i1 [ false, %104 ], [ %122, %121 ]
br i1 %124, label %125, label %131
125: ; preds = %123
%126 = load i64, i64* %14
%127 = sub i64 %126, 1
%128 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 %127
store i8 0, i8* %128
%129 = load i64, i64* %14
%130 = add i64 %129, -1
store i64 %130, i64* %14
br label %104
131: ; preds = %123
br label %132
132: ; preds = %131
%133 = load i8*, i8** %16
%134 = icmp ne i8* %133, null
br i1 %134, label %135, label %149
135: ; preds = %132
%136 = load i8*, i8** %16
%137 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%138 = call i8* @merge(i8* %136, i8* %137)
store i8* %138, i8** %15
%139 = load i8*, i8** %16
%140 = call i32 @free(i8* %139)
store i8* null, i8** %16
%141 = load i8*, i8** %15
%142 = icmp eq i8* %141, null
br i1 %142, label %143, label %148
143: ; preds = %135
%144 = load i32, i32* @errno
store i32 %144, i32* %20
%145 = load i32*, i32** %12
%146 = call i32 @fclose(i32* %145)
%147 = load i32, i32* %20
store i32 %147, i32* @errno
store i32 -1, i32* %6
br label %187
148: ; preds = %135
br label %151
149: ; preds = %132
%150 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
store i8* %150, i8** %15
br label %151
151: ; preds = %149, %148
%152 = load i8*, i8** %15
%153 = call i64 @strlen(i8* %152)
store i64 %153, i64* %14
%154 = icmp ugt i64 %153, 0
br i1 %154, label %155, label %176
155: ; preds = %151
%156 = load i8*, i8** %15
%157 = load i8***, i8**** %8
%158 = load i64*, i64** %9
%159 = load i64*, i64** %10
%160 = call i32 @append_arg(i8* %156, i8*** %157, i64* %158, i64* %159)
store i32 %160, i32* %21
%161 = load i32, i32* %21
%162 = icmp eq i32 %161, -1
br i1 %162, label %163, label %175
163: ; preds = %155
%164 = load i32, i32* @errno
store i32 %164, i32* %22
%165 = load i32*, i32** %12
%166 = call i32 @fclose(i32* %165)
%167 = load i8*, i8** %15
%168 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%169 = icmp ne i8* %167, %168
br i1 %169, label %170, label %173
170: ; preds = %163
%171 = load i8*, i8** %15
%172 = call i32 @free(i8* %171)
br label %173
173: ; preds = %170, %163
%174 = load i32, i32* %22
store i32 %174, i32* @errno
store i32 -1, i32* %6
br label %187
175: ; preds = %155
br label %176
176: ; preds = %175, %151
%177 = load i8*, i8** %15
%178 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%179 = icmp ne i8* %177, %178
br i1 %179, label %180, label %183
180: ; preds = %176
%181 = load i8*, i8** %15
%182 = call i32 @free(i8* %181)
br label %183
183: ; preds = %180, %176
br label %37
184: ; preds = %37
%185 = load i32*, i32** %12
%186 = call i32 @fclose(i32* %185)
store i32 0, i32* %6
br label %187
187: ; preds = %184, %173, %143, %91, %35, %25
%188 = load i32, i32* %6
ret i32 %188
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [88 x i8] c"kickstart[%d]: %s[%d]: ERROR: Nesting too deep (%d levels), circuit breaker triggered!\0A\00"
@.str.1 = [165 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pegasus-isi/pegasus/refs/heads/master/src/tools/pegasus-kickstart/invoke.c\00"
@EMLINK = global i32 0
@errno = global i32 0
@.str.2 = [2 x i8] c"r\00"
define i32 @expand_arg(i8* nocapture %0, i8*** %1, i64* %2, i64* %3, i32 %4) {
%6 = alloca [4096 x i8]
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%8 = icmp sgt i32 %4, 31
br i1 %8, label %9, label %14
9: ; preds = %5
%10 = load i32, i32* @stderr
%11 = tail call i32 (...) @getpid()
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str, i64 0, i64 0), i32 %11, i8* getelementptr inbounds ([165 x i8], [165 x i8]* @.str.1, i64 0, i64 0), i32 103, i32 %4)
%13 = load i32, i32* @EMLINK
store i32 %13, i32* @errno
br label %89
14: ; preds = %5
%15 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %89, label %17
17: ; preds = %14
%18 = call i64 @fgets(i8* %7, i32 4096, i32* %15)
%19 = icmp eq i64 %18, 0
br i1 %19, label %87, label %20
20: ; preds = %17, %45
%21 = phi i8* [ %46, %45 ], [ null, %17 ]
%22 = load i8, i8* %7
switch i8 %22, label %23 [
i8 13, label %83
i8 10, label %83
i8 0, label %83
]
23: ; preds = %20
%24 = call i64 @strlen(i8* %7)
%25 = add i64 %24, -1
%26 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 %25
%27 = load i8, i8* %26
switch i8 %27, label %28 [
i8 13, label %47
i8 10, label %47
]
28: ; preds = %23
%29 = call i8* @merge(i8* %21, i8* %7)
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %38
31: ; preds = %28
%32 = load i32, i32* @errno
%33 = call i32 @fclose(i32* %15)
%34 = icmp eq i8* %21, null
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = call i32 @free(i8* %21)
br label %37
37: ; preds = %31, %35
store i32 %32, i32* @errno
br label %89
38: ; preds = %28
%39 = icmp eq i8* %21, null
br i1 %39, label %42, label %40
40: ; preds = %38
%41 = call i32 @free(i8* %21)
br label %42
42: ; preds = %38, %40
%43 = call i64 @fgets(i8* %7, i32 4096, i32* %15)
%44 = icmp eq i64 %43, 0
br i1 %44, label %87, label %45
45: ; preds = %42, %83
%46 = phi i8* [ %29, %42 ], [ %84, %83 ]
br label %20
47: ; preds = %23, %23
%48 = icmp eq i64 %24, 0
br i1 %48, label %56, label %49
49: ; preds = %47, %54
%50 = phi i64 [ %51, %54 ], [ %24, %47 ]
%51 = add i64 %50, -1
%52 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 %51
%53 = load i8, i8* %52
switch i8 %53, label %56 [
i8 13, label %54
i8 10, label %54
]
54: ; preds = %49, %49
store i8 0, i8* %52
%55 = icmp eq i64 %51, 0
br i1 %55, label %56, label %49
56: ; preds = %54, %49, %47
%57 = icmp eq i8* %21, null
br i1 %57, label %65, label %58
58: ; preds = %56
%59 = call i8* @merge(i8* %21, i8* %7)
%60 = call i32 @free(i8* %21)
%61 = icmp eq i8* %59, null
br i1 %61, label %62, label %65
62: ; preds = %58
%63 = load i32, i32* @errno
%64 = call i32 @fclose(i32* %15)
store i32 %63, i32* @errno
br label %89
65: ; preds = %56, %58
%66 = phi i8* [ %59, %58 ], [ %7, %56 ]
%67 = load i8, i8* %66
%68 = icmp eq i8 %67, 0
br i1 %68, label %79, label %69
69: ; preds = %65
%70 = call i32 @append_arg(i8* %66, i8*** %1, i64* %2, i64* %3)
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %79
72: ; preds = %69
%73 = load i32, i32* @errno
%74 = call i32 @fclose(i32* %15)
%75 = icmp eq i8* %66, %7
br i1 %75, label %78, label %76
76: ; preds = %72
%77 = call i32 @free(i8* %66)
br label %78
78: ; preds = %76, %72
store i32 %73, i32* @errno
br label %89
79: ; preds = %69, %65
%80 = icmp eq i8* %66, %7
br i1 %80, label %83, label %81
81: ; preds = %79
%82 = call i32 @free(i8* %66)
br label %83
83: ; preds = %20, %20, %20, %79, %81
%84 = phi i8* [ null, %81 ], [ null, %79 ], [ %21, %20 ], [ %21, %20 ], [ %21, %20 ]
%85 = call i64 @fgets(i8* %7, i32 4096, i32* %15)
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %45
87: ; preds = %83, %42, %17
%88 = call i32 @fclose(i32* %15)
br label %89
89: ; preds = %78, %37, %14, %87, %62, %9
%90 = phi i32 [ -1, %9 ], [ -1, %62 ], [ -1, %78 ], [ 0, %87 ], [ -1, %14 ], [ -1, %37 ]
ret i32 %90
}