#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[16], odd[16];
  uint16_t csum1, csum2, csum3, csum4;
  csum1 = checksum(data8 + 4, 12);
  csum2 = checksum(data8 + 16, 12);
  data[1] = csum1;
  data[14] = csum2;
  for (i = 0; i < 16; i++) {
    even[i] = data8[i * 2];
    odd[i] = data8[i * 2 + 1];
  }
  csum3 = checksum(even + 1, 14);
  csum4 = checksum(odd + 1, 14);
  data[0] = csum3;
  data[15] = csum4;
  return;
}


x86 assembly (clang, -O0):
<fix_checksums>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x10,%rdi
mov    $0xc,%esi
call   1030 <checksum@plt>
mov    %eax,-0xa4(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x40,%rdi
mov    $0xc,%esi
call   1030 <checksum@plt>
mov    %eax,-0xa8(%rbp)
mov    -0xa4(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0xa8(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x38(%rax)
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    11c6 <fix_checksums+0xb6>
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,-0x60(%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,-0xa0(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1178 <fix_checksums+0x68>
lea    -0x60(%rbp),%rdi
add    $0x4,%rdi
mov    $0xe,%esi
call   1030 <checksum@plt>
mov    %eax,-0xac(%rbp)
lea    -0xa0(%rbp),%rdi
add    $0x4,%rdi
mov    $0xe,%esi
call   1030 <checksum@plt>
mov    %eax,-0xb0(%rbp)
mov    -0xac(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xb0(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x3c(%rax)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fix_checksums>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%rbx
add    $0x10,%rdi
mov    $0xc,%esi
call   1030 <checksum@plt>
mov    %eax,%ebp
lea    0x40(%rbx),%rdi
mov    $0xc,%esi
call   1030 <checksum@plt>
mov    %ebp,0x4(%rbx)
mov    %eax,0x38(%rbx)
mov    (%rbx),%ecx
mov    %ecx,0x40(%rsp)
mov    %ebp,(%rsp)
mov    0x8(%rbx),%ecx
lea    0x44(%rsp),%rdi
mov    %ecx,0x44(%rsp)
mov    0xc(%rbx),%ecx
lea    0x4(%rsp),%r14
mov    %ecx,0x4(%rsp)
mov    0x10(%rbx),%ecx
mov    %ecx,0x48(%rsp)
mov    0x14(%rbx),%ecx
mov    %ecx,0x8(%rsp)
mov    0x18(%rbx),%ecx
mov    %ecx,0x4c(%rsp)
mov    0x1c(%rbx),%ecx
mov    %ecx,0xc(%rsp)
mov    0x20(%rbx),%ecx
mov    %ecx,0x50(%rsp)
mov    0x24(%rbx),%ecx
mov    %ecx,0x10(%rsp)
mov    0x28(%rbx),%ecx
mov    %ecx,0x54(%rsp)
mov    0x2c(%rbx),%ecx
mov    %ecx,0x14(%rsp)
mov    0x30(%rbx),%ecx
mov    %ecx,0x58(%rsp)
mov    0x34(%rbx),%ecx
mov    %ecx,0x18(%rsp)
mov    %eax,0x5c(%rsp)
mov    0x3c(%rbx),%eax
mov    %eax,0x1c(%rsp)
mov    0x40(%rbx),%eax
mov    %eax,0x60(%rsp)
mov    0x44(%rbx),%eax
mov    %eax,0x20(%rsp)
mov    0x48(%rbx),%eax
mov    %eax,0x64(%rsp)
mov    0x4c(%rbx),%eax
mov    %eax,0x24(%rsp)
mov    0x50(%rbx),%eax
mov    %eax,0x68(%rsp)
mov    0x54(%rbx),%eax
mov    %eax,0x28(%rsp)
mov    0x58(%rbx),%eax
mov    %eax,0x6c(%rsp)
mov    0x5c(%rbx),%eax
mov    %eax,0x2c(%rsp)
mov    0x60(%rbx),%eax
mov    %eax,0x70(%rsp)
mov    0x64(%rbx),%eax
mov    %eax,0x30(%rsp)
mov    0x68(%rbx),%eax
mov    %eax,0x74(%rsp)
mov    0x6c(%rbx),%eax
mov    %eax,0x34(%rsp)
mov    0x70(%rbx),%eax
mov    %eax,0x78(%rsp)
mov    0x74(%rbx),%eax
mov    %eax,0x38(%rsp)
mov    0x78(%rbx),%eax
mov    %eax,0x7c(%rsp)
mov    0x7c(%rbx),%eax
mov    %eax,0x3c(%rsp)
mov    $0xe,%esi
call   1030 <checksum@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    $0xe,%esi
call   1030 <checksum@plt>
mov    %ebp,(%rbx)
mov    %eax,0x3c(%rbx)
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @fix_checksums(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32*
%5 = alloca [16 x i32]
%6 = alloca [16 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 12)
store i32 %14, i32* %7
%15 = load i32*, i32** %4
%16 = getelementptr inbounds i32, i32* %15, i64 16
%17 = call i32 @checksum(i32* %16, i32 12)
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 14
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, 16
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 [16 x i32], [16 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 [16 x i32], [16 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 [16 x i32], [16 x i32]* %5, i64 0, i64 0
%52 = getelementptr inbounds i32, i32* %51, i64 1
%53 = call i32 @checksum(i32* %52, i32 14)
store i32 %53, i32* %9
%54 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
%55 = getelementptr inbounds i32, i32* %54, i64 1
%56 = call i32 @checksum(i32* %55, i32 14)
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 15
store i32 %60, i32* %62
ret void
}

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