#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*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
char *malloc(int);
char *memmem(char *, int, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  char *infilename = "";
  char *outfilename = "";
  int optind = 1;
  FILE *infile = NULL;
  FILE *outfile = NULL;
  int fsize;
  char *big_buf = NULL;
  char *signature = "sqsh", *header = NULL;
  int signature_len;
  if (argc == 1)
    usage();
  while (optind < argc) {
    if (!strcmp("-i", argv[optind]) && optind < argc - 1) {
      infilename = argv[++optind];
      optind++;
    } else if (!strcmp("-o", argv[optind]) && optind < argc - 1) {
      outfilename = argv[++optind];
      optind++;
    } else if (!strcmp("-s", argv[optind]) && optind < argc - 1) {
      signature = argv[++optind];
      optind++;
    } else {
      usage();
    };
  }
  signature_len = strlen(signature);
  if (!(infile = fopen(infilename, "r"))) {
    perror(infilename);
    return 1;
  }
  fseek(infile, 0, SEEK_END);
  fsize = ftell(infile);
  fprintf(stderr, "size: %d\n", fsize);
  big_buf = malloc(fsize + 8);
  if (!big_buf) {
    perror("malloc");
    return 1;
  }
  memset(big_buf, 0, fsize);
  fseek(infile, 0, SEEK_SET);
  if (errno)
    perror("fseek");
  fread(big_buf, fsize, 1, infile);
  if (errno)
    perror("fread");
  fclose(infile);
  header = memmem(big_buf, fsize, signature, signature_len);
  if (header) {
    if (!(outfile = fopen(outfilename, "w"))) {
      perror(outfilename);
      exit(1);
    }
    fwrite(header, fsize - (header - big_buf), 1, outfile);
    fclose(outfile);
  } else {
    fprintf(stderr, "signature not found\n");
    exit(1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe0c(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe01(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x48(%rbp)
lea    0xdbe(%rip),%rax
mov    %rax,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    125f <main+0x6f>
mov    $0x0,%al
call   10d0 <usage@plt>
jmp    1264 <main+0x74>
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    138e <main+0x19e>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd82(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12c8 <main+0xd8>
mov    -0x24(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12c8 <main+0xd8>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x24(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1389 <main+0x199>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd2d(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1320 <main+0x130>
mov    -0x24(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1320 <main+0x130>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x24(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1384 <main+0x194>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xcd8(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1378 <main+0x188>
mov    -0x24(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1378 <main+0x188>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x24(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x50(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    137f <main+0x18f>
mov    $0x0,%al
call   10d0 <usage@plt>
jmp    1384 <main+0x194>
jmp    1389 <main+0x199>
jmp    1264 <main+0x74>
mov    -0x50(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xc69(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    13cd <main+0x1dd>
mov    -0x18(%rbp),%rdi
call   10f0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1562 <main+0x372>
mov    -0x30(%rbp),%rdi
mov    0x2c10(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    -0x30(%rbp),%rdi
call   1090 <ftell@plt>
mov    %eax,-0x3c(%rbp)
mov    0x2be4(%rip),%rax
mov    (%rax),%edi
mov    -0x3c(%rbp),%edx
lea    0xc10(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x3c(%rbp),%edi
add    $0x8,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1439 <main+0x249>
lea    0xbf2(%rip),%rdi
call   10f0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1562 <main+0x372>
mov    -0x48(%rbp),%rdi
mov    -0x3c(%rbp),%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x30(%rbp),%rdi
mov    0x2b76(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    0x2b6e(%rip),%rax
cmpq   $0x0,(%rax)
je     1478 <main+0x288>
lea    0xbae(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x48(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x30(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
mov    0x2b3c(%rip),%rax
cmpq   $0x0,(%rax)
je     14aa <main+0x2ba>
lea    0xb82(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x48(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x50(%rbp),%rdx
mov    -0x5c(%rbp),%ecx
call   10a0 <memmem@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     153a <main+0x34a>
mov    -0x20(%rbp),%rdi
lea    0xb4d(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1506 <main+0x316>
mov    -0x20(%rbp),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x58(%rbp),%rdi
movslq -0x3c(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    -0x48(%rbp),%rdx
sub    %rdx,%rcx
sub    %rcx,%rax
mov    %eax,%esi
mov    -0x38(%rbp),%rcx
mov    $0x1,%edx
call   1110 <fwrite@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
jmp    155b <main+0x36b>
mov    0x2a97(%rip),%rax
mov    (%rax),%edi
lea    0xae5(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
xor    %edi,%edi
call   1100 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x1,%edi
jne    120f <main+0x1f>
xor    %eax,%eax
call   10d0 <usage@plt>
jmp    12e1 <main+0xf1>
jle    12e1 <main+0xf1>
mov    %rsi,%rbx
mov    %edi,%r13d
lea    -0x1(%r13),%r14d
mov    $0x1,%r12d
lea    0xded(%rip),%rcx
lea    0xdcd(%rip),%rax
mov    %rax,(%rsp)
mov    %rcx,0x10(%rsp)
mov    %rcx,0x8(%rsp)
jmp    1267 <main+0x77>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rbx,%rbp,8),%rax
mov    %rax,0x10(%rsp)
add    $0x2,%r12d
cmp    %r13d,%r12d
jge    12fd <main+0x10d>
movslq %r12d,%rbp
mov    (%rbx,%rbp,8),%r15
lea    0xd90(%rip),%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    1286 <main+0x96>
cmp    %r14d,%r12d
jl     1250 <main+0x60>
lea    0xd7b(%rip),%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    12b0 <main+0xc0>
cmp    %r14d,%r12d
jge    12b0 <main+0xc0>
mov    0x8(%rbx,%rbp,8),%rax
mov    %rax,0x8(%rsp)
jmp    125a <main+0x6a>
nopw   0x0(%rax,%rax,1)
lea    0xd54(%rip),%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    12d3 <main+0xe3>
cmp    %r14d,%r12d
jge    12d3 <main+0xe3>
mov    0x8(%rbx,%rbp,8),%rax
mov    %rax,(%rsp)
jmp    125a <main+0x6a>
xor    %eax,%eax
call   10d0 <usage@plt>
cmp    %r13d,%r12d
jl     1267 <main+0x77>
jmp    12fd <main+0x10d>
lea    0xd18(%rip),%rax
mov    %rax,(%rsp)
lea    0xd26(%rip),%rax
mov    %rax,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    (%rsp),%rdi
call   1050 <strlen@plt>
mov    %eax,%r14d
lea    0xcfe(%rip),%rsi
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1370 <main+0x180>
mov    %rax,%rbp
mov    0x2cbc(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    %rbp,%rdi
call   1090 <ftell@plt>
mov    %eax,%ebx
mov    0x2c8f(%rip),%r15
mov    (%r15),%edi
lea    0xcbd(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0x8(%rbx),%edi
call   10b0 <malloc@plt>
test   %rax,%rax
jne    138c <main+0x19c>
lea    0xcaa(%rip),%rbx
mov    %rbx,%rdi
call   10f0 <perror@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rax,%r12
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1060 <memset@plt>
mov    0x2c26(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    0x2c1b(%rip),%r13
cmpq   $0x0,0x0(%r13)
je     13c8 <main+0x1d8>
lea    0xc5e(%rip),%rdi
call   10f0 <perror@plt>
mov    %r12,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1030 <fread@plt>
cmpq   $0x0,0x0(%r13)
je     13ed <main+0x1fd>
lea    0xc3f(%rip),%rdi
call   10f0 <perror@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %r12,%rdi
mov    %ebx,%esi
mov    (%rsp),%rdx
mov    %r14d,%ecx
call   10a0 <memmem@plt>
test   %rax,%rax
jne    1426 <main+0x236>
mov    (%r15),%edi
lea    0xc1a(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    %rax,%rbp
lea    0xbfd(%rip),%rsi
mov    0x8(%rsp),%rdi
call   10e0 <fopen@plt>
test   %rax,%rax
jne    1453 <main+0x263>
mov    0x8(%rsp),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    %rax,%r14
sub    %ebp,%r12d
add    %r12d,%ebx
mov    %rbp,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1110 <fwrite@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %edi,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"sqsh\00"
@.str.2 = [3 x i8] c"-i\00"
@.str.3 = [3 x i8] c"-o\00"
@.str.4 = [3 x i8] c"-s\00"
@.str.5 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@stderr = global i32 0
@.str.6 = [10 x i8] c"size: %d\0A\00"
@.str.7 = [7 x i8] c"malloc\00"
@SEEK_SET = global i32 0
@errno = global i64 0
@.str.8 = [6 x i8] c"fseek\00"
@.str.9 = [6 x i8] c"fread\00"
@.str.10 = [2 x i8] c"w\00"
@.str.11 = [21 x i8] c"signature not found\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 i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %7
store i32 1, i32* %8
store i32* null, i32** %9
store i32* null, i32** %10
store i8* null, i8** %12
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %13
store i8* null, i8** %14
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 (...) @usage()
br label %20
20: ; preds = %18, %2
br label %21
21: ; preds = %95, %20
%22 = load i32, i32* %8
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %96
25: ; preds = %21
%26 = load i8**, i8*** %5
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %47, label %33
33: ; preds = %25
%34 = load i32, i32* %8
%35 = load i32, i32* %4
%36 = sub nsw i32 %35, 1
%37 = icmp slt i32 %34, %36
br i1 %37, label %38, label %47
38: ; preds = %33
%39 = load i8**, i8*** %5
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %39, i64 %42
%44 = load i8*, i8** %43
store i8* %44, i8** %6
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %95
47: ; preds = %33, %25
%48 = load i8**, i8*** %5
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
%53 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %52)
%54 = icmp ne i32 %53, 0
br i1 %54, label %69, label %55
55: ; preds = %47
%56 = load i32, i32* %8
%57 = load i32, i32* %4
%58 = sub nsw i32 %57, 1
%59 = icmp slt i32 %56, %58
br i1 %59, label %60, label %69
60: ; preds = %55
%61 = load i8**, i8*** %5
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %61, i64 %64
%66 = load i8*, i8** %65
store i8* %66, i8** %7
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
br label %94
69: ; preds = %55, %47
%70 = load i8**, i8*** %5
%71 = load i32, i32* %8
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8*, i8** %70, i64 %72
%74 = load i8*, i8** %73
%75 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %74)
%76 = icmp ne i32 %75, 0
br i1 %76, label %91, label %77
77: ; preds = %69
%78 = load i32, i32* %8
%79 = load i32, i32* %4
%80 = sub nsw i32 %79, 1
%81 = icmp slt i32 %78, %80
br i1 %81, label %82, label %91
82: ; preds = %77
%83 = load i8**, i8*** %5
%84 = load i32, i32* %8
%85 = add nsw i32 %84, 1
store i32 %85, i32* %8
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8*, i8** %83, i64 %86
%88 = load i8*, i8** %87
store i8* %88, i8** %13
%89 = load i32, i32* %8
%90 = add nsw i32 %89, 1
store i32 %90, i32* %8
br label %93
91: ; preds = %77, %69
%92 = call i32 (...) @usage()
br label %93
93: ; preds = %91, %82
br label %94
94: ; preds = %93, %60
br label %95
95: ; preds = %94, %38
br label %21
96: ; preds = %21
%97 = load i8*, i8** %13
%98 = call i32 @strlen(i8* %97)
store i32 %98, i32* %15
%99 = load i8*, i8** %6
%100 = call i32* @fopen(i8* %99, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %100, i32** %9
%101 = icmp ne i32* %100, null
br i1 %101, label %105, label %102
102: ; preds = %96
%103 = load i8*, i8** %6
%104 = call i32 @perror(i8* %103)
store i32 1, i32* %3
br label %180
105: ; preds = %96
%106 = load i32*, i32** %9
%107 = load i32, i32* @SEEK_END
%108 = call i32 @fseek(i32* %106, i32 0, i32 %107)
%109 = load i32*, i32** %9
%110 = call i32 @ftell(i32* %109)
store i32 %110, i32* %11
%111 = load i32, i32* @stderr
%112 = load i32, i32* %11
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %112)
%114 = load i32, i32* %11
%115 = add nsw i32 %114, 8
%116 = call i8* @malloc(i32 %115)
store i8* %116, i8** %12
%117 = load i8*, i8** %12
%118 = icmp ne i8* %117, null
br i1 %118, label %121, label %119
119: ; preds = %105
%120 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %180
121: ; preds = %105
%122 = load i8*, i8** %12
%123 = load i32, i32* %11
%124 = call i32 @memset(i8* %122, i32 0, i32 %123)
%125 = load i32*, i32** %9
%126 = load i32, i32* @SEEK_SET
%127 = call i32 @fseek(i32* %125, i32 0, i32 %126)
%128 = load i64, i64* @errno
%129 = icmp ne i64 %128, 0
br i1 %129, label %130, label %132
130: ; preds = %121
%131 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %132
132: ; preds = %130, %121
%133 = load i8*, i8** %12
%134 = load i32, i32* %11
%135 = load i32*, i32** %9
%136 = call i32 @fread(i8* %133, i32 %134, i32 1, i32* %135)
%137 = load i64, i64* @errno
%138 = icmp ne i64 %137, 0
br i1 %138, label %139, label %141
139: ; preds = %132
%140 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %141
141: ; preds = %139, %132
%142 = load i32*, i32** %9
%143 = call i32 @fclose(i32* %142)
%144 = load i8*, i8** %12
%145 = load i32, i32* %11
%146 = load i8*, i8** %13
%147 = load i32, i32* %15
%148 = call i8* @memmem(i8* %144, i32 %145, i8* %146, i32 %147)
store i8* %148, i8** %14
%149 = load i8*, i8** %14
%150 = icmp ne i8* %149, null
br i1 %150, label %151, label %174
151: ; preds = %141
%152 = load i8*, i8** %7
%153 = call i32* @fopen(i8* %152, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
store i32* %153, i32** %10
%154 = icmp ne i32* %153, null
br i1 %154, label %159, label %155
155: ; preds = %151
%156 = load i8*, i8** %7
%157 = call i32 @perror(i8* %156)
%158 = call i32 @exit(i32 1)
unreachable
159: ; preds = %151
%160 = load i8*, i8** %14
%161 = load i32, i32* %11
%162 = sext i32 %161 to i64
%163 = load i8*, i8** %14
%164 = load i8*, i8** %12
%165 = ptrtoint i8* %163 to i64
%166 = ptrtoint i8* %164 to i64
%167 = sub i64 %165, %166
%168 = sub nsw i64 %162, %167
%169 = trunc i64 %168 to i32
%170 = load i32*, i32** %10
%171 = call i32 @fwrite(i8* %160, i32 %169, i32 1, i32* %170)
%172 = load i32*, i32** %10
%173 = call i32 @fclose(i32* %172)
br label %178
174: ; preds = %141
%175 = load i32, i32* @stderr
%176 = call i32 (i32, i8*, ...) @fprintf(i32 %175, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
%177 = call i32 @exit(i32 1)
unreachable
178: ; preds = %159
%179 = call i32 @exit(i32 0)
unreachable
180: ; preds = %119, %102
%181 = load i32, i32* %3
ret i32 %181
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"sqsh\00"
@.str.2 = [3 x i8] c"-i\00"
@.str.3 = [3 x i8] c"-o\00"
@.str.4 = [3 x i8] c"-s\00"
@.str.5 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@stderr = global i32 0
@.str.6 = [10 x i8] c"size: %d\0A\00"
@.str.7 = [7 x i8] c"malloc\00"
@SEEK_SET = global i32 0
@errno = global i64 0
@.str.8 = [6 x i8] c"fseek\00"
@.str.9 = [6 x i8] c"fread\00"
@.str.10 = [2 x i8] c"w\00"
@.str.11 = [21 x i8] c"signature not found\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %56
6: ; preds = %2
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %56
8: ; preds = %6
%9 = add nsw i32 %0, -1
br label %10
10: ; preds = %8, %50
%11 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %8 ], [ %54, %50 ]
%12 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %8 ], [ %53, %50 ]
%13 = phi i32 [ 1, %8 ], [ %52, %50 ]
%14 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %8 ], [ %51, %50 ]
%15 = sext i32 %13 to i64
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = load i8*, i8** %16
%18 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* dereferenceable(1) %17)
%19 = icmp eq i32 %18, 0
%20 = icmp slt i32 %13, %9
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %22, label %28
22: ; preds = %10
%23 = add nsw i32 %13, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
%26 = load i8*, i8** %25
%27 = add nsw i32 %13, 2
br label %50
28: ; preds = %10
%29 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* dereferenceable(1) %17)
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i1 %20, i1 false
br i1 %31, label %32, label %38
32: ; preds = %28
%33 = add nsw i32 %13, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %1, i64 %34
%36 = load i8*, i8** %35
%37 = add nsw i32 %13, 2
br label %50
38: ; preds = %28
%39 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* dereferenceable(1) %17)
%40 = icmp eq i32 %39, 0
%41 = select i1 %40, i1 %20, i1 false
br i1 %41, label %42, label %48
42: ; preds = %38
%43 = add nsw i32 %13, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %1, i64 %44
%46 = load i8*, i8** %45
%47 = add nsw i32 %13, 2
br label %50
48: ; preds = %38
%49 = tail call i32 (...) @usage()
br label %50
50: ; preds = %32, %48, %42, %22
%51 = phi i8* [ %14, %48 ], [ %14, %42 ], [ %36, %32 ], [ %14, %22 ]
%52 = phi i32 [ %13, %48 ], [ %47, %42 ], [ %37, %32 ], [ %27, %22 ]
%53 = phi i8* [ %12, %48 ], [ %12, %42 ], [ %12, %32 ], [ %26, %22 ]
%54 = phi i8* [ %11, %48 ], [ %46, %42 ], [ %11, %32 ], [ %11, %22 ]
%55 = icmp slt i32 %52, %0
br i1 %55, label %10, label %56
56: ; preds = %50, %4, %6
%57 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %6 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %4 ], [ %51, %50 ]
%58 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %6 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %4 ], [ %53, %50 ]
%59 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %6 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %4 ], [ %54, %50 ]
%60 = tail call i32 @strlen(i8* %59)
%61 = tail call i32* @fopen(i8* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%62 = icmp eq i32* %61, null
br i1 %62, label %109, label %63
63: ; preds = %56
%64 = load i32, i32* @SEEK_END
%65 = tail call i32 @fseek(i32* %61, i32 0, i32 %64)
%66 = tail call i32 @ftell(i32* %61)
%67 = load i32, i32* @stderr
%68 = tail call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %66)
%69 = add nsw i32 %66, 8
%70 = tail call i8* @malloc(i32 %69)
%71 = icmp eq i8* %70, null
br i1 %71, label %109, label %72
72: ; preds = %63
%73 = tail call i32 @memset(i8* %70, i32 0, i32 %66)
%74 = load i32, i32* @SEEK_SET
%75 = tail call i32 @fseek(i32* %61, i32 0, i32 %74)
%76 = load i64, i64* @errno
%77 = icmp eq i64 %76, 0
br i1 %77, label %80, label %78
78: ; preds = %72
%79 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %80
80: ; preds = %78, %72
%81 = tail call i32 @fread(i8* %70, i32 %66, i32 1, i32* %61)
%82 = load i64, i64* @errno
%83 = icmp eq i64 %82, 0
br i1 %83, label %86, label %84
84: ; preds = %80
%85 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %86
86: ; preds = %84, %80
%87 = tail call i32 @fclose(i32* %61)
%88 = tail call i8* @memmem(i8* %70, i32 %66, i8* %59, i32 %60)
%89 = icmp eq i8* %88, null
br i1 %89, label %105, label %90
90: ; preds = %86
%91 = tail call i32* @fopen(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%92 = icmp eq i32* %91, null
br i1 %92, label %93, label %96
93: ; preds = %90
%94 = tail call i32 @perror(i8* %57)
%95 = tail call i32 @exit(i32 1)
unreachable
96: ; preds = %90
%97 = ptrtoint i8* %88 to i64
%98 = ptrtoint i8* %70 to i64
%99 = sub i64 %98, %97
%100 = trunc i64 %99 to i32
%101 = add i32 %66, %100
%102 = tail call i32 @fwrite(i8* %88, i32 %101, i32 1, i32* %91)
%103 = tail call i32 @fclose(i32* %91)
%104 = tail call i32 @exit(i32 0)
unreachable
105: ; preds = %86
%106 = load i32, i32* @stderr
%107 = tail call i32 (i32, i8*, ...) @fprintf(i32 %106, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
%108 = tail call i32 @exit(i32 1)
unreachable
109: ; preds = %63, %56
%110 = phi i8* [ %58, %56 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), %63 ]
%111 = tail call i32 @perror(i8* %110)
ret i32 1
}