#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),
   (*data)[1] = (unsigned char)((crc) >> 16),
   (*data)[2] = (unsigned char)((crc) >> 8),
   (*data)[3] = (unsigned char)((crc)), (*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
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%eax
shr    $0x10,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,0x1(%rax)
mov    -0x10(%rbp),%eax
shr    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,0x2(%rax)
mov    -0x10(%rbp),%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 = trunc i32 %17 to i8
%19 = load i8**, i8*** %3
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8, i8* %20, i64 0
store i8 %18, i8* %21
%22 = load i32, i32* %5
%23 = lshr i32 %22, 16
%24 = trunc i32 %23 to i8
%25 = load i8**, i8*** %3
%26 = load i8*, i8** %25
%27 = getelementptr inbounds i8, i8* %26, i64 1
store i8 %24, i8* %27
%28 = load i32, i32* %5
%29 = lshr i32 %28, 8
%30 = trunc i32 %29 to i8
%31 = load i8**, i8*** %3
%32 = load i8*, i8** %31
%33 = getelementptr inbounds i8, i8* %32, i64 2
store i8 %30, i8* %33
%34 = load i32, i32* %5
%35 = trunc i32 %34 to i8
%36 = load i8**, i8*** %3
%37 = load i8*, i8** %36
%38 = getelementptr inbounds i8, i8* %37, i64 3
store i8 %35, i8* %38
%39 = load i8**, i8*** %3
%40 = load i8*, i8** %39
%41 = getelementptr inbounds i8, i8* %40, i64 4
store i8* %41, i8** %39
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
}