#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 */

/* Variables and functions */
unsigned int adlersum(unsigned char *, int, unsigned int);
unsigned int writecrc(int, unsigned char *, int, unsigned int);
void writeUncompressed(int fh, unsigned char *p, int len, int last,
                       unsigned int *crc, unsigned int *adler) {
  unsigned char h[5];
  h[0] = !!last;
  h[1] = len & 255;
  h[2] = len / 256;
  h[3] = ~h[1];
  h[4] = ~h[2];
  *crc = writecrc(fh, h, 5, *crc);
  *crc = writecrc(fh, p, len, *crc);
  *adler = adlersum(p, len, *adler);
}


x86 assembly (clang, -O0):
<writeUncompressed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
cmpl   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x2d(%rbp)
mov    -0x14(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x2c(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %al,-0x2b(%rbp)
movzbl -0x2c(%rbp),%eax
xor    $0xffffffff,%eax
mov    %al,-0x2a(%rbp)
movzbl -0x2b(%rbp),%eax
xor    $0xffffffff,%eax
mov    %al,-0x29(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x2d(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
mov    $0x5,%edx
call   1030 <writecrc@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
call   1030 <writecrc@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
call   1040 <adlersum@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeUncompressed>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r9,%r14
mov    %r8,%r12
mov    %edx,%ebx
mov    %rsi,%r15
mov    %edi,%ebp
test   %ecx,%ecx
setne  0xb(%rsp)
lea    0xff(%rbx),%eax
test   %edx,%edx
cmovns %edx,%eax
mov    %bl,0xc(%rsp)
shr    $0x8,%eax
mov    %al,0xd(%rsp)
mov    %ebx,%ecx
not    %cl
mov    %cl,0xe(%rsp)
not    %al
mov    %al,0xf(%rsp)
mov    (%r8),%ecx
lea    0xb(%rsp),%rsi
mov    $0x5,%edx
call   1030 <writecrc@plt>
mov    %eax,(%r12)
mov    %ebp,%edi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %eax,%ecx
call   1030 <writecrc@plt>
mov    %eax,(%r12)
mov    (%r14),%edx
mov    %r15,%rdi
mov    %ebx,%esi
call   1040 <adlersum@plt>
mov    %eax,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @writeUncompressed(i32 %0, i8* %1, i32 %2, i32 %3, i32* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca [5 x i8]
store i32 %0, i32* %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32* %4, i32** %11
store i32* %5, i32** %12
%14 = load i32, i32* %10
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
%17 = xor i1 %16, true
%18 = zext i1 %17 to i32
%19 = trunc i32 %18 to i8
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0, i64 0
store i8 %19, i8* %20
%21 = load i32, i32* %9
%22 = and i32 %21, 255
%23 = trunc i32 %22 to i8
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0, i64 1
store i8 %23, i8* %24
%25 = load i32, i32* %9
%26 = sdiv i32 %25, 256
%27 = trunc i32 %26 to i8
%28 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0, i64 2
store i8 %27, i8* %28
%29 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0, i64 1
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = xor i32 %31, -1
%33 = trunc i32 %32 to i8
%34 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0, i64 3
store i8 %33, i8* %34
%35 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0, i64 2
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = xor i32 %37, -1
%39 = trunc i32 %38 to i8
%40 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0, i64 4
store i8 %39, i8* %40
%41 = load i32, i32* %7
%42 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0, i64 0
%43 = load i32*, i32** %11
%44 = load i32, i32* %43
%45 = call i32 @writecrc(i32 %41, i8* %42, i32 5, i32 %44)
%46 = load i32*, i32** %11
store i32 %45, i32* %46
%47 = load i32, i32* %7
%48 = load i8*, i8** %8
%49 = load i32, i32* %9
%50 = load i32*, i32** %11
%51 = load i32, i32* %50
%52 = call i32 @writecrc(i32 %47, i8* %48, i32 %49, i32 %51)
%53 = load i32*, i32** %11
store i32 %52, i32* %53
%54 = load i8*, i8** %8
%55 = load i32, i32* %9
%56 = load i32*, i32** %12
%57 = load i32, i32* %56
%58 = call i32 @adlersum(i8* %54, i32 %55, i32 %57)
%59 = load i32*, i32** %12
store i32 %58, i32* %59
ret void
}

LLVM IR (-O2):
define void @writeUncompressed(i32 %0, i8* %1, i32 %2, i32 %3, i32* nocapture %4, i32* nocapture %5) {
%7 = alloca [5 x i8]
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%9 = icmp ne i32 %3, 0
%10 = zext i1 %9 to i8
store i8 %10, i8* %8
%11 = trunc i32 %2 to i8
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 1
store i8 %11, i8* %12
%13 = sdiv i32 %2, 256
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 2
store i8 %14, i8* %15
%16 = xor i8 %11, -1
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 3
store i8 %16, i8* %17
%18 = xor i8 %14, -1
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 4
store i8 %18, i8* %19
%20 = load i32, i32* %4
%21 = call i32 @writecrc(i32 %0, i8* %8, i32 5, i32 %20)
store i32 %21, i32* %4
%22 = call i32 @writecrc(i32 %0, i8* %1, i32 %2, i32 %21)
store i32 %22, i32* %4
%23 = load i32, i32* %5
%24 = call i32 @adlersum(i8* %1, i32 %2, i32 %23)
store i32 %24, i32* %5
ret void
}