#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*/ abort();
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int getopt(int, char **, char *);
char *optarg;
scalar_t__ opterr;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ validRecord(char *, int, int);
int main(int argc, char *argv[]) {
  char *infile = NULL;
  char *outfile = "out.dat";
  int record_length = 1024;
  int lookahead_count;
  int c;
  opterr = 0;
  while ((c = getopt(argc, argv, "i:o:c:l:")) != -1)
    switch (c) {
    case 'i':
      infile = optarg;
      break;
    case 'o':
      outfile = optarg;
      break;
    case 'c':
      record_length = atoi(optarg);
      break;
    case 'l':
      lookahead_count = atoi(optarg);
      break;
    default:
      abort();
    }
  if (lookahead_count == 0) {
    lookahead_count = record_length - 20;
  }
  if (infile == NULL || outfile == NULL || record_length <= 20 ||
      lookahead_count > (record_length - 20)) {
    printf("Usage: -i <infile> -o <outfile> -c <record length, must be > 20> "
           "-l <lookahead, must be <= record length - 20");
    return 1;
  }
  printf("Copying from %s to %s with record length %d and lookahead %d\n",
         infile, outfile, record_length, lookahead_count);
  FILE *in;
  FILE *out;
  char buf[record_length];
  int numRecords = 0;
  int nullRecords = 0;
  in = fopen(infile, "r");
  out = fopen(outfile, "w");
  if (in == NULL) {
    printf("Could not open file %s for reading.\n", infile);
    return 1;
  }
  if (out == NULL) {
    printf("Could not open file %s for writing.\n", outfile);
    return 1;
  }
  int count = fread(buf, 1, record_length, in);
  fwrite(buf, 1, count, out);
  while (count > 0) {
    count = fread(buf, 1, record_length, in);
    if (count != 0 && validRecord(buf, count, lookahead_count)) {
      numRecords++;
      fwrite(buf, 1, count, out);
    } else {
      nullRecords++;
    }
  }
  printf("Copied %d records and skipped %d null records.\n", numRecords,
         nullRecords - 1);
  fclose(in);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe7f(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x400,-0x24(%rbp)
mov    0x2e11(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe60(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     1276 <main+0xe6>
mov    -0x2c(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x68(%rbp)
sub    $0xc,%eax
ja     126a <main+0xda>
mov    -0x68(%rbp),%rax
lea    0xdf3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2ddb(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1271 <main+0xe1>
mov    0x2dc8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1271 <main+0xe1>
mov    0x2db5(%rip),%rax
mov    (%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x24(%rbp)
jmp    1271 <main+0xe1>
mov    0x2d9e(%rip),%rax
mov    (%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x28(%rbp)
jmp    1271 <main+0xe1>
mov    $0x0,%al
call   1040 <abort@plt>
jmp    11ce <main+0x3e>
cmpl   $0x0,-0x28(%rbp)
jne    1289 <main+0xf9>
mov    -0x24(%rbp),%eax
sub    $0x14,%eax
mov    %eax,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     12ba <main+0x12a>
cmpq   $0x0,-0x20(%rbp)
je     12ba <main+0x12a>
cmpl   $0x14,-0x24(%rbp)
jle    12ba <main+0x12a>
mov    -0x28(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x14,%ecx
cmp    %ecx,%eax
jle    12d4 <main+0x144>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    148e <main+0x2fe>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
lea    0xdc9(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdc1(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xdaf(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    137d <main+0x1ed>
mov    -0x18(%rbp),%rsi
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x5c(%rbp)
jmp    1487 <main+0x2f7>
cmpq   $0x0,-0x40(%rbp)
jne    13ad <main+0x21d>
mov    -0x20(%rbp),%rsi
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x5c(%rbp)
jmp    1487 <main+0x2f7>
mov    -0x70(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fread@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%edx
mov    -0x40(%rbp),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
cmpl   $0x0,-0x60(%rbp)
jle    1450 <main+0x2c0>
mov    -0x70(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fread@plt>
mov    %eax,-0x60(%rbp)
cmpl   $0x0,-0x60(%rbp)
je     1442 <main+0x2b2>
mov    -0x70(%rbp),%rdi
mov    -0x60(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1030 <validRecord@plt>
cmp    $0x0,%rax
je     1442 <main+0x2b2>
mov    -0x70(%rbp),%rdi
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x60(%rbp),%edx
mov    -0x40(%rbp),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
jmp    144b <main+0x2bb>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    13da <main+0x24a>
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edx
sub    $0x1,%edx
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x5c(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r15
mov    %edi,%ebx
mov    0x2e2b(%rip),%rax
movq   $0x0,(%rax)
lea    0xe45(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    $0x400,%eax
mov    %rax,-0x40(%rbp)
xor    %r14d,%r14d
lea    0xe36(%rip),%r13
mov    0x2e1f(%rip),%r12
jmp    11e4 <main+0x54>
nopl   0x0(%rax,%rax,1)
mov    (%r12),%r14
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r13,%rdx
call   1090 <getopt@plt>
cmp    $0x69,%eax
je     11e0 <main+0x50>
cmp    $0x6b,%eax
jg     1218 <main+0x88>
cmp    $0xffffffff,%eax
je     123e <main+0xae>
cmp    $0x63,%eax
jne    1400 <main+0x270>
mov    (%r12),%rdi
call   10a0 <atoi@plt>
mov    %rax,-0x40(%rbp)
jmp    11e4 <main+0x54>
cmp    $0x6c,%eax
je     1230 <main+0xa0>
cmp    $0x6f,%eax
jne    1400 <main+0x270>
mov    (%r12),%rax
mov    %rax,-0x38(%rbp)
jmp    11e4 <main+0x54>
mov    (%r12),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
jmp    11e4 <main+0x54>
mov    -0x40(%rbp),%rax
add    $0xffffffec,%eax
mov    -0x2c(%rbp),%ecx
test   %ecx,%ecx
cmove  %eax,%ecx
mov    %ecx,-0x2c(%rbp)
test   %r14,%r14
je     13b2 <main+0x222>
cmpq   $0x0,-0x38(%rbp)
je     13b2 <main+0x222>
cmpl   $0x15,-0x40(%rbp)
jl     13b2 <main+0x222>
cmp    %eax,-0x2c(%rbp)
jg     13b2 <main+0x222>
lea    0xe01(%rip),%rdi
mov    %r14,%rsi
mov    -0x38(%rbp),%r12
mov    %r12,%rdx
mov    -0x40(%rbp),%rbx
mov    %ebx,%ecx
mov    -0x2c(%rbp),%r8d
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rsp,-0x48(%rbp)
mov    %ebx,%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    0xe06(%rip),%rsi
mov    %r14,%rdi
call   1080 <fopen@plt>
mov    %rax,%r13
lea    0xdf6(%rip),%rsi
mov    %r12,%rdi
call   1080 <fopen@plt>
test   %r13,%r13
je     13c7 <main+0x237>
mov    %rax,%rbx
test   %rax,%rax
je     13d3 <main+0x243>
mov    %r15,%rdi
mov    $0x1,%esi
mov    -0x40(%rbp),%rdx
mov    %r13,%rcx
call   1050 <fread@plt>
mov    %eax,%r12d
mov    %r15,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %rbx,-0x38(%rbp)
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    $0x0,%r14d
mov    $0x0,%ebx
test   %r12d,%r12d
jle    1383 <main+0x1f3>
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    1338 <main+0x1a8>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
test   %r12d,%r12d
jle    1383 <main+0x1f3>
mov    %r15,%rdi
mov    $0x1,%esi
mov    -0x40(%rbp),%rdx
mov    %r13,%rcx
call   1050 <fread@plt>
mov    %eax,%r12d
test   %eax,%eax
je     1330 <main+0x1a0>
mov    %r15,%rdi
mov    %r12d,%esi
mov    -0x2c(%rbp),%edx
call   1030 <validRecord@plt>
test   %rax,%rax
je     1330 <main+0x1a0>
add    $0x1,%r14d
mov    %r15,%rdi
mov    $0x1,%esi
mov    %r12d,%edx
mov    -0x38(%rbp),%rcx
call   10b0 <fwrite@plt>
test   %r12d,%r12d
jg     1338 <main+0x1a8>
add    $0xffffffff,%ebx
lea    0xd7e(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rdi
call   1060 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x48(%rbp),%rcx
xor    %eax,%eax
jmp    13ee <main+0x25e>
lea    0xc58(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%eax
jmp    13f1 <main+0x261>
lea    0xcf3(%rip),%rdi
mov    %r14,%rsi
jmp    13de <main+0x24e>
lea    0xd0c(%rip),%rdi
mov    -0x38(%rbp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%eax
mov    -0x48(%rbp),%rcx
mov    %rcx,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"out.dat\00"
@opterr = global i64 0
@.str.1 = [9 x i8] c"i:o:c:l:\00"
@optarg = global i8* null
@.str.2 = [110 x i8] c"Usage: -i <infile> -o <outfile> -c <record length, must be > 20> -l <lookahead, must be <= record length - 20\00"
@.str.3 = [62 x i8] c"Copying from %s to %s with record length %d and lookahead %d\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [37 x i8] c"Could not open file %s for reading.\0A\00"
@.str.7 = [37 x i8] c"Could not open file %s for writing.\0A\00"
@.str.8 = [48 x i8] c"Copied %d records and skipped %d null records.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %7
store i32 1024, i32* %8
store i64 0, i64* @opterr
br label %19
19: ; preds = %38, %2
%20 = load i32, i32* %4
%21 = load i8**, i8*** %5
%22 = call i32 @getopt(i32 %20, i8** %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i32 %22, i32* %10
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %39
24: ; preds = %19
%25 = load i32, i32* %10
switch i32 %25, label %36 [
i32 105, label %26
i32 111, label %28
i32 99, label %30
i32 108, label %33
]
26: ; preds = %24
%27 = load i8*, i8** @optarg
store i8* %27, i8** %6
br label %38
28: ; preds = %24
%29 = load i8*, i8** @optarg
store i8* %29, i8** %7
br label %38
30: ; preds = %24
%31 = load i8*, i8** @optarg
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %8
br label %38
33: ; preds = %24
%34 = load i8*, i8** @optarg
%35 = call i32 @atoi(i8* %34)
store i32 %35, i32* %9
br label %38
36: ; preds = %24
%37 = call i32 (...) @abort()
unreachable
38: ; preds = %33, %30, %28, %26
br label %19
39: ; preds = %19
%40 = load i32, i32* %9
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32, i32* %8
%44 = sub nsw i32 %43, 20
store i32 %44, i32* %9
br label %45
45: ; preds = %42, %39
%46 = load i8*, i8** %6
%47 = icmp eq i8* %46, null
br i1 %47, label %59, label %48
48: ; preds = %45
%49 = load i8*, i8** %7
%50 = icmp eq i8* %49, null
br i1 %50, label %59, label %51
51: ; preds = %48
%52 = load i32, i32* %8
%53 = icmp sle i32 %52, 20
br i1 %53, label %59, label %54
54: ; preds = %51
%55 = load i32, i32* %9
%56 = load i32, i32* %8
%57 = sub nsw i32 %56, 20
%58 = icmp sgt i32 %55, %57
br i1 %58, label %59, label %61
59: ; preds = %54, %51, %48, %45
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %128
61: ; preds = %54
%62 = load i8*, i8** %6
%63 = load i8*, i8** %7
%64 = load i32, i32* %8
%65 = load i32, i32* %9
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i8* %62, i8* %63, i32 %64, i32 %65)
%67 = load i32, i32* %8
%68 = zext i32 %67 to i64
%69 = call i8* @llvm.stacksave()
store i8* %69, i8** %13
%70 = alloca i8, i64 %68
store i64 %68, i64* %14
store i32 0, i32* %15
store i32 0, i32* %16
%71 = load i8*, i8** %6
%72 = call i32* @fopen(i8* %71, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %72, i32** %11
%73 = load i8*, i8** %7
%74 = call i32* @fopen(i8* %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %74, i32** %12
%75 = load i32*, i32** %11
%76 = icmp eq i32* %75, null
br i1 %76, label %77, label %80
77: ; preds = %61
%78 = load i8*, i8** %6
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i8* %78)
store i32 1, i32* %3
store i32 1, i32* %17
br label %126
80: ; preds = %61
%81 = load i32*, i32** %12
%82 = icmp eq i32* %81, null
br i1 %82, label %83, label %86
83: ; preds = %80
%84 = load i8*, i8** %7
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %84)
store i32 1, i32* %3
store i32 1, i32* %17
br label %126
86: ; preds = %80
%87 = load i32, i32* %8
%88 = load i32*, i32** %11
%89 = call i32 @fread(i8* %70, i32 1, i32 %87, i32* %88)
store i32 %89, i32* %18
%90 = load i32, i32* %18
%91 = load i32*, i32** %12
%92 = call i32 @fwrite(i8* %70, i32 1, i32 %90, i32* %91)
br label %93
93: ; preds = %116, %86
%94 = load i32, i32* %18
%95 = icmp sgt i32 %94, 0
br i1 %95, label %96, label %117
96: ; preds = %93
%97 = load i32, i32* %8
%98 = load i32*, i32** %11
%99 = call i32 @fread(i8* %70, i32 1, i32 %97, i32* %98)
store i32 %99, i32* %18
%100 = load i32, i32* %18
%101 = icmp ne i32 %100, 0
br i1 %101, label %102, label %113
102: ; preds = %96
%103 = load i32, i32* %18
%104 = load i32, i32* %9
%105 = call i64 @validRecord(i8* %70, i32 %103, i32 %104)
%106 = icmp ne i64 %105, 0
br i1 %106, label %107, label %113
107: ; preds = %102
%108 = load i32, i32* %15
%109 = add nsw i32 %108, 1
store i32 %109, i32* %15
%110 = load i32, i32* %18
%111 = load i32*, i32** %12
%112 = call i32 @fwrite(i8* %70, i32 1, i32 %110, i32* %111)
br label %116
113: ; preds = %102, %96
%114 = load i32, i32* %16
%115 = add nsw i32 %114, 1
store i32 %115, i32* %16
br label %116
116: ; preds = %113, %107
br label %93
117: ; preds = %93
%118 = load i32, i32* %15
%119 = load i32, i32* %16
%120 = sub nsw i32 %119, 1
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0), i32 %118, i32 %120)
%122 = load i32*, i32** %11
%123 = call i32 @fclose(i32* %122)
%124 = load i32*, i32** %12
%125 = call i32 @fclose(i32* %124)
store i32 0, i32* %3
store i32 1, i32* %17
br label %126
126: ; preds = %117, %83, %77
%127 = load i8*, i8** %13
br label %128
128: ; preds = %126, %59
%129 = load i32, i32* %3
ret i32 %129
}

LLVM IR (-O2):
@.str = [8 x i8] c"out.dat\00"
@opterr = global i64 0
@.str.1 = [9 x i8] c"i:o:c:l:\00"
@optarg = global i8* null
@.str.2 = [110 x i8] c"Usage: -i <infile> -o <outfile> -c <record length, must be > 20> -l <lookahead, must be <= record length - 20\00"
@.str.3 = [62 x i8] c"Copying from %s to %s with record length %d and lookahead %d\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [37 x i8] c"Could not open file %s for reading.\0A\00"
@.str.7 = [37 x i8] c"Could not open file %s for writing.\0A\00"
@.str.8 = [48 x i8] c"Copied %d records and skipped %d null records.\0A\00"
define i32 @main(i32 %0, i8** %1) {
store i64 0, i64* @opterr
br label %3
3: ; preds = %25, %2
%4 = phi i32 [ %27, %25 ], [ undef, %2 ]
%5 = phi i32 [ %9, %25 ], [ 1024, %2 ]
%6 = phi i8* [ %13, %25 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %2 ]
%7 = phi i8* [ %16, %25 ], [ null, %2 ]
br label %8
8: ; preds = %3, %22
%9 = phi i32 [ %5, %3 ], [ %24, %22 ]
%10 = phi i8* [ %6, %3 ], [ %13, %22 ]
%11 = phi i8* [ %7, %3 ], [ %16, %22 ]
br label %12
12: ; preds = %8, %20
%13 = phi i8* [ %10, %8 ], [ %21, %20 ]
%14 = phi i8* [ %11, %8 ], [ %16, %20 ]
br label %15
15: ; preds = %12, %18
%16 = phi i8* [ %19, %18 ], [ %14, %12 ]
%17 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
switch i32 %17, label %28 [
i32 -1, label %30
i32 105, label %18
i32 111, label %20
i32 99, label %22
i32 108, label %25
]
18: ; preds = %15
%19 = load i8*, i8** @optarg
br label %15
20: ; preds = %15
%21 = load i8*, i8** @optarg
br label %12
22: ; preds = %15
%23 = load i8*, i8** @optarg
%24 = tail call i32 @atoi(i8* %23)
br label %8
25: ; preds = %15
%26 = load i8*, i8** @optarg
%27 = tail call i32 @atoi(i8* %26)
br label %3
28: ; preds = %15
%29 = tail call i32 (...) @abort()
unreachable
30: ; preds = %15
%31 = icmp eq i32 %4, 0
%32 = add nsw i32 %9, -20
%33 = select i1 %31, i32 %32, i32 %4
%34 = icmp eq i8* %16, null
%35 = icmp eq i8* %13, null
%36 = select i1 %34, i1 true, i1 %35
%37 = icmp slt i32 %9, 21
%38 = select i1 %36, i1 true, i1 %37
%39 = icmp sgt i32 %33, %32
%40 = select i1 %38, i1 true, i1 %39
br i1 %40, label %41, label %43
41: ; preds = %30
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([110 x i8], [110 x i8]* @.str.2, i64 0, i64 0))
br label %87
43: ; preds = %30
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i8* %16, i8* %13, i32 %9, i32 %33)
%45 = zext i32 %9 to i64
%46 = tail call i8* @llvm.stacksave()
%47 = alloca i8, i64 %45
%48 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%49 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%50 = icmp eq i32* %48, null
br i1 %50, label %51, label %53
51: ; preds = %43
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i8* %16)
br label %85
53: ; preds = %43
%54 = icmp eq i32* %49, null
br i1 %54, label %55, label %57
55: ; preds = %53
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %13)
br label %85
57: ; preds = %53
%58 = call i32 @fread(i8* %47, i32 1, i32 %9, i32* %48)
%59 = call i32 @fwrite(i8* %47, i32 1, i32 %58, i32* %49)
%60 = icmp sgt i32 %58, 0
br i1 %60, label %61, label %78
61: ; preds = %57, %74
%62 = phi i32 [ %76, %74 ], [ 0, %57 ]
%63 = phi i32 [ %75, %74 ], [ 0, %57 ]
%64 = call i32 @fread(i8* %47, i32 1, i32 %9, i32* %48)
%65 = icmp eq i32 %64, 0
br i1 %65, label %72, label %66
66: ; preds = %61
%67 = call i64 @validRecord(i8* %47, i32 %64, i32 %33)
%68 = icmp eq i64 %67, 0
br i1 %68, label %72, label %69
69: ; preds = %66
%70 = add nsw i32 %63, 1
%71 = call i32 @fwrite(i8* %47, i32 1, i32 %64, i32* %49)
br label %74
72: ; preds = %66, %61
%73 = add nsw i32 %62, 1
br label %74
74: ; preds = %72, %69
%75 = phi i32 [ %70, %69 ], [ %63, %72 ]
%76 = phi i32 [ %62, %69 ], [ %73, %72 ]
%77 = icmp sgt i32 %64, 0
br i1 %77, label %61, label %78
78: ; preds = %74, %57
%79 = phi i32 [ 0, %57 ], [ %75, %74 ]
%80 = phi i32 [ 0, %57 ], [ %76, %74 ]
%81 = add nsw i32 %80, -1
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0), i32 %79, i32 %81)
%83 = call i32 @fclose(i32* %48)
%84 = call i32 @fclose(i32* %49)
br label %85
85: ; preds = %78, %55, %51
%86 = phi i32 [ 1, %51 ], [ 1, %55 ], [ 0, %78 ]
br label %87
87: ; preds = %85, %41
%88 = phi i32 [ 1, %41 ], [ %86, %85 ]
ret i32 %88
}