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

/* Variables and functions */
unsigned int atoi(char *);
scalar_t__ begins_with(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ isdigit(char);
scalar_t__ isspace(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  unsigned i, l, m;
  char buffer[200], *ptr, *ptr1;
  static unsigned lines[10000], ltop = 0, increment = 10, start = 10;
  static FILE *fp, *fp1;
  printf("MICRO-BASIC 2.1 line renumbering program\n");
  if (argc < 3) {
    fprintf(stderr, "Use: renumber old new [start [increment]]\n\n");
    fprintf(stderr, "Copyright 1993-2000 Dave Dunfield\n");
    fprintf(stderr, "All rights reserved.\n");
    return 1;
  }
  fp = fopen(argv[1], "rvq");
  fp1 = fopen(argv[2], "wvq");
  if (argc > 3)
    start = atoi(argv[3]);
  if (argc > 4)
    increment = atoi(argv[4]);
  m = 0;
  while (fgets(buffer, sizeof(buffer) - 1, fp)) {
    if (!(l = atoi(buffer))) {
      printf("Invalid line number following line %u\n", m);
      return 0;
    }
    if (l <= m) {
      printf("Improper line sequence following line %u\n", m);
      return 0;
    }
    lines[ltop++] = m = l;
  }
  rewind(fp);
  m = 0;
  while (fgets(ptr1 = ptr = buffer, sizeof(buffer), fp)) {
  fixnum:
    while (isspace(*ptr))
      ++ptr;
    while (ptr1 < ptr)
      putc(*ptr1++, fp1);
    if (isdigit(*ptr)) {
      ++m;
      l = atoi(ptr);
      while (isdigit(*ptr))
        ++ptr;
      for (i = 0; i < ltop; ++i)
        if (lines[i] == l) {
          fprintf(fp1, "%u", i * increment + start);
          break;
        }
    }
    while (*(ptr1 = ptr)) {
      if (begins_with(ptr, "THEN")) {
        ptr += 4;
        goto fixnum;
      }
      if (begins_with(ptr, "ORDER")) {
        ptr += 5;
        goto fixnum;
      }
      if (begins_with(ptr, "GOTO")) {
        ptr += 4;
        goto fixnum;
      }
      if (begins_with(ptr, "GOSUB")) {
        ptr += 5;
        goto fixnum;
      }
      if (*ptr != '\r' && *ptr != '\n')
        putc(*ptr, fp1);
      ++ptr;
    }
    putc('\n', fp1);
  }
  fclose(fp1);
  fclose(fp);
  printf("%u lines read, %u fixups\n", ltop, m);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x3,-0x8(%rbp)
jge    1235 <main+0x85>
mov    0x2df8(%rip),%rax
movslq (%rax),%rdi
lea    0xe38(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2de0(%rip),%rax
movslq (%rax),%rdi
lea    0xe4c(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2dc8(%rip),%rax
movslq (%rax),%rdi
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1675 <main+0x4c5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4b(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,0xca88(%rip)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe34(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,0xca75(%rip)
cmpl   $0x3,-0x8(%rbp)
jle    1288 <main+0xd8>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,0x2df4(%rip)
cmpl   $0x4,-0x8(%rbp)
jle    12a5 <main+0xf5>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,0x2dd3(%rip)
movl   $0x0,-0x1c(%rbp)
lea    -0xf0(%rbp),%rdi
mov    0xca1e(%rip),%rdx
mov    $0xc7,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1356 <main+0x1a6>
lea    -0xf0(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jne    1303 <main+0x153>
mov    -0x1c(%rbp),%esi
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1675 <main+0x4c5>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
ja     132c <main+0x17c>
mov    -0x1c(%rbp),%esi
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1675 <main+0x4c5>
mov    -0x18(%rbp),%edx
mov    %edx,-0x1c(%rbp)
mov    0xc998(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0xc98d(%rip)
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2d42(%rip),%rax
mov    %edx,(%rax,%rcx,4)
jmp    12ac <main+0xfc>
mov    0xc97b(%rip),%rdi
call   1060 <rewind@plt>
movl   $0x0,-0x1c(%rbp)
lea    -0xf0(%rbp),%rdi
mov    %rdi,-0xf8(%rbp)
mov    %rdi,-0x100(%rbp)
mov    0xc953(%rip),%rdx
mov    $0xc8,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     163f <main+0x48f>
jmp    139e <main+0x1ee>
jmp    13a3 <main+0x1f3>
mov    -0xf8(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isspace@plt>
cmp    $0x0,%rax
je     13d3 <main+0x223>
mov    -0xf8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf8(%rbp)
jmp    13a3 <main+0x1f3>
jmp    13d8 <main+0x228>
mov    -0x100(%rbp),%rax
cmp    -0xf8(%rbp),%rax
jae    1417 <main+0x267>
mov    -0x100(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x100(%rbp)
mov    (%rax),%al
mov    0xc8d6(%rip),%rsi
movsbl %al,%edi
call   1090 <putc@plt>
jmp    13d8 <main+0x228>
mov    -0xf8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     14e8 <main+0x338>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0xf8(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0xf8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1478 <main+0x2c8>
mov    -0xf8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf8(%rbp)
jmp    1448 <main+0x298>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    0xc848(%rip),%eax
jae    14e3 <main+0x333>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
lea    0x2bf6(%rip),%rax
mov    (%rax,%rcx,4),%eax
cmp    -0x18(%rbp),%eax
jne    14d0 <main+0x320>
mov    0xc833(%rip),%rdi
mov    -0x14(%rbp),%edx
imul   0x2bc1(%rip),%edx
add    0x2bbf(%rip),%edx
lea    0xc24(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    14e3 <main+0x333>
jmp    14d5 <main+0x325>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    147f <main+0x2cf>
jmp    14e8 <main+0x338>
jmp    14ed <main+0x33d>
mov    -0xf8(%rbp),%rax
mov    %rax,-0x100(%rbp)
cmpb   $0x0,(%rax)
je     1629 <main+0x479>
mov    -0xf8(%rbp),%rdi
lea    0xbd9(%rip),%rsi
call   10d0 <begins_with@plt>
cmp    $0x0,%rax
je     1538 <main+0x388>
mov    -0xf8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0xf8(%rbp)
jmp    139e <main+0x1ee>
mov    -0xf8(%rbp),%rdi
lea    0xbaa(%rip),%rsi
call   10d0 <begins_with@plt>
cmp    $0x0,%rax
je     156c <main+0x3bc>
mov    -0xf8(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0xf8(%rbp)
jmp    139e <main+0x1ee>
mov    -0xf8(%rbp),%rdi
lea    0xb7c(%rip),%rsi
call   10d0 <begins_with@plt>
cmp    $0x0,%rax
je     15a0 <main+0x3f0>
mov    -0xf8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0xf8(%rbp)
jmp    139e <main+0x1ee>
mov    -0xf8(%rbp),%rdi
lea    0xb4d(%rip),%rsi
call   10d0 <begins_with@plt>
cmp    $0x0,%rax
je     15d4 <main+0x424>
mov    -0xf8(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0xf8(%rbp)
jmp    139e <main+0x1ee>
mov    -0xf8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
je     1612 <main+0x462>
mov    -0xf8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     1612 <main+0x462>
mov    -0xf8(%rbp),%rax
mov    (%rax),%al
mov    0xc6d6(%rip),%rsi
movsbl %al,%edi
call   1090 <putc@plt>
mov    -0xf8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf8(%rbp)
jmp    14ed <main+0x33d>
mov    0xc6b0(%rip),%rsi
mov    $0xa,%edi
call   1090 <putc@plt>
jmp    1369 <main+0x1b9>
mov    0xc69a(%rip),%rdi
call   1040 <fclose@plt>
mov    0xc686(%rip),%rdi
call   1040 <fclose@plt>
mov    0xc673(%rip),%esi
mov    -0x1c(%rbp),%edx
lea    0xa9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xf04(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x2,%ebp
jg     1253 <main+0x83>
mov    0x2de2(%rip),%rbx
movslq (%rbx),%rcx
lea    0xdf8(%rip),%rdi
mov    $0x2b,%esi
mov    $0x1,%edx
call   10f0 <fwrite@plt>
movslq (%rbx),%rcx
lea    0xe0b(%rip),%rdi
mov    $0x22,%esi
mov    $0x1,%edx
call   10f0 <fwrite@plt>
movslq (%rbx),%rcx
lea    0xe15(%rip),%rdi
mov    $0x15,%esi
mov    $0x1,%edx
call   10f0 <fwrite@plt>
mov    $0x1,%ebp
jmp    15d5 <main+0x405>
mov    0x8(%rbx),%rdi
lea    0xe07(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,0xca7e(%rip)
mov    0x10(%rbx),%rdi
lea    0xdf4(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,0xca6f(%rip)
cmp    $0x3,%ebp
je     12a9 <main+0xd9>
mov    0x18(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,0x2df7(%rip)
cmp    $0x5,%ebp
jb     12a9 <main+0xd9>
mov    0x20(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,0x2ddf(%rip)
mov    0xca38(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0xc7,%esi
call   1090 <fgets@plt>
test   %rax,%rax
je     1328 <main+0x158>
xor    %ebx,%ebx
lea    0x10(%rsp),%r14
lea    0x2dce(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   10d0 <atoi@plt>
test   %eax,%eax
je     15ba <main+0x3ea>
mov    %eax,%ebp
cmp    %ebx,%eax
jbe    15c3 <main+0x3f3>
mov    0xc9e0(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0xc9d7(%rip)
mov    %ebp,(%r15,%rax,4)
mov    0xc9d4(%rip),%rdx
mov    %r14,%rdi
mov    $0xc7,%esi
call   1090 <fgets@plt>
mov    %ebp,%ebx
test   %rax,%rax
jne    12e0 <main+0x110>
mov    0xc9b9(%rip),%rdi
call   1070 <rewind@plt>
mov    0xc9ad(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0xc8,%esi
call   1090 <fgets@plt>
movl   $0x0,0xc(%rsp)
test   %rax,%rax
je     1586 <main+0x3b6>
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%r15
mov    %r15,%r14
jmp    13a6 <main+0x1d6>
nopl   (%rax)
mov    0xc979(%rip),%rsi
mov    $0xa,%edi
call   10a0 <putc@plt>
mov    0xc960(%rip),%rdx
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0xc8,%esi
call   1090 <fgets@plt>
mov    %r15,%r14
test   %rax,%rax
je     1586 <main+0x3b6>
lea    -0x1(%r14),%rbp
sub    %r15,%r14
mov    %rbp,%rbx
mov    %rbx,%r12
mov    %r14,%r13
add    $0x1,%rbx
movsbl 0x1(%r12),%edi
call   1080 <isspace@plt>
add    $0x1,%rbp
add    $0x1,%r14
test   %rax,%rax
jne    13b0 <main+0x1e0>
cmp    %rbx,%r15
jae    13fa <main+0x22a>
nopw   0x0(%rax,%rax,1)
movsbl (%r15),%edi
add    $0x1,%r15
mov    0xc901(%rip),%rsi
call   10a0 <putc@plt>
add    $0xffffffffffffffff,%r13
jne    13e0 <main+0x210>
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1480 <main+0x2b0>
mov    %rbx,%rdi
call   10d0 <atoi@plt>
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%r12),%edi
add    $0x1,%r12
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1420 <main+0x250>
mov    0xc(%rsp),%ecx
add    $0x1,%ecx
mov    0xc89f(%rip),%eax
test   %rax,%rax
lea    0xc81(%rip),%r13
mov    %ecx,0xc(%rsp)
je     14c6 <main+0x2f6>
lea    0x2c48(%rip),%rcx
xor    %edx,%edx
nopw   0x0(%rax,%rax,1)
cmp    %ebp,(%rcx)
je     14a4 <main+0x2d4>
add    $0x1,%rdx
add    $0x4,%rcx
cmp    %rdx,%rax
jne    1460 <main+0x290>
jmp    14c6 <main+0x2f6>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%r12
lea    0xc37(%rip),%rbx
lea    0xc35(%rip),%rbp
lea    0xc34(%rip),%r13
cmpb   $0x0,(%r12)
jne    14df <main+0x30f>
jmp    1370 <main+0x1a0>
mov    0xc845(%rip),%rdi
imul   0x2bd6(%rip),%edx
add    0x2bd4(%rip),%edx
lea    0xbff(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    0xbf4(%rip),%rbx
lea    0xbf2(%rip),%rbp
cmpb   $0x0,(%r12)
je     1370 <main+0x1a0>
mov    %r12,%r15
jmp    14ff <main+0x32f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x0,0x1(%r15)
lea    0x1(%r15),%r15
je     1370 <main+0x1a0>
mov    %r15,%rdi
mov    %rbx,%rsi
call   10e0 <begins_with@plt>
mov    $0x4,%r14d
test   %rax,%rax
jne    1570 <main+0x3a0>
mov    %r15,%rdi
mov    %rbp,%rsi
call   10e0 <begins_with@plt>
test   %rax,%rax
jne    1578 <main+0x3a8>
mov    %r15,%rdi
mov    %r13,%rsi
call   10e0 <begins_with@plt>
test   %rax,%rax
jne    1570 <main+0x3a0>
mov    %r15,%rdi
lea    0xb92(%rip),%rsi
call   10e0 <begins_with@plt>
mov    $0x5,%r14d
test   %rax,%rax
jne    1570 <main+0x3a0>
movzbl (%r15),%eax
cmp    $0xa,%al
je     14f0 <main+0x320>
cmp    $0xd,%al
je     14f0 <main+0x320>
mov    0xc78e(%rip),%rsi
movsbl %al,%edi
call   10a0 <putc@plt>
jmp    14f0 <main+0x320>
nopl   0x0(%rax)
add    %r15,%r14
jmp    13a6 <main+0x1d6>
mov    $0x5,%r14d
add    %r15,%r14
jmp    13a6 <main+0x1d6>
mov    0xc763(%rip),%rdi
call   1050 <fclose@plt>
mov    0xc74f(%rip),%rdi
call   1050 <fclose@plt>
mov    0xc73c(%rip),%esi
lea    0xb2c(%rip),%rdi
mov    0xc(%rsp),%edx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %ebp,%ebp
jmp    15d5 <main+0x405>
lea    0xaac(%rip),%rdi
jmp    15ca <main+0x3fa>
lea    0xaca(%rip),%rdi
xor    %ebp,%ebp
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebp,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.lines = internal global [10000 x i32] zeroinitializer
@main.ltop = internal global i32 0
@main.increment = internal global i32 10
@main.start = internal global i32 10
@main.fp = internal global i32* null
@main.fp1 = internal global i32* null
@.str = [42 x i8] c"MICRO-BASIC 2.1 line renumbering program\0A\00"
@stderr = global i32 0
@.str.1 = [44 x i8] c"Use: renumber old new [start [increment]]\0A\0A\00"
@.str.2 = [35 x i8] c"Copyright 1993-2000 Dave Dunfield\0A\00"
@.str.3 = [22 x i8] c"All rights reserved.\0A\00"
@.str.4 = [4 x i8] c"rvq\00"
@.str.5 = [4 x i8] c"wvq\00"
@.str.6 = [39 x i8] c"Invalid line number following line %u\0A\00"
@.str.7 = [42 x i8] c"Improper line sequence following line %u\0A\00"
@.str.8 = [3 x i8] c"%u\00"
@.str.9 = [5 x i8] c"THEN\00"
@.str.10 = [6 x i8] c"ORDER\00"
@.str.11 = [5 x i8] c"GOTO\00"
@.str.12 = [6 x i8] c"GOSUB\00"
@.str.13 = [26 x i8] c"%u lines read, %u fixups\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [200 x i8]
%10 = alloca i8*
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %28
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i32*
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @stderr
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i32*
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* @stderr
%25 = sext i32 %24 to i64
%26 = inttoptr i64 %25 to i32*
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %212
28: ; preds = %2
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i32* %32, i32** @main.fp
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
store i32* %36, i32** @main.fp1
%37 = load i32, i32* %4
%38 = icmp sgt i32 %37, 3
br i1 %38, label %39, label %44
39: ; preds = %28
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 3
%42 = load i8*, i8** %41
%43 = call i32 @atoi(i8* %42)
store i32 %43, i32* @main.start
br label %44
44: ; preds = %39, %28
%45 = load i32, i32* %4
%46 = icmp sgt i32 %45, 4
br i1 %46, label %47, label %52
47: ; preds = %44
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 4
%50 = load i8*, i8** %49
%51 = call i32 @atoi(i8* %50)
store i32 %51, i32* @main.increment
br label %52
52: ; preds = %47, %44
store i32 0, i32* %8
br label %53
53: ; preds = %72, %52
%54 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%55 = load i32*, i32** @main.fp
%56 = call i64 @fgets(i8* %54, i32 199, i32* %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %78
58: ; preds = %53
%59 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%60 = call i32 @atoi(i8* %59)
store i32 %60, i32* %7
%61 = icmp ne i32 %60, 0
br i1 %61, label %65, label %62
62: ; preds = %58
%63 = load i32, i32* %8
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i32 %63)
store i32 0, i32* %3
br label %212
65: ; preds = %58
%66 = load i32, i32* %7
%67 = load i32, i32* %8
%68 = icmp ule i32 %66, %67
br i1 %68, label %69, label %72
69: ; preds = %65
%70 = load i32, i32* %8
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i32 %70)
store i32 0, i32* %3
br label %212
72: ; preds = %65
%73 = load i32, i32* %7
store i32 %73, i32* %8
%74 = load i32, i32* @main.ltop
%75 = add i32 %74, 1
store i32 %75, i32* @main.ltop
%76 = zext i32 %74 to i64
%77 = getelementptr inbounds [10000 x i32], [10000 x i32]* @main.lines, i64 0, i64 %76
store i32 %73, i32* %77
br label %53
78: ; preds = %53
%79 = load i32*, i32** @main.fp
%80 = call i32 @rewind(i32* %79)
store i32 0, i32* %8
br label %81
81: ; preds = %201, %78
%82 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
store i8* %82, i8** %10
store i8* %82, i8** %11
%83 = load i32*, i32** @main.fp
%84 = call i64 @fgets(i8* %82, i32 200, i32* %83)
%85 = icmp ne i64 %84, 0
br i1 %85, label %86, label %204
86: ; preds = %81
br label %87
87: ; preds = %180, %173, %166, %159, %86
br label %88
88: ; preds = %93, %87
%89 = load i8*, i8** %10
%90 = load i8, i8* %89
%91 = call i64 @isspace(i8 signext %90)
%92 = icmp ne i64 %91, 0
br i1 %92, label %93, label %96
93: ; preds = %88
%94 = load i8*, i8** %10
%95 = getelementptr inbounds i8, i8* %94, i32 1
store i8* %95, i8** %10
br label %88
96: ; preds = %88
br label %97
97: ; preds = %101, %96
%98 = load i8*, i8** %11
%99 = load i8*, i8** %10
%100 = icmp ult i8* %98, %99
br i1 %100, label %101, label %107
101: ; preds = %97
%102 = load i8*, i8** %11
%103 = getelementptr inbounds i8, i8* %102, i32 1
store i8* %103, i8** %11
%104 = load i8, i8* %102
%105 = load i32*, i32** @main.fp1
%106 = call i32 @putc(i8 signext %104, i32* %105)
br label %97
107: ; preds = %97
%108 = load i8*, i8** %10
%109 = load i8, i8* %108
%110 = call i64 @isdigit(i8 signext %109)
%111 = icmp ne i64 %110, 0
br i1 %111, label %112, label %150
112: ; preds = %107
%113 = load i32, i32* %8
%114 = add i32 %113, 1
store i32 %114, i32* %8
%115 = load i8*, i8** %10
%116 = call i32 @atoi(i8* %115)
store i32 %116, i32* %7
br label %117
117: ; preds = %122, %112
%118 = load i8*, i8** %10
%119 = load i8, i8* %118
%120 = call i64 @isdigit(i8 signext %119)
%121 = icmp ne i64 %120, 0
br i1 %121, label %122, label %125
122: ; preds = %117
%123 = load i8*, i8** %10
%124 = getelementptr inbounds i8, i8* %123, i32 1
store i8* %124, i8** %10
br label %117
125: ; preds = %117
store i32 0, i32* %6
br label %126
126: ; preds = %146, %125
%127 = load i32, i32* %6
%128 = load i32, i32* @main.ltop
%129 = icmp ult i32 %127, %128
br i1 %129, label %130, label %149
130: ; preds = %126
%131 = load i32, i32* %6
%132 = zext i32 %131 to i64
%133 = getelementptr inbounds [10000 x i32], [10000 x i32]* @main.lines, i64 0, i64 %132
%134 = load i32, i32* %133
%135 = load i32, i32* %7
%136 = icmp eq i32 %134, %135
br i1 %136, label %137, label %145
137: ; preds = %130
%138 = load i32*, i32** @main.fp1
%139 = load i32, i32* %6
%140 = load i32, i32* @main.increment
%141 = mul i32 %139, %140
%142 = load i32, i32* @main.start
%143 = add i32 %141, %142
%144 = call i32 (i32*, i8*, ...) @fprintf(i32* %138, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %143)
br label %149
145: ; preds = %130
br label %146
146: ; preds = %145
%147 = load i32, i32* %6
%148 = add i32 %147, 1
store i32 %148, i32* %6
br label %126
149: ; preds = %137, %126
br label %150
150: ; preds = %149, %107
br label %151
151: ; preds = %198, %150
%152 = load i8*, i8** %10
store i8* %152, i8** %11
%153 = load i8, i8* %152
%154 = icmp ne i8 %153, 0
br i1 %154, label %155, label %201
155: ; preds = %151
%156 = load i8*, i8** %10
%157 = call i64 @begins_with(i8* %156, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%158 = icmp ne i64 %157, 0
br i1 %158, label %159, label %162
159: ; preds = %155
%160 = load i8*, i8** %10
%161 = getelementptr inbounds i8, i8* %160, i64 4
store i8* %161, i8** %10
br label %87
162: ; preds = %155
%163 = load i8*, i8** %10
%164 = call i64 @begins_with(i8* %163, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%165 = icmp ne i64 %164, 0
br i1 %165, label %166, label %169
166: ; preds = %162
%167 = load i8*, i8** %10
%168 = getelementptr inbounds i8, i8* %167, i64 5
store i8* %168, i8** %10
br label %87
169: ; preds = %162
%170 = load i8*, i8** %10
%171 = call i64 @begins_with(i8* %170, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%172 = icmp ne i64 %171, 0
br i1 %172, label %173, label %176
173: ; preds = %169
%174 = load i8*, i8** %10
%175 = getelementptr inbounds i8, i8* %174, i64 4
store i8* %175, i8** %10
br label %87
176: ; preds = %169
%177 = load i8*, i8** %10
%178 = call i64 @begins_with(i8* %177, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%179 = icmp ne i64 %178, 0
br i1 %179, label %180, label %183
180: ; preds = %176
%181 = load i8*, i8** %10
%182 = getelementptr inbounds i8, i8* %181, i64 5
store i8* %182, i8** %10
br label %87
183: ; preds = %176
%184 = load i8*, i8** %10
%185 = load i8, i8* %184
%186 = sext i8 %185 to i32
%187 = icmp ne i32 %186, 13
br i1 %187, label %188, label %198
188: ; preds = %183
%189 = load i8*, i8** %10
%190 = load i8, i8* %189
%191 = sext i8 %190 to i32
%192 = icmp ne i32 %191, 10
br i1 %192, label %193, label %198
193: ; preds = %188
%194 = load i8*, i8** %10
%195 = load i8, i8* %194
%196 = load i32*, i32** @main.fp1
%197 = call i32 @putc(i8 signext %195, i32* %196)
br label %198
198: ; preds = %193, %188, %183
%199 = load i8*, i8** %10
%200 = getelementptr inbounds i8, i8* %199, i32 1
store i8* %200, i8** %10
br label %151
201: ; preds = %151
%202 = load i32*, i32** @main.fp1
%203 = call i32 @putc(i8 signext 10, i32* %202)
br label %81
204: ; preds = %81
%205 = load i32*, i32** @main.fp1
%206 = call i32 @fclose(i32* %205)
%207 = load i32*, i32** @main.fp
%208 = call i32 @fclose(i32* %207)
%209 = load i32, i32* @main.ltop
%210 = load i32, i32* %8
%211 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i32 %209, i32 %210)
store i32 0, i32* %3
br label %212
212: ; preds = %204, %69, %62, %15
%213 = load i32, i32* %3
ret i32 %213
}

LLVM IR (-O2):
@main.lines = internal unnamed_addr global [10000 x i32] zeroinitializer
@main.ltop = internal unnamed_addr global i32 0
@main.increment = internal unnamed_addr global i32 10
@main.start = internal unnamed_addr global i32 10
@main.fp = internal unnamed_addr global i32* null
@main.fp1 = internal unnamed_addr global i32* null
@stderr = global i32 0
@.str.1 = [44 x i8] c"Use: renumber old new [start [increment]]\0A\0A\00"
@.str.2 = [35 x i8] c"Copyright 1993-2000 Dave Dunfield\0A\00"
@.str.3 = [22 x i8] c"All rights reserved.\0A\00"
@.str.4 = [4 x i8] c"rvq\00"
@.str.5 = [4 x i8] c"wvq\00"
@.str.6 = [39 x i8] c"Invalid line number following line %u\0A\00"
@.str.7 = [42 x i8] c"Improper line sequence following line %u\0A\00"
@.str.8 = [3 x i8] c"%u\00"
@.str.9 = [5 x i8] c"THEN\00"
@.str.10 = [6 x i8] c"ORDER\00"
@.str.11 = [5 x i8] c"GOTO\00"
@.str.12 = [6 x i8] c"GOSUB\00"
@.str.13 = [26 x i8] c"%u lines read, %u fixups\0A\00"
@str = [41 x i8] c"MICRO-BASIC 2.1 line renumbering program\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [200 x i8]
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%6 = icmp slt i32 %0, 3
br i1 %6, label %7, label %20
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i32*
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i64 43, i64 1, i32* %10)
%12 = load i32, i32* @stderr
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i32*
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i64 34, i64 1, i32* %14)
%16 = load i32, i32* @stderr
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i32*
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i64 21, i64 1, i32* %18)
br label %170
20: ; preds = %2
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = tail call i32* @fopen(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i32* %23, i32** @main.fp
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32* @fopen(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
store i32* %26, i32** @main.fp1
%27 = icmp eq i32 %0, 3
br i1 %27, label %37, label %28
28: ; preds = %20
%29 = getelementptr inbounds i8*, i8** %1, i64 3
%30 = load i8*, i8** %29
%31 = tail call i32 @atoi(i8* %30)
store i32 %31, i32* @main.start
%32 = icmp ugt i32 %0, 4
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = getelementptr inbounds i8*, i8** %1, i64 4
%35 = load i8*, i8** %34
%36 = tail call i32 @atoi(i8* %35)
store i32 %36, i32* @main.increment
br label %37
37: ; preds = %20, %33, %28
%38 = load i32*, i32** @main.fp
%39 = call i64 @fgets(i8* %4, i32 199, i32* %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %59, label %41
41: ; preds = %37, %51
%42 = phi i32 [ %43, %51 ], [ 0, %37 ]
%43 = call i32 @atoi(i8* %4)
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i32 %42)
br label %170
47: ; preds = %41
%48 = icmp ugt i32 %43, %42
br i1 %48, label %51, label %49
49: ; preds = %47
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i32 %42)
br label %170
51: ; preds = %47
%52 = load i32, i32* @main.ltop
%53 = add i32 %52, 1
store i32 %53, i32* @main.ltop
%54 = zext i32 %52 to i64
%55 = getelementptr inbounds [10000 x i32], [10000 x i32]* @main.lines, i64 0, i64 %54
store i32 %43, i32* %55
%56 = load i32*, i32** @main.fp
%57 = call i64 @fgets(i8* %4, i32 199, i32* %56)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %41
59: ; preds = %51, %37
%60 = load i32*, i32** @main.fp
%61 = call i32 @rewind(i32* %60)
%62 = load i32*, i32** @main.fp
%63 = call i64 @fgets(i8* %4, i32 200, i32* %62)
%64 = icmp eq i64 %63, 0
br i1 %64, label %162, label %65
65: ; preds = %59, %135
%66 = phi i32 [ %124, %135 ], [ 0, %59 ]
%67 = phi i8* [ %136, %135 ], [ %4, %59 ]
%68 = phi i8* [ %137, %135 ], [ %4, %59 ]
%69 = ptrtoint i8* %68 to i64
br label %70
70: ; preds = %70, %65
%71 = phi i8* [ %67, %65 ], [ %75, %70 ]
%72 = load i8, i8* %71
%73 = call i64 @isspace(i8 signext %72)
%74 = icmp eq i64 %73, 0
%75 = getelementptr inbounds i8, i8* %71, i64 1
br i1 %74, label %76, label %70
76: ; preds = %70
%77 = icmp ult i8* %68, %71
br i1 %77, label %78, label %89
78: ; preds = %76
%79 = ptrtoint i8* %71 to i64
%80 = sub i64 %79, %69
%81 = getelementptr i8, i8* %68, i64 %80
br label %82
82: ; preds = %78, %82
%83 = phi i8* [ %84, %82 ], [ %68, %78 ]
%84 = getelementptr inbounds i8, i8* %83, i64 1
%85 = load i8, i8* %83
%86 = load i32*, i32** @main.fp1
%87 = call i32 @putc(i8 signext %85, i32* %86)
%88 = icmp eq i8* %84, %81
br i1 %88, label %89, label %82
89: ; preds = %82, %76
%90 = load i8, i8* %71
%91 = call i64 @isdigit(i8 signext %90)
%92 = icmp eq i64 %91, 0
br i1 %92, label %123, label %93
93: ; preds = %89
%94 = call i32 @atoi(i8* %71)
br label %95
95: ; preds = %95, %93
%96 = phi i8* [ %71, %93 ], [ %100, %95 ]
%97 = load i8, i8* %96
%98 = call i64 @isdigit(i8 signext %97)
%99 = icmp eq i64 %98, 0
%100 = getelementptr inbounds i8, i8* %96, i64 1
br i1 %99, label %101, label %95
101: ; preds = %95
%102 = add i32 %66, 1
%103 = load i32, i32* @main.ltop
%104 = icmp eq i32 %103, 0
br i1 %104, label %123, label %105
105: ; preds = %101
%106 = zext i32 %103 to i64
br label %107
107: ; preds = %105, %120
%108 = phi i64 [ 0, %105 ], [ %121, %120 ]
%109 = getelementptr inbounds [10000 x i32], [10000 x i32]* @main.lines, i64 0, i64 %108
%110 = load i32, i32* %109
%111 = icmp eq i32 %110, %94
br i1 %111, label %112, label %120
112: ; preds = %107
%113 = trunc i64 %108 to i32
%114 = load i32*, i32** @main.fp1
%115 = load i32, i32* @main.increment
%116 = mul i32 %115, %113
%117 = load i32, i32* @main.start
%118 = add i32 %116, %117
%119 = call i32 (i32*, i8*, ...) @fprintf(i32* %114, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %118)
br label %123
120: ; preds = %107
%121 = add nuw nsw i64 %108, 1
%122 = icmp eq i64 %121, %106
br i1 %122, label %123, label %107
123: ; preds = %120, %101, %112, %89
%124 = phi i32 [ %102, %112 ], [ %66, %89 ], [ %102, %101 ], [ %102, %120 ]
%125 = phi i8* [ %96, %112 ], [ %71, %89 ], [ %96, %101 ], [ %96, %120 ]
%126 = load i8, i8* %125
%127 = icmp eq i8 %126, 0
br i1 %127, label %156, label %128
128: ; preds = %123, %152
%129 = phi i8* [ %153, %152 ], [ %125, %123 ]
%130 = call i64 @begins_with(i8* %129, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%131 = icmp eq i64 %130, 0
br i1 %131, label %138, label %132
132: ; preds = %128, %144, %141, %138
%133 = phi i64 [ 5, %138 ], [ 4, %141 ], [ 5, %144 ], [ 4, %128 ]
%134 = getelementptr inbounds i8, i8* %129, i64 %133
br label %135
135: ; preds = %132, %156
%136 = phi i8* [ %134, %132 ], [ %4, %156 ]
%137 = phi i8* [ %129, %132 ], [ %4, %156 ]
br label %65
138: ; preds = %128
%139 = call i64 @begins_with(i8* %129, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%140 = icmp eq i64 %139, 0
br i1 %140, label %141, label %132
141: ; preds = %138
%142 = call i64 @begins_with(i8* %129, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%143 = icmp eq i64 %142, 0
br i1 %143, label %144, label %132
144: ; preds = %141
%145 = call i64 @begins_with(i8* %129, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%146 = icmp eq i64 %145, 0
br i1 %146, label %147, label %132
147: ; preds = %144
%148 = load i8, i8* %129
switch i8 %148, label %149 [
i8 13, label %152
i8 10, label %152
]
149: ; preds = %147
%150 = load i32*, i32** @main.fp1
%151 = call i32 @putc(i8 signext %148, i32* %150)
br label %152
152: ; preds = %147, %147, %149
%153 = getelementptr inbounds i8, i8* %129, i64 1
%154 = load i8, i8* %153
%155 = icmp eq i8 %154, 0
br i1 %155, label %156, label %128
156: ; preds = %152, %123
%157 = load i32*, i32** @main.fp1
%158 = call i32 @putc(i8 signext 10, i32* %157)
%159 = load i32*, i32** @main.fp
%160 = call i64 @fgets(i8* %4, i32 200, i32* %159)
%161 = icmp eq i64 %160, 0
br i1 %161, label %162, label %135
162: ; preds = %156, %59
%163 = phi i32 [ 0, %59 ], [ %124, %156 ]
%164 = load i32*, i32** @main.fp1
%165 = call i32 @fclose(i32* %164)
%166 = load i32*, i32** @main.fp
%167 = call i32 @fclose(i32* %166)
%168 = load i32, i32* @main.ltop
%169 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i32 %168, i32 %163)
br label %170
170: ; preds = %162, %49, %45, %7
%171 = phi i32 [ 1, %7 ], [ 0, %49 ], [ 0, %45 ], [ 0, %162 ]
ret i32 %171
}