#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_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  size_t avail_in;
  size_t avail_out;
  char *msg;
  size_t total_out;
  size_t total_in;
  void *next_out;
  void *next_in;
  scalar_t__ opaque;
  scalar_t__ zfree;
  scalar_t__ zalloc;
};
typedef TYPE_1__ z_stream;
typedef scalar_t__ voidpf;
typedef scalar_t__ free_func;
typedef scalar_t__ alloc_func;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ MAX_WBITS;
int /*<<< orphan*/ Z_NO_FLUSH;
int Z_OK;
int Z_STREAM_END;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, int);
int inflate(TYPE_1__ *, int /*<<< orphan*/);
int inflateEnd(TYPE_1__ *);
int inflateInit2(TYPE_1__ *, scalar_t__);
int /*<<< orphan*/ stderr;
int zlib_load(void *dst, size_t dstsize, size_t *size, void *src,
              size_t srcsize) {
  int err;
  z_stream d_stream;
  d_stream.zalloc = (alloc_func)0;
  d_stream.zfree = (free_func)0;
  d_stream.opaque = (voidpf)0;
  d_stream.next_in = src;
  d_stream.avail_in = srcsize;
  d_stream.avail_out = dstsize;
  d_stream.next_out = dst;
  err = inflateInit2(&d_stream, MAX_WBITS + 32);
  {
    if (err != Z_OK) {
      fprintf(stderr, "slideshow: %s error: %s (%d)\n", "inflateInit",
              d_stream.msg, err);
      exit(EXIT_FAILURE);
    }
  };
  while (d_stream.total_out < dstsize && d_stream.total_in < srcsize) {
    err = inflate(&d_stream, Z_NO_FLUSH);
    if (err == Z_STREAM_END) {
      break;
    }
    {
      if (err != Z_OK) {
        fprintf(stderr, "slideshow: %s error: %s (%d)\n", "inflate",
                d_stream.msg, err);
        exit(EXIT_FAILURE);
      }
    };
  }
  *size = d_stream.total_out;
  err = inflateEnd(&d_stream);
  {
    if (err != Z_OK) {
      fprintf(stderr, "slideshow: %s error: %s (%d)\n", "inflateEnd",
              d_stream.msg, err);
      exit(EXIT_FAILURE);
    }
  };
  return 0;
}


