#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 */
#define Z_BUF_ERROR 133
#define Z_DATA_ERROR 132
#define Z_MEM_ERROR 131
#define Z_NEED_DICT 130
#define Z_OK 129
#define Z_STREAM_END 128
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ stderr;
void testcompval(int rv, char *func) {
  switch (rv) {
  case Z_OK:
  case Z_STREAM_END:
  case Z_NEED_DICT:
    break;
  case Z_MEM_ERROR:
    fprintf(stderr, "%s: failed due to lack of memory\n", func);
    exit(7);
  case Z_BUF_ERROR:
    fprintf(stderr, "%s: failed due to lack of room in buffer\n", func);
    exit(7);
  case Z_DATA_ERROR:
    fprintf(stderr, "%s: failed due to corrupted/incomplete data\n", func);
    exit(7);
  default:
    fprintf(stderr, "%s: unexpected error %d\n", func, rv);
    exit(7);
  }
}


x86 assembly (clang, -O0):
<testcompval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     11cc <testcompval+0xac>
mov    -0x18(%rbp),%rax
lea    0xeb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    11f4 <testcompval+0xd4>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x7,%edi
call   1040 <exit@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xea4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x7,%edi
call   1040 <exit@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xea9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x7,%edi
call   1040 <exit@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x4(%rbp),%ecx
lea    0xeae(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x7,%edi
call   1040 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testcompval>:
push   %rax
mov    %edi,%ecx
lea    -0x80(%rcx),%eax
cmp    $0x3,%eax
jae    112d <testcompval+0xd>
pop    %rax
ret
mov    %rsi,%rdx
mov    0x2ea9(%rip),%rax
cmp    $0x85,%ecx
je     115a <testcompval+0x3a>
cmp    $0x84,%ecx
je     1165 <testcompval+0x45>
cmp    $0x83,%ecx
jne    117f <testcompval+0x5f>
mov    (%rax),%edi
lea    0xea8(%rip),%rsi
jmp    116e <testcompval+0x4e>
mov    (%rax),%edi
lea    0xebf(%rip),%rsi
jmp    116e <testcompval+0x4e>
mov    (%rax),%edi
lea    0xede(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x7,%edi
call   1040 <exit@plt>
mov    (%rax),%edi
lea    0xef1(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x7,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"%s: failed due to lack of memory\0A\00"
@.str.1 = [42 x i8] c"%s: failed due to lack of room in buffer\0A\00"
@.str.2 = [45 x i8] c"%s: failed due to corrupted/incomplete data\0A\00"
@.str.3 = [25 x i8] c"%s: unexpected error %d\0A\00"
define void @testcompval(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
switch i32 %5, label %22 [
i32 129, label %6
i32 128, label %6
i32 130, label %6
i32 131, label %7
i32 133, label %12
i32 132, label %17
]
6: ; preds = %2, %2, %2
br label %28
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %4
%10 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = call i32 @exit(i32 7)
unreachable
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %4
%15 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 7)
unreachable
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %4
%20 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 7)
unreachable
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %4
%25 = load i32, i32* %3
%26 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %24, i32 %25)
%27 = call i32 @exit(i32 7)
unreachable
28: ; preds = %6
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"%s: failed due to lack of memory\0A\00"
@.str.1 = [42 x i8] c"%s: failed due to lack of room in buffer\0A\00"
@.str.2 = [45 x i8] c"%s: failed due to corrupted/incomplete data\0A\00"
@.str.3 = [25 x i8] c"%s: unexpected error %d\0A\00"
define void @testcompval(i32 %0, i8* %1) {
switch i32 %0, label %15 [
i32 129, label %19
i32 128, label %19
i32 130, label %19
i32 131, label %3
i32 133, label %7
i32 132, label %11
]
3: ; preds = %2
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %1)
%6 = tail call i32 @exit(i32 7)
unreachable
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%10 = tail call i32 @exit(i32 7)
unreachable
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%14 = tail call i32 @exit(i32 7)
unreachable
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %1, i32 %0)
%18 = tail call i32 @exit(i32 7)
unreachable
19: ; preds = %2, %2, %2
ret void
}