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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ feof(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
size_t fread(scalar_t__ **, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ *freopen(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int update_crc(int, scalar_t__);
int main(int argc, char *argv[]) {
  if (freopen(NULL, "rb", stdin) == NULL) {
    perror("freopen");
    exit(EXIT_FAILURE);
  }
  uint32_t crc = 0xffffffff;
  uint32_t sscrc = 0xffffffff;
  while (1) {
    uint8_t value[2];
    size_t rd = fread(&value, sizeof(uint8_t), 2, stdin);
    if (rd < 2) {
      if (feof(stdin)) {
        if (rd > 0)
          fprintf(stderr, "WARNING: EOF while reading sample.\n");
        break;
      }
      perror("fread");
      exit(EXIT_FAILURE);
    }
    crc = update_crc(crc, value[0]);
    crc = update_crc(crc, value[1]);
    if (value[0] != 0 || value[1] != 0) {
      sscrc = update_crc(sscrc, value[0]);
      sscrc = update_crc(sscrc, value[1]);
    }
  }
  crc ^= 0xffffffff;
  sscrc ^= 0xffffffff;
  printf("%08x, %08x\n", crc, sscrc);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%edi
lea    0xe56(%rip),%rsi
call   1050 <freopen@plt>
cmp    $0x0,%rax
jne    11d3 <main+0x53>
lea    0xe43(%rip),%rdi
call   1090 <perror@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
movl   $0xffffffff,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
mov    0x2dfc(%rip),%rax
mov    (%rax),%ecx
mov    $0x8,%esi
mov    $0x2,%edx
call   1030 <fread@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x2,-0x38(%rbp)
jae    1263 <main+0xe3>
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
cmp    $0x0,%rax
je     1249 <main+0xc9>
cmpq   $0x0,-0x38(%rbp)
jbe    1244 <main+0xc4>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
lea    0xdcc(%rip),%rsi
call   1060 <fprintf@plt>
jmp    12ba <main+0x13a>
lea    0xddf(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1080 <update_crc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1080 <update_crc@plt>
mov    %eax,-0x14(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1297 <main+0x117>
cmpq   $0x0,-0x28(%rbp)
je     12b5 <main+0x135>
mov    -0x18(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1080 <update_crc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1080 <update_crc@plt>
mov    %eax,-0x18(%rbp)
jmp    11e1 <main+0x61>
mov    -0x14(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xd5c(%rip),%rdi
call   1040 <printf@plt>
mov    0x2ce3(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    0x2e55(%rip),%r12
mov    (%r12),%edx
lea    0xe62(%rip),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <freopen@plt>
test   %rax,%rax
je     12a3 <main+0x123>
mov    (%r12),%ecx
mov    %rsp,%rdi
mov    $0x8,%esi
mov    $0x2,%edx
call   1030 <fread@plt>
cmp    $0x2,%rax
jae    11d7 <main+0x57>
mov    %rax,%rbp
mov    $0xffffffff,%r15d
jmp    1251 <main+0xd1>
mov    $0xffffffff,%r15d
mov    %rsp,%r14
mov    $0xffffffff,%ebx
jmp    120c <main+0x8c>
nopw   0x0(%rax,%rax,1)
mov    (%r12),%ecx
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x2,%edx
call   1030 <fread@plt>
cmp    $0x2,%rax
jb     124c <main+0xcc>
mov    (%rsp),%rsi
mov    %ebx,%edi
call   1080 <update_crc@plt>
mov    0x8(%rsp),%rsi
mov    %eax,%edi
call   1080 <update_crc@plt>
mov    %eax,%ebx
mov    (%rsp),%rsi
mov    0x8(%rsp),%rax
or     %rsi,%rax
je     11f0 <main+0x70>
mov    %r15d,%edi
call   1080 <update_crc@plt>
mov    0x8(%rsp),%rsi
mov    %eax,%edi
call   1080 <update_crc@plt>
mov    %eax,%r15d
jmp    11f0 <main+0x70>
mov    %rax,%rbp
not    %ebx
mov    (%r12),%edi
call   1070 <feof@plt>
test   %rax,%rax
je     12ac <main+0x12c>
test   %rbp,%rbp
je     1279 <main+0xf9>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
lea    0xd97(%rip),%rsi
call   1060 <fprintf@plt>
not    %r15d
lea    0xdb2(%rip),%rdi
mov    %ebx,%esi
mov    %r15d,%edx
call   1040 <printf@plt>
mov    0x2d34(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd59(%rip),%rdi
jmp    12b3 <main+0x133>
lea    0xd7c(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@stdin = global i32 0
@.str.1 = [8 x i8] c"freopen\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.2 = [36 x i8] c"WARNING: EOF while reading sample.\0A\00"
@.str.3 = [6 x i8] c"fread\00"
@.str.4 = [12 x i8] c"%08x, %08x\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [2 x i64]
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* @stdin
%11 = call i32* @freopen(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
store i32 -1, i32* %6
store i32 -1, i32* %7
br label %18
18: ; preds = %17, %64
%19 = bitcast [2 x i64]* %8 to i64**
%20 = load i32, i32* @stdin
%21 = call i64 @fread(i64** %19, i32 8, i32 2, i32 %20)
store i64 %21, i64* %9
%22 = load i64, i64* %9
%23 = icmp ult i64 %22, 2
br i1 %23, label %24, label %39
24: ; preds = %18
%25 = load i32, i32* @stdin
%26 = call i64 @feof(i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %24
%29 = load i64, i64* %9
%30 = icmp ugt i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %34
34: ; preds = %31, %28
br label %65
35: ; preds = %24
%36 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %18
%40 = load i32, i32* %6
%41 = getelementptr inbounds [2 x i64], [2 x i64]* %8, i64 0, i64 0
%42 = load i64, i64* %41
%43 = call i32 @update_crc(i32 %40, i64 %42)
store i32 %43, i32* %6
%44 = load i32, i32* %6
%45 = getelementptr inbounds [2 x i64], [2 x i64]* %8, i64 0, i64 1
%46 = load i64, i64* %45
%47 = call i32 @update_crc(i32 %44, i64 %46)
store i32 %47, i32* %6
%48 = getelementptr inbounds [2 x i64], [2 x i64]* %8, i64 0, i64 0
%49 = load i64, i64* %48
%50 = icmp ne i64 %49, 0
br i1 %50, label %55, label %51
51: ; preds = %39
%52 = getelementptr inbounds [2 x i64], [2 x i64]* %8, i64 0, i64 1
%53 = load i64, i64* %52
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %64
55: ; preds = %51, %39
%56 = load i32, i32* %7
%57 = getelementptr inbounds [2 x i64], [2 x i64]* %8, i64 0, i64 0
%58 = load i64, i64* %57
%59 = call i32 @update_crc(i32 %56, i64 %58)
store i32 %59, i32* %7
%60 = load i32, i32* %7
%61 = getelementptr inbounds [2 x i64], [2 x i64]* %8, i64 0, i64 1
%62 = load i64, i64* %61
%63 = call i32 @update_crc(i32 %60, i64 %62)
store i32 %63, i32* %7
br label %64
64: ; preds = %55, %51
br label %18
65: ; preds = %34
%66 = load i32, i32* %6
%67 = xor i32 %66, -1
store i32 %67, i32* %6
%68 = load i32, i32* %7
%69 = xor i32 %68, -1
store i32 %69, i32* %7
%70 = load i32, i32* %6
%71 = load i32, i32* %7
%72 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %70, i32 %71)
%73 = load i32, i32* @EXIT_SUCCESS
ret i32 %73
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@stdin = global i32 0
@.str.1 = [8 x i8] c"freopen\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.2 = [36 x i8] c"WARNING: EOF while reading sample.\0A\00"
@.str.3 = [6 x i8] c"fread\00"
@.str.4 = [12 x i8] c"%08x, %08x\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2 x i64]
%4 = load i32, i32* @stdin
%5 = tail call i32* @freopen(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp eq i32* %5, null
br i1 %6, label %16, label %7
7: ; preds = %2
%8 = bitcast [2 x i64]* %3 to i8*
%9 = bitcast [2 x i64]* %3 to i64**
%10 = load i32, i32* @stdin
%11 = call i64 @fread(i64** %9, i32 8, i32 2, i32 %10)
%12 = icmp ult i64 %11, 2
br i1 %12, label %22, label %13
13: ; preds = %7
%14 = getelementptr inbounds [2 x i64], [2 x i64]* %3, i64 0, i64 0
%15 = getelementptr inbounds [2 x i64], [2 x i64]* %3, i64 0, i64 1
br label %38
16: ; preds = %2
%17 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %54
%21 = xor i32 %44, -1
br label %22
22: ; preds = %20, %7
%23 = phi i32 [ 0, %7 ], [ %21, %20 ]
%24 = phi i32 [ -1, %7 ], [ %55, %20 ]
%25 = phi i64 [ %11, %7 ], [ %57, %20 ]
%26 = load i32, i32* @stdin
%27 = call i64 @feof(i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %22
%30 = icmp eq i64 %25, 0
br i1 %30, label %59, label %31
31: ; preds = %29
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %59
34: ; preds = %22
%35 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %13, %54
%39 = phi i32 [ -1, %13 ], [ %55, %54 ]
%40 = phi i32 [ -1, %13 ], [ %44, %54 ]
%41 = load i64, i64* %14
%42 = call i32 @update_crc(i32 %40, i64 %41)
%43 = load i64, i64* %15
%44 = call i32 @update_crc(i32 %42, i64 %43)
%45 = load i64, i64* %14
%46 = icmp ne i64 %45, 0
%47 = load i64, i64* %15
%48 = icmp ne i64 %47, 0
%49 = select i1 %46, i1 true, i1 %48
br i1 %49, label %50, label %54
50: ; preds = %38
%51 = call i32 @update_crc(i32 %39, i64 %45)
%52 = load i64, i64* %15
%53 = call i32 @update_crc(i32 %51, i64 %52)
br label %54
54: ; preds = %50, %38
%55 = phi i32 [ %53, %50 ], [ %39, %38 ]
%56 = load i32, i32* @stdin
%57 = call i64 @fread(i64** %9, i32 8, i32 2, i32 %56)
%58 = icmp ult i64 %57, 2
br i1 %58, label %20, label %38
59: ; preds = %31, %29
%60 = xor i32 %24, -1
%61 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %23, i32 %60)
%62 = load i32, i32* @EXIT_SUCCESS
ret i32 %62
}