long bndl(data, maxl, rcp)
char *data;
long maxl;
struct res *rcp;
{
  char *rcntp, *skipsp(), *getline(), *lp;
  char *outp(), *outs(), *outl(), *outc();
  char *datap = data;
  int j, m1, m2, rcnt, bcnt, resid;
  long tmp;
  char *map, *index();
  if ((lp = skipsp(getline())) == 0)
    fatal("no type specified");
  checktype(lp);
  datap = outc(datap, lp[0], &maxl);
  datap = outc(datap, lp[1], &maxl);
  datap = outc(datap, lp[2], &maxl);
  datap = outc(datap, lp[3], &maxl);
  if ((lp = getline()) == 0 || sscanf(lp, "%d", &resid) != 1)
    fatal("bad res id");
  if ((lp = getline()) == 0 || sscanf(lp, "%d", &bcnt) != 1)
    fatal("bad res id");
  datap = outs(datap, resid, &maxl);
  datap = outs(datap, bcnt - 1, &maxl);
  for (j = 0; j < bcnt; j++) {
    if ((lp = skipsp(getline())) == 0)
      fatal("missing bundle resource def");
    map = index(lp, ' ');
    if (map)
      *map++ = 0;
    checktype(lp);
    datap = outc(datap, lp[0], &maxl);
    datap = outc(datap, lp[1], &maxl);
    datap = outc(datap, lp[2], &maxl);
    datap = outc(datap, lp[3], &maxl);
    rcntp = datap;
    rcnt = 0;
    datap = outs(datap, 0, &maxl);
    while (map && sscanf(map, "%d %d", &m1, &m2) == 2) {
      rcnt++;
      datap = outs(datap, m1, &maxl);
      datap = outs(datap, m2, &maxl);
      if (map = index(map, ';'))
        map++;
    }
    tmp = sizeof(short);
    outs(rcntp, rcnt - 1, &tmp);
  }
  return (datap - data);
}


