#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 */
struct stat {
  int st_size;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fstat(int /*<<< orphan*/, struct stat *);
int ftruncate(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int process(int /*<<< orphan*/ *);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
scalar_t__ strncasecmp(char *, char *, int);
int main(int argc, char **argv) {
  char *filename;
  int fix = 0;
  if (argc < 2) {
    printf("Usage: %s [--fix] <file.aof>\n", argv[0]);
    exit(1);
  } else if (argc == 2) {
    filename = argv[1];
  } else if (argc == 3) {
    if (strcmp(argv[1], "--fix") != 0) {
      printf("Invalid argument: %s\n", argv[1]);
      exit(1);
    }
    filename = argv[2];
    fix = 1;
  } else {
    printf("Invalid arguments\n");
    exit(1);
  }
  FILE *fp = fopen(filename, "r+");
  if (fp == NULL) {
    printf("Cannot open file: %s\n", filename);
    exit(1);
  }
  struct stat sb;
  if (fstat(fileno(fp), &sb) == -1) {
    printf("Cannot stat file: %s\n", filename);
    exit(1);
  }
  ssize_t size = sb.st_size;
  if (size == (ssize_t)0) {
    printf("Empty file: %s\n", filename);
    exit(1);
  }
  ssize_t pos = process(fp);
  ssize_t diff = size - pos;
  if (diff > 0) {
    if (fix) {
      char buf[2];
      printf("This will shrink the AOF from %ld bytes, with %ld bytes, to %ld "
             "bytes\n",
             size, diff, pos);
      printf("Continue? [y/N]: ");
      if (fgets(buf, sizeof(buf), stdin) == NULL ||
          strncasecmp(buf, "y", 1) != 0) {
        printf("Aborting...\n");
        exit(1);
      }
      if (ftruncate(fileno(fp), pos) == -1) {
        printf("Failed to truncate AOF\n");
        exit(1);
      } else {
        printf("Successfully truncated AOF\n");
      }
    } else {
      printf("AOF is not valid\n");
      exit(1);
    }
  } else {
    printf("AOF is valid\n");
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11f6 <main+0x46>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1211 <main+0x61>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    128e <main+0xde>
cmpl   $0x3,-0x8(%rbp)
jne    1271 <main+0xc1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf4(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1259 <main+0xa9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
jmp    1289 <main+0xd9>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    128e <main+0xde>
jmp    1293 <main+0xe3>
mov    -0x18(%rbp),%rdi
lea    0xdaf(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12ce <main+0x11e>
mov    -0x18(%rbp),%rsi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x28(%rbp),%rdi
call   1090 <fileno@plt>
mov    %eax,%edi
lea    -0x30(%rbp),%rsi
call   10d0 <fstat@plt>
cmp    $0xffffffff,%eax
jne    1307 <main+0x157>
mov    -0x18(%rbp),%rsi
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    1333 <main+0x183>
mov    -0x18(%rbp),%rsi
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x28(%rbp),%rdi
call   1060 <process@plt>
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
sub    -0x38(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jle    143d <main+0x28d>
cmpl   $0x0,-0x1c(%rbp)
je     1420 <main+0x270>
mov    -0x34(%rbp),%esi
mov    -0x3c(%rbp),%edx
mov    -0x38(%rbp),%ecx
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x3e(%rbp),%rdi
mov    0x2c5c(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     13c1 <main+0x211>
lea    -0x3e(%rbp),%rdi
lea    0xd38(%rip),%rsi
mov    $0x1,%edx
call   10a0 <strncasecmp@plt>
cmp    $0x0,%rax
je     13d9 <main+0x229>
lea    0xd1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x28(%rbp),%rdi
call   1090 <fileno@plt>
mov    %eax,%edi
mov    -0x38(%rbp),%esi
call   1050 <ftruncate@plt>
cmp    $0xffffffff,%eax
jne    140d <main+0x25d>
lea    0xcf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xcf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1438 <main+0x288>
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    144b <main+0x29b>
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jle    1311 <main+0x151>
mov    %edi,%ebp
mov    $0x1,%ecx
cmp    $0x2,%edi
je     1209 <main+0x49>
cmp    $0x3,%ebp
jne    135c <main+0x19c>
mov    0x8(%rbx),%rdi
lea    0xe28(%rip),%rsi
call   1090 <strcmp@plt>
mov    $0x2,%ecx
test   %rax,%rax
jne    1372 <main+0x1b2>
mov    (%rbx,%rcx,8),%r14
lea    0xe26(%rip),%rsi
mov    %r14,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     131d <main+0x15d>
mov    %rax,%r15
mov    %rax,%rdi
call   10a0 <fileno@plt>
lea    0x10(%rsp),%rsi
mov    %eax,%edi
call   10e0 <fstat@plt>
cmp    $0xffffffff,%eax
je     1326 <main+0x166>
mov    0x10(%rsp),%ebx
test   %ebx,%ebx
je     132f <main+0x16f>
mov    %r15,%rdi
call   1070 <process@plt>
mov    %ebx,%edx
sub    %eax,%edx
jle    12e7 <main+0x127>
cmp    $0x2,%ebp
je     134a <main+0x18a>
mov    %eax,%r14d
lea    0xe03(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe38(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d52(%rip),%rax
mov    (%rax),%edx
lea    0xe(%rsp),%rdi
mov    $0x2,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     1308 <main+0x148>
lea    0xe1f(%rip),%rsi
lea    0xe(%rsp),%rdi
mov    $0x1,%edx
call   10b0 <strncasecmp@plt>
test   %rax,%rax
jne    1308 <main+0x148>
mov    %r15,%rdi
call   10a0 <fileno@plt>
mov    %eax,%edi
mov    %r14d,%esi
call   1060 <ftruncate@plt>
cmp    $0xffffffff,%eax
je     1353 <main+0x193>
lea    0xe1f(%rip),%rdi
jmp    12ee <main+0x12e>
lea    0xdf8(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe27(%rip),%rdi
jmp    1363 <main+0x1a3>
mov    (%rbx),%rsi
lea    0xce5(%rip),%rdi
jmp    1339 <main+0x179>
lea    0xd19(%rip),%rdi
jmp    1336 <main+0x176>
lea    0xd26(%rip),%rdi
jmp    1336 <main+0x176>
lea    0xd33(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xda2(%rip),%rdi
jmp    1363 <main+0x1a3>
lea    0xdc5(%rip),%rdi
jmp    1363 <main+0x1a3>
lea    0xd71(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x8(%rbx),%rsi
lea    0xca7(%rip),%rdi
jmp    1339 <main+0x179>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [30 x i8] c"Usage: %s [--fix] <file.aof>\0A\00"
@.str.1 = [6 x i8] c"--fix\00"
@.str.2 = [22 x i8] c"Invalid argument: %s\0A\00"
@.str.3 = [19 x i8] c"Invalid arguments\0A\00"
@.str.4 = [3 x i8] c"r+\00"
@.str.5 = [22 x i8] c"Cannot open file: %s\0A\00"
@.str.6 = [22 x i8] c"Cannot stat file: %s\0A\00"
@.str.7 = [16 x i8] c"Empty file: %s\0A\00"
@.str.8 = [71 x i8] c"This will shrink the AOF from %ld bytes, with %ld bytes, to %ld bytes\0A\00"
@.str.9 = [18 x i8] c"Continue? [y/N]: \00"
@stdin = global i32 0
@.str.10 = [2 x i8] c"y\00"
@.str.11 = [13 x i8] c"Aborting...\0A\00"
@.str.12 = [24 x i8] c"Failed to truncate AOF\0A\00"
@.str.13 = [28 x i8] c"Successfully truncated AOF\0A\00"
@.str.14 = [18 x i8] c"AOF is not valid\0A\00"
@.str.15 = [14 x i8] c"AOF is valid\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca %struct.stat
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [2 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %2
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 2
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
store i8* %28, i8** %6
br label %52
29: ; preds = %22
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, 3
br i1 %31, label %32, label %48
32: ; preds = %29
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %32
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %41)
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %32
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 2
%47 = load i8*, i8** %46
store i8* %47, i8** %6
store i32 1, i32* %7
br label %51
48: ; preds = %29
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %44
br label %52
52: ; preds = %51, %25
br label %53
53: ; preds = %52
%54 = load i8*, i8** %6
%55 = call i32* @fopen(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %55, i32** %8
%56 = load i32*, i32** %8
%57 = icmp eq i32* %56, null
br i1 %57, label %58, label %62
58: ; preds = %53
%59 = load i8*, i8** %6
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %59)
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %53
%63 = load i32*, i32** %8
%64 = call i32 @fileno(i32* %63)
%65 = call i32 @fstat(i32 %64, %struct.stat* %9)
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %71
67: ; preds = %62
%68 = load i8*, i8** %6
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %68)
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %62
%72 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%73 = load i32, i32* %72
store i32 %73, i32* %10
%74 = load i32, i32* %10
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %71
%77 = load i8*, i8** %6
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %77)
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %71
%81 = load i32*, i32** %8
%82 = call i32 @process(i32* %81)
store i32 %82, i32* %11
%83 = load i32, i32* %10
%84 = load i32, i32* %11
%85 = sub nsw i32 %83, %84
store i32 %85, i32* %12
%86 = load i32, i32* %12
%87 = icmp sgt i32 %86, 0
br i1 %87, label %88, label %124
88: ; preds = %80
%89 = load i32, i32* %7
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %120
91: ; preds = %88
%92 = load i32, i32* %10
%93 = load i32, i32* %12
%94 = load i32, i32* %11
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.8, i64 0, i64 0), i32 %92, i32 %93, i32 %94)
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
%97 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%98 = load i32, i32* @stdin
%99 = call i32* @fgets(i8* %97, i32 2, i32 %98)
%100 = icmp eq i32* %99, null
br i1 %100, label %105, label %101
101: ; preds = %91
%102 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%103 = call i64 @strncasecmp(i8* %102, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32 1)
%104 = icmp ne i64 %103, 0
br i1 %104, label %105, label %108
105: ; preds = %101, %91
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
%107 = call i32 @exit(i32 1)
unreachable
108: ; preds = %101
%109 = load i32*, i32** %8
%110 = call i32 @fileno(i32* %109)
%111 = load i32, i32* %11
%112 = call i32 @ftruncate(i32 %110, i32 %111)
%113 = icmp eq i32 %112, -1
br i1 %113, label %114, label %117
114: ; preds = %108
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
%116 = call i32 @exit(i32 1)
unreachable
117: ; preds = %108
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %119
119: ; preds = %117
br label %123
120: ; preds = %88
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0))
%122 = call i32 @exit(i32 1)
unreachable
123: ; preds = %119
br label %126
124: ; preds = %80
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0))
br label %126
126: ; preds = %124, %123
%127 = load i32*, i32** %8
%128 = call i32 @fclose(i32* %127)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [30 x i8] c"Usage: %s [--fix] <file.aof>\0A\00"
@.str.1 = [6 x i8] c"--fix\00"
@.str.2 = [22 x i8] c"Invalid argument: %s\0A\00"
@.str.4 = [3 x i8] c"r+\00"
@.str.5 = [22 x i8] c"Cannot open file: %s\0A\00"
@.str.6 = [22 x i8] c"Cannot stat file: %s\0A\00"
@.str.7 = [16 x i8] c"Empty file: %s\0A\00"
@.str.8 = [71 x i8] c"This will shrink the AOF from %ld bytes, with %ld bytes, to %ld bytes\0A\00"
@.str.9 = [18 x i8] c"Continue? [y/N]: \00"
@stdin = global i32 0
@.str.10 = [2 x i8] c"y\00"
@str = [18 x i8] c"Invalid arguments\00"
@str.16 = [13 x i8] c"AOF is valid\00"
@str.17 = [17 x i8] c"AOF is not valid\00"
@str.18 = [27 x i8] c"Successfully truncated AOF\00"
@str.19 = [23 x i8] c"Failed to truncate AOF\00"
@str.20 = [12 x i8] c"Aborting...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca [2 x i8]
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = icmp eq i32 %0, 2
br i1 %11, label %26, label %12
12: ; preds = %10
%13 = icmp eq i32 %0, 3
br i1 %13, label %14, label %23
14: ; preds = %12
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %14
%20 = load i8*, i8** %15
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %12
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %14, %10
%27 = phi i64 [ 1, %10 ], [ 2, %14 ]
%28 = getelementptr inbounds i8*, i8** %1, i64 %27
%29 = load i8*, i8** %28
%30 = tail call i32* @fopen(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %35
32: ; preds = %26
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %29)
%34 = tail call i32 @exit(i32 1)
unreachable
35: ; preds = %26
%36 = bitcast %struct.stat* %3 to i8*
%37 = tail call i32 @fileno(i32* %30)
%38 = call i32 @fstat(i32 %37, %struct.stat* %3)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %29)
%42 = tail call i32 @exit(i32 1)
unreachable
43: ; preds = %35
%44 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%45 = load i32, i32* %44
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %29)
%49 = tail call i32 @exit(i32 1)
unreachable
50: ; preds = %43
%51 = tail call i32 @process(i32* %30)
%52 = sub nsw i32 %45, %51
%53 = icmp sgt i32 %52, 0
br i1 %53, label %54, label %80
54: ; preds = %50
br i1 %11, label %77, label %55
55: ; preds = %54
%56 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.8, i64 0, i64 0), i32 %45, i32 %52, i32 %51)
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
%59 = load i32, i32* @stdin
%60 = call i32* @fgets(i8* %56, i32 2, i32 %59)
%61 = icmp eq i32* %60, null
br i1 %61, label %65, label %62
62: ; preds = %55
%63 = call i64 @strncasecmp(i8* %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32 1)
%64 = icmp eq i64 %63, 0
br i1 %64, label %68, label %65
65: ; preds = %62, %55
%66 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.20, i64 0, i64 0))
%67 = call i32 @exit(i32 1)
unreachable
68: ; preds = %62
%69 = call i32 @fileno(i32* %30)
%70 = call i32 @ftruncate(i32 %69, i32 %51)
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %75
72: ; preds = %68
%73 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.19, i64 0, i64 0))
%74 = call i32 @exit(i32 1)
unreachable
75: ; preds = %68
%76 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.18, i64 0, i64 0))
br label %82
77: ; preds = %54
%78 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.17, i64 0, i64 0))
%79 = tail call i32 @exit(i32 1)
unreachable
80: ; preds = %50
%81 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.16, i64 0, i64 0))
br label %82
82: ; preds = %80, %75
%83 = call i32 @fclose(i32* %30)
ret i32 0
}