#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
int ts_crc32(int *, int);
uint32_t ts_section_data_calculate_crc(uint8_t *section_data,
                                       int secdata_size) {
  uint32_t check_crc = ts_crc32(section_data, secdata_size);
  section_data[secdata_size + 0] = ((check_crc & ~0x00ffffff) >> 24);
  section_data[secdata_size + 1] = ((check_crc & ~0xff00ffff) >> 16);
  section_data[secdata_size + 2] = ((check_crc & ~0xffff00ff) >> 8);
  section_data[secdata_size + 3] = (check_crc & ~0xffffff00);
  return check_crc;
}


x86 assembly (clang, -O0):
<ts_section_data_calculate_crc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <ts_crc32@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edx
and    $0xff000000,%edx
sar    $0x18,%edx
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%edx
and    $0xff0000,%edx
shr    $0x10,%edx
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%edx
and    $0xff00,%edx
shr    $0x8,%edx
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%edx
and    $0xff,%edx
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ts_section_data_calculate_crc>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <ts_crc32@plt>
mov    %eax,%ecx
mov    %eax,%edi
movzbl %ch,%edx
movzbl %cl,%esi
sar    $0x18,%eax
movslq %ebp,%rbp
mov    %eax,(%rbx,%rbp,4)
shr    $0x10,%edi
movzbl %dil,%eax
mov    %eax,0x4(%rbx,%rbp,4)
mov    %edx,0x8(%rbx,%rbp,4)
mov    %esi,0xc(%rbx,%rbp,4)
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ts_section_data_calculate_crc(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32*, i32** %3
%7 = load i32, i32* %4
%8 = call i32 @ts_crc32(i32* %6, i32 %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = and i32 %9, -16777216
%11 = ashr i32 %10, 24
%12 = load i32*, i32** %3
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 0
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %12, i64 %15
store i32 %11, i32* %16
%17 = load i32, i32* %5
%18 = and i32 %17, 16711680
%19 = lshr i32 %18, 16
%20 = load i32*, i32** %3
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %20, i64 %23
store i32 %19, i32* %24
%25 = load i32, i32* %5
%26 = and i32 %25, 65280
%27 = lshr i32 %26, 8
%28 = load i32*, i32** %3
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %28, i64 %31
store i32 %27, i32* %32
%33 = load i32, i32* %5
%34 = and i32 %33, 255
%35 = load i32*, i32** %3
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %35, i64 %38
store i32 %34, i32* %39
%40 = load i32, i32* %5
ret i32 %40
}

LLVM IR (-O2):
define i32 @ts_section_data_calculate_crc(i32* %0, i32 %1) {
%3 = tail call i32 @ts_crc32(i32* %0, i32 %1)
%4 = ashr i32 %3, 24
%5 = sext i32 %1 to i64
%6 = getelementptr inbounds i32, i32* %0, i64 %5
store i32 %4, i32* %6
%7 = lshr i32 %3, 16
%8 = and i32 %7, 255
%9 = add nsw i32 %1, 1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i32, i32* %0, i64 %10
store i32 %8, i32* %11
%12 = lshr i32 %3, 8
%13 = and i32 %12, 255
%14 = add nsw i32 %1, 2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %0, i64 %15
store i32 %13, i32* %16
%17 = and i32 %3, 255
%18 = add nsw i32 %1, 3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %0, i64 %19
store i32 %17, i32* %20
ret i32 %3
}