#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 scalar_t__ uLong;
typedef scalar_t__ uInt;

/* Variables and functions */
unsigned char const *Z_NULL;
scalar_t__ crc32(scalar_t__, unsigned char const *, scalar_t__);
int /*<<< orphan*/ fwrite(unsigned char const *, scalar_t__, int,
                          int /*<<< orphan*/);
int /*<<< orphan*/ put_uLong(scalar_t__);
int /*<<< orphan*/ stdout;
void put_chunk(const unsigned char *chunk, uInt length) {
  uLong crc;
  put_uLong(length - 4);
  fwrite(chunk, length, 1, stdout);
  crc = crc32(0, Z_NULL, 0);
  put_uLong(crc32(crc, chunk, length));
}


x86 assembly (clang, -O0):
<put_chunk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
sub    $0x4,%rdi
call   1040 <put_uLong@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e7c(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rdi
call   1030 <crc32@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <crc32@plt>
mov    %rax,%rdi
call   1040 <put_uLong@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_chunk>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    -0x4(%rsi),%rdi
call   1040 <put_uLong@plt>
mov    0x2e8e(%rip),%rax
mov    (%rax),%ecx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%rsi
xor    %edi,%edi
xor    %edx,%edx
call   1030 <crc32@plt>
mov    %rax,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <crc32@plt>
mov    %rax,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <put_uLong@plt>

LLVM IR (-O0):
@stdout = global i32 0
@Z_NULL = global i8* null
define void @put_chunk(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i64, i64* %4
%7 = sub nsw i64 %6, 4
%8 = call i32 @put_uLong(i64 %7)
%9 = load i8*, i8** %3
%10 = load i64, i64* %4
%11 = load i32, i32* @stdout
%12 = call i32 @fwrite(i8* %9, i64 %10, i32 1, i32 %11)
%13 = load i8*, i8** @Z_NULL
%14 = call i64 @crc32(i64 0, i8* %13, i64 0)
store i64 %14, i64* %5
%15 = load i64, i64* %5
%16 = load i8*, i8** %3
%17 = load i64, i64* %4
%18 = call i64 @crc32(i64 %15, i8* %16, i64 %17)
%19 = call i32 @put_uLong(i64 %18)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@Z_NULL = global i8* null
define void @put_chunk(i8* %0, i64 %1) {
%3 = add nsw i64 %1, -4
%4 = tail call i32 @put_uLong(i64 %3)
%5 = load i32, i32* @stdout
%6 = tail call i32 @fwrite(i8* %0, i64 %1, i32 1, i32 %5)
%7 = load i8*, i8** @Z_NULL
%8 = tail call i64 @crc32(i64 0, i8* %7, i64 0)
%9 = tail call i64 @crc32(i64 %8, i8* %0, i64 %1)
%10 = tail call i32 @put_uLong(i64 %9)
ret void
}