#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 /*<<< orphan*/ st_mode;
};
typedef int /*<<< orphan*/ fileName;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
scalar_t__ S_ISREG(int /*<<< orphan*/);
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ finishArchive();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int handleFile(int, char *, int, int, char **);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  int f, x;
  char fileName[1024];
  char *realName;
  struct stat statBuf;
  int serr;
  int rate;
  int err = 0;
  int compType;
  int compLvl = -1;
  compType = 0;
  for (x = 1; x < argc; x++) {
    if (strcmp(argv[x], "-c") == 0 && argc >= x - 2) {
      compType = atoi(argv[x + 1]);
      x++;
    } else if (strcmp(argv[x], "-l") == 0 && argc >= x - 2) {
      compLvl = atoi(argv[x + 1]);
      if (compLvl < 1 || compLvl > 9)
        err = 1;
      x++;
    } else {
      err = 1;
    }
  }
  if (err) {
    fprintf(stderr, "%s - Program to create espfs images\n", argv[0]);
    fprintf(stderr,
            "Usage: \nfind | %s [-c compressor] [-l compression_level] ",
            argv[0]);
    fprintf(stderr, "> out.espfs\n");
    fprintf(stderr, "Compressors:\n");
    fprintf(stderr, "0 - None(default)\n");
    fprintf(stderr, "\nCompression level: 1 is worst but low RAM usage, higher "
                    "is better compression \nbut uses more ram on "
                    "decompression. -1 = compressors default.\n");
    exit(0);
  }
  while (fgets(fileName, sizeof(fileName), stdin)) {
    fileName[strlen(fileName) - 1] = 0;
    serr = stat(fileName, &statBuf);
    if ((serr == 0) && S_ISREG(statBuf.st_mode)) {
      realName = fileName;
      if (fileName[0] == '.')
        realName++;
      if (realName[0] == '/')
        realName++;
      f = open(fileName, O_RDONLY);
      if (f > 0) {
        char *compName = "unknown";
        rate = handleFile(f, realName, compType, compLvl, &compName);
        fprintf(stderr, "%s (%d%%, %s)\n", realName, rate, compName);
        close(f);
      } else {
        perror(fileName);
      }
    } else {
      if (serr != 0) {
        perror(fileName);
      }
    }
  }
  finishArchive();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x43c(%rbp)
