#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 uint32_t;

/* Variables and functions */
int adler32(unsigned char *, unsigned int);
int checkadler32(unsigned char *buffer, unsigned int size) {
  size -= 4;
  uint32_t checksum = adler32(buffer, size);
  buffer += size;
  return checksum ==
         (((uint32_t)buffer[3] << 24) | ((uint32_t)buffer[2] << 16) |
          ((uint32_t)buffer[1] << 8) | (uint32_t)buffer[0]);
}


x86 assembly (clang, -O0):
<checkadler32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <adler32@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
shl    $0x18,%ecx
mov    -0x8(%rbp),%rdx
movzbl 0x2(%rdx),%edx
shl    $0x10,%edx
or     %edx,%ecx
mov    -0x8(%rbp),%rdx
movzbl 0x1(%rdx),%edx
shl    $0x8,%edx
or     %edx,%ecx
mov    -0x8(%rbp),%rdx
movzbl (%rdx),%edx
or     %edx,%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkadler32>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
add    $0xfffffffc,%ebx
mov    %ebx,%esi
call   1030 <adler32@plt>
xor    %ecx,%ecx
cmp    (%r14,%rbx,1),%eax
sete   %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @checkadler32(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = sub i32 %6, 4
store i32 %7, i32* %4
%8 = load i8*, i8** %3
%9 = load i32, i32* %4
%10 = call i32 @adler32(i8* %8, i32 %9)
store i32 %10, i32* %5
%11 = load i32, i32* %4
%12 = load i8*, i8** %3
%13 = zext i32 %11 to i64
%14 = getelementptr inbounds i8, i8* %12, i64 %13
store i8* %14, i8** %3
%15 = load i32, i32* %5
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 3
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = shl i32 %19, 24
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 2
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = shl i32 %24, 16
%26 = or i32 %20, %25
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = shl i32 %30, 8
%32 = or i32 %26, %31
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i64 0
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = or i32 %32, %36
%38 = icmp eq i32 %15, %37
%39 = zext i1 %38 to i32
ret i32 %39
}

LLVM IR (-O2):
define i32 @checkadler32(i8* %0, i32 %1) {
%3 = add i32 %1, -4
%4 = tail call i32 @adler32(i8* %0, i32 %3)
%5 = zext i32 %3 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = getelementptr inbounds i8, i8* %6, i64 3
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = shl nuw i32 %9, 24
%11 = getelementptr inbounds i8, i8* %6, i64 2
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = shl nuw nsw i32 %13, 16
%15 = or i32 %14, %10
%16 = getelementptr inbounds i8, i8* %6, i64 1
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = shl nuw nsw i32 %18, 8
%20 = or i32 %15, %19
%21 = load i8, i8* %6
%22 = zext i8 %21 to i32
%23 = or i32 %20, %22
%24 = icmp eq i32 %4, %23
%25 = zext i1 %24 to i32
ret i32 %25
}