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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ copy_lines(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int /*<<< orphan*/, int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
char *strchr(char const *, char);
int strlen(char *);
unsigned long strtoul(char *, char **, int);
int /*<<< orphan*/ *xtmpfile();
long added_hunk(const char *meta, long offset, FILE *modify, FILE *t,
                unsigned long morig_count, unsigned long mnew_count) {
  long this_offset = 0;
  char *line = NULL;
  size_t linelen = 0;
  char *p = strchr(meta, '-'), *q;
  unsigned long orig_offset = 0, new_offset;
  unsigned long orig_count = 0, new_count = 0;
  FILE *newhunk = xtmpfile();
  if (!newhunk)
    error(EXIT_FAILURE, errno, "Couldn't create temporary file");
  if (p) {
    p++;
    orig_offset = strtoul(p, &q, 10);
  }
  if (!p || p == q) {
    if (p)
      p[strlen(p) - 1] = '\0';
    error(EXIT_FAILURE, 0, "Hunk addition requires original line: %s", meta);
  }
  while (morig_count || mnew_count) {
    if (getline(&line, &linelen, modify) == -1)
      break;
    if (line[0] != '+')
      error(EXIT_FAILURE, 0, "Only whole hunks may be added");
    mnew_count--;
    switch (line[1]) {
    case ' ':
      orig_count++;
      new_count++;
      break;
    case '+':
      new_count++;
      this_offset++;
      break;
    case '-':
      orig_count++;
      this_offset--;
      break;
    default:
      error(EXIT_FAILURE, 0, "Multiple added hunks not supported");
    }
    fputs(line + 1, newhunk);
  }
  new_offset = orig_offset + offset;
  if (!new_count)
    new_offset--;
  fprintf(t, "@@ -%lu", orig_offset);
  if (orig_count != 1)
    fprintf(t, ",%lu", orig_count);
  fprintf(t, " +%lu", new_offset);
  if (new_count != 1)
    fprintf(t, ",%lu", new_count);
  fprintf(t, " @@\n");
  rewind(newhunk);
  while (copy_lines(newhunk, t, 100))
    ;
  fclose(newhunk);
  if (line)
    free(line);
  return this_offset;
}


x86 assembly (clang, -O0):
<added_hunk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2d,%esi
call   1060 <strchr@plt>
mov    %rax,-0x50(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x70(%rbp)
movq   $0x0,-0x78(%rbp)
mov    $0x0,%al
call   1080 <xtmpfile@plt>
mov    %rax,-0x80(%rbp)
cmpq   $0x0,-0x80(%rbp)
jne    125b <added_hunk+0x9b>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
mov    0x2d95(%rip),%rax
mov    (%rax),%esi
lea    0xdac(%rip),%rdx
mov    $0x0,%al
call   10c0 <error@plt>
cmpq   $0x0,-0x50(%rbp)
je     1288 <added_hunk+0xc8>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x58(%rbp),%rsi
mov    $0xa,%edx
call   10d0 <strtoul@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     12a1 <added_hunk+0xe1>
mov    -0x50(%rbp),%rax
cmp    -0x58(%rbp),%rax
jne    12f0 <added_hunk+0x130>
cmpq   $0x0,-0x50(%rbp)
je     12d3 <added_hunk+0x113>
mov    -0x50(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x50(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rcx
xor    %esi,%esi
lea    0xd36(%rip),%rdx
mov    $0x0,%al
call   10c0 <error@plt>
jmp    12f5 <added_hunk+0x135>
mov    $0x1,%al
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x89(%rbp)
jne    1316 <added_hunk+0x156>
cmpq   $0x0,-0x30(%rbp)
setne  %al
mov    %al,-0x89(%rbp)
mov    -0x89(%rbp),%al
test   $0x1,%al
jne    1329 <added_hunk+0x169>
jmp    1447 <added_hunk+0x287>
mov    -0x18(%rbp),%rdx
lea    -0x40(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   10e0 <getline@plt>
cmp    $0xffffffff,%eax
jne    1348 <added_hunk+0x188>
jmp    1447 <added_hunk+0x287>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
je     1371 <added_hunk+0x1b1>
mov    0x2c79(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
lea    0xcde(%rip),%rdx
mov    $0x0,%al
call   10c0 <error@plt>
mov    -0x30(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
mov    -0x40(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x90(%rbp)
sub    $0x20,%eax
je     13c1 <added_hunk+0x201>
jmp    1399 <added_hunk+0x1d9>
mov    -0x90(%rbp),%eax
sub    $0x2b,%eax
je     13de <added_hunk+0x21e>
jmp    13ad <added_hunk+0x1ed>
mov    -0x90(%rbp),%eax
sub    $0x2d,%eax
je     13fb <added_hunk+0x23b>
jmp    1418 <added_hunk+0x258>
mov    -0x70(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x70(%rbp)
mov    -0x78(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x78(%rbp)
jmp    1431 <added_hunk+0x271>
mov    -0x78(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x78(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1431 <added_hunk+0x271>
mov    -0x70(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x70(%rbp)
mov    -0x38(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x38(%rbp)
jmp    1431 <added_hunk+0x271>
mov    0x2bb9(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
lea    0xc3c(%rip),%rdx
mov    $0x0,%al
call   10c0 <error@plt>
mov    -0x40(%rbp),%rdi
add    $0x1,%rdi
mov    -0x80(%rbp),%rsi
call   1090 <fputs@plt>
jmp    12f5 <added_hunk+0x135>
mov    -0x60(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    146a <added_hunk+0x2aa>
mov    -0x68(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x68(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x60(%rbp),%rdx
lea    0xc10(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
cmpq   $0x1,-0x70(%rbp)
je     14a1 <added_hunk+0x2e1>
mov    -0x20(%rbp),%rdi
mov    -0x70(%rbp),%rdx
lea    0xbf7(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x68(%rbp),%rdx
lea    0xbe6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
cmpq   $0x1,-0x78(%rbp)
je     14d8 <added_hunk+0x318>
mov    -0x20(%rbp),%rdi
mov    -0x78(%rbp),%rdx
lea    0xbc0(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xbb9(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x80(%rbp),%rdi
call   1070 <rewind@plt>
mov    -0x80(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x64,%edx
call   10b0 <copy_lines@plt>
cmp    $0x0,%rax
je     1514 <added_hunk+0x354>
jmp    14f3 <added_hunk+0x333>
mov    -0x80(%rbp),%rdi
call   1040 <fclose@plt>
cmpq   $0x0,-0x40(%rbp)
je     1531 <added_hunk+0x371>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<added_hunk>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9,%r13
mov    %r8,0x20(%rsp)
mov    %rcx,%r14
mov    %rdx,0x30(%rsp)
mov    %rsi,0x28(%rsp)
mov    %rdi,%r15
movq   $0x0,0x8(%rsp)
movq   $0x0,0x40(%rsp)
mov    $0x2d,%esi
call   1060 <strchr@plt>
mov    %rax,%rbp
xor    %eax,%eax
call   1080 <xtmpfile@plt>
mov    %rax,%rbx
test   %rax,%rax
je     125c <added_hunk+0x8c>
test   %rbp,%rbp
je     1281 <added_hunk+0xb1>
add    $0x1,%rbp
lea    0x38(%rsp),%rsi
mov    %rbp,%rdi
mov    $0xa,%edx
call   10d0 <strtoul@plt>
mov    %rax,0x18(%rsp)
cmp    0x38(%rsp),%rbp
jne    12a4 <added_hunk+0xd4>
mov    %rbp,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
jmp    1288 <added_hunk+0xb8>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
mov    0x2d74(%rip),%rax
mov    (%rax),%esi
lea    0xd8b(%rip),%rdx
xor    %eax,%eax
call   10c0 <error@plt>
test   %rbp,%rbp
jne    1229 <added_hunk+0x59>
xor    %eax,%eax
mov    %rax,0x18(%rsp)
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
lea    0xd87(%rip),%rdx
xor    %esi,%esi
mov    %r15,%rcx
xor    %eax,%eax
call   10c0 <error@plt>
mov    0x20(%rsp),%rax
or     %r13,%rax
je     1391 <added_hunk+0x1c1>
add    $0xffffffffffffffff,%r13
mov    0x2d1b(%rip),%rbp
xor    %r15d,%r15d
xor    %r12d,%r12d
xor    %eax,%eax
mov    %rax,0x10(%rsp)
nopw   0x0(%rax,%rax,1)
lea    0x8(%rsp),%rdi
lea    0x40(%rsp),%rsi
mov    0x30(%rsp),%rdx
call   10e0 <getline@plt>
cmp    $0xffffffff,%eax
je     139e <added_hunk+0x1ce>
mov    0x8(%rsp),%rdi
cmpb   $0x2b,(%rdi)
je     130f <added_hunk+0x13f>
mov    0x0(%rbp),%edi
xor    %esi,%esi
lea    0xd45(%rip),%rdx
xor    %eax,%eax
call   10c0 <error@plt>
mov    0x8(%rsp),%rdi
movsbl 0x1(%rdi),%eax
cmp    $0x2d,%eax
je     1330 <added_hunk+0x160>
cmp    $0x2b,%eax
je     1340 <added_hunk+0x170>
cmp    $0x20,%eax
jne    1350 <added_hunk+0x180>
add    $0x1,%r12
add    $0x1,%r15
jmp    1368 <added_hunk+0x198>
nopl   0x0(%rax)
add    $0x1,%r12
addq   $0xffffffffffffffff,0x10(%rsp)
jmp    1368 <added_hunk+0x198>
nopl   0x0(%rax)
add    $0x1,%r15
addq   $0x1,0x10(%rsp)
jmp    1368 <added_hunk+0x198>
nopl   0x0(%rax)
mov    0x0(%rbp),%edi
xor    %esi,%esi
lea    0xd0a(%rip),%rdx
xor    %eax,%eax
call   10c0 <error@plt>
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
mov    %rbx,%rsi
call   1090 <fputs@plt>
add    $0xffffffffffffffff,%r13
setb   %al
cmpq   $0x0,0x20(%rsp)
jne    12d0 <added_hunk+0x100>
test   %al,%al
jne    12d0 <added_hunk+0x100>
jmp    139e <added_hunk+0x1ce>
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xor    %r12d,%r12d
xor    %r15d,%r15d
mov    0x28(%rsp),%rbp
mov    0x18(%rsp),%rdx
add    %rdx,%rbp
cmp    $0x1,%r15
sbb    $0x0,%rbp
lea    0xccf(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   10a0 <fprintf@plt>
cmp    $0x1,%r12
je     13de <added_hunk+0x20e>
lea    0xcc0(%rip),%rsi
mov    %r14,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xcb1(%rip),%rsi
mov    %r14,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
cmp    $0x1,%r15
je     140c <added_hunk+0x23c>
lea    0xc92(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xc89(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10f0 <fwrite@plt>
mov    %rbx,%rdi
call   1070 <rewind@plt>
nopl   (%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x64,%edx
call   10b0 <copy_lines@plt>
test   %rax,%rax
jne    1430 <added_hunk+0x260>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     145c <added_hunk+0x28c>
call   1030 <free@plt>
mov    0x10(%rsp),%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@errno = global i32 0
@.str = [31 x i8] c"Couldn't create temporary file\00"
@.str.1 = [41 x i8] c"Hunk addition requires original line: %s\00"
@.str.2 = [30 x i8] c"Only whole hunks may be added\00"
@.str.3 = [35 x i8] c"Multiple added hunks not supported\00"
@.str.4 = [8 x i8] c"@@ -%lu\00"
@.str.5 = [5 x i8] c",%lu\00"
@.str.6 = [6 x i8] c" +%lu\00"
@.str.7 = [5 x i8] c" @@\0A\00"
define i64 @added_hunk(i8* %0, i64 %1, i32* %2, i32* %3, i64 %4, i64 %5) {
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i64
%19 = alloca i64
%20 = alloca i64
%21 = alloca i64
%22 = alloca i32*
store i8* %0, i8** %7
store i64 %1, i64* %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i64 %4, i64* %11
store i64 %5, i64* %12
store i64 0, i64* %13
store i8* null, i8** %14
store i64 0, i64* %15
%23 = load i8*, i8** %7
%24 = call i8* @strchr(i8* %23, i8 signext 45)
store i8* %24, i8** %16
store i64 0, i64* %18
store i64 0, i64* %20
store i64 0, i64* %21
%25 = call i32* (...) @xtmpfile()
store i32* %25, i32** %22
%26 = load i32*, i32** %22
%27 = icmp ne i32* %26, null
br i1 %27, label %32, label %28
28: ; preds = %6
%29 = load i32, i32* @EXIT_FAILURE
%30 = load i32, i32* @errno
%31 = call i32 (i32, i32, i8*, ...) @error(i32 %29, i32 %30, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %32
32: ; preds = %28, %6
%33 = load i8*, i8** %16
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %40
35: ; preds = %32
%36 = load i8*, i8** %16
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %16
%38 = load i8*, i8** %16
%39 = call i64 @strtoul(i8* %38, i8** %17, i32 10)
store i64 %39, i64* %18
br label %40
40: ; preds = %35, %32
%41 = load i8*, i8** %16
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = load i8*, i8** %16
%45 = load i8*, i8** %17
%46 = icmp eq i8* %44, %45
br i1 %46, label %47, label %61
47: ; preds = %43, %40
%48 = load i8*, i8** %16
%49 = icmp ne i8* %48, null
br i1 %49, label %50, label %57
50: ; preds = %47
%51 = load i8*, i8** %16
%52 = load i8*, i8** %16
%53 = call i32 @strlen(i8* %52)
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %51, i64 %55
store i8 0, i8* %56
br label %57
57: ; preds = %50, %47
%58 = load i32, i32* @EXIT_FAILURE
%59 = load i8*, i8** %7
%60 = call i32 (i32, i32, i8*, ...) @error(i32 %58, i32 0, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %57, %43
br label %62
62: ; preds = %109, %61
%63 = load i64, i64* %11
%64 = icmp ne i64 %63, 0
br i1 %64, label %68, label %65
65: ; preds = %62
%66 = load i64, i64* %12
%67 = icmp ne i64 %66, 0
br label %68
68: ; preds = %65, %62
%69 = phi i1 [ true, %62 ], [ %67, %65 ]
br i1 %69, label %70, label %114
70: ; preds = %68
%71 = load i32*, i32** %9
%72 = call i32 @getline(i8** %14, i64* %15, i32* %71)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %75
74: ; preds = %70
br label %114
75: ; preds = %70
%76 = load i8*, i8** %14
%77 = getelementptr inbounds i8, i8* %76, i64 0
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = icmp ne i32 %79, 43
br i1 %80, label %81, label %84
81: ; preds = %75
%82 = load i32, i32* @EXIT_FAILURE
%83 = call i32 (i32, i32, i8*, ...) @error(i32 %82, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %84
84: ; preds = %81, %75
%85 = load i64, i64* %12
%86 = add i64 %85, -1
store i64 %86, i64* %12
%87 = load i8*, i8** %14
%88 = getelementptr inbounds i8, i8* %87, i64 1
%89 = load i8, i8* %88
%90 = sext i8 %89 to i32
switch i32 %90, label %106 [
i32 32, label %91
i32 43, label %96
i32 45, label %101
]
91: ; preds = %84
%92 = load i64, i64* %20
%93 = add i64 %92, 1
store i64 %93, i64* %20
%94 = load i64, i64* %21
%95 = add i64 %94, 1
store i64 %95, i64* %21
br label %109
96: ; preds = %84
%97 = load i64, i64* %21
%98 = add i64 %97, 1
store i64 %98, i64* %21
%99 = load i64, i64* %13
%100 = add nsw i64 %99, 1
store i64 %100, i64* %13
br label %109
101: ; preds = %84
%102 = load i64, i64* %20
%103 = add i64 %102, 1
store i64 %103, i64* %20
%104 = load i64, i64* %13
%105 = add nsw i64 %104, -1
store i64 %105, i64* %13
br label %109
106: ; preds = %84
%107 = load i32, i32* @EXIT_FAILURE
%108 = call i32 (i32, i32, i8*, ...) @error(i32 %107, i32 0, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
br label %109
109: ; preds = %106, %101, %96, %91
%110 = load i8*, i8** %14
%111 = getelementptr inbounds i8, i8* %110, i64 1
%112 = load i32*, i32** %22
%113 = call i32 @fputs(i8* %111, i32* %112)
br label %62
114: ; preds = %74, %68
%115 = load i64, i64* %18
%116 = load i64, i64* %8
%117 = add i64 %115, %116
store i64 %117, i64* %19
%118 = load i64, i64* %21
%119 = icmp ne i64 %118, 0
br i1 %119, label %123, label %120
120: ; preds = %114
%121 = load i64, i64* %19
%122 = add i64 %121, -1
store i64 %122, i64* %19
br label %123
123: ; preds = %120, %114
%124 = load i32*, i32** %10
%125 = load i64, i64* %18
%126 = call i32 (i32*, i8*, ...) @fprintf(i32* %124, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i64 %125)
%127 = load i64, i64* %20
%128 = icmp ne i64 %127, 1
br i1 %128, label %129, label %133
129: ; preds = %123
%130 = load i32*, i32** %10
%131 = load i64, i64* %20
%132 = call i32 (i32*, i8*, ...) @fprintf(i32* %130, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 %131)
br label %133
133: ; preds = %129, %123
%134 = load i32*, i32** %10
%135 = load i64, i64* %19
%136 = call i32 (i32*, i8*, ...) @fprintf(i32* %134, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i64 %135)
%137 = load i64, i64* %21
%138 = icmp ne i64 %137, 1
br i1 %138, label %139, label %143
139: ; preds = %133
%140 = load i32*, i32** %10
%141 = load i64, i64* %21
%142 = call i32 (i32*, i8*, ...) @fprintf(i32* %140, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 %141)
br label %143
143: ; preds = %139, %133
%144 = load i32*, i32** %10
%145 = call i32 (i32*, i8*, ...) @fprintf(i32* %144, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%146 = load i32*, i32** %22
%147 = call i32 @rewind(i32* %146)
br label %148
148: ; preds = %153, %143
%149 = load i32*, i32** %22
%150 = load i32*, i32** %10
%151 = call i64 @copy_lines(i32* %149, i32* %150, i32 100)
%152 = icmp ne i64 %151, 0
br i1 %152, label %153, label %154
153: ; preds = %148
br label %148
154: ; preds = %148
%155 = load i32*, i32** %22
%156 = call i32 @fclose(i32* %155)
%157 = load i8*, i8** %14
%158 = icmp ne i8* %157, null
br i1 %158, label %159, label %162
159: ; preds = %154
%160 = load i8*, i8** %14
%161 = call i32 @free(i8* %160)
br label %162
162: ; preds = %159, %154
%163 = load i64, i64* %13
ret i64 %163
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@errno = global i32 0
@.str = [31 x i8] c"Couldn't create temporary file\00"
@.str.1 = [41 x i8] c"Hunk addition requires original line: %s\00"
@.str.2 = [30 x i8] c"Only whole hunks may be added\00"
@.str.3 = [35 x i8] c"Multiple added hunks not supported\00"
@.str.4 = [8 x i8] c"@@ -%lu\00"
@.str.5 = [5 x i8] c",%lu\00"
@.str.6 = [6 x i8] c" +%lu\00"
@.str.7 = [5 x i8] c" @@\0A\00"
define i64 @added_hunk(i8* %0, i64 %1, i32* %2, i32* %3, i64 %4, i64 %5) {
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = bitcast i8** %7 to i8*
store i8* null, i8** %7
%11 = bitcast i64* %8 to i8*
store i64 0, i64* %8
%12 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 45)
%13 = bitcast i8** %9 to i8*
%14 = tail call i32* (...) @xtmpfile()
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %20
16: ; preds = %6
%17 = load i32, i32* @EXIT_FAILURE
%18 = load i32, i32* @errno
%19 = tail call i32 (i32, i32, i8*, ...) @error(i32 %17, i32 %18, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %16, %6
%21 = icmp eq i8* %12, null
br i1 %21, label %32, label %22
22: ; preds = %20
%23 = getelementptr inbounds i8, i8* %12, i64 1
%24 = call i64 @strtoul(i8* %23, i8** %9, i32 10)
%25 = load i8*, i8** %9
%26 = icmp eq i8* %23, %25
br i1 %26, label %27, label %36
27: ; preds = %22
%28 = tail call i32 @strlen(i8* %23)
%29 = add nsw i32 %28, -1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %23, i64 %30
store i8 0, i8* %31
br label %32
32: ; preds = %20, %27
%33 = phi i64 [ %24, %27 ], [ 0, %20 ]
%34 = load i32, i32* @EXIT_FAILURE
%35 = tail call i32 (i32, i32, i8*, ...) @error(i32 %34, i32 0, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %36
36: ; preds = %22, %32
%37 = phi i64 [ %24, %22 ], [ %33, %32 ]
%38 = icmp ne i64 %4, 0
%39 = or i64 %4, %5
%40 = icmp eq i64 %39, 0
br i1 %40, label %84, label %41
41: ; preds = %36, %75
%42 = phi i64 [ %58, %75 ], [ %5, %36 ]
%43 = phi i64 [ %79, %75 ], [ 0, %36 ]
%44 = phi i64 [ %78, %75 ], [ 0, %36 ]
%45 = phi i64 [ %77, %75 ], [ 0, %36 ]
%46 = call i32 @getline(i8** %7, i64* %8, i32* %2)
%47 = icmp eq i32 %46, -1
br i1 %47, label %84, label %48
48: ; preds = %41
%49 = load i8*, i8** %7
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 43
br i1 %51, label %56, label %52
52: ; preds = %48
%53 = load i32, i32* @EXIT_FAILURE
%54 = call i32 (i32, i32, i8*, ...) @error(i32 %53, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%55 = load i8*, i8** %7
br label %56
56: ; preds = %52, %48
%57 = phi i8* [ %55, %52 ], [ %49, %48 ]
%58 = add i64 %42, -1
%59 = getelementptr inbounds i8, i8* %57, i64 1
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
switch i32 %61, label %71 [
i32 32, label %62
i32 43, label %65
i32 45, label %68
]
62: ; preds = %56
%63 = add i64 %44, 1
%64 = add i64 %43, 1
br label %75
65: ; preds = %56
%66 = add i64 %43, 1
%67 = add nsw i64 %45, 1
br label %75
68: ; preds = %56
%69 = add i64 %44, 1
%70 = add nsw i64 %45, -1
br label %75
71: ; preds = %56
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 (i32, i32, i8*, ...) @error(i32 %72, i32 0, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%74 = load i8*, i8** %7
br label %75
75: ; preds = %71, %68, %65, %62
%76 = phi i8* [ %74, %71 ], [ %57, %68 ], [ %57, %65 ], [ %57, %62 ]
%77 = phi i64 [ %45, %71 ], [ %70, %68 ], [ %67, %65 ], [ %45, %62 ]
%78 = phi i64 [ %44, %71 ], [ %69, %68 ], [ %44, %65 ], [ %63, %62 ]
%79 = phi i64 [ %43, %71 ], [ %43, %68 ], [ %66, %65 ], [ %64, %62 ]
%80 = getelementptr inbounds i8, i8* %76, i64 1
%81 = call i32 @fputs(i8* %80, i32* %14)
%82 = icmp ne i64 %58, 0
%83 = select i1 %38, i1 true, i1 %82
br i1 %83, label %41, label %84
84: ; preds = %75, %41, %36
%85 = phi i64 [ 0, %36 ], [ %45, %41 ], [ %77, %75 ]
%86 = phi i64 [ 0, %36 ], [ %44, %41 ], [ %78, %75 ]
%87 = phi i64 [ 0, %36 ], [ %43, %41 ], [ %79, %75 ]
%88 = add i64 %37, %1
%89 = icmp eq i64 %87, 0
%90 = sext i1 %89 to i64
%91 = add i64 %88, %90
%92 = call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i64 %37)
%93 = icmp eq i64 %86, 1
br i1 %93, label %96, label %94
94: ; preds = %84
%95 = call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 %86)
br label %96
96: ; preds = %94, %84
%97 = call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i64 %91)
%98 = icmp eq i64 %87, 1
br i1 %98, label %101, label %99
99: ; preds = %96
%100 = call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 %87)
br label %101
101: ; preds = %99, %96
%102 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i64 4, i64 1, i32* %3)
%103 = call i32 @rewind(i32* %14)
br label %104
104: ; preds = %104, %101
%105 = call i64 @copy_lines(i32* %14, i32* %3, i32 100)
%106 = icmp eq i64 %105, 0
br i1 %106, label %107, label %104
107: ; preds = %104
%108 = call i32 @fclose(i32* %14)
%109 = load i8*, i8** %7
%110 = icmp eq i8* %109, null
br i1 %110, label %113, label %111
111: ; preds = %107
%112 = call i32 @free(i8* %109)
br label %113
113: ; preds = %111, %107
ret i64 %85
}