movl   $0xffffffff,-0x444(%rbp)
ff ff ff
movl   $0x0,-0x440(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    131a <main+0x14a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdd3(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1277 <main+0xa7>
mov    -0x8(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jl     1277 <main+0xa7>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x440(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1307 <main+0x137>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd79(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12f8 <main+0x128>
mov    -0x8(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jl     12f8 <main+0x128>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x444(%rbp)
cmpl   $0x1,-0x444(%rbp)
jl     12e0 <main+0x110>
cmpl   $0x9,-0x444(%rbp)
jle    12ea <main+0x11a>
movl   $0x1,-0x43c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1302 <main+0x132>
movl   $0x1,-0x43c(%rbp)
jmp    1307 <main+0x137>
jmp    130c <main+0x13c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    120e <main+0x3e>
cmpl   $0x0,-0x43c(%rbp)
je     13c6 <main+0x1f6>
mov    0x2ca2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xcc8(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c84(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xccf(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c66(%rip),%rax
mov    (%rax),%edi
lea    0xcf2(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c4f(%rip),%rax
mov    (%rax),%edi
lea    0xce8(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c38(%rip),%rax
mov    (%rax),%edi
lea    0xcdf(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c21(%rip),%rax
mov    (%rax),%edi
lea    0xcdb(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
jmp    13cb <main+0x1fb>
lea    -0x420(%rbp),%rdi
mov    0x2c07(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     155c <main+0x38c>
lea    -0x420(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x420(%rbp,%rax,1)
lea    -0x420(%rbp),%rdi
lea    -0x430(%rbp),%rsi
call   1080 <stat@plt>
mov    %eax,-0x434(%rbp)
cmpl   $0x0,-0x434(%rbp)
jne    1539 <main+0x369>
mov    -0x430(%rbp),%edi
call   10b0 <S_ISREG@plt>
cmp    $0x0,%rax
je     1539 <main+0x369>
lea    -0x420(%rbp),%rax
mov    %rax,-0x428(%rbp)
movsbl -0x420(%rbp),%eax
cmp    $0x2e,%eax
jne    1473 <main+0x2a3>
mov    -0x428(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x428(%rbp)
mov    -0x428(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1498 <main+0x2c8>
mov    -0x428(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x428(%rbp)
lea    -0x420(%rbp),%rdi
mov    0x2b42(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1528 <main+0x358>
lea    0xc61(%rip),%rax
mov    %rax,-0x450(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x428(%rbp),%rsi
mov    -0x440(%rbp),%edx
mov    -0x444(%rbp),%ecx
lea    -0x450(%rbp),%r8
call   1090 <handleFile@plt>
mov    %eax,-0x438(%rbp)
mov    0x2ad9(%rip),%rax
mov    (%rax),%edi
mov    -0x428(%rbp),%rdx
mov    -0x438(%rbp),%ecx
mov    -0x450(%rbp),%r8
lea    0xc16(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
jmp    1534 <main+0x364>
lea    -0x420(%rbp),%rdi
call   10d0 <perror@plt>
jmp    1557 <main+0x387>
cmpl   $0x0,-0x434(%rbp)
je     1552 <main+0x382>
lea    -0x420(%rbp),%rdi
call   10d0 <perror@plt>
jmp    1557 <main+0x387>
jmp    13cb <main+0x1fb>
mov    $0x0,%al
call   10a0 <finishArchive@plt>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
cmp    $0x2,%edi
jl     12a0 <main+0xd0>
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0xc(%rsp)
movl   $0xffffffff,0x8(%rsp)
ff
xor    %r13d,%r13d
mov    $0x1,%r12d
jmp    1223 <main+0x53>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%r13d
add    $0x1,%r12d
cmp    %ebp,%r12d
jge    12b2 <main+0xe2>
movslq %r12d,%r14
mov    (%rbx,%r14,8),%rdi
lea    0xdcf(%rip),%rsi
call   1060 <strcmp@plt>
lea    -0x2(%r14),%r15d
test   %rax,%rax
jne    1260 <main+0x90>
cmp    %ebp,%r15d
jg     1260 <main+0x90>
lea    0x1(%r14),%r12d
mov    0x8(%rbx,%r14,8),%rdi
call   10e0 <atoi@plt>
mov    %eax,0xc(%rsp)
jmp    1216 <main+0x46>
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%r14,8),%rdi
lea    0xd98(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1210 <main+0x40>
cmp    %ebp,%r15d
jg     1210 <main+0x40>
lea    0x1(%r14),%r12d
mov    0x8(%rbx,%r14,8),%rdi
call   10e0 <atoi@plt>
mov    %eax,0x8(%rsp)
add    $0xfffffff6,%eax
cmp    $0xfffffff7,%eax
mov    $0x1,%eax
cmovb  %eax,%r13d
jmp    1216 <main+0x46>
movl   $0x0,0xc(%rsp)
movl   $0xffffffff,0x8(%rsp)
ff
jmp    12bb <main+0xeb>
test   %r13d,%r13d
jne    13f1 <main+0x221>
mov    0x2d1e(%rip),%r14
mov    (%r14),%edx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     13d6 <main+0x206>
lea    0x21(%rsp),%rbp
lea    0x22(%rsp),%r15
jmp    1319 <main+0x149>
mov    %rbx,%rdi
call   10d0 <perror@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     13d6 <main+0x206>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
call   1080 <stat@plt>
test   %eax,%eax
jne    12ec <main+0x11c>
mov    0x10(%rsp),%edi
call   10b0 <S_ISREG@plt>
test   %rax,%rax
je     1300 <main+0x130>
xor    %eax,%eax
cmpb   $0x2e,0x20(%rsp)
sete   %al
mov    %rbx,%rcx
cmove  %rbp,%rcx
mov    %rbp,%r12
cmove  %r15,%r12
cmpb   $0x2f,0x20(%rsp,%rax,1)
cmovne %rcx,%r12
mov    0x2c79(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10c0 <open@plt>
test   %eax,%eax
jle    12ec <main+0x11c>
mov    %eax,%r13d
lea    0xd97(%rip),%rax
mov    %rax,0x18(%rsp)
mov    %r13d,%edi
mov    %r12,%rsi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0x18(%rsp),%r8
call   1090 <handleFile@plt>
mov    0x2c21(%rip),%rcx
mov    (%rcx),%edi
mov    0x18(%rsp),%r8
lea    0xd6d(%rip),%rsi
mov    %r12,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r13d,%edi
call   1040 <close@plt>
jmp    1300 <main+0x130>
xor    %eax,%eax
call   10a0 <finishArchive@plt>
xor    %eax,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bd8(%rip),%rbp
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0xc01(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0xc12(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xc3b(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xc37(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xc34(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xc36(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [3 x i8] c"-c\00"
@.str.1 = [3 x i8] c"-l\00"
@stderr = global i32 0
@.str.2 = [37 x i8] c"%s - Program to create espfs images\0A\00"
@.str.3 = [58 x i8] c"Usage: \0Afind | %s [-c compressor] [-l compression_level] \00"
@.str.4 = [13 x i8] c"> out.espfs\0A\00"
@.str.5 = [14 x i8] c"Compressors:\0A\00"
@.str.6 = [19 x i8] c"0 - None(default)\0A\00"
@.str.7 = [143 x i8] c"\0ACompression level: 1 is worst but low RAM usage, higher is better compression \0Abut uses more ram on decompression. -1 = compressors default.\0A\00"
@stdin = global i32 0
@O_RDONLY = global i32 0
@.str.8 = [8 x i8] c"unknown\00"
@.str.9 = [15 x i8] c"%s (%d%%, %s)\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 [1024 x i8]
%9 = alloca i8*
%10 = alloca %struct.stat
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %13
store i32 -1, i32* %15
store i32 0, i32* %14
store i32 1, i32* %7
br label %17
17: ; preds = %77, %2
%18 = load i32, i32* %7
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %80
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %44
29: ; preds = %21
%30 = load i32, i32* %4
%31 = load i32, i32* %7
%32 = sub nsw i32 %31, 2
%33 = icmp sge i32 %30, %32
br i1 %33, label %34, label %44
34: ; preds = %29
%35 = load i8**, i8*** %5
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %35, i64 %38
%40 = load i8*, i8** %39
%41 = call i32 @atoi(i8* %40)
store i32 %41, i32* %14
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %76
44: ; preds = %29, %21
%45 = load i8**, i8*** %5
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %74
52: ; preds = %44
%53 = load i32, i32* %4
%54 = load i32, i32* %7
%55 = sub nsw i32 %54, 2
%56 = icmp sge i32 %53, %55
br i1 %56, label %57, label %74
57: ; preds = %52
%58 = load i8**, i8*** %5
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %58, i64 %61
%63 = load i8*, i8** %62
%64 = call i32 @atoi(i8* %63)
store i32 %64, i32* %15
%65 = load i32, i32* %15
%66 = icmp slt i32 %65, 1
br i1 %66, label %70, label %67
67: ; preds = %57
%68 = load i32, i32* %15
%69 = icmp sgt i32 %68, 9
br i1 %69, label %70, label %71
70: ; preds = %67, %57
store i32 1, i32* %13
br label %71
71: ; preds = %70, %67
%72 = load i32, i32* %7
%73 = add nsw i32 %72, 1
store i32 %73, i32* %7
br label %75
74: ; preds = %52, %44
store i32 1, i32* %13
br label %75
75: ; preds = %74, %71
br label %76
76: ; preds = %75, %34
br label %77
77: ; preds = %76
%78 = load i32, i32* %7
%79 = add nsw i32 %78, 1
store i32 %79, i32* %7
br label %17
80: ; preds = %17
%81 = load i32, i32* %13
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %103
83: ; preds = %80
%84 = load i32, i32* @stderr
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 0
%87 = load i8*, i8** %86
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %87)
%89 = load i32, i32* @stderr
%90 = load i8**, i8*** %5
%91 = getelementptr inbounds i8*, i8** %90, i64 0
%92 = load i8*, i8** %91
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i8* %92)
%94 = load i32, i32* @stderr
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%96 = load i32, i32* @stderr
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%98 = load i32, i32* @stderr
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.7, i64 0, i64 0))
%102 = call i32 @exit(i32 0)
unreachable
103: ; preds = %80
br label %104
104: ; preds = %172, %103
%105 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%106 = load i32, i32* @stdin
%107 = call i64 @fgets(i8* %105, i32 1024, i32 %106)
%108 = icmp ne i64 %107, 0
br i1 %108, label %109, label %173
109: ; preds = %104
%110 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%111 = call i32 @strlen(i8* %110)
%112 = sub nsw i32 %111, 1
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 %113
store i8 0, i8* %114
%115 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%116 = call i32 @stat(i8* %115, %struct.stat* %10)
store i32 %116, i32* %11
%117 = load i32, i32* %11
%118 = icmp eq i32 %117, 0
br i1 %118, label %119, label %165
119: ; preds = %109
%120 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%121 = load i32, i32* %120
%122 = call i64 @S_ISREG(i32 %121)
%123 = icmp ne i64 %122, 0
br i1 %123, label %124, label %165
124: ; preds = %119
%125 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
store i8* %125, i8** %9
%126 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%127 = load i8, i8* %126
%128 = sext i8 %127 to i32
%129 = icmp eq i32 %128, 46
br i1 %129, label %130, label %133
130: ; preds = %124
%131 = load i8*, i8** %9
%132 = getelementptr inbounds i8, i8* %131, i32 1
store i8* %132, i8** %9
br label %133
133: ; preds = %130, %124
%134 = load i8*, i8** %9
%135 = getelementptr inbounds i8, i8* %134, i64 0
%136 = load i8, i8* %135
%137 = sext i8 %136 to i32
%138 = icmp eq i32 %137, 47
br i1 %138, label %139, label %142
139: ; preds = %133
%140 = load i8*, i8** %9
%141 = getelementptr inbounds i8, i8* %140, i32 1
store i8* %141, i8** %9
br label %142
142: ; preds = %139, %133
%143 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%144 = load i32, i32* @O_RDONLY
%145 = call i32 @open(i8* %143, i32 %144)
store i32 %145, i32* %6
%146 = load i32, i32* %6
%147 = icmp sgt i32 %146, 0
br i1 %147, label %148, label %161
148: ; preds = %142
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8** %16
%149 = load i32, i32* %6
%150 = load i8*, i8** %9
%151 = load i32, i32* %14
%152 = load i32, i32* %15
%153 = call i32 @handleFile(i32 %149, i8* %150, i32 %151, i32 %152, i8** %16)
store i32 %153, i32* %12
%154 = load i32, i32* @stderr
%155 = load i8*, i8** %9
%156 = load i32, i32* %12
%157 = load i8*, i8** %16
%158 = call i32 (i32, i8*, ...) @fprintf(i32 %154, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %155, i32 %156, i8* %157)
%159 = load i32, i32* %6
%160 = call i32 @close(i32 %159)
br label %164
161: ; preds = %142
%162 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%163 = call i32 @perror(i8* %162)
br label %164
164: ; preds = %161, %148
br label %172
165: ; preds = %119, %109
%166 = load i32, i32* %11
%167 = icmp ne i32 %166, 0
br i1 %167, label %168, label %171
168: ; preds = %165
%169 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%170 = call i32 @perror(i8* %169)
br label %171
171: ; preds = %168, %165
br label %172
172: ; preds = %171, %164
br label %104
173: ; preds = %104
%174 = call i32 (...) @finishArchive()
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [3 x i8] c"-c\00"
@.str.1 = [3 x i8] c"-l\00"
@stderr = global i32 0
@.str.2 = [37 x i8] c"%s - Program to create espfs images\0A\00"
@.str.3 = [58 x i8] c"Usage: \0Afind | %s [-c compressor] [-l compression_level] \00"
@.str.4 = [13 x i8] c"> out.espfs\0A\00"
@.str.5 = [14 x i8] c"Compressors:\0A\00"
@.str.6 = [19 x i8] c"0 - None(default)\0A\00"
@.str.7 = [143 x i8] c"\0ACompression level: 1 is worst but low RAM usage, higher is better compression \0Abut uses more ram on decompression. -1 = compressors default.\0A\00"
@stdin = global i32 0
@O_RDONLY = global i32 0
@.str.8 = [8 x i8] c"unknown\00"
@.str.9 = [15 x i8] c"%s (%d%%, %s)\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca %struct.stat
%5 = alloca i8*
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = bitcast %struct.stat* %4 to i8*
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %51
9: ; preds = %2, %42
%10 = phi i32 [ %46, %42 ], [ -1, %2 ]
%11 = phi i32 [ %45, %42 ], [ 0, %2 ]
%12 = phi i32 [ %44, %42 ], [ 0, %2 ]
%13 = phi i32 [ %47, %42 ], [ 1, %2 ]
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
%19 = add nsw i32 %13, -2
%20 = icmp sgt i32 %19, %0
%21 = select i1 %18, i1 true, i1 %20
br i1 %21, label %28, label %22
22: ; preds = %9
%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 = tail call i32 @atoi(i8* %26)
br label %42
28: ; preds = %9
%29 = load i8*, i8** %15
%30 = tail call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
%32 = select i1 %31, i1 true, i1 %20
br i1 %32, label %42, label %33
33: ; preds = %28
%34 = add nsw i32 %13, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %1, i64 %35
%37 = load i8*, i8** %36
%38 = tail call i32 @atoi(i8* %37)
%39 = add i32 %38, -10
%40 = icmp ult i32 %39, -9
%41 = select i1 %40, i32 1, i32 %12
br label %42
42: ; preds = %28, %22, %33
%43 = phi i32 [ %23, %22 ], [ %34, %33 ], [ %13, %28 ]
%44 = phi i32 [ %12, %22 ], [ %41, %33 ], [ 1, %28 ]
%45 = phi i32 [ %27, %22 ], [ %11, %33 ], [ %11, %28 ]
%46 = phi i32 [ %10, %22 ], [ %38, %33 ], [ %10, %28 ]
%47 = add nsw i32 %43, 1
%48 = icmp slt i32 %47, %0
br i1 %48, label %9, label %49
49: ; preds = %42
%50 = icmp eq i32 %44, 0
br i1 %50, label %51, label %62
51: ; preds = %2, %49
%52 = phi i32 [ %46, %49 ], [ -1, %2 ]
%53 = phi i32 [ %45, %49 ], [ 0, %2 ]
%54 = load i32, i32* @stdin
%55 = call i64 @fgets(i8* %6, i32 1024, i32 %54)
%56 = icmp eq i64 %55, 0
br i1 %56, label %114, label %57
57: ; preds = %51
%58 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 1
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 2
%61 = bitcast i8** %5 to i8*
br label %78
62: ; preds = %49
%63 = load i32, i32* @stderr
%64 = load i8*, i8** %1
%65 = tail call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %64)
%66 = load i32, i32* @stderr
%67 = load i8*, i8** %1
%68 = tail call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i8* %67)
%69 = load i32, i32* @stderr
%70 = tail call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%71 = load i32, i32* @stderr
%72 = tail call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%73 = load i32, i32* @stderr
%74 = tail call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%75 = load i32, i32* @stderr
%76 = tail call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.7, i64 0, i64 0))
%77 = tail call i32 @exit(i32 0)
unreachable
78: ; preds = %57, %110
%79 = call i32 @strlen(i8* %6)
%80 = add nsw i32 %79, -1
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %81
store i8 0, i8* %82
%83 = call i32 @stat(i8* %6, %struct.stat* %4)
%84 = icmp eq i32 %83, 0
br i1 %84, label %85, label %108
85: ; preds = %78
%86 = load i32, i32* %58
%87 = call i64 @S_ISREG(i32 %86)
%88 = icmp eq i64 %87, 0
br i1 %88, label %110, label %89
89: ; preds = %85
%90 = load i8, i8* %6
%91 = icmp eq i8 %90, 46
%92 = select i1 %91, i8* %59, i8* %6
%93 = load i8, i8* %92
%94 = icmp eq i8 %93, 47
%95 = select i1 %91, i8* %60, i8* %59
%96 = select i1 %94, i8* %95, i8* %92
%97 = load i32, i32* @O_RDONLY
%98 = call i32 @open(i8* %6, i32 %97)
%99 = icmp sgt i32 %98, 0
br i1 %99, label %100, label %106
100: ; preds = %89
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8** %5
%101 = call i32 @handleFile(i32 %98, i8* %96, i32 %53, i32 %52, i8** %5)
%102 = load i32, i32* @stderr
%103 = load i8*, i8** %5
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %102, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %96, i32 %101, i8* %103)
%105 = call i32 @close(i32 %98)
br label %110
106: ; preds = %89
%107 = call i32 @perror(i8* %6)
br label %110
108: ; preds = %78
%109 = call i32 @perror(i8* %6)
br label %110
110: ; preds = %85, %108, %100, %106
%111 = load i32, i32* @stdin
%112 = call i64 @fgets(i8* %6, i32 1024, i32 %111)
%113 = icmp eq i64 %112, 0
br i1 %113, label %114, label %78
114: ; preds = %110, %51
%115 = call i32 (...) @finishArchive()
ret i32 0
}