#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 */
int errno;
int /*<<< orphan*/ exit(int);
int gzclose(int /*<<< orphan*/);
int /*<<< orphan*/ gzopen(char *, char *);
int gzprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, ...);
int main(void) {
  gzFile f;
  int ret;
  if (!(f = gzopen("/dev/null", "w"))) {
    perror("/dev/null");
    exit(1);
  }
  ret = gzprintf(f, "%10240s", "");
  printf("gzprintf -> %d\n", ret);
  ret = gzclose(f);
  printf("gzclose -> %d [%d]\n", ret, errno);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe8d(%rip),%rsi
call   1060 <gzopen@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    11a4 <main+0x44>
lea    0xe6b(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%edi
lea    0xe5e(%rip),%rsi
lea    0xe82(%rip),%rdx
call   1040 <gzprintf@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
call   1030 <gzclose@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    0x2dfd(%rip),%rax
mov    (%rax),%edx
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xe98(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <gzopen@plt>
test   %eax,%eax
jne    118e <main+0x2e>
lea    0xe81(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    %eax,%ebx
lea    0xe75(%rip),%rsi
lea    0xe99(%rip),%rdx
mov    %eax,%edi
call   1040 <gzprintf@plt>
lea    0xe68(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1030 <gzclose@plt>
mov    0x2e1d(%rip),%rcx
mov    (%rcx),%edx
lea    0xe58(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"/dev/null\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [8 x i8] c"%10240s\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [16 x i8] c"gzprintf -> %d\0A\00"
@.str.5 = [20 x i8] c"gzclose -> %d [%d]\0A\00"
@errno = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @gzopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 %4, i32* %2
%5 = icmp ne i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = load i32, i32* %2
%11 = call i32 @gzprintf(i32 %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %2
%15 = call i32 @gzclose(i32 %14)
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = load i32, i32* @errno
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %16, i32 %17)
%19 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [10 x i8] c"/dev/null\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [8 x i8] c"%10240s\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [16 x i8] c"gzprintf -> %d\0A\00"
@.str.5 = [20 x i8] c"gzclose -> %d [%d]\0A\00"
@errno = global i32 0
define i32 @main() {
%1 = tail call i32 @gzopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %0
%7 = tail call i32 @gzprintf(i32 %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %7)
%9 = tail call i32 @gzclose(i32 %1)
%10 = load i32, i32* @errno
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %9, i32 %10)
%12 = tail call i32 @exit(i32 0)
unreachable
}