#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  char *msg;
};
typedef TYPE_1__ z_stream;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
void zlib_error(int ret, char *msg, z_stream *zs) {
  fprintf(stderr, "%s: zlib error (%d): last zlib error: %s\n", msg, ret,
          zs->msg ? zs->msg : "unknown");
  perror("errno:");
  exit(1);
}


x86 assembly (clang, -O0):
<zlib_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     117b <zlib_error+0x4b>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    118b <zlib_error+0x5b>
lea    0xea8(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    118b <zlib_error+0x5b>
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%edi
mov    -0x38(%rbp),%r8
lea    0xe60(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xe86(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<zlib_error>:
push   %rax
mov    %rsi,%rax
mov    %edi,%ecx
mov    0x2ea3(%rip),%rsi
mov    (%rsi),%edi
mov    (%rdx),%rdx
test   %rdx,%rdx
lea    0xede(%rip),%r8
cmovne %rdx,%r8
lea    0xea9(%rip),%rsi
mov    %rax,%rdx
call   1030 <fprintf@plt>
lea    0xecc(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i8* }
@stderr = global i32 0
@.str = [42 x i8] c"%s: zlib error (%d): last zlib error: %s\0A\00"
@.str.1 = [8 x i8] c"unknown\00"
@.str.2 = [7 x i8] c"errno:\00"
define void @zlib_error(i32 %0, i8* %1, %struct.TYPE_3__* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.TYPE_3__*
store i32 %0, i32* %4
store i8* %1, i8** %5
store %struct.TYPE_3__* %2, %struct.TYPE_3__** %6
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %5
%9 = load i32, i32* %4
%10 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 0
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %3
%15 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %15, i32 0, i32 0
%17 = load i8*, i8** %16
br label %19
18: ; preds = %3
br label %19
19: ; preds = %18, %14
%20 = phi i8* [ %17, %14 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %18 ]
%21 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %9, i8* %20)
%22 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i8* }
@stderr = global i32 0
@.str = [42 x i8] c"%s: zlib error (%d): last zlib error: %s\0A\00"
@.str.1 = [8 x i8] c"unknown\00"
@.str.2 = [7 x i8] c"errno:\00"
define void @zlib_error(i32 %0, i8* %1, %struct.TYPE_3__* nocapture %2) {
%4 = load i32, i32* @stderr
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 0
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
%8 = select i1 %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %6
%9 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %0, i8* %8)
%10 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
}