#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_tzx(const char *name) {
  char *tmp_name = NULL;
  size_t l = strlen(name);
  int exit_status;
  char *argv[4];
  if (l < 4 || strcasecmp(name + l - 4, ".tzx") != 0)
    return NULL;
  argv[0] = lib_stralloc("64tzxtap");
  argv[1] = archdep_filename_parameter(name);
  argv[2] = NULL;
  ;
  exit_status = archdep_spawn("64tzxtap", argv, &tmp_name, NULL);
  lib_free(argv[0]);
  lib_free(argv[1]);
  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_tzx>:
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   $0x4,-0x20(%rbp)
jb     11be <try_uncompress_with_tzx+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_tzx+0x5b>
movq   $0x0,-0x8(%rbp)
jmp    124e <try_uncompress_with_tzx+0xde>
lea    0xe33(%rip),%rdi
call   1050 <lib_stralloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <archdep_filename_parameter@plt>
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x40(%rbp)
lea    -0x50(%rbp),%rsi
lea    0xe0a(%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>
cmpl   $0x0,-0x24(%rbp)
jne    1234 <try_uncompress_with_tzx+0xc4>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    124e <try_uncompress_with_tzx+0xde>
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_tzx>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
call   1080 <strlen@plt>
cmp    $0x4,%rax
jb     121a <try_uncompress_with_tzx+0xaa>
lea    (%rbx,%rax,1),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe5f(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    121a <try_uncompress_with_tzx+0xaa>
lea    0xe53(%rip),%r14
mov    %r14,%rdi
call   1050 <lib_stralloc@plt>
mov    %rax,0x10(%rsp)
mov    %rbx,%rdi
call   1040 <archdep_filename_parameter@plt>
mov    %rax,0x18(%rsp)
movq   $0x0,0x20(%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    0x8(%rsp),%rax
test   %ebx,%ebx
je     121c <try_uncompress_with_tzx+0xac>
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".tzx\00"
@.str.1 = [9 x i8] c"64tzxtap\00"
define i8* @try_uncompress_with_tzx(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, 4
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 %44
20: ; preds = %12
%21 = call i8* @lib_stralloc(i8* getelementptr inbounds ([9 x i8], [9 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 = load i8*, i8** %3
%24 = call i8* @archdep_filename_parameter(i8* %23)
%25 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 1
store i8* %24, i8** %25
%26 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 2
store i8* null, i8** %26
%27 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
%28 = call i32 @archdep_spawn(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %27, i8** %4, i32* null)
store i32 %28, i32* %6
%29 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
%30 = load i8*, i8** %29
%31 = call i32 @lib_free(i8* %30)
%32 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @lib_free(i8* %33)
%35 = load i32, i32* %6
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %20
%38 = load i8*, i8** %4
store i8* %38, i8** %2
br label %44
39: ; preds = %20
%40 = load i8*, i8** %4
%41 = call i32 @ioutil_remove(i8* %40)
%42 = load i8*, i8** %4
%43 = call i32 @lib_free(i8* %42)
store i8* null, i8** %2
br label %44
44: ; preds = %39, %37, %19
%45 = load i8*, i8** %2
ret i8* %45
}

LLVM IR (-O2):
@.str = [5 x i8] c".tzx\00"
@.str.1 = [9 x i8] c"64tzxtap\00"
define i8* @try_uncompress_with_tzx(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, 4
br i1 %7, label %30, 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 %30
13: ; preds = %8
%14 = tail call i8* @lib_stralloc(i8* getelementptr inbounds ([9 x i8], [9 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* @archdep_filename_parameter(i8* %0)
%17 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 1
store i8* %16, i8** %17
%18 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 2
store i8* null, i8** %18
%19 = call i32 @archdep_spawn(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %15, i8** %2, i32* null)
%20 = load i8*, i8** %15
%21 = call i32 @lib_free(i8* %20)
%22 = load i8*, i8** %17
%23 = call i32 @lib_free(i8* %22)
%24 = icmp eq i32 %19, 0
%25 = load i8*, i8** %2
br i1 %24, label %30, label %26
26: ; preds = %13
%27 = call i32 @ioutil_remove(i8* %25)
%28 = load i8*, i8** %2
%29 = call i32 @lib_free(i8* %28)
br label %30
30: ; preds = %13, %1, %8, %26
%31 = phi i8* [ null, %26 ], [ null, %8 ], [ null, %1 ], [ %25, %13 ]
ret i8* %31
}