#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 /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ checksum(int /*<<< orphan*/ *, int);
void fix_checksums(uint16_t *data) {
  int i;
  uint8_t *data8 = (uint8_t *)data;
  uint8_t even[32], odd[32];
  uint16_t csum1, csum2, csum3, csum4;
  csum1 = checksum(data8 + 4, 28);
  csum2 = checksum(data8 + 32, 28);
  data[1] = csum1;
  data[30] = csum2;
  for (i = 0; i < 32; i++) {
    even[i] = data8[i * 2];
    odd[i] = data8[i * 2 + 1];
  }
  csum3 = checksum(even + 1, 30);
  csum4 = checksum(odd + 1, 30);
  data[0] = csum3;
  data[31] = csum4;
  return;
}


x86 assembly (clang, -O0):
<fix_checksums>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x10,%rdi
mov    $0x1c,%esi
call   1030 <checksum@plt>
mov    %eax,-0x124(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x80,%rdi
mov    $0x1c,%esi
call   1030 <checksum@plt>
mov    %eax,-0x128(%rbp)
mov    -0x124(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x128(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x78(%rax)
movl   $0x0,-0xc(%rbp)
cmpl   $0x20,-0xc(%rbp)
jge    11cc <fix_checksums+0xbc>
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0xc(%rbp),%rax
mov    %ecx,-0xa0(%rbp,%rax,4)
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0xc(%rbp),%rax
mov    %ecx,-0x120(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117b <fix_checksums+0x6b>
lea    -0xa0(%rbp),%rdi
add    $0x4,%rdi
mov    $0x1e,%esi
call   1030 <checksum@plt>
mov    %eax,-0x12c(%rbp)
lea    -0x120(%rbp),%rdi
add    $0x4,%rdi
mov    $0x1e,%esi
call   1030 <checksum@plt>
mov    %eax,-0x130(%rbp)
mov    -0x12c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x130(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x7c(%rax)
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fix_checksums>:
push   %rbp
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
add    $0x10,%rdi
mov    $0x1c,%esi
call   1030 <checksum@plt>
mov    %eax,%ebp
lea    0x80(%rbx),%rdi
mov    $0x1c,%esi
call   1030 <checksum@plt>
mov    %ebp,0x4(%rbx)
mov    %eax,0x78(%rbx)
movups 0x10(%rbx),%xmm0
movups (%rbx),%xmm1
movaps %xmm1,%xmm2
shufps $0x88,%xmm0,%xmm2
shufps $0xdd,%xmm0,%xmm1
movaps %xmm2,0x80(%rsp)
movaps %xmm1,(%rsp)
movups 0x20(%rbx),%xmm0
movups 0x30(%rbx),%xmm1
movaps %xmm0,%xmm2
shufps $0x88,%xmm1,%xmm2
shufps $0xdd,%xmm1,%xmm0
movaps %xmm2,0x90(%rsp)
movaps %xmm0,0x10(%rsp)
movups 0x40(%rbx),%xmm0
movups 0x50(%rbx),%xmm1
movaps %xmm0,%xmm2
shufps $0x88,%xmm1,%xmm2
shufps $0xdd,%xmm1,%xmm0
movaps %xmm2,0xa0(%rsp)
movaps %xmm0,0x20(%rsp)
movups 0x60(%rbx),%xmm0
movups 0x70(%rbx),%xmm1
movaps %xmm0,%xmm2
shufps $0x88,%xmm1,%xmm2
shufps $0xdd,%xmm1,%xmm0
movaps %xmm2,0xb0(%rsp)
movaps %xmm0,0x30(%rsp)
movups 0x80(%rbx),%xmm0
movups 0x90(%rbx),%xmm1
movaps %xmm0,%xmm2
shufps $0x88,%xmm1,%xmm2
shufps $0xdd,%xmm1,%xmm0
movaps %xmm2,0xc0(%rsp)
movaps %xmm0,0x40(%rsp)
movups 0xa0(%rbx),%xmm0
movups 0xb0(%rbx),%xmm1
movaps %xmm0,%xmm2
shufps $0x88,%xmm1,%xmm2
shufps $0xdd,%xmm1,%xmm0
movaps %xmm2,0xd0(%rsp)
movaps %xmm0,0x50(%rsp)
movups 0xc0(%rbx),%xmm0
movups 0xd0(%rbx),%xmm1
movaps %xmm0,%xmm2
shufps $0x88,%xmm1,%xmm2
shufps $0xdd,%xmm1,%xmm0
movaps %xmm2,0xe0(%rsp)
movaps %xmm0,0x60(%rsp)
movups 0xe0(%rbx),%xmm0
movups 0xf0(%rbx),%xmm1
movaps %xmm0,%xmm2
shufps $0x88,%xmm1,%xmm2
shufps $0xdd,%xmm1,%xmm0
movaps %xmm2,0xf0(%rsp)
movaps %xmm0,0x70(%rsp)
lea    0x84(%rsp),%rdi
mov    $0x1e,%esi
call   1030 <checksum@plt>
mov    %eax,%ebp
lea    0x4(%rsp),%rdi
mov    $0x1e,%esi
call   1030 <checksum@plt>
mov    %ebp,(%rbx)
mov    %eax,0x7c(%rbx)
add    $0x108,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @fix_checksums(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32*
%5 = alloca [32 x i32]
%6 = alloca [32 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %2
%11 = load i32*, i32** %2
store i32* %11, i32** %4
%12 = load i32*, i32** %4
%13 = getelementptr inbounds i32, i32* %12, i64 4
%14 = call i32 @checksum(i32* %13, i32 28)
store i32 %14, i32* %7
%15 = load i32*, i32** %4
%16 = getelementptr inbounds i32, i32* %15, i64 32
%17 = call i32 @checksum(i32* %16, i32 28)
store i32 %17, i32* %8
%18 = load i32, i32* %7
%19 = load i32*, i32** %2
%20 = getelementptr inbounds i32, i32* %19, i64 1
store i32 %18, i32* %20
%21 = load i32, i32* %8
%22 = load i32*, i32** %2
%23 = getelementptr inbounds i32, i32* %22, i64 30
store i32 %21, i32* %23
store i32 0, i32* %3
br label %24
24: ; preds = %47, %1
%25 = load i32, i32* %3
%26 = icmp slt i32 %25, 32
br i1 %26, label %27, label %50
27: ; preds = %24
%28 = load i32*, i32** %4
%29 = load i32, i32* %3
%30 = mul nsw i32 %29, 2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %28, i64 %31
%33 = load i32, i32* %32
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 %35
store i32 %33, i32* %36
%37 = load i32*, i32** %4
%38 = load i32, i32* %3
%39 = mul nsw i32 %38, 2
%40 = add nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %37, i64 %41
%43 = load i32, i32* %42
%44 = load i32, i32* %3
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 %45
store i32 %43, i32* %46
br label %47
47: ; preds = %27
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 1
store i32 %49, i32* %3
br label %24
50: ; preds = %24
%51 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 0
%52 = getelementptr inbounds i32, i32* %51, i64 1
%53 = call i32 @checksum(i32* %52, i32 30)
store i32 %53, i32* %9
%54 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%55 = getelementptr inbounds i32, i32* %54, i64 1
%56 = call i32 @checksum(i32* %55, i32 30)
store i32 %56, i32* %10
%57 = load i32, i32* %9
%58 = load i32*, i32** %2
%59 = getelementptr inbounds i32, i32* %58, i64 0
store i32 %57, i32* %59
%60 = load i32, i32* %10
%61 = load i32*, i32** %2
%62 = getelementptr inbounds i32, i32* %61, i64 31
store i32 %60, i32* %62
ret void
}

LLVM IR (-O2):
define void @fix_checksums(i32* %0) {
%2 = alloca [32 x i32]
%3 = alloca [32 x i32]
%4 = bitcast [32 x i32]* %2 to i8*
%5 = bitcast [32 x i32]* %3 to i8*
%6 = getelementptr inbounds i32, i32* %0, i64 4
%7 = tail call i32 @checksum(i32* %6, i32 28)
%8 = getelementptr inbounds i32, i32* %0, i64 32
%9 = tail call i32 @checksum(i32* %8, i32 28)
%10 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %7, i32* %10
%11 = getelementptr inbounds i32, i32* %0, i64 30
store i32 %9, i32* %11
%12 = bitcast i32* %0 to <8 x i32>*
%13 = load <8 x i32>, <8 x i32>* %12
%14 = shufflevector <8 x i32> %13, <8 x i32> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
%15 = shufflevector <8 x i32> %13, <8 x i32> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
%16 = bitcast [32 x i32]* %2 to <4 x i32>*
store <4 x i32> %14, <4 x i32>* %16
%17 = bitcast [32 x i32]* %3 to <4 x i32>*
store <4 x i32> %15, <4 x i32>* %17
%18 = getelementptr inbounds i32, i32* %0, i64 8
%19 = bitcast i32* %18 to <8 x i32>*
%20 = load <8 x i32>, <8 x i32>* %19
%21 = shufflevector <8 x i32> %20, <8 x i32> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
%22 = shufflevector <8 x i32> %20, <8 x i32> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
%23 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 4
%24 = bitcast i32* %23 to <4 x i32>*
store <4 x i32> %21, <4 x i32>* %24
%25 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 4
%26 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> %22, <4 x i32>* %26
%27 = getelementptr inbounds i32, i32* %0, i64 16
%28 = bitcast i32* %27 to <8 x i32>*
%29 = load <8 x i32>, <8 x i32>* %28
%30 = shufflevector <8 x i32> %29, <8 x i32> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
%31 = shufflevector <8 x i32> %29, <8 x i32> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
%32 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 8
%33 = bitcast i32* %32 to <4 x i32>*
store <4 x i32> %30, <4 x i32>* %33
%34 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 8
%35 = bitcast i32* %34 to <4 x i32>*
store <4 x i32> %31, <4 x i32>* %35
%36 = getelementptr inbounds i32, i32* %0, i64 24
%37 = bitcast i32* %36 to <8 x i32>*
%38 = load <8 x i32>, <8 x i32>* %37
%39 = shufflevector <8 x i32> %38, <8 x i32> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
%40 = shufflevector <8 x i32> %38, <8 x i32> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
%41 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 12
%42 = bitcast i32* %41 to <4 x i32>*
store <4 x i32> %39, <4 x i32>* %42
%43 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 12
%44 = bitcast i32* %43 to <4 x i32>*
store <4 x i32> %40, <4 x i32>* %44
%45 = getelementptr inbounds i32, i32* %0, i64 32
%46 = bitcast i32* %45 to <8 x i32>*
%47 = load <8 x i32>, <8 x i32>* %46
%48 = shufflevector <8 x i32> %47, <8 x i32> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
%49 = shufflevector <8 x i32> %47, <8 x i32> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
%50 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 16
%51 = bitcast i32* %50 to <4 x i32>*
store <4 x i32> %48, <4 x i32>* %51
%52 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 16
%53 = bitcast i32* %52 to <4 x i32>*
store <4 x i32> %49, <4 x i32>* %53
%54 = getelementptr inbounds i32, i32* %0, i64 40
%55 = bitcast i32* %54 to <8 x i32>*
%56 = load <8 x i32>, <8 x i32>* %55
%57 = shufflevector <8 x i32> %56, <8 x i32> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
%58 = shufflevector <8 x i32> %56, <8 x i32> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
%59 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 20
%60 = bitcast i32* %59 to <4 x i32>*
store <4 x i32> %57, <4 x i32>* %60
%61 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 20
%62 = bitcast i32* %61 to <4 x i32>*
store <4 x i32> %58, <4 x i32>* %62
%63 = getelementptr inbounds i32, i32* %0, i64 48
%64 = bitcast i32* %63 to <8 x i32>*
%65 = load <8 x i32>, <8 x i32>* %64
%66 = shufflevector <8 x i32> %65, <8 x i32> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
%67 = shufflevector <8 x i32> %65, <8 x i32> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
%68 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 24
%69 = bitcast i32* %68 to <4 x i32>*
store <4 x i32> %66, <4 x i32>* %69
%70 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 24
%71 = bitcast i32* %70 to <4 x i32>*
store <4 x i32> %67, <4 x i32>* %71
%72 = getelementptr inbounds i32, i32* %0, i64 56
%73 = bitcast i32* %72 to <8 x i32>*
%74 = load <8 x i32>, <8 x i32>* %73
%75 = shufflevector <8 x i32> %74, <8 x i32> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
%76 = shufflevector <8 x i32> %74, <8 x i32> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
%77 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 28
%78 = bitcast i32* %77 to <4 x i32>*
store <4 x i32> %75, <4 x i32>* %78
%79 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 28
%80 = bitcast i32* %79 to <4 x i32>*
store <4 x i32> %76, <4 x i32>* %80
%81 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 1
%82 = call i32 @checksum(i32* %81, i32 30)
%83 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 1
%84 = call i32 @checksum(i32* %83, i32 30)
store i32 %82, i32* %0
%85 = getelementptr inbounds i32, i32* %0, i64 31
store i32 %84, i32* %85
ret void
}