#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 */

/* Variables and functions */
unsigned int checksum(char *, unsigned int);
unsigned int getInt(char const **, int *);
int /*<<< orphan*/ memcpy(char *, char const *, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int delta_apply(const char *zSrc, int lenSrc, const char *zDelta, int lenDelta,
                char *zOut) {
  unsigned int limit;
  unsigned int total = 0;
  char *zOrigOut = zOut;
  limit = getInt(&zDelta, &lenDelta);
  if (*zDelta != '\n') {
    printf("ERROR: size integer not terminated by "
           "\/n"
           "\n");
    return -1;
  }
  zDelta++;
  lenDelta--;
  while (*zDelta && lenDelta > 0) {
    unsigned int cnt, ofst;
    cnt = getInt(&zDelta, &lenDelta);
    switch (zDelta[0]) {
    case '@': {
      zDelta++;
      lenDelta--;
      ofst = getInt(&zDelta, &lenDelta);
      if (lenDelta > 0 && zDelta[0] != ',') {
        printf("ERROR: copy command not terminated by ','\n");
        return -1;
      }
      zDelta++;
      lenDelta--;

      total += cnt;
      if (total > limit) {
        printf("ERROR: copy exceeds output file size\n");
        return -1;
      }
      if (ofst + cnt > lenSrc) {
        printf("ERROR: copy extends past end of input: ofst: %d, cnt: %d, "
               "lenSrc: %d \n",
               ofst, cnt, lenSrc);
        return -1;
      }
      memcpy(zOut, &zSrc[ofst], cnt);
      zOut += cnt;
      break;
    }
    case ':': {
      zDelta++;
      lenDelta--;
      total += cnt;
      if (total > limit) {
        printf(
            "ERROR:  insert command gives an output larger than predicted\n");
        return -1;
      }

      if (cnt > lenDelta) {
        printf("ERROR: insert count exceeds size of delta\n");
        return -1;
      }
      memcpy(zOut, zDelta, cnt);
      zOut += cnt;
      zDelta += cnt;
      lenDelta -= cnt;
      break;
    }
    case ';': {
      zDelta++;
      lenDelta--;
      zOut[0] = 0;
      if (cnt != checksum(zOrigOut, total)) {
        return -1;
      }
      if (total != limit) {
        printf("ERROR: generated size does not match predicted size\n");
        return -1;
      }
      return total;
    }
    default: {
      printf("ERROR: unknown delta operator\n");
      return -1;
    }
    }
  }
  printf("ERROR: unterminated delta\n");
  return -1;
}


x86 assembly (clang, -O0):
<delta_apply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1060 <getInt@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     11a3 <delta_apply+0x63>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1481 <delta_apply+0x341>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x49(%rbp)
je     11d7 <delta_apply+0x97>
cmpl   $0x0,-0x24(%rbp)
setg   %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
test   $0x1,%al
jne    11e7 <delta_apply+0xa7>
jmp    146c <delta_apply+0x32c>
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1060 <getInt@plt>
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x50(%rbp)
sub    $0x3a,%eax
je     132b <delta_apply+0x1eb>
jmp    120f <delta_apply+0xcf>
mov    -0x50(%rbp),%eax
sub    $0x3b,%eax
je     13d5 <delta_apply+0x295>
jmp    1220 <delta_apply+0xe0>
mov    -0x50(%rbp),%eax
sub    $0x40,%eax
jne    144d <delta_apply+0x30d>
jmp    1231 <delta_apply+0xf1>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1060 <getInt@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    128a <delta_apply+0x14a>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
je     128a <delta_apply+0x14a>
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1481 <delta_apply+0x341>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x44(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jbe    12ce <delta_apply+0x18e>
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1481 <delta_apply+0x341>
mov    -0x48(%rbp),%eax
add    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jbe    1300 <delta_apply+0x1c0>
mov    -0x48(%rbp),%esi
mov    -0x44(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1481 <delta_apply+0x341>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x48(%rbp),%eax
add    %rax,%rsi
mov    -0x44(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x44(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
jmp    1467 <delta_apply+0x327>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x44(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jbe    136f <delta_apply+0x22f>
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1481 <delta_apply+0x341>
mov    -0x44(%rbp),%eax
cmp    -0x24(%rbp),%eax
jbe    1395 <delta_apply+0x255>
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1481 <delta_apply+0x341>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x44(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x44(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x44(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x44(%rbp),%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
jmp    1467 <delta_apply+0x327>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x44(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   1040 <checksum@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
cmp    %ecx,%eax
je     141c <delta_apply+0x2dc>
movl   $0xffffffff,-0x4(%rbp)
jmp    1481 <delta_apply+0x341>
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
je     1442 <delta_apply+0x302>
lea    0xcfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1481 <delta_apply+0x341>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1481 <delta_apply+0x341>
lea    0xd0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1481 <delta_apply+0x341>
jmp    11b8 <delta_apply+0x78>
lea    0xd0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delta_apply>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %rdx,0x8(%rsp)
mov    %ecx,0x4(%rsp)
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rsi
call   1070 <getInt@plt>
mov    %eax,%r13d
mov    0x8(%rsp),%rax
cmpb   $0xa,(%rax)
jne    12f8 <delta_apply+0x1a8>
mov    %rbx,0x20(%rsp)
mov    %ebp,0x14(%rsp)
mov    %r14,0x18(%rsp)
lea    0x1(%rax),%rcx
mov    %rcx,0x8(%rsp)
mov    0x4(%rsp),%ecx
lea    -0x1(%rcx),%edx
mov    %edx,0x4(%rsp)
cmpb   $0x0,0x1(%rax)
je     12ef <delta_apply+0x19f>
cmp    $0x2,%ecx
jl     12ef <delta_apply+0x19f>
xor    %ebp,%ebp
lea    0x8(%rsp),%r14
lea    0x4(%rsp),%r15
mov    0x18(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <getInt@plt>
mov    %eax,%r12d
mov    0x8(%rsp),%rsi
movsbl (%rsi),%eax
cmp    $0x3a,%eax
je     1290 <delta_apply+0x140>
cmp    $0x40,%eax
jne    131c <delta_apply+0x1cc>
add    $0x1,%rsi
mov    %rsi,0x8(%rsp)
addl   $0xffffffff,0x4(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <getInt@plt>
mov    0x4(%rsp),%ecx
mov    0x8(%rsp),%rdx
test   %ecx,%ecx
jle    1237 <delta_apply+0xe7>
cmpb   $0x2c,(%rdx)
jne    1391 <delta_apply+0x241>
add    $0x1,%rdx
mov    %rdx,0x8(%rsp)
add    $0xffffffff,%ecx
mov    %ecx,0x4(%rsp)
add    %r12d,%ebp
cmp    %r13d,%ebp
ja     135a <delta_apply+0x20a>
lea    (%rax,%r12,1),%ecx
cmp    0x14(%rsp),%ecx
ja     1375 <delta_apply+0x225>
mov    %eax,%esi
add    0x20(%rsp),%rsi
mov    %rbx,%rdi
mov    %r12d,%edx
call   1060 <memcpy@plt>
mov    %r12d,%eax
mov    0x8(%rsp),%rdx
mov    0x4(%rsp),%ecx
jmp    12df <delta_apply+0x18f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rsi
mov    %rsi,0x8(%rsp)
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
mov    %eax,0x4(%rsp)
add    %r12d,%ebp
cmp    %r13d,%ebp
ja     1363 <delta_apply+0x213>
cmp    %eax,%r12d
ja     136c <delta_apply+0x21c>
mov    %rbx,%rdi
mov    %r12d,%edx
call   1060 <memcpy@plt>
mov    %r12d,%eax
mov    0x8(%rsp),%rdx
add    %rax,%rdx
mov    %rdx,0x8(%rsp)
mov    0x4(%rsp),%ecx
sub    %r12d,%ecx
mov    %ecx,0x4(%rsp)
cmpb   $0x0,(%rdx)
je     12ef <delta_apply+0x19f>
add    %rax,%rbx
test   %ecx,%ecx
jg     11e0 <delta_apply+0x90>
lea    0xd51(%rip),%rdi
jmp    12ff <delta_apply+0x1af>
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r13d
mov    %r13d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x3b,%eax
jne    1351 <delta_apply+0x201>
add    $0x1,%rsi
mov    %rsi,0x8(%rsp)
addl   $0xffffffff,0x4(%rsp)
movb   $0x0,(%rbx)
mov    0x18(%rsp),%rdi
mov    %ebp,%esi
call   1050 <checksum@plt>
cmp    %eax,%r12d
jne    1304 <delta_apply+0x1b4>
cmp    %r13d,%ebp
je     130a <delta_apply+0x1ba>
lea    0xd12(%rip),%rdi
jmp    12ff <delta_apply+0x1af>
lea    0xdf3(%rip),%rdi
jmp    12ff <delta_apply+0x1af>
lea    0xd9b(%rip),%rdi
jmp    12ff <delta_apply+0x1af>
lea    0xd55(%rip),%rdi
jmp    12ff <delta_apply+0x1af>
lea    0xd22(%rip),%rdi
jmp    12ff <delta_apply+0x1af>
lea    0xc84(%rip),%rdi
mov    %eax,%esi
mov    %r12d,%edx
mov    0x14(%rsp),%ecx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1304 <delta_apply+0x1b4>
lea    0xd89(%rip),%rdi
jmp    12ff <delta_apply+0x1af>

LLVM IR (-O0):
@.str = [42 x i8] c"ERROR: size integer not terminated by /n\0A\00"
@.str.1 = [43 x i8] c"ERROR: copy command not terminated by ','\0A\00"
@.str.2 = [38 x i8] c"ERROR: copy exceeds output file size\0A\00"
@.str.3 = [71 x i8] c"ERROR: copy extends past end of input: ofst: %d, cnt: %d, lenSrc: %d \0A\00"
@.str.4 = [62 x i8] c"ERROR: insert command gives an output larger than predicted\0A\00"
@.str.5 = [43 x i8] c"ERROR: insert count exceeds size of delta\0A\00"
@.str.6 = [53 x i8] c"ERROR: generated size does not match predicted size\0A\00"
@.str.7 = [31 x i8] c"ERROR: unknown delta operator\0A\00"
@.str.8 = [27 x i8] c"ERROR: unterminated delta\0A\00"
define i32 @delta_apply(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i32 0, i32* %13
%17 = load i8*, i8** %11
store i8* %17, i8** %14
%18 = call i32 @getInt(i8** %9, i32* %10)
store i32 %18, i32* %12
%19 = load i8*, i8** %9
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 10
br i1 %22, label %23, label %25
23: ; preds = %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %6
br label %159
25: ; preds = %5
%26 = load i8*, i8** %9
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %9
%28 = load i32, i32* %10
%29 = add nsw i32 %28, -1
store i32 %29, i32* %10
br label %30
30: ; preds = %156, %25
%31 = load i8*, i8** %9
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %30
%36 = load i32, i32* %10
%37 = icmp sgt i32 %36, 0
br label %38
38: ; preds = %35, %30
%39 = phi i1 [ false, %30 ], [ %37, %35 ]
br i1 %39, label %40, label %157
40: ; preds = %38
%41 = call i32 @getInt(i8** %9, i32* %10)
store i32 %41, i32* %15
%42 = load i8*, i8** %9
%43 = getelementptr inbounds i8, i8* %42, i64 0
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
switch i32 %45, label %154 [
i32 64, label %46
i32 58, label %98
i32 59, label %133
]
46: ; preds = %40
%47 = load i8*, i8** %9
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %9
%49 = load i32, i32* %10
%50 = add nsw i32 %49, -1
store i32 %50, i32* %10
%51 = call i32 @getInt(i8** %9, i32* %10)
store i32 %51, i32* %16
%52 = load i32, i32* %10
%53 = icmp sgt i32 %52, 0
br i1 %53, label %54, label %62
54: ; preds = %46
%55 = load i8*, i8** %9
%56 = getelementptr inbounds i8, i8* %55, i64 0
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp ne i32 %58, 44
br i1 %59, label %60, label %62
60: ; preds = %54
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %6
br label %159
62: ; preds = %54, %46
%63 = load i8*, i8** %9
%64 = getelementptr inbounds i8, i8* %63, i32 1
store i8* %64, i8** %9
%65 = load i32, i32* %10
%66 = add nsw i32 %65, -1
store i32 %66, i32* %10
%67 = load i32, i32* %15
%68 = load i32, i32* %13
%69 = add i32 %68, %67
store i32 %69, i32* %13
%70 = load i32, i32* %13
%71 = load i32, i32* %12
%72 = icmp ugt i32 %70, %71
br i1 %72, label %73, label %75
73: ; preds = %62
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %6
br label %159
75: ; preds = %62
%76 = load i32, i32* %16
%77 = load i32, i32* %15
%78 = add i32 %76, %77
%79 = load i32, i32* %8
%80 = icmp ugt i32 %78, %79
br i1 %80, label %81, label %86
81: ; preds = %75
%82 = load i32, i32* %16
%83 = load i32, i32* %15
%84 = load i32, i32* %8
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.3, i64 0, i64 0), i32 %82, i32 %83, i32 %84)
store i32 -1, i32* %6
br label %159
86: ; preds = %75
%87 = load i8*, i8** %11
%88 = load i8*, i8** %7
%89 = load i32, i32* %16
%90 = zext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %88, i64 %90
%92 = load i32, i32* %15
%93 = call i32 @memcpy(i8* %87, i8* %91, i32 %92)
%94 = load i32, i32* %15
%95 = load i8*, i8** %11
%96 = zext i32 %94 to i64
%97 = getelementptr inbounds i8, i8* %95, i64 %96
store i8* %97, i8** %11
br label %156
98: ; preds = %40
%99 = load i8*, i8** %9
%100 = getelementptr inbounds i8, i8* %99, i32 1
store i8* %100, i8** %9
%101 = load i32, i32* %10
%102 = add nsw i32 %101, -1
store i32 %102, i32* %10
%103 = load i32, i32* %15
%104 = load i32, i32* %13
%105 = add i32 %104, %103
store i32 %105, i32* %13
%106 = load i32, i32* %13
%107 = load i32, i32* %12
%108 = icmp ugt i32 %106, %107
br i1 %108, label %109, label %111
109: ; preds = %98
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %6
br label %159
111: ; preds = %98
%112 = load i32, i32* %15
%113 = load i32, i32* %10
%114 = icmp ugt i32 %112, %113
br i1 %114, label %115, label %117
115: ; preds = %111
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %6
br label %159
117: ; preds = %111
%118 = load i8*, i8** %11
%119 = load i8*, i8** %9
%120 = load i32, i32* %15
%121 = call i32 @memcpy(i8* %118, i8* %119, i32 %120)
%122 = load i32, i32* %15
%123 = load i8*, i8** %11
%124 = zext i32 %122 to i64
%125 = getelementptr inbounds i8, i8* %123, i64 %124
store i8* %125, i8** %11
%126 = load i32, i32* %15
%127 = load i8*, i8** %9
%128 = zext i32 %126 to i64
%129 = getelementptr inbounds i8, i8* %127, i64 %128
store i8* %129, i8** %9
%130 = load i32, i32* %15
%131 = load i32, i32* %10
%132 = sub i32 %131, %130
store i32 %132, i32* %10
br label %156
133: ; preds = %40
%134 = load i8*, i8** %9
%135 = getelementptr inbounds i8, i8* %134, i32 1
store i8* %135, i8** %9
%136 = load i32, i32* %10
%137 = add nsw i32 %136, -1
store i32 %137, i32* %10
%138 = load i8*, i8** %11
%139 = getelementptr inbounds i8, i8* %138, i64 0
store i8 0, i8* %139
%140 = load i32, i32* %15
%141 = load i8*, i8** %14
%142 = load i32, i32* %13
%143 = call i32 @checksum(i8* %141, i32 %142)
%144 = icmp ne i32 %140, %143
br i1 %144, label %145, label %146
145: ; preds = %133
store i32 -1, i32* %6
br label %159
146: ; preds = %133
%147 = load i32, i32* %13
%148 = load i32, i32* %12
%149 = icmp ne i32 %147, %148
br i1 %149, label %150, label %152
150: ; preds = %146
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %6
br label %159
152: ; preds = %146
%153 = load i32, i32* %13
store i32 %153, i32* %6
br label %159
154: ; preds = %40
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %6
br label %159
156: ; preds = %117, %86
br label %30
157: ; preds = %38
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %6
br label %159
159: ; preds = %157, %154, %152, %150, %145, %115, %109, %81, %73, %60, %23
%160 = load i32, i32* %6
ret i32 %160
}

LLVM IR (-O2):
@.str.3 = [71 x i8] c"ERROR: copy extends past end of input: ofst: %d, cnt: %d, lenSrc: %d \0A\00"
@str = [26 x i8] c"ERROR: unterminated delta\00"
@str.9 = [52 x i8] c"ERROR: generated size does not match predicted size\00"
@str.10 = [42 x i8] c"ERROR: insert count exceeds size of delta\00"
@str.11 = [61 x i8] c"ERROR: insert command gives an output larger than predicted\00"
@str.12 = [37 x i8] c"ERROR: copy exceeds output file size\00"
@str.13 = [42 x i8] c"ERROR: copy command not terminated by ','\00"
@str.14 = [30 x i8] c"ERROR: unknown delta operator\00"
@str.15 = [41 x i8] c"ERROR: size integer not terminated by /n\00"
define i32 @delta_apply(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
store i8* %2, i8** %6
store i32 %3, i32* %7
%8 = call i32 @getInt(i8** %6, i32* %7)
%9 = load i8*, i8** %6
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 10
br i1 %11, label %14, label %12
12: ; preds = %5
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.15, i64 0, i64 0))
br label %104
14: ; preds = %5
%15 = getelementptr inbounds i8, i8* %9, i64 1
store i8* %15, i8** %6
%16 = load i32, i32* %7
%17 = add nsw i32 %16, -1
store i32 %17, i32* %7
%18 = load i8, i8* %15
%19 = icmp ne i8 %18, 0
%20 = icmp sgt i32 %16, 1
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %22, label %102
22: ; preds = %14, %92
%23 = phi i8* [ %97, %92 ], [ %4, %14 ]
%24 = phi i32 [ %95, %92 ], [ 0, %14 ]
%25 = call i32 @getInt(i8** %6, i32* %7)
%26 = load i8*, i8** %6
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
switch i32 %28, label %90 [
i32 64, label %29
i32 58, label %61
i32 59, label %80
]
29: ; preds = %22
%30 = getelementptr inbounds i8, i8* %26, i64 1
store i8* %30, i8** %6
%31 = load i32, i32* %7
%32 = add nsw i32 %31, -1
store i32 %32, i32* %7
%33 = call i32 @getInt(i8** %6, i32* %7)
%34 = load i32, i32* %7
%35 = icmp sgt i32 %34, 0
%36 = load i8*, i8** %6
br i1 %35, label %37, label %42
37: ; preds = %29
%38 = load i8, i8* %36
%39 = icmp eq i8 %38, 44
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.13, i64 0, i64 0))
br label %104
42: ; preds = %29, %37
%43 = getelementptr inbounds i8, i8* %36, i64 1
store i8* %43, i8** %6
%44 = add nsw i32 %34, -1
store i32 %44, i32* %7
%45 = add i32 %25, %24
%46 = icmp ugt i32 %45, %8
br i1 %46, label %47, label %49
47: ; preds = %42
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.12, i64 0, i64 0))
br label %104
49: ; preds = %42
%50 = add i32 %33, %25
%51 = icmp ugt i32 %50, %1
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.3, i64 0, i64 0), i32 %33, i32 %25, i32 %1)
br label %104
54: ; preds = %49
%55 = zext i32 %33 to i64
%56 = getelementptr inbounds i8, i8* %0, i64 %55
%57 = call i32 @memcpy(i8* %23, i8* %56, i32 %25)
%58 = zext i32 %25 to i64
%59 = load i8*, i8** %6
%60 = load i32, i32* %7
br label %92
61: ; preds = %22
%62 = getelementptr inbounds i8, i8* %26, i64 1
store i8* %62, i8** %6
%63 = load i32, i32* %7
%64 = add nsw i32 %63, -1
store i32 %64, i32* %7
%65 = add i32 %25, %24
%66 = icmp ugt i32 %65, %8
br i1 %66, label %67, label %69
67: ; preds = %61
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.11, i64 0, i64 0))
br label %104
69: ; preds = %61
%70 = icmp ugt i32 %25, %64
br i1 %70, label %71, label %73
71: ; preds = %69
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.10, i64 0, i64 0))
br label %104
73: ; preds = %69
%74 = call i32 @memcpy(i8* %23, i8* %62, i32 %25)
%75 = zext i32 %25 to i64
%76 = load i8*, i8** %6
%77 = getelementptr inbounds i8, i8* %76, i64 %75
store i8* %77, i8** %6
%78 = load i32, i32* %7
%79 = sub i32 %78, %25
store i32 %79, i32* %7
br label %92
80: ; preds = %22
%81 = getelementptr inbounds i8, i8* %26, i64 1
store i8* %81, i8** %6
%82 = load i32, i32* %7
%83 = add nsw i32 %82, -1
store i32 %83, i32* %7
store i8 0, i8* %23
%84 = call i32 @checksum(i8* %4, i32 %24)
%85 = icmp eq i32 %25, %84
br i1 %85, label %86, label %104
86: ; preds = %80
%87 = icmp eq i32 %24, %8
br i1 %87, label %104, label %88
88: ; preds = %86
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.9, i64 0, i64 0))
br label %104
90: ; preds = %22
%91 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.14, i64 0, i64 0))
br label %104
92: ; preds = %54, %73
%93 = phi i32 [ %79, %73 ], [ %60, %54 ]
%94 = phi i8* [ %77, %73 ], [ %59, %54 ]
%95 = phi i32 [ %65, %73 ], [ %45, %54 ]
%96 = phi i64 [ %75, %73 ], [ %58, %54 ]
%97 = getelementptr inbounds i8, i8* %23, i64 %96
%98 = load i8, i8* %94
%99 = icmp ne i8 %98, 0
%100 = icmp sgt i32 %93, 0
%101 = select i1 %99, i1 %100, i1 false
br i1 %101, label %22, label %102
102: ; preds = %92, %14
%103 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %104
104: ; preds = %86, %80, %52, %47, %40, %71, %67, %88, %90, %102, %12
%105 = phi i32 [ -1, %12 ], [ -1, %102 ], [ %8, %86 ], [ -1, %80 ], [ -1, %52 ], [ -1, %47 ], [ -1, %40 ], [ -1, %71 ], [ -1, %67 ], [ -1, %88 ], [ -1, %90 ]
ret i32 %105
}