x86 assembly (clang, -O0):
<bndl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1070 <getline@plt>
mov    %rax,%rdi
mov    $0x0,%al
call   1080 <skipsp@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11c9 <bndl+0x49>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   10a0 <fatal@plt>
mov    -0x28(%rbp),%rdi
mov    $0x0,%al
call   1050 <checktype@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rax
movsbl (%rax),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1060 <outc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rax
movsbl 0x1(%rax),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1060 <outc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rax
movsbl 0x2(%rax),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1060 <outc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rax
movsbl 0x3(%rax),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1060 <outc@plt>
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1070 <getline@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1273 <bndl+0xf3>
mov    -0x28(%rbp),%rdi
lea    0xddd(%rip),%rsi
lea    -0x48(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     1281 <bndl+0x101>
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   10a0 <fatal@plt>
mov    $0x0,%al
call   1070 <getline@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     12b5 <bndl+0x135>
mov    -0x28(%rbp),%rdi
lea    0xd9b(%rip),%rsi
lea    -0x44(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     12c3 <bndl+0x143>
lea    0xd56(%rip),%rdi
mov    $0x0,%al
call   10a0 <fatal@plt>
mov    -0x30(%rbp),%rdi
mov    -0x48(%rbp),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1090 <outs@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x44(%rbp),%esi
sub    $0x1,%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1090 <outs@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    14cb <bndl+0x34b>
mov    $0x0,%al
call   1070 <getline@plt>
mov    %rax,%rdi
mov    $0x0,%al
call   1080 <skipsp@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1332 <bndl+0x1b2>
lea    0xcf2(%rip),%rdi
mov    $0x0,%al
call   10a0 <fatal@plt>
mov    -0x28(%rbp),%rdi
mov    $0x20,%esi
call   1030 <index@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     1361 <bndl+0x1e1>
mov    -0x58(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x58(%rbp)
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
mov    $0x0,%al
call   1050 <checktype@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rax
movsbl (%rax),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1060 <outc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rax
movsbl 0x1(%rax),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1060 <outc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rax
movsbl 0x2(%rax),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1060 <outc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rax
movsbl 0x3(%rax),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1060 <outc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1090 <outs@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x58(%rbp)
mov    %al,-0x59(%rbp)
je     142e <bndl+0x2ae>
mov    -0x58(%rbp),%rdi
lea    0xc23(%rip),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x2,%eax
sete   %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
test   $0x1,%al
jne    143e <bndl+0x2be>
jmp    14a0 <bndl+0x320>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1090 <outs@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x3c(%rbp),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1090 <outs@plt>
mov    %rax,-0x30(%rbp)
mov    -0x58(%rbp),%rdi
mov    $0x3b,%esi
call   1030 <index@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
je     149b <bndl+0x31b>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    13fb <bndl+0x27b>
movq   $0x2,-0x50(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%esi
sub    $0x1,%esi
lea    -0x50(%rbp),%rdx
mov    $0x0,%al
call   1090 <outs@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12f9 <bndl+0x179>
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bndl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r14
mov    %rsi,0x10(%rsp)
xor    %eax,%eax
call   1070 <getline@plt>
mov    %rax,%rdi
xor    %eax,%eax
call   1080 <skipsp@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11bd <bndl+0x3d>
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   10a0 <fatal@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <checktype@plt>
movsbl (%rbx),%esi
lea    0x10(%rsp),%rbp
mov    %r14,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <outc@plt>
movsbl 0x1(%rbx),%esi
mov    %rax,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <outc@plt>
movsbl 0x2(%rbx),%esi
mov    %rax,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <outc@plt>
movsbl 0x3(%rbx),%esi
mov    %rax,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <outc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1070 <getline@plt>
test   %rax,%rax
je     1239 <bndl+0xb9>
lea    0xe17(%rip),%rsi
lea    0x1c(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     1247 <bndl+0xc7>
lea    0xdd2(%rip),%rdi
xor    %eax,%eax
call   10a0 <fatal@plt>
xor    %eax,%eax
call   1070 <getline@plt>
test   %rax,%rax
je     126e <bndl+0xee>
lea    0xde2(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     127c <bndl+0xfc>
lea    0xd9d(%rip),%rdi
xor    %eax,%eax
call   10a0 <fatal@plt>
mov    %r14,0x28(%rsp)
mov    0x1c(%rsp),%esi
lea    0x10(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1090 <outs@plt>
mov    0xc(%rsp),%esi
add    $0xffffffff,%esi
mov    %rax,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1090 <outs@plt>
mov    %rax,%r15
cmpl   $0x0,0xc(%rsp)
jle    1438 <bndl+0x2b8>
lea    0x10(%rsp),%rbx
xor    %r14d,%r14d
jmp    12fe <bndl+0x17e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movq   $0x2,0x30(%rsp)
add    $0xffffffff,%r12d
mov    %rbp,%rdi
mov    %r12d,%esi
lea    0x30(%rsp),%rdx
xor    %eax,%eax
call   1090 <outs@plt>
add    $0x1,%r14d
cmp    0xc(%rsp),%r14d
jge    1438 <bndl+0x2b8>
xor    %eax,%eax
call   1070 <getline@plt>
mov    %rax,%rdi
xor    %eax,%eax
call   1080 <skipsp@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1325 <bndl+0x1a5>
lea    0xcff(%rip),%rdi
xor    %eax,%eax
call   10a0 <fatal@plt>
mov    %rbp,%rdi
mov    $0x20,%esi
call   1030 <index@plt>
test   %rax,%rax
je     1350 <bndl+0x1d0>
mov    %rax,%r13
add    $0x1,%r13
movb   $0x0,(%rax)
jmp    1353 <bndl+0x1d3>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %r13d,%r13d
xor    %r12d,%r12d
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <checktype@plt>
movsbl 0x0(%rbp),%esi
mov    %r15,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <outc@plt>
movsbl 0x1(%rbp),%esi
mov    %rax,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <outc@plt>
movsbl 0x2(%rbp),%esi
mov    %rax,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <outc@plt>
movsbl 0x3(%rbp),%esi
mov    %rax,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <outc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
xor    %esi,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <outs@plt>
mov    %rax,%r15
test   %r13,%r13
je     12d0 <bndl+0x150>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
lea    0xc5f(%rip),%rsi
lea    0x24(%rsp),%rdx
lea    0x20(%rsp),%rcx
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x2,%eax
jne    12d0 <bndl+0x150>
add    $0x1,%r12d
mov    0x24(%rsp),%esi
mov    %r15,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <outs@plt>
mov    0x20(%rsp),%esi
mov    %rax,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <outs@plt>
mov    %rax,%r15
mov    %r13,%rdi
mov    $0x3b,%esi
call   1030 <index@plt>
lea    0x1(%rax),%r13
test   %rax,%rax
jne    13d0 <bndl+0x250>
jmp    12d0 <bndl+0x150>
sub    0x28(%rsp),%r15
mov    %r15,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.res = type opaque
@.str = [18 x i8] c"no type specified\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"bad res id\00"
@.str.3 = [28 x i8] c"missing bundle resource def\00"
@.str.4 = [6 x i8] c"%d %d\00"
define i64 @bndl(i8* %0, i64 %1, %struct.res* nocapture readnone %2) {
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
store i64 %1, i64* %4
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = bitcast i32* %7 to i8*
%13 = bitcast i32* %8 to i8*
%14 = bitcast i64* %9 to i8*
%15 = tail call i8* (...) @getline()
%16 = tail call i8* (i8*, ...) bitcast (i8* (...)* @skipsp to i8* (i8*, ...)*)(i8* %15)
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %20
18: ; preds = %3
%19 = tail call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %3
%21 = tail call i32 (i8*, ...) bitcast (i32 (...)* @checktype to i32 (i8*, ...)*)(i8* %16)
%22 = load i8, i8* %16
%23 = sext i8 %22 to i32
%24 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outc to i8* (i8*, i32, i64*, ...)*)(i8* %0, i32 %23, i64* %4)
%25 = getelementptr inbounds i8, i8* %16, i64 1
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outc to i8* (i8*, i32, i64*, ...)*)(i8* %24, i32 %27, i64* %4)
%29 = getelementptr inbounds i8, i8* %16, i64 2
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outc to i8* (i8*, i32, i64*, ...)*)(i8* %28, i32 %31, i64* %4)
%33 = getelementptr inbounds i8, i8* %16, i64 3
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outc to i8* (i8*, i32, i64*, ...)*)(i8* %32, i32 %35, i64* %4)
%37 = call i8* (...) @getline()
%38 = icmp eq i8* %37, null
br i1 %38, label %42, label %39
39: ; preds = %20
%40 = call i32 (i8*, i8*, ...) @sscanf(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%41 = icmp eq i32 %40, 1
br i1 %41, label %44, label %42
42: ; preds = %39, %20
%43 = call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %44
44: ; preds = %42, %39
%45 = call i8* (...) @getline()
%46 = icmp eq i8* %45, null
br i1 %46, label %50, label %47
47: ; preds = %44
%48 = call i32 (i8*, i8*, ...) @sscanf(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%49 = icmp eq i32 %48, 1
br i1 %49, label %52, label %50
50: ; preds = %47, %44
%51 = call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %50, %47
%53 = load i32, i32* %8
%54 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outs to i8* (i8*, i32, i64*, ...)*)(i8* %36, i32 %53, i64* %4)
%55 = load i32, i32* %7
%56 = add nsw i32 %55, -1
%57 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outs to i8* (i8*, i32, i64*, ...)*)(i8* %54, i32 %56, i64* %4)
%58 = load i32, i32* %7
%59 = icmp sgt i32 %58, 0
br i1 %59, label %60, label %116
60: ; preds = %52, %108
%61 = phi i32 [ %113, %108 ], [ 0, %52 ]
%62 = phi i8* [ %109, %108 ], [ %57, %52 ]
%63 = call i8* (...) @getline()
%64 = call i8* (i8*, ...) bitcast (i8* (...)* @skipsp to i8* (i8*, ...)*)(i8* %63)
%65 = icmp eq i8* %64, null
br i1 %65, label %66, label %68
66: ; preds = %60
%67 = call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %68
68: ; preds = %66, %60
%69 = call i8* @index(i8* %64, i32 32)
%70 = icmp eq i8* %69, null
br i1 %70, label %73, label %71
71: ; preds = %68
%72 = getelementptr inbounds i8, i8* %69, i64 1
store i8 0, i8* %69
br label %73
73: ; preds = %71, %68
%74 = phi i8* [ %72, %71 ], [ null, %68 ]
%75 = call i32 (i8*, ...) bitcast (i32 (...)* @checktype to i32 (i8*, ...)*)(i8* %64)
%76 = load i8, i8* %64
%77 = sext i8 %76 to i32
%78 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outc to i8* (i8*, i32, i64*, ...)*)(i8* %62, i32 %77, i64* %4)
%79 = getelementptr inbounds i8, i8* %64, i64 1
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outc to i8* (i8*, i32, i64*, ...)*)(i8* %78, i32 %81, i64* %4)
%83 = getelementptr inbounds i8, i8* %64, i64 2
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
%86 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outc to i8* (i8*, i32, i64*, ...)*)(i8* %82, i32 %85, i64* %4)
%87 = getelementptr inbounds i8, i8* %64, i64 3
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outc to i8* (i8*, i32, i64*, ...)*)(i8* %86, i32 %89, i64* %4)
%91 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outs to i8* (i8*, i32, i64*, ...)*)(i8* %90, i32 0, i64* %4)
%92 = icmp eq i8* %74, null
br i1 %92, label %108, label %93
93: ; preds = %73, %99
%94 = phi i8* [ %107, %99 ], [ %74, %73 ]
%95 = phi i32 [ %100, %99 ], [ 0, %73 ]
%96 = phi i8* [ %104, %99 ], [ %91, %73 ]
%97 = call i32 (i8*, i8*, ...) @sscanf(i8* %94, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %5, i32* %6)
%98 = icmp eq i32 %97, 2
br i1 %98, label %99, label %108
99: ; preds = %93
%100 = add nuw nsw i32 %95, 1
%101 = load i32, i32* %5
%102 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outs to i8* (i8*, i32, i64*, ...)*)(i8* %96, i32 %101, i64* %4)
%103 = load i32, i32* %6
%104 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outs to i8* (i8*, i32, i64*, ...)*)(i8* %102, i32 %103, i64* %4)
%105 = call i8* @index(i8* %94, i32 59)
%106 = icmp eq i8* %105, null
%107 = getelementptr inbounds i8, i8* %105, i64 1
br i1 %106, label %108, label %93
108: ; preds = %93, %99, %73
%109 = phi i8* [ %91, %73 ], [ %104, %99 ], [ %96, %93 ]
%110 = phi i32 [ 0, %73 ], [ %100, %99 ], [ %95, %93 ]
store i64 2, i64* %9
%111 = add nsw i32 %110, -1
%112 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outs to i8* (i8*, i32, i64*, ...)*)(i8* %90, i32 %111, i64* %9)
%113 = add nuw nsw i32 %61, 1
%114 = load i32, i32* %7
%115 = icmp slt i32 %113, %114
br i1 %115, label %60, label %116
116: ; preds = %108, %52
%117 = phi i8* [ %57, %52 ], [ %109, %108 ]
%118 = ptrtoint i8* %117 to i64
%119 = ptrtoint i8* %0 to i64
%120 = sub i64 %118, %119
ret i64 %120
}