#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 */

/* Variables and functions */
scalar_t__ execcmd(char *);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char *);
char *strrchr(char *, char);
int /*<<< orphan*/ trace(int, char *, ...);
extern int uncompress(const char *file, char *uncfile) {
  int stat = 0;
  char *p, cmd[2048] = "", tmpfile[1024] = "", buff[1024], *fname, *dir = "";
  trace(3, "uncompress: file=%s\n", file);
  strcpy(tmpfile, file);
  if (!(p = strrchr(tmpfile, '.')))
    return 0;
  if (!strcmp(p, ".z") || !strcmp(p, ".Z") || !strcmp(p, ".gz") ||
      !strcmp(p, ".GZ") || !strcmp(p, ".zip") || !strcmp(p, ".ZIP")) {
    strcpy(uncfile, tmpfile);
    uncfile[p - tmpfile] = '\0';
    sprintf(cmd, "gzip -f -d -c \"%s\" > \"%s\"", tmpfile, uncfile);
    if (execcmd(cmd)) {
      remove(uncfile);
      return -1;
    }
    strcpy(tmpfile, uncfile);
    stat = 1;
  }
  if ((p = strrchr(tmpfile, '.')) && !strcmp(p, ".tar")) {
    strcpy(uncfile, tmpfile);
    uncfile[p - tmpfile] = '\0';
    strcpy(buff, tmpfile);
    fname = buff;
    if ((p = strrchr(buff, '/'))) {
      *p = '\0';
      dir = fname;
      fname = p + 1;
    }
    sprintf(cmd, "tar -C \"%s\" -xf \"%s\"", dir, tmpfile);
    if (execcmd(cmd)) {
      if (stat)
        remove(tmpfile);
      return -1;
    }
    if (stat)
      remove(tmpfile);
    stat = 1;
  } else if ((p = strrchr(tmpfile, '.')) && strlen(p) > 3 &&
             (*(p + 3) == 'd' || *(p + 3) == 'D')) {
    strcpy(uncfile, tmpfile);
    uncfile[p - tmpfile + 3] = *(p + 3) == 'D' ? 'O' : 'o';
    sprintf(cmd, "crx2rnx < \"%s\" > \"%s\"", tmpfile, uncfile);
    if (execcmd(cmd)) {
      remove(uncfile);
      if (stat)
        remove(tmpfile);
      return -1;
    }
    if (stat)
      remove(tmpfile);
    stat = 1;
  }
  trace(3, "uncompress: stat=%d\n", stat);
  return stat;
}


