#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*/ EOF;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
char *malloc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ *strchr(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  char *appstr;
  appstr = malloc(strlen(*argv));
  strcpy(appstr, *argv);
  argv++;
  if ((argc < 3) | (argc > 4))
    usage(appstr);
  char *fpsstr, *infilestr, *outfilestr;
  fpsstr = malloc(strlen(*argv));
  strcpy(fpsstr, *argv);
  argv++;
  infilestr = malloc(strlen(*argv));
  strcpy(infilestr, *argv);
  argv++;
  if (argc == 4) {
    outfilestr = malloc(strlen(*argv));
    strcpy(outfilestr, *argv);
  }
  printf("appstr: %s\n", appstr);
  printf("fpsstr: %s\n", fpsstr);
  printf("infilestr: %s\n", infilestr);
  printf("outfilestr: %s\n", outfilestr);
  bool useoutfile = (outfilestr != NULL);
  putchar('\n');
  char fps;
  fps = (char)strtol(fpsstr, NULL, 16);
  if (((fpsstr != "0") & (fps == 0)) | (fps < 0)) {
    printf("ERROR: Unknown FPS code %s!\n", fpsstr);
    usage(appstr);
  }
  printf("Changing fps code to %d...\n", fps);
  FILE *infile, *outfile;
  if (useoutfile) {
    puts("Using outfile...");
    infile = fopen(infilestr, "rb");
    outfile = fopen(outfilestr, "wb");
  } else {
    puts("Updating infile...");
    infile = fopen(infilestr, "r+b");
  }
  if (infile == NULL) {
    puts(infilestr);
    printf("Failed to open file %s\n", infilestr);
    usage(appstr);
  }
  if (useoutfile & (outfile == NULL)) {
    printf("Failed to open file %s\n", outfilestr);
    usage(appstr);
  }
  char token[4] = {0x00, 0x00, 0x01, 0xB3};
  char hdr[4];
  fgets(hdr, 4, infile);
  while (strchr(hdr, EOF) == NULL) {
    if (hdr == token) {
      printf("Sequence header found at %d\n", ftell(infile));
      fseek(infile, 4, SEEK_CUR);
      printf("FPS code: %x\n", fgetc(infile));
    }
    fseek(infile, -2, SEEK_CUR);
    fgets(hdr, 4, infile);
  }
  fclose(infile);
  if (useoutfile)
    fclose(outfile);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%eax
cmpl   $0x4,-0x8(%rbp)
setg   %cl
and    $0x1,%cl
movzbl %cl,%ecx
or     %ecx,%eax
cmp    $0x0,%eax
je     1246 <main+0x76>
mov    -0x18(%rbp),%rdi
call   10e0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    12dd <main+0x10d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rsi
lea    0xd18(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xd0c(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xd09(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
cmpq   $0x0,-0x30(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x34(%rbp)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   10b0 <strtol@plt>
mov    %al,-0x35(%rbp)
lea    0xcdc(%rip),%rax
cmp    %rax,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
movsbl -0x35(%rbp),%ecx
cmp    $0x0,%ecx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
movsbl -0x35(%rbp),%ecx
cmp    $0x0,%ecx
setl   %cl
and    $0x1,%cl
movzbl %cl,%ecx
or     %ecx,%eax
cmp    $0x0,%eax
je     13af <main+0x1df>
mov    -0x20(%rbp),%rsi
lea    0xc9a(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <usage@plt>
movsbl -0x35(%rbp),%esi
lea    0xc9c(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
cmpl   $0x0,-0x34(%rbp)
je     1404 <main+0x234>
lea    0xca0(%rip),%rdi
call   1050 <puts@plt>
mov    -0x28(%rbp),%rdi
lea    0xca1(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xc90(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x48(%rbp)
jmp    1424 <main+0x254>
lea    0xc7e(%rip),%rdi
call   1050 <puts@plt>
mov    -0x28(%rbp),%rdi
lea    0xc81(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1453 <main+0x283>
mov    -0x28(%rbp),%rdi
call   1050 <puts@plt>
mov    -0x28(%rbp),%rsi
lea    0xc5d(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <usage@plt>
mov    -0x34(%rbp),%eax
cmpq   $0x0,-0x48(%rbp)
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     148a <main+0x2ba>
mov    -0x30(%rbp),%rsi
lea    0xc26(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <usage@plt>
mov    0xc28(%rip),%eax
mov    %eax,-0x4c(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    $0x4,%esi
call   10a0 <fgets@plt>
lea    -0x50(%rbp),%rdi
mov    0x2b30(%rip),%rax
mov    (%rax),%esi
call   1080 <strchr@plt>
cmp    $0x0,%rax
jne    14ef <main+0x31f>
mov    -0x40(%rbp),%rdi
mov    0x2b1c(%rip),%rax
mov    (%rax),%edx
mov    $0xfffffffe,%esi
call   10d0 <fseek@plt>
lea    -0x50(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    $0x4,%esi
call   10a0 <fgets@plt>
jmp    14a5 <main+0x2d5>
mov    -0x40(%rbp),%rdi
call   1060 <fclose@plt>
cmpl   $0x0,-0x34(%rbp)
je     150b <main+0x33b>
mov    -0x48(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,%r14
mov    (%rbx),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
lea    -0x5(%rbp),%eax
cmp    $0xfffffffd,%eax
ja     120d <main+0x3d>
mov    %r14,%rdi
call   10e0 <usage@plt>
mov    0x8(%rbx),%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,%r13
mov    0x8(%rbx),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
mov    0x10(%rbx),%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,%r12
mov    0x10(%rbx),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
cmp    $0x4,%ebp
jne    126f <main+0x9f>
mov    0x18(%rbx),%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,%r15
mov    0x18(%rbx),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
lea    0xd8a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd85(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd80(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd7e(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10b0 <strtol@plt>
xor    %ecx,%ecx
movsbl %al,%ebx
shl    $0x18,%eax
sete   %cl
shr    $0x1f,%eax
or     %ecx,%eax
je     12f7 <main+0x127>
lea    0xd52(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r14,%rdi
call   10e0 <usage@plt>
lea    0xd56(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1090 <printf@plt>
test   %r15,%r15
je     1427 <main+0x257>
lea    0xd59(%rip),%rdi
call   1050 <puts@plt>
lea    0xd5e(%rip),%rsi
mov    %r12,%rdi
call   10f0 <fopen@plt>
mov    %rax,%rbx
lea    0xd4f(%rip),%rsi
mov    %r15,%rdi
call   10f0 <fopen@plt>
mov    %rax,%r13
test   %rbx,%rbx
jne    1366 <main+0x196>
mov    %r12,%rdi
call   1050 <puts@plt>
lea    0xd4a(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r14,%rdi
call   10e0 <usage@plt>
test   %r15,%r15
je     1389 <main+0x1b9>
test   %r13,%r13
jne    1389 <main+0x1b9>
lea    0xd27(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r14,%rdi
call   10e0 <usage@plt>
lea    0x4(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x4,%esi
mov    %rbx,%rdx
call   10a0 <fgets@plt>
mov    0x2c3b(%rip),%r14
mov    (%r14),%esi
mov    %rbp,%rdi
call   1080 <strchr@plt>
test   %rax,%rax
jne    1401 <main+0x231>
mov    0x2c2c(%rip),%r12
lea    0x4(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0xfffffffe,%esi
call   10d0 <fseek@plt>
mov    %rbp,%rdi
mov    $0x4,%esi
mov    %rbx,%rdx
call   10a0 <fgets@plt>
mov    (%r14),%esi
mov    %rbp,%rdi
call   1080 <strchr@plt>
test   %rax,%rax
je     13d0 <main+0x200>
mov    %rbx,%rdi
call   1060 <fclose@plt>
test   %r15,%r15
je     1416 <main+0x246>
mov    %r13,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc59(%rip),%rdi
call   1050 <puts@plt>
lea    0xc60(%rip),%rsi
mov    %r12,%rdi
call   10f0 <fopen@plt>
mov    %rax,%rbx
test   %rbx,%rbx
jne    1366 <main+0x196>
jmp    1345 <main+0x175>

LLVM IR (-O0):
@.str = [12 x i8] c"appstr: %s\0A\00"
@.str.1 = [12 x i8] c"fpsstr: %s\0A\00"
@.str.2 = [15 x i8] c"infilestr: %s\0A\00"
@.str.3 = [16 x i8] c"outfilestr: %s\0A\00"
@.str.4 = [2 x i8] c"0\00"
@.str.5 = [29 x i8] c"ERROR: Unknown FPS code %s!\0A\00"
@.str.6 = [28 x i8] c"Changing fps code to %d...\0A\00"
@.str.7 = [17 x i8] c"Using outfile...\00"
@.str.8 = [3 x i8] c"rb\00"
@.str.9 = [3 x i8] c"wb\00"
@.str.10 = [19 x i8] c"Updating infile...\00"
@.str.11 = [4 x i8] c"r+b\00"
@.str.12 = [24 x i8] c"Failed to open file %s\0A\00"
@__const.main.token = [4 x i8] c"\00\00\01\B3"
@EOF = global i32 0
@SEEK_CUR = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca [4 x i8]
%15 = alloca [4 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i8**, i8*** %5
%17 = load i8*, i8** %16
%18 = call i32 @strlen(i8* %17)
%19 = call i8* @malloc(i32 %18)
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = load i8**, i8*** %5
%22 = load i8*, i8** %21
%23 = call i32 @strcpy(i8* %20, i8* %22)
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i32 1
store i8** %25, i8*** %5
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 3
%28 = zext i1 %27 to i32
%29 = load i32, i32* %4
%30 = icmp sgt i32 %29, 4
%31 = zext i1 %30 to i32
%32 = or i32 %28, %31
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %2
%35 = load i8*, i8** %6
%36 = call i32 @usage(i8* %35)
br label %37
37: ; preds = %34, %2
%38 = load i8**, i8*** %5
%39 = load i8*, i8** %38
%40 = call i32 @strlen(i8* %39)
%41 = call i8* @malloc(i32 %40)
store i8* %41, i8** %7
%42 = load i8*, i8** %7
%43 = load i8**, i8*** %5
%44 = load i8*, i8** %43
%45 = call i32 @strcpy(i8* %42, i8* %44)
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i32 1
store i8** %47, i8*** %5
%48 = load i8**, i8*** %5
%49 = load i8*, i8** %48
%50 = call i32 @strlen(i8* %49)
%51 = call i8* @malloc(i32 %50)
store i8* %51, i8** %8
%52 = load i8*, i8** %8
%53 = load i8**, i8*** %5
%54 = load i8*, i8** %53
%55 = call i32 @strcpy(i8* %52, i8* %54)
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i32 1
store i8** %57, i8*** %5
%58 = load i32, i32* %4
%59 = icmp eq i32 %58, 4
br i1 %59, label %60, label %69
60: ; preds = %37
%61 = load i8**, i8*** %5
%62 = load i8*, i8** %61
%63 = call i32 @strlen(i8* %62)
%64 = call i8* @malloc(i32 %63)
store i8* %64, i8** %9
%65 = load i8*, i8** %9
%66 = load i8**, i8*** %5
%67 = load i8*, i8** %66
%68 = call i32 @strcpy(i8* %65, i8* %67)
br label %69
69: ; preds = %60, %37
%70 = load i8*, i8** %6
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %70)
%72 = load i8*, i8** %7
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %72)
%74 = load i8*, i8** %8
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %74)
%76 = load i8*, i8** %9
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %76)
%78 = load i8*, i8** %9
%79 = icmp ne i8* %78, null
%80 = zext i1 %79 to i32
store i32 %80, i32* %10
%81 = call i32 @putchar(i8 signext 10)
%82 = load i8*, i8** %7
%83 = call i64 @strtol(i8* %82, i32* null, i32 16)
%84 = trunc i64 %83 to i8
store i8 %84, i8* %11
%85 = load i8*, i8** %7
%86 = icmp ne i8* %85, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%87 = zext i1 %86 to i32
%88 = load i8, i8* %11
%89 = sext i8 %88 to i32
%90 = icmp eq i32 %89, 0
%91 = zext i1 %90 to i32
%92 = and i32 %87, %91
%93 = load i8, i8* %11
%94 = sext i8 %93 to i32
%95 = icmp slt i32 %94, 0
%96 = zext i1 %95 to i32
%97 = or i32 %92, %96
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %104
99: ; preds = %69
%100 = load i8*, i8** %7
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %100)
%102 = load i8*, i8** %6
%103 = call i32 @usage(i8* %102)
br label %104
104: ; preds = %99, %69
%105 = load i8, i8* %11
%106 = sext i8 %105 to i32
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %106)
%108 = load i32, i32* %10
%109 = icmp ne i32 %108, 0
br i1 %109, label %110, label %116
110: ; preds = %104
%111 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%112 = load i8*, i8** %8
%113 = call i32* @fopen(i8* %112, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
store i32* %113, i32** %12
%114 = load i8*, i8** %9
%115 = call i32* @fopen(i8* %114, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
store i32* %115, i32** %13
br label %120
116: ; preds = %104
%117 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
%118 = load i8*, i8** %8
%119 = call i32* @fopen(i8* %118, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
store i32* %119, i32** %12
br label %120
120: ; preds = %116, %110
%121 = load i32*, i32** %12
%122 = icmp eq i32* %121, null
br i1 %122, label %123, label %130
123: ; preds = %120
%124 = load i8*, i8** %8
%125 = call i32 @puts(i8* %124)
%126 = load i8*, i8** %8
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i8* %126)
%128 = load i8*, i8** %6
%129 = call i32 @usage(i8* %128)
br label %130
130: ; preds = %123, %120
%131 = load i32, i32* %10
%132 = load i32*, i32** %13
%133 = icmp eq i32* %132, null
%134 = zext i1 %133 to i32
%135 = and i32 %131, %134
%136 = icmp ne i32 %135, 0
br i1 %136, label %137, label %142
137: ; preds = %130
%138 = load i8*, i8** %9
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i8* %138)
%140 = load i8*, i8** %6
%141 = call i32 @usage(i8* %140)
br label %142
142: ; preds = %137, %130
%143 = bitcast [4 x i8]* %14 to i8*
%144 = getelementptr inbounds [4 x i8], [4 x i8]* %15, i64 0, i64 0
%145 = load i32*, i32** %12
%146 = call i32 @fgets(i8* %144, i32 4, i32* %145)
br label %147
147: ; preds = %152, %142
%148 = getelementptr inbounds [4 x i8], [4 x i8]* %15, i64 0, i64 0
%149 = load i32, i32* @EOF
%150 = call i32* @strchr(i8* %148, i32 %149)
%151 = icmp eq i32* %150, null
br i1 %151, label %152, label %159
152: ; preds = %147
%153 = load i32*, i32** %12
%154 = load i32, i32* @SEEK_CUR
%155 = call i32 @fseek(i32* %153, i32 -2, i32 %154)
%156 = getelementptr inbounds [4 x i8], [4 x i8]* %15, i64 0, i64 0
%157 = load i32*, i32** %12
%158 = call i32 @fgets(i8* %156, i32 4, i32* %157)
br label %147
159: ; preds = %147
%160 = load i32*, i32** %12
%161 = call i32 @fclose(i32* %160)
%162 = load i32, i32* %10
%163 = icmp ne i32 %162, 0
br i1 %163, label %164, label %167
164: ; preds = %159
%165 = load i32*, i32** %13
%166 = call i32 @fclose(i32* %165)
br label %167
167: ; preds = %164, %159
%168 = load i32, i32* %3
ret i32 %168
}

LLVM IR (-O2):
@.str = [12 x i8] c"appstr: %s\0A\00"
@.str.1 = [12 x i8] c"fpsstr: %s\0A\00"
@.str.2 = [15 x i8] c"infilestr: %s\0A\00"
@.str.3 = [16 x i8] c"outfilestr: %s\0A\00"
@.str.5 = [29 x i8] c"ERROR: Unknown FPS code %s!\0A\00"
@.str.6 = [28 x i8] c"Changing fps code to %d...\0A\00"
@.str.7 = [17 x i8] c"Using outfile...\00"
@.str.8 = [3 x i8] c"rb\00"
@.str.9 = [3 x i8] c"wb\00"
@.str.10 = [19 x i8] c"Updating infile...\00"
@.str.11 = [4 x i8] c"r+b\00"
@.str.12 = [24 x i8] c"Failed to open file %s\0A\00"
@EOF = global i32 0
@SEEK_CUR = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i8]
%4 = load i8*, i8** %1
%5 = tail call i32 @strlen(i8* %4)
%6 = tail call i8* @malloc(i32 %5)
%7 = load i8*, i8** %1
%8 = tail call i32 @strcpy(i8* %6, i8* %7)
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = add i32 %0, -5
%11 = icmp ult i32 %10, -2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = tail call i32 @usage(i8* %6)
br label %14
14: ; preds = %12, %2
%15 = load i8*, i8** %9
%16 = tail call i32 @strlen(i8* %15)
%17 = tail call i8* @malloc(i32 %16)
%18 = load i8*, i8** %9
%19 = tail call i32 @strcpy(i8* %17, i8* %18)
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32 @strlen(i8* %21)
%23 = tail call i8* @malloc(i32 %22)
%24 = load i8*, i8** %20
%25 = tail call i32 @strcpy(i8* %23, i8* %24)
%26 = getelementptr inbounds i8*, i8** %1, i64 3
%27 = icmp eq i32 %0, 4
br i1 %27, label %28, label %34
28: ; preds = %14
%29 = load i8*, i8** %26
%30 = tail call i32 @strlen(i8* %29)
%31 = tail call i8* @malloc(i32 %30)
%32 = load i8*, i8** %26
%33 = tail call i32 @strcpy(i8* %31, i8* %32)
br label %34
34: ; preds = %28, %14
%35 = phi i8* [ %31, %28 ], [ undef, %14 ]
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %6)
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %35)
%40 = icmp ne i8* %35, null
%41 = tail call i32 @putchar(i8 signext 10)
%42 = tail call i64 @strtol(i8* nocapture %17, i32* null, i32 16)
%43 = trunc i64 %42 to i32
%44 = shl i32 %43, 24
%45 = ashr exact i32 %44, 24
%46 = icmp eq i32 %44, 0
%47 = zext i1 %46 to i32
%48 = lshr i32 %44, 31
%49 = or i32 %48, %47
%50 = icmp eq i32 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %34
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %17)
%53 = tail call i32 @usage(i8* %6)
br label %54
54: ; preds = %51, %34
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %45)
br i1 %40, label %56, label %60
56: ; preds = %54
%57 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%58 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%59 = tail call i32* @fopen(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
br label %63
60: ; preds = %54
%61 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
%62 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
br label %63
63: ; preds = %60, %56
%64 = phi i32* [ %58, %56 ], [ %62, %60 ]
%65 = phi i32* [ %59, %56 ], [ undef, %60 ]
%66 = icmp eq i32* %64, null
br i1 %66, label %67, label %71
67: ; preds = %63
%68 = tail call i32 @puts(i8* dereferenceable(1) %23)
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i8* %23)
%70 = tail call i32 @usage(i8* %6)
br label %71
71: ; preds = %67, %63
%72 = icmp eq i32* %65, null
%73 = and i1 %40, %72
br i1 %73, label %74, label %77
74: ; preds = %71
%75 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i8* %35)
%76 = tail call i32 @usage(i8* %6)
br label %77
77: ; preds = %74, %71
%78 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%79 = call i32 @fgets(i8* %78, i32 4, i32* %64)
%80 = load i32, i32* @EOF
%81 = call i32* @strchr(i8* %78, i32 %80)
%82 = icmp eq i32* %81, null
br i1 %82, label %83, label %90
83: ; preds = %77, %83
%84 = load i32, i32* @SEEK_CUR
%85 = call i32 @fseek(i32* %64, i32 -2, i32 %84)
%86 = call i32 @fgets(i8* %78, i32 4, i32* %64)
%87 = load i32, i32* @EOF
%88 = call i32* @strchr(i8* %78, i32 %87)
%89 = icmp eq i32* %88, null
br i1 %89, label %83, label %90
90: ; preds = %83, %77
%91 = call i32 @fclose(i32* %64)
br i1 %40, label %92, label %94
92: ; preds = %90
%93 = call i32 @fclose(i32* %65)
br label %94
94: ; preds = %92, %90
ret i32 0
}