#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 int32_t;

/* Variables and functions */
int /*<<< orphan*/ md4(int *, int, int *);
int /*<<< orphan*/ md5(int *, int, int *);
int /*<<< orphan*/ memcpy(int *, int *, int);
int /*<<< orphan*/ sha1(int *, int, int *);
void gen_ka1_checksum(uint8_t *checksum, uint8_t *seed, uint8_t mode) {
  uint8_t checksum_t[32] = {0};
  int32_t temp_num;
  switch (mode) {
  case 0:
    temp_num = 20000711;
    memcpy(checksum, (uint8_t *)&temp_num, 4);
    temp_num = 126;
    memcpy(checksum + 4, (uint8_t *)&temp_num, 4);
    break;
  case 1:
    md5(seed, 4, checksum_t);
    checksum[0] = checksum_t[2];
    checksum[1] = checksum_t[3];
    checksum[2] = checksum_t[8];
    checksum[3] = checksum_t[9];
    checksum[4] = checksum_t[5];
    checksum[5] = checksum_t[6];
    checksum[6] = checksum_t[13];
    checksum[7] = checksum_t[14];
    break;
  case 2:
    md4(seed, 4, checksum_t);
    checksum[0] = checksum_t[1];
    checksum[1] = checksum_t[2];
    checksum[2] = checksum_t[8];
    checksum[3] = checksum_t[9];
    checksum[4] = checksum_t[4];
    checksum[5] = checksum_t[5];
    checksum[6] = checksum_t[11];
    checksum[7] = checksum_t[12];
    break;
  case 3:
    sha1(seed, 4, checksum_t);
    checksum[0] = checksum_t[2];
    checksum[1] = checksum_t[3];
    checksum[2] = checksum_t[9];
    checksum[3] = checksum_t[10];
    checksum[4] = checksum_t[5];
    checksum[5] = checksum_t[6];
    checksum[6] = checksum_t[15];
    checksum[7] = checksum_t[16];
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<gen_ka1_checksum>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xorps  %xmm0,%xmm0
movaps %xmm0,-0xc0(%rbp)
movaps %xmm0,-0x30(%rbp)
movaps %xmm0,-0x40(%rbp)
movaps %xmm0,-0x50(%rbp)
movaps %xmm0,-0x60(%rbp)
movaps %xmm0,-0x70(%rbp)
movaps %xmm0,-0x80(%rbp)
movaps %xmm0,-0x90(%rbp)
movaps %xmm0,-0xa0(%rbp)
mov    -0x14(%rbp),%eax
mov    %rax,-0xb0(%rbp)
sub    $0x3,%rax
ja     1357 <gen_ka1_checksum+0x217>
mov    -0xb0(%rbp),%rax
lea    0xe58(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1312fc7,-0xa4(%rbp)
2f 31 01
mov    -0x8(%rbp),%rdi
lea    -0xa4(%rbp),%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
movl   $0x7e,-0xa4(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x10,%rdi
lea    -0xa4(%rbp),%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
jmp    135c <gen_ka1_checksum+0x21c>
mov    -0x10(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
mov    $0x4,%esi
call   1060 <md5@plt>
mov    -0x98(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x94(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x80(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x7c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x8c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x88(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x6c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x68(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x1c(%rax)
jmp    135c <gen_ka1_checksum+0x21c>
mov    -0x10(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
mov    $0x4,%esi
call   1040 <md4@plt>
mov    -0x9c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x98(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x80(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x7c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x90(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x8c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x74(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x70(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x1c(%rax)
jmp    135c <gen_ka1_checksum+0x21c>
mov    -0x10(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
mov    $0x4,%esi
call   1030 <sha1@plt>
mov    -0x98(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x94(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x7c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x78(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x8c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x88(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x64(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x60(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x1c(%rax)
jmp    135c <gen_ka1_checksum+0x21c>
jmp    135c <gen_ka1_checksum+0x21c>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_ka1_checksum>:
push   %r14
push   %rbx
sub    $0x98,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
cmp    $0x3,%edx
ja     126f <gen_ka1_checksum+0x12f>
mov    %rdi,%rbx
mov    %edx,%eax
lea    0xe73(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1312fc7,0xc(%rsp)
01
lea    0xc(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
movl   $0x7e,0xc(%rsp)
add    $0x10,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
jmp    126f <gen_ka1_checksum+0x12f>
lea    0x10(%rsp),%rdx
mov    %rsi,%rdi
mov    $0x4,%esi
call   1060 <md5@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
movlhps %xmm1,%xmm0
movups %xmm0,(%rbx)
movsd  0x24(%rsp),%xmm0
movsd  0x44(%rsp),%xmm1
jmp    1268 <gen_ka1_checksum+0x128>
lea    0x10(%rsp),%rdx
mov    %rsi,%rdi
mov    $0x4,%esi
call   1040 <md4@plt>
movsd  0x14(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
movlhps %xmm1,%xmm0
movups %xmm0,(%rbx)
movsd  0x20(%rsp),%xmm0
movsd  0x3c(%rsp),%xmm1
jmp    1268 <gen_ka1_checksum+0x128>
lea    0x10(%rsp),%rdx
mov    %rsi,%rdi
mov    $0x4,%esi
call   1030 <sha1@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x34(%rsp),%xmm1
movlhps %xmm1,%xmm0
movups %xmm0,(%rbx)
movsd  0x24(%rsp),%xmm0
movsd  0x4c(%rsp),%xmm1
movlhps %xmm1,%xmm0
movups %xmm0,0x10(%rbx)
add    $0x98,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @gen_ka1_checksum(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca [32 x i32]
%8 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%9 = bitcast [32 x i32]* %7 to i8*
%10 = load i32, i32* %6
switch i32 %10, label %125 [
i32 0, label %11
i32 1, label %17
i32 2, label %53
i32 3, label %89
]
11: ; preds = %3
store i32 20000711, i32* %8
%12 = load i32*, i32** %4
%13 = call i32 @memcpy(i32* %12, i32* %8, i32 4)
store i32 126, i32* %8
%14 = load i32*, i32** %4
%15 = getelementptr inbounds i32, i32* %14, i64 4
%16 = call i32 @memcpy(i32* %15, i32* %8, i32 4)
br label %126
17: ; preds = %3
%18 = load i32*, i32** %5
%19 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 0
%20 = call i32 @md5(i32* %18, i32 4, i32* %19)
%21 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 2
%22 = load i32, i32* %21
%23 = load i32*, i32** %4
%24 = getelementptr inbounds i32, i32* %23, i64 0
store i32 %22, i32* %24
%25 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 3
%26 = load i32, i32* %25
%27 = load i32*, i32** %4
%28 = getelementptr inbounds i32, i32* %27, i64 1
store i32 %26, i32* %28
%29 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 8
%30 = load i32, i32* %29
%31 = load i32*, i32** %4
%32 = getelementptr inbounds i32, i32* %31, i64 2
store i32 %30, i32* %32
%33 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 9
%34 = load i32, i32* %33
%35 = load i32*, i32** %4
%36 = getelementptr inbounds i32, i32* %35, i64 3
store i32 %34, i32* %36
%37 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 5
%38 = load i32, i32* %37
%39 = load i32*, i32** %4
%40 = getelementptr inbounds i32, i32* %39, i64 4
store i32 %38, i32* %40
%41 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 6
%42 = load i32, i32* %41
%43 = load i32*, i32** %4
%44 = getelementptr inbounds i32, i32* %43, i64 5
store i32 %42, i32* %44
%45 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 13
%46 = load i32, i32* %45
%47 = load i32*, i32** %4
%48 = getelementptr inbounds i32, i32* %47, i64 6
store i32 %46, i32* %48
%49 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 14
%50 = load i32, i32* %49
%51 = load i32*, i32** %4
%52 = getelementptr inbounds i32, i32* %51, i64 7
store i32 %50, i32* %52
br label %126
53: ; preds = %3
%54 = load i32*, i32** %5
%55 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 0
%56 = call i32 @md4(i32* %54, i32 4, i32* %55)
%57 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 1
%58 = load i32, i32* %57
%59 = load i32*, i32** %4
%60 = getelementptr inbounds i32, i32* %59, i64 0
store i32 %58, i32* %60
%61 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 2
%62 = load i32, i32* %61
%63 = load i32*, i32** %4
%64 = getelementptr inbounds i32, i32* %63, i64 1
store i32 %62, i32* %64
%65 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 8
%66 = load i32, i32* %65
%67 = load i32*, i32** %4
%68 = getelementptr inbounds i32, i32* %67, i64 2
store i32 %66, i32* %68
%69 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 9
%70 = load i32, i32* %69
%71 = load i32*, i32** %4
%72 = getelementptr inbounds i32, i32* %71, i64 3
store i32 %70, i32* %72
%73 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 4
%74 = load i32, i32* %73
%75 = load i32*, i32** %4
%76 = getelementptr inbounds i32, i32* %75, i64 4
store i32 %74, i32* %76
%77 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 5
%78 = load i32, i32* %77
%79 = load i32*, i32** %4
%80 = getelementptr inbounds i32, i32* %79, i64 5
store i32 %78, i32* %80
%81 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 11
%82 = load i32, i32* %81
%83 = load i32*, i32** %4
%84 = getelementptr inbounds i32, i32* %83, i64 6
store i32 %82, i32* %84
%85 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 12
%86 = load i32, i32* %85
%87 = load i32*, i32** %4
%88 = getelementptr inbounds i32, i32* %87, i64 7
store i32 %86, i32* %88
br label %126
89: ; preds = %3
%90 = load i32*, i32** %5
%91 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 0
%92 = call i32 @sha1(i32* %90, i32 4, i32* %91)
%93 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 2
%94 = load i32, i32* %93
%95 = load i32*, i32** %4
%96 = getelementptr inbounds i32, i32* %95, i64 0
store i32 %94, i32* %96
%97 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 3
%98 = load i32, i32* %97
%99 = load i32*, i32** %4
%100 = getelementptr inbounds i32, i32* %99, i64 1
store i32 %98, i32* %100
%101 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 9
%102 = load i32, i32* %101
%103 = load i32*, i32** %4
%104 = getelementptr inbounds i32, i32* %103, i64 2
store i32 %102, i32* %104
%105 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 10
%106 = load i32, i32* %105
%107 = load i32*, i32** %4
%108 = getelementptr inbounds i32, i32* %107, i64 3
store i32 %106, i32* %108
%109 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 5
%110 = load i32, i32* %109
%111 = load i32*, i32** %4
%112 = getelementptr inbounds i32, i32* %111, i64 4
store i32 %110, i32* %112
%113 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 6
%114 = load i32, i32* %113
%115 = load i32*, i32** %4
%116 = getelementptr inbounds i32, i32* %115, i64 5
store i32 %114, i32* %116
%117 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 15
%118 = load i32, i32* %117
%119 = load i32*, i32** %4
%120 = getelementptr inbounds i32, i32* %119, i64 6
store i32 %118, i32* %120
%121 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 16
%122 = load i32, i32* %121
%123 = load i32*, i32** %4
%124 = getelementptr inbounds i32, i32* %123, i64 7
store i32 %122, i32* %124
br label %126
125: ; preds = %3
br label %126
126: ; preds = %125, %89, %53, %17, %11
ret void
}

LLVM IR (-O2):
define void @gen_ka1_checksum(i32* %0, i32* %1, i32 %2) {
%4 = alloca [32 x i32]
%5 = alloca i32
%6 = bitcast [32 x i32]* %4 to i8*
%7 = bitcast i32* %5 to i8*
switch i32 %2, label %72 [
i32 0, label %8
i32 1, label %12
i32 2, label %32
i32 3, label %52
]
8: ; preds = %3
store i32 20000711, i32* %5
%9 = call i32 @memcpy(i32* %0, i32* %5, i32 4)
store i32 126, i32* %5
%10 = getelementptr inbounds i32, i32* %0, i64 4
%11 = call i32 @memcpy(i32* %10, i32* %5, i32 4)
br label %72
12: ; preds = %3
%13 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 0
%14 = call i32 @md5(i32* %1, i32 4, i32* %13)
%15 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 2
%16 = bitcast i32* %15 to <2 x i32>*
%17 = load <2 x i32>, <2 x i32>* %16
%18 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 8
%19 = bitcast i32* %18 to <2 x i32>*
%20 = load <2 x i32>, <2 x i32>* %19
%21 = shufflevector <2 x i32> %17, <2 x i32> %20, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%22 = bitcast i32* %0 to <4 x i32>*
store <4 x i32> %21, <4 x i32>* %22
%23 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 5
%24 = getelementptr inbounds i32, i32* %0, i64 4
%25 = bitcast i32* %23 to <2 x i32>*
%26 = load <2 x i32>, <2 x i32>* %25
%27 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 13
%28 = bitcast i32* %27 to <2 x i32>*
%29 = load <2 x i32>, <2 x i32>* %28
%30 = shufflevector <2 x i32> %26, <2 x i32> %29, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%31 = bitcast i32* %24 to <4 x i32>*
store <4 x i32> %30, <4 x i32>* %31
br label %72
32: ; preds = %3
%33 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 0
%34 = call i32 @md4(i32* %1, i32 4, i32* %33)
%35 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 1
%36 = bitcast i32* %35 to <2 x i32>*
%37 = load <2 x i32>, <2 x i32>* %36
%38 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 8
%39 = bitcast i32* %38 to <2 x i32>*
%40 = load <2 x i32>, <2 x i32>* %39
%41 = shufflevector <2 x i32> %37, <2 x i32> %40, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%42 = bitcast i32* %0 to <4 x i32>*
store <4 x i32> %41, <4 x i32>* %42
%43 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 4
%44 = getelementptr inbounds i32, i32* %0, i64 4
%45 = bitcast i32* %43 to <2 x i32>*
%46 = load <2 x i32>, <2 x i32>* %45
%47 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 11
%48 = bitcast i32* %47 to <2 x i32>*
%49 = load <2 x i32>, <2 x i32>* %48
%50 = shufflevector <2 x i32> %46, <2 x i32> %49, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%51 = bitcast i32* %44 to <4 x i32>*
store <4 x i32> %50, <4 x i32>* %51
br label %72
52: ; preds = %3
%53 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 0
%54 = call i32 @sha1(i32* %1, i32 4, i32* %53)
%55 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 2
%56 = bitcast i32* %55 to <2 x i32>*
%57 = load <2 x i32>, <2 x i32>* %56
%58 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 9
%59 = bitcast i32* %58 to <2 x i32>*
%60 = load <2 x i32>, <2 x i32>* %59
%61 = shufflevector <2 x i32> %57, <2 x i32> %60, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%62 = bitcast i32* %0 to <4 x i32>*
store <4 x i32> %61, <4 x i32>* %62
%63 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 5
%64 = getelementptr inbounds i32, i32* %0, i64 4
%65 = bitcast i32* %63 to <2 x i32>*
%66 = load <2 x i32>, <2 x i32>* %65
%67 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 15
%68 = bitcast i32* %67 to <2 x i32>*
%69 = load <2 x i32>, <2 x i32>* %68
%70 = shufflevector <2 x i32> %66, <2 x i32> %69, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%71 = bitcast i32* %64 to <4 x i32>*
store <4 x i32> %70, <4 x i32>* %71
br label %72
72: ; preds = %3, %52, %32, %12, %8
ret void
}