#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 */
char *_d_malloc(size_t);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int /*<<< orphan*/ strcmp(char const *, char *);
size_t strlen(char const *);
char *_d_uncompress(const char *f) {
  size_t n = strlen(f);
  char *z = NULL;
  if (n > 3 && !strcmp(&f[n - 3], ".gz")) {
    z = _d_malloc(n + 6);
    sprintf(z, "zcat %s", f);
  } else if (n > 3 && !strcmp(&f[n - 3], ".xz")) {
    z = _d_malloc(n + 7);
    sprintf(z, "xzcat %s", f);
  } else if (n > 4 && !strcmp(&f[n - 4], ".bz2")) {
    z = _d_malloc(n + 7);
    sprintf(z, "bzcat %s", f);
  }
  return z;
}


x86 assembly (clang, -O0):
<_d_uncompress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x3,-0x10(%rbp)
jbe    11ba <_d_uncompress+0x7a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
sub    $0x3,%rax
add    %rax,%rdi
lea    0xe7e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11ba <_d_uncompress+0x7a>
mov    -0x10(%rbp),%rdi
add    $0x6,%rdi
call   1050 <_d_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe67(%rip),%rsi
call   1060 <sprintf@plt>
jmp    1271 <_d_uncompress+0x131>
cmpq   $0x3,-0x10(%rbp)
jbe    1213 <_d_uncompress+0xd3>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
sub    $0x3,%rax
add    %rax,%rdi
lea    0xe29(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1213 <_d_uncompress+0xd3>
mov    -0x10(%rbp),%rdi
add    $0x7,%rdi
call   1050 <_d_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xdff(%rip),%rsi
call   1060 <sprintf@plt>
jmp    126c <_d_uncompress+0x12c>
cmpq   $0x4,-0x10(%rbp)
jbe    1267 <_d_uncompress+0x127>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
sub    $0x4,%rax
add    %rax,%rdi
lea    0xddd(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1267 <_d_uncompress+0x127>
mov    -0x10(%rbp),%rdi
add    $0x7,%rdi
call   1050 <_d_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xdb4(%rip),%rsi
call   1060 <sprintf@plt>
jmp    126c <_d_uncompress+0x12c>
jmp    1271 <_d_uncompress+0x131>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_d_uncompress>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
cmp    $0x4,%rax
jb     11a2 <_d_uncompress+0x62>
mov    %rax,%rbx
lea    (%rax,%r14,1),%r15
add    $0xfffffffffffffffd,%r15
lea    0xe9b(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11a6 <_d_uncompress+0x66>
lea    0xe8c(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11be <_d_uncompress+0x7e>
cmp    $0x5,%rbx
jb     11a2 <_d_uncompress+0x62>
lea    (%rbx,%r14,1),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe78(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11d6 <_d_uncompress+0x96>
xor    %ebx,%ebx
jmp    11f7 <_d_uncompress+0xb7>
add    $0x6,%rbx
mov    %rbx,%rdi
call   1050 <_d_malloc@plt>
mov    %rax,%rbx
lea    0xe5b(%rip),%rsi
jmp    11ec <_d_uncompress+0xac>
add    $0x7,%rbx
mov    %rbx,%rdi
call   1050 <_d_malloc@plt>
mov    %rax,%rbx
lea    0xe34(%rip),%rsi
jmp    11ec <_d_uncompress+0xac>
add    $0x7,%rbx
mov    %rbx,%rdi
call   1050 <_d_malloc@plt>
mov    %rax,%rbx
lea    0xe2a(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1060 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c".gz\00"
@.str.1 = [8 x i8] c"zcat %s\00"
@.str.2 = [4 x i8] c".xz\00"
@.str.3 = [9 x i8] c"xzcat %s\00"
@.str.4 = [5 x i8] c".bz2\00"
@.str.5 = [9 x i8] c"bzcat %s\00"
define i8* @_d_uncompress(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @strlen(i8* %5)
store i64 %6, i64* %3
store i8* null, i8** %4
%7 = load i64, i64* %3
%8 = icmp ugt i64 %7, 3
br i1 %8, label %9, label %23
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = load i64, i64* %3
%12 = sub i64 %11, 3
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %9
%17 = load i64, i64* %3
%18 = add i64 %17, 6
%19 = call i8* @_d_malloc(i64 %18)
store i8* %19, i8** %4
%20 = load i8*, i8** %4
%21 = load i8*, i8** %2
%22 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %59
23: ; preds = %9, %1
%24 = load i64, i64* %3
%25 = icmp ugt i64 %24, 3
br i1 %25, label %26, label %40
26: ; preds = %23
%27 = load i8*, i8** %2
%28 = load i64, i64* %3
%29 = sub i64 %28, 3
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = call i32 @strcmp(i8* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %40, label %33
33: ; preds = %26
%34 = load i64, i64* %3
%35 = add i64 %34, 7
%36 = call i8* @_d_malloc(i64 %35)
store i8* %36, i8** %4
%37 = load i8*, i8** %4
%38 = load i8*, i8** %2
%39 = call i32 @sprintf(i8* %37, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %38)
br label %58
40: ; preds = %26, %23
%41 = load i64, i64* %3
%42 = icmp ugt i64 %41, 4
br i1 %42, label %43, label %57
43: ; preds = %40
%44 = load i8*, i8** %2
%45 = load i64, i64* %3
%46 = sub i64 %45, 4
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = call i32 @strcmp(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp ne i32 %48, 0
br i1 %49, label %57, label %50
50: ; preds = %43
%51 = load i64, i64* %3
%52 = add i64 %51, 7
%53 = call i8* @_d_malloc(i64 %52)
store i8* %53, i8** %4
%54 = load i8*, i8** %4
%55 = load i8*, i8** %2
%56 = call i32 @sprintf(i8* %54, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %55)
br label %57
57: ; preds = %50, %43, %40
br label %58
58: ; preds = %57, %33
br label %59
59: ; preds = %58, %16
%60 = load i8*, i8** %4
ret i8* %60
}

LLVM IR (-O2):
@.str = [4 x i8] c".gz\00"
@.str.1 = [8 x i8] c"zcat %s\00"
@.str.2 = [4 x i8] c".xz\00"
@.str.3 = [9 x i8] c"xzcat %s\00"
@.str.4 = [5 x i8] c".bz2\00"
@.str.5 = [9 x i8] c"bzcat %s\00"
define i8* @_d_uncompress(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = icmp ugt i64 %2, 3
br i1 %3, label %4, label %31
4: ; preds = %1
%5 = add i64 %2, -3
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = add i64 %2, 6
%11 = tail call i8* @_d_malloc(i64 %10)
%12 = tail call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %31
13: ; preds = %4
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = add i64 %2, 7
%18 = tail call i8* @_d_malloc(i64 %17)
%19 = tail call i32 @sprintf(i8* dereferenceable(1) %18, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %31
20: ; preds = %13
%21 = icmp ugt i64 %2, 4
br i1 %21, label %22, label %31
22: ; preds = %20
%23 = add i64 %2, -4
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = tail call i32 @strcmp(i8* dereferenceable(1) %24, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = add i64 %2, 7
%29 = tail call i8* @_d_malloc(i64 %28)
%30 = tail call i32 @sprintf(i8* dereferenceable(1) %29, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %0)
br label %31
31: ; preds = %1, %16, %27, %22, %20, %9
%32 = phi i8* [ null, %22 ], [ %29, %27 ], [ null, %20 ], [ %18, %16 ], [ %11, %9 ], [ null, %1 ]
ret i8* %32
}