#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 */
int /*<<< orphan*/ error(char *);
int inflate();
int gunzip() {
  int res;
  if ((res = inflate())) {
    switch (res) {
    case 0:
      break;
    case 1:
      error("invalid compressed format (err=1)");
      break;
    case 2:
      error("invalid compressed format (err=2)");
      break;
    case 3:
      error("out of memory");
      break;
    default:
      error("invalid compressed format (other)");
    }
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<gunzip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <inflate@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     11b0 <gunzip+0x90>
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x3,%rax
ja     1198 <gunzip+0x78>
mov    -0x10(%rbp),%rax
lea    0xea9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    11a4 <gunzip+0x84>
lea    0xea4(%rip),%rdi
call   1040 <error@plt>
jmp    11a4 <gunzip+0x84>
lea    0xeb5(%rip),%rdi
call   1040 <error@plt>
jmp    11a4 <gunzip+0x84>
lea    0xec6(%rip),%rdi
call   1040 <error@plt>
jmp    11a4 <gunzip+0x84>
lea    0xec3(%rip),%rdi
call   1040 <error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b7 <gunzip+0x97>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gunzip>:
push   %rax
xor    %eax,%eax
call   1030 <inflate@plt>
cmp    $0x3,%eax
ja     114f <gunzip+0x2f>
lea    0xedc(%rip),%rdi
mov    %eax,%ecx
lea    0xec3(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xee5(%rip),%rdi
jmp    115f <gunzip+0x3f>
lea    0xf0c(%rip),%rdi
jmp    115f <gunzip+0x3f>
lea    0xef5(%rip),%rdi
call   1040 <error@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"invalid compressed format (err=1)\00"
@.str.1 = [34 x i8] c"invalid compressed format (err=2)\00"
@.str.2 = [14 x i8] c"out of memory\00"
@.str.3 = [34 x i8] c"invalid compressed format (other)\00"
define i32 @gunzip() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @inflate()
store i32 %3, i32* %2
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %17
5: ; preds = %0
%6 = load i32, i32* %2
switch i32 %6, label %14 [
i32 0, label %7
i32 1, label %8
i32 2, label %10
i32 3, label %12
]
7: ; preds = %5
br label %16
8: ; preds = %5
%9 = call i32 @error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %16
10: ; preds = %5
%11 = call i32 @error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %16
12: ; preds = %5
%13 = call i32 @error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %16
14: ; preds = %5
%15 = call i32 @error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %14, %12, %10, %8, %7
store i32 -1, i32* %1
br label %18
17: ; preds = %0
store i32 0, i32* %1
br label %18
18: ; preds = %17, %16
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [34 x i8] c"invalid compressed format (err=1)\00"
@.str.1 = [34 x i8] c"invalid compressed format (err=2)\00"
@.str.2 = [14 x i8] c"out of memory\00"
@.str.3 = [34 x i8] c"invalid compressed format (other)\00"
define i32 @gunzip() {
%1 = tail call i32 (...) @inflate()
switch i32 %1, label %4 [
i32 0, label %8
i32 3, label %3
i32 1, label %5
i32 2, label %2
]
2: ; preds = %0
br label %5
3: ; preds = %0
br label %5
4: ; preds = %0
br label %5
5: ; preds = %0, %4, %3, %2
%6 = phi i8* [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), %0 ]
%7 = tail call i32 @error(i8* %6)
br label %8
8: ; preds = %5, %0
%9 = phi i32 [ %1, %0 ], [ -1, %5 ]
ret i32 %9
}