#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 stbiw__crc32(unsigned char *, int);
void stbiw__wpcrc(unsigned char **data, int len) {
  unsigned int crc = stbiw__crc32(*data - len - 4, len + 4);
  ((*data)[0] = (unsigned char)(((crc) >> 24) & 0xff),
   (*data)[1] = (unsigned char)(((crc) >> 16) & 0xff),
   (*data)[2] = (unsigned char)(((crc) >> 8) & 0xff),
   (*data)[3] = (unsigned char)(((crc)) & 0xff), (*data) += 4);
  ;
}


x86 assembly (clang, -O0):
<stbiw__wpcrc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
movslq -0xc(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
mov    -0xc(%rbp),%esi
add    $0x4,%esi
call   1030 <stbiw__crc32@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
shr    $0x18,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%eax
shr    $0x10,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,0x1(%rax)
mov    -0x10(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,0x2(%rax)
mov    -0x10(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,0x3(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x4,%rcx
mov    %rcx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stbiw__wpcrc>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rax
movslq %esi,%rsi
mov    %rsi,%rcx
neg    %rcx
lea    (%rax,%rcx,1),%rdi
add    $0xfffffffffffffffc,%rdi
add    $0x4,%esi
call   1030 <stbiw__crc32@plt>
mov    %eax,%ecx
shr    $0x18,%ecx
mov    (%rbx),%rdx
mov    %cl,(%rdx)
mov    %eax,%ecx
shr    $0x10,%ecx
mov    (%rbx),%rdx
mov    %cl,0x1(%rdx)
mov    (%rbx),%rcx
mov    %ah,0x2(%rcx)
mov    (%rbx),%rcx
mov    %al,0x3(%rcx)
addq   $0x4,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @stbiw__wpcrc(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 i8**, i8*** %3
%7 = load i8*, i8** %6
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = sub i64 0, %9
%11 = getelementptr inbounds i8, i8* %7, i64 %10
%12 = getelementptr inbounds i8, i8* %11, i64 -4
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 4
%15 = call i32 @stbiw__crc32(i8* %12, i32 %14)
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = lshr i32 %16, 24
%18 = and i32 %17, 255
%19 = trunc i32 %18 to i8
%20 = load i8**, i8*** %3
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8, i8* %21, i64 0
store i8 %19, i8* %22
%23 = load i32, i32* %5
%24 = lshr i32 %23, 16
%25 = and i32 %24, 255
%26 = trunc i32 %25 to i8
%27 = load i8**, i8*** %3
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i64 1
store i8 %26, i8* %29
%30 = load i32, i32* %5
%31 = lshr i32 %30, 8
%32 = and i32 %31, 255
%33 = trunc i32 %32 to i8
%34 = load i8**, i8*** %3
%35 = load i8*, i8** %34
%36 = getelementptr inbounds i8, i8* %35, i64 2
store i8 %33, i8* %36
%37 = load i32, i32* %5
%38 = and i32 %37, 255
%39 = trunc i32 %38 to i8
%40 = load i8**, i8*** %3
%41 = load i8*, i8** %40
%42 = getelementptr inbounds i8, i8* %41, i64 3
store i8 %39, i8* %42
%43 = load i8**, i8*** %3
%44 = load i8*, i8** %43
%45 = getelementptr inbounds i8, i8* %44, i64 4
store i8* %45, i8** %43
ret void
}

LLVM IR (-O2):
define void @stbiw__wpcrc(i8** nocapture %0, i32 %1) {
%3 = load i8*, i8** %0
%4 = sext i32 %1 to i64
%5 = sub nsw i64 0, %4
%6 = getelementptr inbounds i8, i8* %3, i64 %5
%7 = getelementptr inbounds i8, i8* %6, i64 -4
%8 = add nsw i32 %1, 4
%9 = tail call i32 @stbiw__crc32(i8* %7, i32 %8)
%10 = lshr i32 %9, 24
%11 = trunc i32 %10 to i8
%12 = load i8*, i8** %0
store i8 %11, i8* %12
%13 = lshr i32 %9, 16
%14 = trunc i32 %13 to i8
%15 = load i8*, i8** %0
%16 = getelementptr inbounds i8, i8* %15, i64 1
store i8 %14, i8* %16
%17 = lshr i32 %9, 8
%18 = trunc i32 %17 to i8
%19 = load i8*, i8** %0
%20 = getelementptr inbounds i8, i8* %19, i64 2
store i8 %18, i8* %20
%21 = trunc i32 %9 to i8
%22 = load i8*, i8** %0
%23 = getelementptr inbounds i8, i8* %22, i64 3
store i8 %21, i8* %23
%24 = load i8*, i8** %0
%25 = getelementptr inbounds i8, i8* %24, i64 4
store i8* %25, i8** %0
ret void
}