x86 assembly (clang, -O0):
<zlib_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%rsi
add    $0x20,%rsi
lea    -0x80(%rbp),%rdi
call   1040 <inflateInit2@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2e25(%rip),%rcx
cmp    (%rcx),%eax
je     1205 <zlib_load+0xb5>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
mov    -0x70(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
lea    0xe15(%rip),%rsi
lea    0xe2c(%rip),%rdx
call   1050 <fprintf@plt>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    120a <zlib_load+0xba>
mov    -0x68(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x81(%rbp)
jae    1231 <zlib_load+0xe1>
mov    -0x60(%rbp),%rax
cmp    -0x28(%rbp),%rax
setb   %al
mov    %al,-0x81(%rbp)
mov    -0x81(%rbp),%al
test   $0x1,%al
jne    1244 <zlib_load+0xf4>
jmp    12b9 <zlib_load+0x169>
mov    0x2d75(%rip),%rax
mov    (%rax),%esi
lea    -0x80(%rbp),%rdi
call   1030 <inflate@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2d7d(%rip),%rcx
cmp    (%rcx),%eax
jne    1270 <zlib_load+0x120>
jmp    12b9 <zlib_load+0x169>
mov    -0x2c(%rbp),%eax
mov    0x2d76(%rip),%rcx
cmp    (%rcx),%eax
je     12b4 <zlib_load+0x164>
mov    0x2d3f(%rip),%rax
mov    (%rax),%edi
mov    -0x70(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
lea    0xd66(%rip),%rsi
lea    0xd89(%rip),%rdx
call   1050 <fprintf@plt>
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    120a <zlib_load+0xba>
mov    -0x68(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x80(%rbp),%rdi
call   1060 <inflateEnd@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2d16(%rip),%rcx
cmp    (%rcx),%eax
je     1314 <zlib_load+0x1c4>
mov    0x2cdf(%rip),%rax
mov    (%rax),%edi
mov    -0x70(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
lea    0xd06(%rip),%rsi
lea    0xd31(%rip),%rdx
call   1050 <fprintf@plt>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zlib_load>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r8,%r15
mov    %rdx,(%rsp)
mov    %rsi,%rbx
xorps  %xmm0,%xmm0
movups %xmm0,0x40(%rsp)
movq   $0x0,0x50(%rsp)
mov    %rcx,0x38(%rsp)
mov    %r8,0x8(%rsp)
mov    %rsi,0x10(%rsp)
mov    %rdi,0x30(%rsp)
mov    0x2e44(%rip),%rax
mov    (%rax),%rsi
add    $0x20,%rsi
lea    0x8(%rsp),%rdi
call   1040 <inflateInit2@plt>
mov    0x2e44(%rip),%r13
cmp    0x0(%r13),%eax
jne    1256 <zlib_load+0x106>
mov    0x2e03(%rip),%rbp
lea    0x8(%rsp),%r12
mov    0x2e17(%rip),%r14
nopl   0x0(%rax)
mov    0x20(%rsp),%rax
cmp    %rbx,%rax
jae    122e <zlib_load+0xde>
cmp    %r15,0x28(%rsp)
jae    122e <zlib_load+0xde>
mov    0x0(%rbp),%esi
mov    %r12,%rdi
call   1030 <inflate@plt>
cmp    (%r14),%eax
je     1229 <zlib_load+0xd9>
cmp    0x0(%r13),%eax
je     11d0 <zlib_load+0x80>
mov    0x2dca(%rip),%rcx
mov    (%rcx),%edi
mov    0x18(%rsp),%rcx
lea    0xdf4(%rip),%rsi
lea    0xe17(%rip),%rdx
mov    %eax,%r8d
call   1050 <fprintf@plt>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    0x20(%rsp),%rax
mov    (%rsp),%rcx
mov    %rax,(%rcx)
lea    0x8(%rsp),%rdi
call   1060 <inflateEnd@plt>
cmp    0x0(%r13),%eax
jne    1274 <zlib_load+0x124>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d6b(%rip),%rcx
mov    (%rcx),%edi
mov    0x18(%rsp),%rcx
lea    0xd95(%rip),%rsi
lea    0xdac(%rip),%rdx
jmp    1213 <zlib_load+0xc3>
mov    0x2d4d(%rip),%rcx
mov    (%rcx),%edi
mov    0x18(%rsp),%rcx
lea    0xd77(%rip),%rsi
lea    0xda2(%rip),%rdx
jmp    1213 <zlib_load+0xc3>

LLVM IR (-O0):
%struct.TYPE_5__ = type { i64, i64, i8*, i64, i64, i8*, i8*, i64, i64, i64 }
@MAX_WBITS = global i64 0
@Z_OK = global i32 0
@stderr = global i32 0
@.str = [30 x i8] c"slideshow: %s error: %s (%d)\0A\00"
@.str.1 = [12 x i8] c"inflateInit\00"
@EXIT_FAILURE = global i32 0
@Z_NO_FLUSH = global i32 0
@Z_STREAM_END = global i32 0
@.str.2 = [8 x i8] c"inflate\00"
@.str.3 = [11 x i8] c"inflateEnd\00"
define i32 @zlib_load(i8* %0, i64 %1, i64* %2, i8* %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca %struct.TYPE_5__
store i8* %0, i8** %6
store i64 %1, i64* %7
store i64* %2, i64** %8
store i8* %3, i8** %9
store i64 %4, i64* %10
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 9
store i64 0, i64* %13
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 8
store i64 0, i64* %14
%15 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 7
store i64 0, i64* %15
%16 = load i8*, i8** %9
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 6
store i8* %16, i8** %17
%18 = load i64, i64* %10
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 0
store i64 %18, i64* %19
%20 = load i64, i64* %7
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 1
store i64 %20, i64* %21
%22 = load i8*, i8** %6
%23 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 5
store i8* %22, i8** %23
%24 = load i64, i64* @MAX_WBITS
%25 = add nsw i64 %24, 32
%26 = call i32 @inflateInit2(%struct.TYPE_5__* %12, i64 %25)
store i32 %26, i32* %11
%27 = load i32, i32* %11
%28 = load i32, i32* @Z_OK
%29 = icmp ne i32 %27, %28
br i1 %29, label %30, label %38
30: ; preds = %5
%31 = load i32, i32* @stderr
%32 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 2
%33 = load i8*, i8** %32
%34 = load i32, i32* %11
%35 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %33, i32 %34)
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %5
br label %39
39: ; preds = %70, %38
%40 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 3
%41 = load i64, i64* %40
%42 = load i64, i64* %7
%43 = icmp ult i64 %41, %42
br i1 %43, label %44, label %49
44: ; preds = %39
%45 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 4
%46 = load i64, i64* %45
%47 = load i64, i64* %10
%48 = icmp ult i64 %46, %47
br label %49
49: ; preds = %44, %39
%50 = phi i1 [ false, %39 ], [ %48, %44 ]
br i1 %50, label %51, label %71
51: ; preds = %49
%52 = load i32, i32* @Z_NO_FLUSH
%53 = call i32 @inflate(%struct.TYPE_5__* %12, i32 %52)
store i32 %53, i32* %11
%54 = load i32, i32* %11
%55 = load i32, i32* @Z_STREAM_END
%56 = icmp eq i32 %54, %55
br i1 %56, label %57, label %58
57: ; preds = %51
br label %71
58: ; preds = %51
%59 = load i32, i32* %11
%60 = load i32, i32* @Z_OK
%61 = icmp ne i32 %59, %60
br i1 %61, label %62, label %70
62: ; preds = %58
%63 = load i32, i32* @stderr
%64 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 2
%65 = load i8*, i8** %64
%66 = load i32, i32* %11
%67 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %65, i32 %66)
%68 = load i32, i32* @EXIT_FAILURE
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %58
br label %39
71: ; preds = %57, %49
%72 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 3
%73 = load i64, i64* %72
%74 = load i64*, i64** %8
store i64 %73, i64* %74
%75 = call i32 @inflateEnd(%struct.TYPE_5__* %12)
store i32 %75, i32* %11
%76 = load i32, i32* %11
%77 = load i32, i32* @Z_OK
%78 = icmp ne i32 %76, %77
br i1 %78, label %79, label %87
79: ; preds = %71
%80 = load i32, i32* @stderr
%81 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 2
%82 = load i8*, i8** %81
%83 = load i32, i32* %11
%84 = call i32 @fprintf(i32 %80, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %82, i32 %83)
%85 = load i32, i32* @EXIT_FAILURE
%86 = call i32 @exit(i32 %85)
unreachable
87: ; preds = %71
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i64, i64, i8*, i64, i64, i8*, i8*, i64, i64, i64 }
@MAX_WBITS = global i64 0
@Z_OK = global i32 0
@stderr = global i32 0
@.str = [30 x i8] c"slideshow: %s error: %s (%d)\0A\00"
@.str.1 = [12 x i8] c"inflateInit\00"
@EXIT_FAILURE = global i32 0
@Z_NO_FLUSH = global i32 0
@Z_STREAM_END = global i32 0
@.str.2 = [8 x i8] c"inflate\00"
@.str.3 = [11 x i8] c"inflateEnd\00"
define i32 @zlib_load(i8* %0, i64 %1, i64* nocapture writeonly %2, i8* %3, i64 %4) {
%6 = alloca %struct.TYPE_5__
%7 = bitcast %struct.TYPE_5__* %6 to i8*
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 7
%9 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 6
%10 = bitcast i64* %8 to i8*
store i8* %3, i8** %9
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 0
store i64 %4, i64* %11
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 1
store i64 %1, i64* %12
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 5
store i8* %0, i8** %13
%14 = load i64, i64* @MAX_WBITS
%15 = add nsw i64 %14, 32
%16 = call i32 @inflateInit2(%struct.TYPE_5__* %6, i64 %15)
%17 = load i32, i32* @Z_OK
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %22
19: ; preds = %5
%20 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 3
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 4
br label %29
22: ; preds = %5
%23 = load i32, i32* @stderr
%24 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 2
%25 = load i8*, i8** %24
%26 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %25, i32 %16)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %19, %42
%30 = load i64, i64* %20
%31 = icmp ult i64 %30, %1
%32 = load i64, i64* %21
%33 = icmp ult i64 %32, %4
%34 = select i1 %31, i1 %33, i1 false
br i1 %34, label %35, label %52
35: ; preds = %29
%36 = load i32, i32* @Z_NO_FLUSH
%37 = call i32 @inflate(%struct.TYPE_5__* %6, i32 %36)
%38 = load i32, i32* @Z_STREAM_END
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = load i64, i64* %20
br label %52
42: ; preds = %35
%43 = load i32, i32* @Z_OK
%44 = icmp eq i32 %37, %43
br i1 %44, label %29, label %45
45: ; preds = %42
%46 = load i32, i32* @stderr
%47 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 2
%48 = load i8*, i8** %47
%49 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %48, i32 %37)
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %29, %40
%53 = phi i64 [ %41, %40 ], [ %30, %29 ]
store i64 %53, i64* %2
%54 = call i32 @inflateEnd(%struct.TYPE_5__* %6)
%55 = load i32, i32* @Z_OK
%56 = icmp eq i32 %54, %55
br i1 %56, label %64, label %57
57: ; preds = %52
%58 = load i32, i32* @stderr
%59 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 2
%60 = load i8*, i8** %59
%61 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %60, i32 %54)
%62 = load i32, i32* @EXIT_FAILURE
%63 = call i32 @exit(i32 %62)
unreachable
64: ; preds = %52
ret i32 0
}