#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 Z_ERRNO;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *,
                           char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
char *zError(int);
int gzerr(int err, char *msg, z_stream *s) {
  if (err) {
    fprintf(stderr, "%s: %s%s%s\n", msg,
            (err == Z_ERRNO) ? strerror(errno) : zError(err),
            s->msg ? " - " : "", s->msg ? s->msg : "");
  }
  return err;
}


x86 assembly (clang, -O0):
<gzerr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     120c <gzerr+0xdc>
mov    0x2e84(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e7d(%rip),%rcx
cmp    (%rcx),%eax
jne    118a <gzerr+0x5a>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %rax,-0x30(%rbp)
jmp    1196 <gzerr+0x66>
mov    -0x4(%rbp),%edi
call   1030 <zError@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
lea    0xe5f(%rip),%rax
lea    0xe59(%rip),%rcx
cmp    $0x0,%rdx
cmovne %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11dd <gzerr+0xad>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    11ed <gzerr+0xbd>
lea    0xe27(%rip),%rax
mov    %rax,-0x48(%rbp)
jmp    11ed <gzerr+0xbd>
mov    -0x38(%rbp),%r8
mov    -0x40(%rbp),%rcx
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%edi
mov    -0x48(%rbp),%r9
lea    0xdf9(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gzerr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
test   %edi,%edi
je     11a1 <gzerr+0x71>
mov    %rdx,%rbp
mov    %rsi,%r14
mov    0x2e8e(%rip),%rax
mov    (%rax),%r15d
mov    0x2e94(%rip),%rax
cmp    %ebx,(%rax)
jne    1168 <gzerr+0x38>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
jmp    116f <gzerr+0x3f>
mov    %ebx,%edi
call   1030 <zError@plt>
mov    0x0(%rbp),%r9
test   %r9,%r9
lea    0xe8e(%rip),%rcx
lea    0xe88(%rip),%r8
cmove  %rcx,%r8
cmove  %rcx,%r9
lea    0xe6d(%rip),%rsi
mov    %r15d,%edi
mov    %r14,%rdx
mov    %rax,%rcx
call   1040 <fprintf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i8* }
@stderr = global i32 0
@.str = [12 x i8] c"%s: %s%s%s\0A\00"
@Z_ERRNO = global i32 0
@errno = global i32 0
@.str.1 = [4 x i8] c" - \00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @gzerr(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* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %41
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %5
%12 = load i32, i32* %4
%13 = load i32, i32* @Z_ERRNO
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i32, i32* @errno
%17 = call i8* @strerror(i32 %16)
br label %21
18: ; preds = %9
%19 = load i32, i32* %4
%20 = call i8* @zError(i32 %19)
br label %21
21: ; preds = %18, %15
%22 = phi i8* [ %17, %15 ], [ %20, %18 ]
%23 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i32 0, i32 0
%25 = load i8*, i8** %24
%26 = icmp ne i8* %25, null
%27 = zext i1 %26 to i64
%28 = select i1 %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%29 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%30 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %29, i32 0, i32 0
%31 = load i8*, i8** %30
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %37
33: ; preds = %21
%34 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%35 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %34, i32 0, i32 0
%36 = load i8*, i8** %35
br label %38
37: ; preds = %21
br label %38
38: ; preds = %37, %33
%39 = phi i8* [ %36, %33 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %37 ]
%40 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %22, i8* %28, i8* %39)
br label %41
41: ; preds = %38, %3
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i8* }
@stderr = global i32 0
@.str = [12 x i8] c"%s: %s%s%s\0A\00"
@Z_ERRNO = global i32 0
@errno = global i32 0
@.str.1 = [4 x i8] c" - \00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @gzerr(i32 returned %0, i8* %1, %struct.TYPE_3__* nocapture %2) {
%4 = icmp eq i32 %0, 0
br i1 %4, label %22, label %5
5: ; preds = %3
%6 = load i32, i32* @stderr
%7 = load i32, i32* @Z_ERRNO
%8 = icmp eq i32 %7, %0
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = load i32, i32* @errno
%11 = tail call i8* @strerror(i32 %10)
br label %14
12: ; preds = %5
%13 = tail call i8* @zError(i32 %0)
br label %14
14: ; preds = %12, %9
%15 = phi i8* [ %11, %9 ], [ %13, %12 ]
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 0
%17 = load i8*, i8** %16
%18 = icmp eq i8* %17, null
%19 = select i1 %18, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%20 = select i1 %18, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %17
%21 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %15, i8* %19, i8* %20)
br label %22
22: ; preds = %14, %3
ret i32 %0
}