x86 assembly (clang, -O0):
<uncompress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x830(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1080 <memset@plt>
lea    -0xc30(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
lea    0xeb4(%rip),%rax
mov    %rax,-0x1040(%rbp)
mov    -0x10(%rbp),%rdx
mov    $0x3,%edi
lea    0xe12(%rip),%rsi
mov    $0x0,%al
call   10a0 <trace@plt>
lea    -0xc30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0xc30(%rbp),%rdi
mov    $0x2e,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1230 <uncompress+0xa0>
movl   $0x0,-0x4(%rbp)
jmp    15b9 <uncompress+0x429>
mov    -0x28(%rbp),%rdi
lea    0xdda(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
je     12c6 <uncompress+0x136>
mov    -0x28(%rbp),%rdi
lea    0xdc4(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
je     12c6 <uncompress+0x136>
mov    -0x28(%rbp),%rdi
lea    0xdae(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
je     12c6 <uncompress+0x136>
mov    -0x28(%rbp),%rdi
lea    0xd99(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
je     12c6 <uncompress+0x136>
mov    -0x28(%rbp),%rdi
lea    0xd84(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
je     12c6 <uncompress+0x136>
mov    -0x28(%rbp),%rdi
lea    0xd70(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    134c <uncompress+0x1bc>
mov    -0x18(%rbp),%rdi
lea    -0xc30(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
lea    -0xc30(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
lea    -0x830(%rbp),%rdi
lea    -0xc30(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xd28(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x830(%rbp),%rdi
call   1050 <execcmd@plt>
cmp    $0x0,%rax
je     1335 <uncompress+0x1a5>
mov    -0x18(%rbp),%rdi
call   1030 <remove@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b9 <uncompress+0x429>
lea    -0xc30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x1,-0x1c(%rbp)
lea    -0xc30(%rbp),%rdi
mov    $0x2e,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1489 <uncompress+0x2f9>
mov    -0x28(%rbp),%rdi
lea    0xcd1(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    1489 <uncompress+0x2f9>
mov    -0x18(%rbp),%rdi
lea    -0xc30(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
lea    -0xc30(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
lea    -0x1030(%rbp),%rdi
lea    -0xc30(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x1030(%rbp),%rax
mov    %rax,-0x1038(%rbp)
lea    -0x1030(%rbp),%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     140e <uncompress+0x27e>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x1038(%rbp),%rax
mov    %rax,-0x1040(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1038(%rbp)
lea    -0x830(%rbp),%rdi
mov    -0x1040(%rbp),%rdx
lea    -0xc30(%rbp),%rcx
lea    0xc22(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x830(%rbp),%rdi
call   1050 <execcmd@plt>
cmp    $0x0,%rax
je     1467 <uncompress+0x2d7>
cmpl   $0x0,-0x1c(%rbp)
je     145b <uncompress+0x2cb>
lea    -0xc30(%rbp),%rdi
call   1030 <remove@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b9 <uncompress+0x429>
cmpl   $0x0,-0x1c(%rbp)
je     147d <uncompress+0x2ed>
lea    -0xc30(%rbp),%rdi
call   1030 <remove@plt>
movl   $0x1,-0x1c(%rbp)
jmp    159d <uncompress+0x40d>
lea    -0xc30(%rbp),%rdi
mov    $0x2e,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1598 <uncompress+0x408>
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x3,%eax
jle    1598 <uncompress+0x408>
mov    -0x28(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x64,%eax
je     14dc <uncompress+0x34c>
mov    -0x28(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x44,%eax
jne    1598 <uncompress+0x408>
mov    -0x18(%rbp),%rdi
lea    -0xc30(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rax
movsbl 0x3(%rax),%edx
mov    $0x6f,%eax
mov    $0x4f,%ecx
cmp    $0x44,%edx
cmove  %ecx,%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
lea    -0xc30(%rbp),%rsi
sub    %rsi,%rcx
mov    %dl,0x3(%rax,%rcx,1)
lea    -0x830(%rbp),%rdi
lea    -0xc30(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xb2c(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x830(%rbp),%rdi
call   1050 <execcmd@plt>
cmp    $0x0,%rax
je     157b <uncompress+0x3eb>
mov    -0x18(%rbp),%rdi
call   1030 <remove@plt>
cmpl   $0x0,-0x1c(%rbp)
je     156f <uncompress+0x3df>
lea    -0xc30(%rbp),%rdi
call   1030 <remove@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b9 <uncompress+0x429>
cmpl   $0x0,-0x1c(%rbp)
je     1591 <uncompress+0x401>
lea    -0xc30(%rbp),%rdi
call   1030 <remove@plt>
movl   $0x1,-0x1c(%rbp)
jmp    159d <uncompress+0x40d>
mov    -0x1c(%rbp),%edx
mov    $0x3,%edi
lea    0xacb(%rip),%rsi
mov    $0x0,%al
call   10a0 <trace@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uncompress>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1000,%rsp
mov    %rsi,%r14
mov    %rdi,%rbp
lea    0x400(%rsp),%rdi
xor    %r15d,%r15d
mov    $0x800,%edx
xor    %esi,%esi
call   1080 <memset@plt>
mov    %rsp,%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <memset@plt>
lea    0xe2b(%rip),%rsi
mov    $0x3,%edi
mov    %rbp,%rdx
xor    %eax,%eax
call   10a0 <trace@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1070 <strrchr@plt>
test   %rax,%rax
je     143c <uncompress+0x2ac>
mov    %rax,%rbp
lea    0xe06(%rip),%rsi
mov    %rax,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1282 <uncompress+0xf2>
lea    0xdf6(%rip),%rsi
mov    %rbp,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1282 <uncompress+0xf2>
lea    0xde6(%rip),%rsi
mov    %rbp,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1282 <uncompress+0xf2>
lea    0xdd7(%rip),%rsi
mov    %rbp,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1282 <uncompress+0xf2>
lea    0xdc8(%rip),%rsi
mov    %rbp,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1282 <uncompress+0xf2>
lea    0xdba(%rip),%rsi
mov    %rbp,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1282 <uncompress+0xf2>
xor    %r15d,%r15d
mov    $0x1,%r12b
jmp    12e6 <uncompress+0x156>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
sub    %rbx,%rbp
movb   $0x0,(%r14,%rbp,1)
lea    0xd91(%rip),%rsi
lea    0x400(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   10b0 <sprintf@plt>
mov    %rbp,%rdi
call   1050 <execcmd@plt>
test   %rax,%rax
je     12d2 <uncompress+0x142>
mov    %r14,%rdi
call   1030 <remove@plt>
mov    $0xffffffff,%r15d
jmp    143c <uncompress+0x2ac>
mov    %rsp,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    $0x1,%r15d
xor    %r12d,%r12d
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1070 <strrchr@plt>
test   %rax,%rax
je     1426 <uncompress+0x296>
mov    %rax,%rbp
lea    0xd3e(%rip),%rsi
mov    %rax,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     138a <uncompress+0x1fa>
mov    %rbp,%rdi
call   1060 <strlen@plt>
cmp    $0x4,%eax
jl     1426 <uncompress+0x296>
mov    0x3(%rbp),%al
or     $0x20,%al
cmp    $0x64,%al
jne    1426 <uncompress+0x296>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
cmpb   $0x44,0x3(%rbp)
setne  %al
shl    $0x5,%al
or     $0x4f,%al
sub    %rbx,%rbp
mov    %al,0x3(%rbp,%r14,1)
lea    0xd08(%rip),%rsi
lea    0x400(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   10b0 <sprintf@plt>
mov    %rbp,%rdi
call   1050 <execcmd@plt>
test   %rax,%rax
je     140d <uncompress+0x27d>
mov    %r14,%rdi
call   1030 <remove@plt>
jmp    13f8 <uncompress+0x268>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
sub    %rbx,%rbp
movb   $0x0,(%r14,%rbp,1)
lea    0xc00(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
test   %rax,%rax
je     13c7 <uncompress+0x237>
movb   $0x0,(%rax)
jmp    13ce <uncompress+0x23e>
lea    0xcbd(%rip),%rbp
lea    0xc77(%rip),%rsi
lea    0x400(%rsp),%rbx
mov    %rsp,%rcx
mov    %rbx,%rdi
mov    %rbp,%rdx
call   10b0 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <execcmd@plt>
test   %rax,%rax
je     140d <uncompress+0x27d>
mov    $0xffffffff,%r15d
test   %r12b,%r12b
jne    143c <uncompress+0x2ac>
mov    %rsp,%rdi
call   1030 <remove@plt>
jmp    143c <uncompress+0x2ac>
mov    $0x1,%r15d
test   %r12b,%r12b
jne    1426 <uncompress+0x296>
mov    %rsp,%rdi
call   1030 <remove@plt>
mov    $0x1,%r15d
lea    0xc4a(%rip),%rsi
mov    $0x3,%edi
mov    %r15d,%edx
xor    %eax,%eax
call   10a0 <trace@plt>
mov    %r15d,%eax
add    $0x1000,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [21 x i8] c"uncompress: file=%s\0A\00"
@.str.2 = [3 x i8] c".z\00"
@.str.3 = [3 x i8] c".Z\00"
@.str.4 = [4 x i8] c".gz\00"
@.str.5 = [4 x i8] c".GZ\00"
@.str.6 = [5 x i8] c".zip\00"
@.str.7 = [5 x i8] c".ZIP\00"
@.str.8 = [26 x i8] c"gzip -f -d -c \22%s\22 > \22%s\22\00"
@.str.9 = [5 x i8] c".tar\00"
@.str.10 = [21 x i8] c"tar -C \22%s\22 -xf \22%s\22\00"
@.str.11 = [22 x i8] c"crx2rnx < \22%s\22 > \22%s\22\00"
@.str.12 = [21 x i8] c"uncompress: stat=%d\0A\00"
define i32 @uncompress(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [2048 x i8]
%9 = alloca [1024 x i8]
%10 = alloca [1024 x i8]
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
%13 = bitcast [2048 x i8]* %8 to i8*
%14 = bitcast [1024 x i8]* %9 to i8*
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %12
%15 = load i8*, i8** %4
%16 = call i32 (i32, i8*, ...) @trace(i32 3, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%18 = load i8*, i8** %4
%19 = call i32 @strcpy(i8* %17, i8* %18)
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%21 = call i8* @strrchr(i8* %20, i8 signext 46)
store i8* %21, i8** %7
%22 = icmp ne i8* %21, null
br i1 %22, label %24, label %23
23: ; preds = %2
store i32 0, i32* %3
br label %194
24: ; preds = %2
%25 = load i8*, i8** %7
%26 = call i32 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %48
28: ; preds = %24
%29 = load i8*, i8** %7
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %48
32: ; preds = %28
%33 = load i8*, i8** %7
%34 = call i32 @strcmp(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %48
36: ; preds = %32
%37 = load i8*, i8** %7
%38 = call i32 @strcmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %48
40: ; preds = %36
%41 = load i8*, i8** %7
%42 = call i32 @strcmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load i8*, i8** %7
%46 = call i32 @strcmp(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%47 = icmp ne i32 %46, 0
br i1 %47, label %73, label %48
48: ; preds = %44, %40, %36, %32, %28, %24
%49 = load i8*, i8** %5
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%51 = call i32 @strcpy(i8* %49, i8* %50)
%52 = load i8*, i8** %5
%53 = load i8*, i8** %7
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%55 = ptrtoint i8* %53 to i64
%56 = ptrtoint i8* %54 to i64
%57 = sub i64 %55, %56
%58 = getelementptr inbounds i8, i8* %52, i64 %57
store i8 0, i8* %58
%59 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%61 = load i8*, i8** %5
%62 = call i32 @sprintf(i8* %59, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %60, i8* %61)
%63 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%64 = call i64 @execcmd(i8* %63)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %48
%67 = load i8*, i8** %5
%68 = call i32 @remove(i8* %67)
store i32 -1, i32* %3
br label %194
69: ; preds = %48
%70 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%71 = load i8*, i8** %5
%72 = call i32 @strcpy(i8* %70, i8* %71)
store i32 1, i32* %6
br label %73
73: ; preds = %69, %44
%74 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%75 = call i8* @strrchr(i8* %74, i8 signext 46)
store i8* %75, i8** %7
%76 = icmp ne i8* %75, null
br i1 %76, label %77, label %126
77: ; preds = %73
%78 = load i8*, i8** %7
%79 = call i32 @strcmp(i8* %78, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%80 = icmp ne i32 %79, 0
br i1 %80, label %126, label %81
81: ; preds = %77
%82 = load i8*, i8** %5
%83 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%84 = call i32 @strcpy(i8* %82, i8* %83)
%85 = load i8*, i8** %5
%86 = load i8*, i8** %7
%87 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%88 = ptrtoint i8* %86 to i64
%89 = ptrtoint i8* %87 to i64
%90 = sub i64 %88, %89
%91 = getelementptr inbounds i8, i8* %85, i64 %90
store i8 0, i8* %91
%92 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%93 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%94 = call i32 @strcpy(i8* %92, i8* %93)
%95 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
store i8* %95, i8** %11
%96 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%97 = call i8* @strrchr(i8* %96, i8 signext 47)
store i8* %97, i8** %7
%98 = icmp ne i8* %97, null
br i1 %98, label %99, label %104
99: ; preds = %81
%100 = load i8*, i8** %7
store i8 0, i8* %100
%101 = load i8*, i8** %11
store i8* %101, i8** %12
%102 = load i8*, i8** %7
%103 = getelementptr inbounds i8, i8* %102, i64 1
store i8* %103, i8** %11
br label %104
104: ; preds = %99, %81
%105 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%106 = load i8*, i8** %12
%107 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%108 = call i32 @sprintf(i8* %105, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* %106, i8* %107)
%109 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%110 = call i64 @execcmd(i8* %109)
%111 = icmp ne i64 %110, 0
br i1 %111, label %112, label %119
112: ; preds = %104
%113 = load i32, i32* %6
%114 = icmp ne i32 %113, 0
br i1 %114, label %115, label %118
115: ; preds = %112
%116 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%117 = call i32 @remove(i8* %116)
br label %118
118: ; preds = %115, %112
store i32 -1, i32* %3
br label %194
119: ; preds = %104
%120 = load i32, i32* %6
%121 = icmp ne i32 %120, 0
br i1 %121, label %122, label %125
122: ; preds = %119
%123 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%124 = call i32 @remove(i8* %123)
br label %125
125: ; preds = %122, %119
store i32 1, i32* %6
br label %190
126: ; preds = %77, %73
%127 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%128 = call i8* @strrchr(i8* %127, i8 signext 46)
store i8* %128, i8** %7
%129 = icmp ne i8* %128, null
br i1 %129, label %130, label %189
130: ; preds = %126
%131 = load i8*, i8** %7
%132 = call i32 @strlen(i8* %131)
%133 = icmp sgt i32 %132, 3
br i1 %133, label %134, label %189
134: ; preds = %130
%135 = load i8*, i8** %7
%136 = getelementptr inbounds i8, i8* %135, i64 3
%137 = load i8, i8* %136
%138 = sext i8 %137 to i32
%139 = icmp eq i32 %138, 100
br i1 %139, label %146, label %140
140: ; preds = %134
%141 = load i8*, i8** %7
%142 = getelementptr inbounds i8, i8* %141, i64 3
%143 = load i8, i8* %142
%144 = sext i8 %143 to i32
%145 = icmp eq i32 %144, 68
br i1 %145, label %146, label %189
146: ; preds = %140, %134
%147 = load i8*, i8** %5
%148 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%149 = call i32 @strcpy(i8* %147, i8* %148)
%150 = load i8*, i8** %7
%151 = getelementptr inbounds i8, i8* %150, i64 3
%152 = load i8, i8* %151
%153 = sext i8 %152 to i32
%154 = icmp eq i32 %153, 68
%155 = zext i1 %154 to i64
%156 = select i1 %154, i32 79, i32 111
%157 = trunc i32 %156 to i8
%158 = load i8*, i8** %5
%159 = load i8*, i8** %7
%160 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%161 = ptrtoint i8* %159 to i64
%162 = ptrtoint i8* %160 to i64
%163 = sub i64 %161, %162
%164 = add nsw i64 %163, 3
%165 = getelementptr inbounds i8, i8* %158, i64 %164
store i8 %157, i8* %165
%166 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%167 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%168 = load i8*, i8** %5
%169 = call i32 @sprintf(i8* %166, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8* %167, i8* %168)
%170 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%171 = call i64 @execcmd(i8* %170)
%172 = icmp ne i64 %171, 0
br i1 %172, label %173, label %182
173: ; preds = %146
%174 = load i8*, i8** %5
%175 = call i32 @remove(i8* %174)
%176 = load i32, i32* %6
%177 = icmp ne i32 %176, 0
br i1 %177, label %178, label %181
178: ; preds = %173
%179 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%180 = call i32 @remove(i8* %179)
br label %181
181: ; preds = %178, %173
store i32 -1, i32* %3
br label %194
182: ; preds = %146
%183 = load i32, i32* %6
%184 = icmp ne i32 %183, 0
br i1 %184, label %185, label %188
185: ; preds = %182
%186 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%187 = call i32 @remove(i8* %186)
br label %188
188: ; preds = %185, %182
store i32 1, i32* %6
br label %189
189: ; preds = %188, %140, %130, %126
br label %190
190: ; preds = %189, %125
%191 = load i32, i32* %6
%192 = call i32 (i32, i8*, ...) @trace(i32 3, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i32 %191)
%193 = load i32, i32* %6
store i32 %193, i32* %3
br label %194
194: ; preds = %190, %181, %118, %66, %23
%195 = load i32, i32* %3
ret i32 %195
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [21 x i8] c"uncompress: file=%s\0A\00"
@.str.2 = [3 x i8] c".z\00"
@.str.3 = [3 x i8] c".Z\00"
@.str.4 = [4 x i8] c".gz\00"
@.str.5 = [4 x i8] c".GZ\00"
@.str.6 = [5 x i8] c".zip\00"
@.str.7 = [5 x i8] c".ZIP\00"
@.str.8 = [26 x i8] c"gzip -f -d -c \22%s\22 > \22%s\22\00"
@.str.9 = [5 x i8] c".tar\00"
@.str.10 = [21 x i8] c"tar -C \22%s\22 -xf \22%s\22\00"
@.str.11 = [22 x i8] c"crx2rnx < \22%s\22 > \22%s\22\00"
@.str.12 = [21 x i8] c"uncompress: stat=%d\0A\00"
define i32 @uncompress(i8* %0, i8* %1) {
%3 = alloca [2048 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = tail call i32 (i32, i8*, ...) @trace(i32 3, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = call i32 @strcpy(i8* %7, i8* %0)
%11 = call i8* @strrchr(i8* %7, i8 signext 46)
%12 = icmp eq i8* %11, null
br i1 %12, label %100, label %13
13: ; preds = %2
%14 = call i32 @strcmp(i8* %11, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %31, label %16
16: ; preds = %13
%17 = call i32 @strcmp(i8* %11, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %31, label %19
19: ; preds = %16
%20 = call i32 @strcmp(i8* %11, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %31, label %22
22: ; preds = %19
%23 = call i32 @strcmp(i8* %11, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %22
%26 = call i32 @strcmp(i8* %11, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = call i32 @strcmp(i8* %11, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %44
31: ; preds = %28, %25, %22, %19, %16, %13
%32 = call i32 @strcpy(i8* %1, i8* %7)
%33 = ptrtoint i8* %11 to i64
%34 = ptrtoint [1024 x i8]* %4 to i64
%35 = sub i64 %33, %34
%36 = getelementptr inbounds i8, i8* %1, i64 %35
store i8 0, i8* %36
%37 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %7, i8* %1)
%38 = call i64 @execcmd(i8* %6)
%39 = icmp eq i64 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %31
%41 = call i32 @remove(i8* %1)
br label %100
42: ; preds = %31
%43 = call i32 @strcpy(i8* %7, i8* %1)
br label %44
44: ; preds = %42, %28
%45 = phi i1 [ false, %42 ], [ true, %28 ]
%46 = phi i32 [ 1, %42 ], [ 0, %28 ]
%47 = call i8* @strrchr(i8* %7, i8 signext 46)
%48 = icmp eq i8* %47, null
br i1 %48, label %97, label %49
49: ; preds = %44
%50 = call i32 @strcmp(i8* %47, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %71
52: ; preds = %49
%53 = call i32 @strcpy(i8* %1, i8* %7)
%54 = ptrtoint i8* %47 to i64
%55 = ptrtoint [1024 x i8]* %4 to i64
%56 = sub i64 %54, %55
%57 = getelementptr inbounds i8, i8* %1, i64 %56
store i8 0, i8* %57
%58 = call i32 @strcpy(i8* %8, i8* %7)
%59 = call i8* @strrchr(i8* %8, i8 signext 47)
%60 = icmp eq i8* %59, null
br i1 %60, label %62, label %61
61: ; preds = %52
store i8 0, i8* %59
br label %62
62: ; preds = %61, %52
%63 = phi i8* [ %8, %61 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %52 ]
%64 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* %63, i8* %7)
%65 = call i64 @execcmd(i8* %6)
%66 = icmp eq i64 %65, 0
br i1 %66, label %70, label %67
67: ; preds = %62
br i1 %45, label %100, label %68
68: ; preds = %67
%69 = call i32 @remove(i8* %7)
br label %100
70: ; preds = %62
br i1 %45, label %97, label %95
71: ; preds = %49
%72 = call i32 @strlen(i8* %47)
%73 = icmp sgt i32 %72, 3
br i1 %73, label %74, label %97
74: ; preds = %71
%75 = getelementptr inbounds i8, i8* %47, i64 3
%76 = load i8, i8* %75
switch i8 %76, label %97 [
i8 100, label %77
i8 68, label %77
]
77: ; preds = %74, %74
%78 = call i32 @strcpy(i8* %1, i8* %7)
%79 = load i8, i8* %75
%80 = icmp eq i8 %79, 68
%81 = select i1 %80, i8 79, i8 111
%82 = ptrtoint i8* %47 to i64
%83 = ptrtoint [1024 x i8]* %4 to i64
%84 = sub i64 3, %83
%85 = add i64 %84, %82
%86 = getelementptr inbounds i8, i8* %1, i64 %85
store i8 %81, i8* %86
%87 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8* %7, i8* %1)
%88 = call i64 @execcmd(i8* %6)
%89 = icmp eq i64 %88, 0
br i1 %89, label %94, label %90
90: ; preds = %77
%91 = call i32 @remove(i8* %1)
br i1 %45, label %100, label %92
92: ; preds = %90
%93 = call i32 @remove(i8* %7)
br label %100
94: ; preds = %77
br i1 %45, label %97, label %95
95: ; preds = %94, %70
%96 = call i32 @remove(i8* %7)
br label %97
97: ; preds = %95, %44, %94, %74, %70, %71
%98 = phi i32 [ %46, %71 ], [ 1, %70 ], [ %46, %74 ], [ 1, %94 ], [ %46, %44 ], [ 1, %95 ]
%99 = call i32 (i32, i8*, ...) @trace(i32 3, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i32 %98)
br label %100
100: ; preds = %90, %92, %67, %68, %2, %97, %40
%101 = phi i32 [ %98, %97 ], [ -1, %40 ], [ 0, %2 ], [ -1, %68 ], [ -1, %67 ], [ -1, %92 ], [ -1, %90 ]
ret i32 %101
}