#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 */
typedef int /*<<< orphan*/ gzFile;

/* Variables and functions */
scalar_t__ gzerror(int /*<<< orphan*/, int *);
size_t gzwrite(int /*<<< orphan*/, void *, size_t);
int /*<<< orphan*/ my_err(char *, long long, ...);
void util_must_gzwrite(gzFile gzf, void *buf, size_t size) {
  int errnum;
  if (gzwrite(gzf, buf, size) != size) {
    if (gzerror(gzf, &errnum)) {
      my_err("error writing %lld bytes: %s", (long long)size,
             gzerror(gzf, &errnum));
    } else {
      my_err("error writing %lld bytes\n", (long long)size);
    }
  }
}


x86 assembly (clang, -O0):
<util_must_gzwrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <gzwrite@plt>
cmp    -0x18(%rbp),%rax
je     11b8 <util_must_gzwrite+0x88>
mov    -0x4(%rbp),%edi
lea    -0x1c(%rbp),%rsi
call   1030 <gzerror@plt>
cmp    $0x0,%rax
je     11a1 <util_must_gzwrite+0x71>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x1c(%rbp),%rsi
call   1030 <gzerror@plt>
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1050 <my_err@plt>
jmp    11b3 <util_must_gzwrite+0x83>
mov    -0x18(%rbp),%rsi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1050 <my_err@plt>
jmp    11b8 <util_must_gzwrite+0x88>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_must_gzwrite>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %edi,%ebp
call   1040 <gzwrite@plt>
cmp    %rbx,%rax
je     1186 <util_must_gzwrite+0x56>
lea    0x4(%rsp),%rsi
mov    %ebp,%edi
call   1030 <gzerror@plt>
test   %rax,%rax
je     1175 <util_must_gzwrite+0x45>
lea    0x4(%rsp),%rsi
mov    %ebp,%edi
call   1030 <gzerror@plt>
lea    0xe9a(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <my_err@plt>
jmp    1186 <util_must_gzwrite+0x56>
lea    0xea1(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <my_err@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"error writing %lld bytes: %s\00"
@.str.1 = [26 x i8] c"error writing %lld bytes\0A\00"
define void @util_must_gzwrite(i32 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load i32, i32* %4
%9 = load i8*, i8** %5
%10 = load i64, i64* %6
%11 = call i64 @gzwrite(i32 %8, i8* %9, i64 %10)
%12 = load i64, i64* %6
%13 = icmp ne i64 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %3
%15 = load i32, i32* %4
%16 = call i64 @gzerror(i32 %15, i32* %7)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = load i64, i64* %6
%20 = load i32, i32* %4
%21 = call i64 @gzerror(i32 %20, i32* %7)
%22 = call i32 (i8*, i64, ...) @my_err(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i64 %19, i64 %21)
br label %26
23: ; preds = %14
%24 = load i64, i64* %6
%25 = call i32 (i8*, i64, ...) @my_err(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 %24)
br label %26
26: ; preds = %23, %18
br label %27
27: ; preds = %26, %3
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"error writing %lld bytes: %s\00"
@.str.1 = [26 x i8] c"error writing %lld bytes\0A\00"
define void @util_must_gzwrite(i32 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = tail call i64 @gzwrite(i32 %0, i8* %1, i64 %2)
%7 = icmp eq i64 %6, %2
br i1 %7, label %16, label %8
8: ; preds = %3
%9 = call i64 @gzerror(i32 %0, i32* %4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = call i64 @gzerror(i32 %0, i32* %4)
%13 = call i32 (i8*, i64, ...) @my_err(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i64 %2, i64 %12)
br label %16
14: ; preds = %8
%15 = call i32 (i8*, i64, ...) @my_err(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 %2)
br label %16
16: ; preds = %11, %14, %3
ret void
}