#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 *archdep_filename_parameter(char const *);
int archdep_spawn(char *, char **, char **, int /*<<< orphan*/ *);
int /*<<< orphan*/ ioutil_remove(char *);
int /*<<< orphan*/ lib_free(char *);
char *lib_stralloc(char *);
scalar_t__ strcasecmp(char const *, char *);
size_t strlen(char const *);
char *try_uncompress_with_bzip(const char *name) {
  char *tmp_name = NULL;
  size_t l = strlen(name);
  int exit_status;
  char *argv[4];
  if (l < 5 || strcasecmp(name + l - 4, ".bz2") != 0)
    return NULL;
  argv[0] = lib_stralloc("bzip2");
  argv[1] = lib_stralloc("-cd");
  argv[2] = archdep_filename_parameter(name);
  argv[3] = NULL;
  ;
  exit_status = archdep_spawn("bzip2", argv, &tmp_name, NULL);
  lib_free(argv[0]);
  lib_free(argv[1]);
  lib_free(argv[2]);
  if (exit_status == 0) {
    ;
    return tmp_name;
  } else {
    ;
    ioutil_remove(tmp_name);
    lib_free(tmp_name);
    return NULL;
  }
}


x86 assembly (clang, -O0):
<try_uncompress_with_bzip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x5,-0x20(%rbp)
jb     11be <try_uncompress_with_bzip+0x4e>
mov    -0x10(%rbp),%rdi
add    -0x20(%rbp),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe51(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11cb <try_uncompress_with_bzip+0x5b>
movq   $0x0,-0x8(%rbp)
jmp    1267 <try_uncompress_with_bzip+0xf7>
lea    0xe33(%rip),%rdi
call   1050 <lib_stralloc@plt>
mov    %rax,-0x50(%rbp)
lea    0xe29(%rip),%rdi
call   1050 <lib_stralloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <archdep_filename_parameter@plt>
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x50(%rbp),%rsi
lea    0xdfa(%rip),%rdi
lea    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1070 <archdep_spawn@plt>
mov    %eax,-0x24(%rbp)
mov    -0x50(%rbp),%rdi
call   1060 <lib_free@plt>
mov    -0x48(%rbp),%rdi
call   1060 <lib_free@plt>
mov    -0x40(%rbp),%rdi
call   1060 <lib_free@plt>
cmpl   $0x0,-0x24(%rbp)
jne    124d <try_uncompress_with_bzip+0xdd>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1267 <try_uncompress_with_bzip+0xf7>
mov    -0x18(%rbp),%rdi
call   1090 <ioutil_remove@plt>
mov    -0x18(%rbp),%rdi
call   1060 <lib_free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<try_uncompress_with_bzip>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
call   1080 <strlen@plt>
cmp    $0x5,%rax
jb     1239 <try_uncompress_with_bzip+0xc9>
lea    (%rbx,%rax,1),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe5f(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    1239 <try_uncompress_with_bzip+0xc9>
lea    0xe4f(%rip),%r14
mov    %r14,%rdi
call   1050 <lib_stralloc@plt>
mov    %rax,0x10(%rsp)
lea    0xe41(%rip),%rdi
call   1050 <lib_stralloc@plt>
mov    %rax,0x18(%rsp)
mov    %rbx,%rdi
call   1040 <archdep_filename_parameter@plt>
mov    %rax,0x20(%rsp)
movq   $0x0,0x28(%rsp)
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %r14,%rdi
xor    %ecx,%ecx
call   1070 <archdep_spawn@plt>
mov    %eax,%ebx
mov    0x10(%rsp),%rdi
call   1060 <lib_free@plt>
mov    0x18(%rsp),%rdi
call   1060 <lib_free@plt>
mov    0x20(%rsp),%rdi
call   1060 <lib_free@plt>
mov    0x8(%rsp),%rax
test   %ebx,%ebx
je     123b <try_uncompress_with_bzip+0xcb>
mov    %rax,%rdi
call   1090 <ioutil_remove@plt>
mov    0x8(%rsp),%rdi
call   1060 <lib_free@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c".bz2\00"
@.str.1 = [6 x i8] c"bzip2\00"
@.str.2 = [4 x i8] c"-cd\00"
define i8* @try_uncompress_with_bzip(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca [4 x i8*]
store i8* %0, i8** %3
store i8* null, i8** %4
%8 = load i8*, i8** %3
%9 = call i64 @strlen(i8* %8)
store i64 %9, i64* %5
%10 = load i64, i64* %5
%11 = icmp ult i64 %10, 5
br i1 %11, label %19, label %12
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = load i64, i64* %5
%15 = getelementptr inbounds i8, i8* %13, i64 %14
%16 = getelementptr inbounds i8, i8* %15, i64 -4
%17 = call i64 @strcasecmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %12, %1
store i8* null, i8** %2
br label %49
20: ; preds = %12
%21 = call i8* @lib_stralloc(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%22 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
store i8* %21, i8** %22
%23 = call i8* @lib_stralloc(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%24 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 1
store i8* %23, i8** %24
%25 = load i8*, i8** %3
%26 = call i8* @archdep_filename_parameter(i8* %25)
%27 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 2
store i8* %26, i8** %27
%28 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 3
store i8* null, i8** %28
%29 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
%30 = call i32 @archdep_spawn(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %29, i8** %4, i32* null)
store i32 %30, i32* %6
%31 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
%32 = load i8*, i8** %31
%33 = call i32 @lib_free(i8* %32)
%34 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @lib_free(i8* %35)
%37 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 2
%38 = load i8*, i8** %37
%39 = call i32 @lib_free(i8* %38)
%40 = load i32, i32* %6
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %20
%43 = load i8*, i8** %4
store i8* %43, i8** %2
br label %49
44: ; preds = %20
%45 = load i8*, i8** %4
%46 = call i32 @ioutil_remove(i8* %45)
%47 = load i8*, i8** %4
%48 = call i32 @lib_free(i8* %47)
store i8* null, i8** %2
br label %49
49: ; preds = %44, %42, %19
%50 = load i8*, i8** %2
ret i8* %50
}

LLVM IR (-O2):
@.str = [5 x i8] c".bz2\00"
@.str.1 = [6 x i8] c"bzip2\00"
@.str.2 = [4 x i8] c"-cd\00"
define i8* @try_uncompress_with_bzip(i8* %0) {
%2 = alloca i8*
%3 = alloca [4 x i8*]
%4 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = bitcast [4 x i8*]* %3 to i8*
%7 = icmp ult i64 %5, 5
br i1 %7, label %34, label %8
8: ; preds = %1
%9 = getelementptr inbounds i8, i8* %0, i64 %5
%10 = getelementptr inbounds i8, i8* %9, i64 -4
%11 = tail call i64 @strcasecmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %34
13: ; preds = %8
%14 = tail call i8* @lib_stralloc(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
store i8* %14, i8** %15
%16 = tail call i8* @lib_stralloc(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%17 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 1
store i8* %16, i8** %17
%18 = tail call i8* @archdep_filename_parameter(i8* %0)
%19 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 2
store i8* %18, i8** %19
%20 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 3
store i8* null, i8** %20
%21 = call i32 @archdep_spawn(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %15, i8** %2, i32* null)
%22 = load i8*, i8** %15
%23 = call i32 @lib_free(i8* %22)
%24 = load i8*, i8** %17
%25 = call i32 @lib_free(i8* %24)
%26 = load i8*, i8** %19
%27 = call i32 @lib_free(i8* %26)
%28 = icmp eq i32 %21, 0
%29 = load i8*, i8** %2
br i1 %28, label %34, label %30
30: ; preds = %13
%31 = call i32 @ioutil_remove(i8* %29)
%32 = load i8*, i8** %2
%33 = call i32 @lib_free(i8* %32)
br label %34
34: ; preds = %13, %1, %8, %30
%35 = phi i8* [ null, %30 ], [ null, %8 ], [ null, %1 ], [ %29, %13 ]
ret i8* %35
}