#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 */
int /*<<< orphan*/ printf(char *, long);
void main(void) {
  long datalen = 296;
  char data[] = {
      0x05, 0x03, 0x04, 0x00, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,    0,    0,    0,    0};
  char data1[] = {
      0x05, 0x10, 0x24, 0x81, 0x4d, 0xf6, 0xa7, 0x52, 0xbd, 0x83, 0xec, 0xe9,
      0x88, 0xbc, 0xcc, 0x0f, 0x90, 0xf4, 0x99, 0x97, 0xb0, 0xf6, 0xae, 0xa3,
      0x9b, 0x99, 0x98, 0xb6, 0xf7, 0xfb, 0x55, 0x8b, 0xbe, 0x23, 0x68, 0xf3,
      0xc7, 0xad, 0x72, 0xe6, 0xf2, 0x1b, 0x88, 0xdf, 0x9c, 0x1e, 0xb4, 0xa3,
      0x1d, 0x59, 0xac, 0xe5, 0xa9, 0xdd, 0xe8, 0x97, 0x65, 0x63, 0xd9, 0xe6,
      0x7c, 0xb8, 0xad, 0x2b, 0x8b, 0xce, 0x3f, 0xa5, 0x73, 0x3d, 0xcd, 0x8c,
      0xc9, 0x65, 0xbb, 0xfb, 0x3f, 0x99, 0x1d, 0xc4, 0xa0, 0x15, 0x3c, 0x29,
      0xf4, 0xc7, 0xbf, 0xbd, 0x32, 0xfa, 0xd6, 0xf6, 0xde, 0x29, 0x0f, 0xf6,
      0x9d, 0xe4, 0xbf, 0x7b, 0xfd, 0x58, 0x27, 0xa2, 0xb3, 0x7f, 0x7b, 0xfd,
      0x9f, 0xd6, 0xb7, 0x80, 0x4a, 0x71, 0xb6, 0xa8, 0xdd, 0xd1, 0xe0, 0x31,
      0xe8, 0x0c, 0xc3, 0xed, 0xb7, 0x33, 0xc2, 0x0b, 0x71, 0xbb, 0xe6, 0xff,
      0x00, 0x67, 0x83, 0xd6, 0x9d, 0xb0, 0xde, 0x68, 0xcf, 0x25, 0xd5, 0xbd,
      0xf5, 0x85, 0xc4, 0xaa, 0x53, 0x6c, 0x9b, 0xb3, 0x1f, 0xd7, 0x35, 0xc9,
      0x3d, 0x64, 0xf5, 0x34, 0x53, 0x56, 0x5a, 0x1c, 0xb4, 0x30, 0x6a, 0x37,
      0x1c, 0x0d, 0x52, 0xfa, 0x3c, 0x7f, 0x7f, 0x23, 0xbb, 0x8f, 0xef, 0x7f,
      0xb2, 0x7f, 0xef, 0xaa, 0x82, 0xe1, 0x6f, 0xfc, 0xdb, 0x88, 0x5f, 0x52,
      0xbb, 0xf9, 0x37, 0x7c, 0xcc, 0x4e, 0x1b, 0x0e, 0x57, 0xfb, 0xde, 0xd5,
      0xe8, 0x9c, 0x7e, 0xd2, 0x1d, 0x8e, 0x46, 0x6b, 0xc9, 0x3e, 0x62, 0x64,
      0xce, 0x17, 0xb9, 0xed, 0x5c, 0xaa, 0xdc, 0xb8, 0x47, 0x22, 0xba, 0x60,
      0x8c, 0x31, 0x0e, 0xcc, 0xf4, 0x5d, 0x2e, 0xf0, 0x06, 0x45, 0xdd, 0xc7,
      0x7a, 0xda, 0xbb, 0xbb, 0xc4, 0x13, 0x30, 0x2c, 0xc5, 0x57, 0x27, 0x00,
      0xf1, 0x9e, 0x95, 0xc1, 0x34, 0x74, 0xa6, 0x32, 0xea, 0xfa, 0xca, 0x4d,
      0x21, 0x55, 0x65, 0x5f, 0x33, 0x04, 0x00, 0x47, 0x5e, 0x63, 0xcf, 0x24,
      0x7b, 0x51, 0xa8, 0x6b, 0x16, 0xf7, 0x31, 0x4b, 0x1d, 0xad, 0xc2, 0x33,
      0x37, 0x98, 0xa7, 0x2c, 0x07, 0x58, 0x9c, 0x77, 0x6e, 0xc7, 0xc1};
  char bits[] = {1, 2, 4, 8, 16, 32, 64, 128};
  long chksum = 0;
  long i, j;
  int inputbit, lastbit, xorbit;
  for (i = 0; i < datalen; i++)
    for (j = 0; j <= 7; j++) {
      lastbit = chksum & 0x0001;
      chksum >>= 1;
      inputbit = data[i] & bits[j] ? 1 : 0;
      xorbit = inputbit ^ lastbit;
      if (xorbit)
        chksum ^= 0x8408;
    }
  printf("Checksum: 0x%lX\n", chksum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2e0,%rsp
movq   $0x128,-0x8(%rbp)
lea    -0x180(%rbp),%rdi
xor    %esi,%esi
mov    $0x16d,%edx
call   1040 <memset@plt>
movb   $0x5,-0x180(%rbp)
movb   $0x3,-0x17f(%rbp)
movb   $0x4,-0x17e(%rbp)
movb   $0x1,-0x17c(%rbp)
lea    -0x2b0(%rbp),%rdi
lea    0xe80(%rip),%rsi
mov    $0x12b,%edx
call   1050 <memcpy@plt>
mov    0xf9a(%rip),%rax
mov    %rax,-0x2b8(%rbp)
movq   $0x0,-0x2c0(%rbp)
movq   $0x0,-0x2c8(%rbp)
mov    -0x2c8(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    1299 <main+0x169>
movq   $0x0,-0x2d0(%rbp)
cmpq   $0x7,-0x2d0(%rbp)
07
jg     127d <main+0x14d>
mov    -0x2c0(%rbp),%rax
and    $0x1,%rax
mov    %eax,-0x2d8(%rbp)
mov    -0x2c0(%rbp),%rax
sar    $0x1,%rax
mov    %rax,-0x2c0(%rbp)
mov    -0x2c8(%rbp),%rax
movsbl -0x180(%rbp,%rax,1),%edx
ff
mov    -0x2d0(%rbp),%rax
movsbl -0x2b8(%rbp,%rax,1),%eax
ff
and    %eax,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x2d4(%rbp)
mov    -0x2d4(%rbp),%eax
xor    -0x2d8(%rbp),%eax
mov    %eax,-0x2dc(%rbp)
cmpl   $0x0,-0x2dc(%rbp)
je     1261 <main+0x131>
mov    -0x2c0(%rbp),%rax
xor    $0x8408,%rax
mov    %rax,-0x2c0(%rbp)
jmp    1266 <main+0x136>
mov    -0x2d0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x2d0(%rbp)
jmp    11ca <main+0x9a>
jmp    1282 <main+0x152>
mov    -0x2c8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x2c8(%rbp)
jmp    11ae <main+0x7e>
mov    -0x2c0(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
add    $0x2e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x170,%rsp
mov    %rsp,%rdi
xor    %ebx,%ebx
mov    $0x16d,%edx
xor    %esi,%esi
call   1040 <memset@plt>
movw   $0x403,0x1(%rsp)
movb   $0x1,0x4(%rsp)
mov    $0x5,%cl
mov    $0x1,%esi
nopl   0x0(%rax)
mov    %rbx,%rdx
sar    %rdx
test   $0x1,%cl
sete   %al
xor    %al,%bl
mov    %rdx,%rax
xor    $0x8408,%rax
test   $0x1,%bl
cmovne %rdx,%rax
mov    %rax,%rdx
sar    %rdx
test   $0x2,%cl
sete   %bl
xor    %bl,%al
mov    %rdx,%rdi
xor    $0x8408,%rdi
test   $0x1,%al
cmovne %rdx,%rdi
mov    %rdi,%rax
sar    %rax
test   $0x4,%cl
sete   %dl
xor    %dl,%dil
mov    %rax,%rdx
xor    $0x8408,%rdx
test   $0x1,%dil
cmovne %rax,%rdx
mov    %rdx,%rax
sar    %rax
test   $0x8,%cl
sete   %bl
xor    %bl,%dl
mov    %rax,%rdi
xor    $0x8408,%rdi
test   $0x1,%dl
cmovne %rax,%rdi
mov    %rdi,%rax
sar    %rax
test   $0x10,%cl
sete   %dl
xor    %dl,%dil
mov    %rax,%rdx
xor    $0x8408,%rdx
test   $0x1,%dil
cmovne %rax,%rdx
mov    %rdx,%rax
sar    %rax
test   $0x20,%cl
sete   %bl
xor    %bl,%dl
mov    %rax,%rdi
xor    $0x8408,%rdi
test   $0x1,%dl
cmovne %rax,%rdi
mov    %rdi,%rax
sar    %rax
test   $0x40,%cl
sete   %dl
xor    %dl,%dil
mov    %rax,%rdx
xor    $0x8408,%rdx
test   $0x1,%dil
cmovne %rax,%rdx
mov    %rdx,%rax
sar    %rax
test   %cl,%cl
setns  %cl
xor    %cl,%dl
mov    %rax,%rbx
xor    $0x8408,%rbx
test   $0x1,%dl
cmovne %rax,%rbx
cmp    $0x128,%rsi
je     1261 <main+0x141>
movzbl (%rsp,%rsi,1),%ecx
add    $0x1,%rsi
jmp    1150 <main+0x30>
lea    0xd98(%rip),%rdi
mov    %rbx,%rsi
add    $0x170,%rsp
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@__const.main.data1 = [299 x i8] c"\05\10$\81M\F6\A7R\BD\83\EC\E9\88\BC\CC\0F\90\F4\99\97\B0\F6\AE\A3\9B\99\98\B6\F7\FBU\8B\BE#h\F3\C7\ADr\E6\F2\1B\88\DF\9C\1E\B4\A3\1DY\AC\E5\A9\DD\E8\97ec\D9\E6|\B8\AD+\8B\CE?\A5s=\CD\8C\C9e\BB\FB?\99\1D\C4\A0\15<)\F4\C7\BF\BD2\FA\D6\F6\DE)\0F\F6\9D\E4\BF{\FDX'\A2\B3\7F{\FD\9F\D6\B7\80Jq\B6\A8\DD\D1\E01\E8\0C\C3\ED\B73\C2\0Bq\BB\E6\FF\00g\83\D6\9D\B0\DEh\CF%\D5\BD\F5\85\C4\AASl\9B\B3\1F\D75\C9=d\F54SVZ\1C\B40j7\1C\0DR\FA<\7F\7F#\BB\8F\EF\7F\B2\7F\EF\AA\82\E1o\FC\DB\88_R\BB\F97|\CCN\1B\0EW\FB\DE\D5\E8\9C~\D2\1D\8EFk\C9>bd\CE\17\B9\ED\\\AA\DC\B8G\22\BA`\8C1\0E\CC\F4].\F0\06E\DD\C7z\DA\BB\BB\C4\130,\C5W'\00\F1\9E\95\C14t\A62\EA\FA\CAM!Ue_3\04\00G^c\CF${Q\A8k\16\F71K\1D\AD\C237\98\A7,\07X\9Cwn\C7\C1"
@__const.main.bits = [8 x i8] c"\01\02\04\08\10 @\80"
@.str = [17 x i8] c"Checksum: 0x%lX\0A\00"
define void @main() {
%1 = alloca i64
%2 = alloca [365 x i8]
%3 = alloca [299 x i8]
%4 = alloca [8 x i8]
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i64 296, i64* %1
%11 = bitcast [365 x i8]* %2 to i8*
%12 = bitcast i8* %11 to <{ i8, i8, i8, i8, i8, [360 x i8] }>*
%13 = getelementptr inbounds <{ i8, i8, i8, i8, i8, [360 x i8] }>, <{ i8, i8, i8, i8, i8, [360 x i8] }>* %12, i32 0, i32 0
store i8 5, i8* %13
%14 = getelementptr inbounds <{ i8, i8, i8, i8, i8, [360 x i8] }>, <{ i8, i8, i8, i8, i8, [360 x i8] }>* %12, i32 0, i32 1
store i8 3, i8* %14
%15 = getelementptr inbounds <{ i8, i8, i8, i8, i8, [360 x i8] }>, <{ i8, i8, i8, i8, i8, [360 x i8] }>* %12, i32 0, i32 2
store i8 4, i8* %15
%16 = getelementptr inbounds <{ i8, i8, i8, i8, i8, [360 x i8] }>, <{ i8, i8, i8, i8, i8, [360 x i8] }>* %12, i32 0, i32 4
store i8 1, i8* %16
%17 = bitcast [299 x i8]* %3 to i8*
%18 = bitcast [8 x i8]* %4 to i8*
store i64 0, i64* %5
store i64 0, i64* %6
br label %19
19: ; preds = %58, %0
%20 = load i64, i64* %6
%21 = load i64, i64* %1
%22 = icmp slt i64 %20, %21
br i1 %22, label %23, label %61
23: ; preds = %19
store i64 0, i64* %7
br label %24
24: ; preds = %54, %23
%25 = load i64, i64* %7
%26 = icmp sle i64 %25, 7
br i1 %26, label %27, label %57
27: ; preds = %24
%28 = load i64, i64* %5
%29 = and i64 %28, 1
%30 = trunc i64 %29 to i32
store i32 %30, i32* %9
%31 = load i64, i64* %5
%32 = ashr i64 %31, 1
store i64 %32, i64* %5
%33 = load i64, i64* %6
%34 = getelementptr inbounds [365 x i8], [365 x i8]* %2, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = load i64, i64* %7
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = and i32 %36, %40
%42 = icmp ne i32 %41, 0
%43 = zext i1 %42 to i64
%44 = select i1 %42, i32 1, i32 0
store i32 %44, i32* %8
%45 = load i32, i32* %8
%46 = load i32, i32* %9
%47 = xor i32 %45, %46
store i32 %47, i32* %10
%48 = load i32, i32* %10
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %27
%51 = load i64, i64* %5
%52 = xor i64 %51, 33800
store i64 %52, i64* %5
br label %53
53: ; preds = %50, %27
br label %54
54: ; preds = %53
%55 = load i64, i64* %7
%56 = add nsw i64 %55, 1
store i64 %56, i64* %7
br label %24
57: ; preds = %24
br label %58
58: ; preds = %57
%59 = load i64, i64* %6
%60 = add nsw i64 %59, 1
store i64 %60, i64* %6
br label %19
61: ; preds = %19
%62 = load i64, i64* %5
%63 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %62)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"Checksum: 0x%lX\0A\00"
define void @main() {
%1 = alloca [365 x i8]
%2 = getelementptr inbounds [365 x i8], [365 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [365 x i8], [365 x i8]* %1, i64 0, i64 1
store i8 3, i8* %3
%4 = getelementptr inbounds [365 x i8], [365 x i8]* %1, i64 0, i64 2
store i8 4, i8* %4
%5 = getelementptr inbounds [365 x i8], [365 x i8]* %1, i64 0, i64 4
store i8 1, i8* %5
br label %6
6: ; preds = %75, %0
%7 = phi i8 [ 5, %0 ], [ %77, %75 ]
%8 = phi i64 [ 0, %0 ], [ %72, %75 ]
%9 = phi i64 [ 0, %0 ], [ %73, %75 ]
%10 = ashr i64 %8, 1
%11 = and i8 %7, 1
%12 = icmp eq i8 %11, 0
%13 = and i64 %8, 1
%14 = icmp ne i64 %13, 0
%15 = xor i1 %14, %12
%16 = xor i64 %10, 33800
%17 = select i1 %15, i64 %10, i64 %16
%18 = ashr i64 %17, 1
%19 = and i8 %7, 2
%20 = icmp eq i8 %19, 0
%21 = and i64 %17, 1
%22 = icmp ne i64 %21, 0
%23 = xor i1 %22, %20
%24 = xor i64 %18, 33800
%25 = select i1 %23, i64 %18, i64 %24
%26 = ashr i64 %25, 1
%27 = and i8 %7, 4
%28 = icmp eq i8 %27, 0
%29 = and i64 %25, 1
%30 = icmp ne i64 %29, 0
%31 = xor i1 %30, %28
%32 = xor i64 %26, 33800
%33 = select i1 %31, i64 %26, i64 %32
%34 = ashr i64 %33, 1
%35 = and i8 %7, 8
%36 = icmp eq i8 %35, 0
%37 = and i64 %33, 1
%38 = icmp ne i64 %37, 0
%39 = xor i1 %38, %36
%40 = xor i64 %34, 33800
%41 = select i1 %39, i64 %34, i64 %40
%42 = ashr i64 %41, 1
%43 = and i8 %7, 16
%44 = icmp eq i8 %43, 0
%45 = and i64 %41, 1
%46 = icmp ne i64 %45, 0
%47 = xor i1 %46, %44
%48 = xor i64 %42, 33800
%49 = select i1 %47, i64 %42, i64 %48
%50 = ashr i64 %49, 1
%51 = and i8 %7, 32
%52 = icmp eq i8 %51, 0
%53 = and i64 %49, 1
%54 = icmp ne i64 %53, 0
%55 = xor i1 %54, %52
%56 = xor i64 %50, 33800
%57 = select i1 %55, i64 %50, i64 %56
%58 = ashr i64 %57, 1
%59 = and i8 %7, 64
%60 = icmp eq i8 %59, 0
%61 = and i64 %57, 1
%62 = icmp ne i64 %61, 0
%63 = xor i1 %62, %60
%64 = xor i64 %58, 33800
%65 = select i1 %63, i64 %58, i64 %64
%66 = ashr i64 %65, 1
%67 = icmp sgt i8 %7, -1
%68 = and i64 %65, 1
%69 = icmp ne i64 %68, 0
%70 = xor i1 %69, %67
%71 = xor i64 %66, 33800
%72 = select i1 %70, i64 %66, i64 %71
%73 = add nuw nsw i64 %9, 1
%74 = icmp eq i64 %73, 296
br i1 %74, label %78, label %75
75: ; preds = %6
%76 = getelementptr inbounds [365 x i8], [365 x i8]* %1, i64 0, i64 %73
%77 = load i8, i8* %76
br label %6
78: ; preds = %6
%79 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %72)
ret void
}