#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);
void filladler32(unsigned char *buffer, unsigned int size) {
  size -= 4;
  uint32_t checksum = adler32(buffer, size);
  buffer += size;
  buffer[0] = checksum;
  buffer[1] = checksum >> 8;
  buffer[2] = checksum >> 16;
  buffer[3] = checksum >> 24;
}


x86 assembly (clang, -O0):
<filladler32>:
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    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x10(%rbp),%eax
sar    $0x10,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x10(%rbp),%eax
sar    $0x18,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x3(%rax)
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @filladler32(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 = trunc i32 %15 to i8
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 0
store i8 %16, i8* %18
%19 = load i32, i32* %5
%20 = ashr i32 %19, 8
%21 = trunc i32 %20 to i8
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 1
store i8 %21, i8* %23
%24 = load i32, i32* %5
%25 = ashr i32 %24, 16
%26 = trunc i32 %25 to i8
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 2
store i8 %26, i8* %28
%29 = load i32, i32* %5
%30 = ashr i32 %29, 24
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 3
store i8 %31, i8* %33
ret void
}

LLVM IR (-O2):
define void @filladler32(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 = trunc i32 %4 to i8
store i8 %7, i8* %6
%8 = lshr i32 %4, 8
%9 = trunc i32 %8 to i8
%10 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %9, i8* %10
%11 = lshr i32 %4, 16
%12 = trunc i32 %11 to i8
%13 = getelementptr inbounds i8, i8* %6, i64 2
store i8 %12, i8* %13
%14 = lshr i32 %4, 24
%15 = trunc i32 %14 to i8
%16 = getelementptr inbounds i8, i8* %6, i64 3
store i8 %15, i8* %16
ret void
}