#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*/ uintmax_t;

/* Variables and functions */
unsigned short CRC_Block(unsigned char *, size_t);
size_t fread(unsigned char *, int, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, unsigned short);
unsigned char *realloc(unsigned char *, size_t);
int /*<<< orphan*/ stdin;
int main() {
  unsigned char *buf = NULL;
  size_t bufsize = 0;
  size_t newbufsize;
  size_t nread;
  for (;;) {
    newbufsize = 2 * bufsize + 1;
    buf = realloc(buf, newbufsize);
    nread = fread(buf + bufsize, 1, newbufsize - bufsize, stdin);
    if (nread != newbufsize - bufsize) {
      unsigned short crc = CRC_Block(buf, bufsize + nread);
      printf("%ju.%u\n", (uintmax_t)(bufsize + nread), crc);
      break;
    }
    bufsize = newbufsize;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <realloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
sub    -0x18(%rbp),%rdx
mov    0x2e51(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    -0x18(%rbp),%rcx
cmp    %rcx,%rax
je     11f0 <main+0xb0>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    -0x28(%rbp),%rsi
call   1050 <CRC_Block@plt>
mov    %ax,-0x2a(%rbp)
mov    -0x18(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %eax,%esi
lea    0xe1e(%rip),%rdi
movzwl -0x2a(%rbp),%edx
call   1040 <printf@plt>
jmp    11fd <main+0xbd>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    115f <main+0x1f>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r12d,%r12d
mov    0x2e93(%rip),%r13
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
mov    %r12,%rbp
add    %r12,%r12
add    $0x1,%r12
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <realloc@plt>
mov    %rax,%r14
lea    (%rax,%rbp,1),%rdi
mov    %r12,%rbx
sub    %rbp,%rbx
mov    0x0(%r13),%ecx
mov    $0x1,%esi
mov    %rbx,%rdx
call   1030 <fread@plt>
cmp    %rbx,%rax
je     1160 <main+0x20>
mov    %rax,%r15
add    %rbp,%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <CRC_Block@plt>
movzwl %ax,%edx
lea    0xe4d(%rip),%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [8 x i8] c"%ju.%u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i16
store i32 0, i32* %1
store i8* null, i8** %2
store i64 0, i64* %3
br label %7
7: ; preds = %39, %0
%8 = load i64, i64* %3
%9 = mul i64 2, %8
%10 = add i64 %9, 1
store i64 %10, i64* %4
%11 = load i8*, i8** %2
%12 = load i64, i64* %4
%13 = call i8* @realloc(i8* %11, i64 %12)
store i8* %13, i8** %2
%14 = load i8*, i8** %2
%15 = load i64, i64* %3
%16 = getelementptr inbounds i8, i8* %14, i64 %15
%17 = load i64, i64* %4
%18 = load i64, i64* %3
%19 = sub i64 %17, %18
%20 = load i32, i32* @stdin
%21 = call i64 @fread(i8* %16, i32 1, i64 %19, i32 %20)
store i64 %21, i64* %5
%22 = load i64, i64* %5
%23 = load i64, i64* %4
%24 = load i64, i64* %3
%25 = sub i64 %23, %24
%26 = icmp ne i64 %22, %25
br i1 %26, label %27, label %39
27: ; preds = %7
%28 = load i8*, i8** %2
%29 = load i64, i64* %3
%30 = load i64, i64* %5
%31 = add i64 %29, %30
%32 = call zeroext i16 @CRC_Block(i8* %28, i64 %31)
store i16 %32, i16* %6
%33 = load i64, i64* %3
%34 = load i64, i64* %5
%35 = add i64 %33, %34
%36 = trunc i64 %35 to i32
%37 = load i16, i16* %6
%38 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %36, i16 zeroext %37)
br label %41
39: ; preds = %7
%40 = load i64, i64* %4
store i64 %40, i64* %3
br label %7
41: ; preds = %27
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [8 x i8] c"%ju.%u\0A\00"
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 0, %0 ], [ %5, %1 ]
%3 = phi i8* [ null, %0 ], [ %6, %1 ]
%4 = shl i64 %2, 1
%5 = or i64 %4, 1
%6 = tail call i8* @realloc(i8* %3, i64 %5)
%7 = getelementptr inbounds i8, i8* %6, i64 %2
%8 = sub i64 %5, %2
%9 = load i32, i32* @stdin
%10 = tail call i64 @fread(i8* %7, i32 1, i64 %8, i32 %9)
%11 = icmp eq i64 %10, %8
br i1 %11, label %1, label %12
12: ; preds = %1
%13 = add i64 %10, %2
%14 = tail call zeroext i16 @CRC_Block(i8* %6, i64 %13)
%15 = trunc i64 %13 to i32
%16 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %15, i16 zeroext %14)
ret i32 0
}