#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 fread(short *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  int i = 0;
  while (1) {
    short val;
    int nb;
    i++;
    nb = fread(&val, 2, 2, stdin);
    if (nb > 0) {
      if ((i % 10000) == 0)
        printf("%d \n", val + 32768);
    } else
      printf("%d nb\n", nb);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%ecx
lea    -0x16(%rbp),%rdi
mov    $0x2,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    119b <main+0x7b>
mov    -0x14(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1196 <main+0x76>
movswl -0x16(%rbp),%esi
add    $0x8000,%esi
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
jmp    11aa <main+0x8a>
mov    -0x1c(%rbp),%esi
lea    0xe60(%rip),%rdi
call   1040 <printf@plt>
jmp    113d <main+0x1d>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
mov    $0x1,%ebx
mov    $0xd1b71759,%r13d
mov    0x2ea6(%rip),%r14
lea    0x6(%rsp),%r12
jmp    1164 <main+0x44>
nopl   0x0(%rax)
lea    0xeae(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
add    $0xffffffff,%ebp
add    $0x1,%ebx
mov    %ebx,%eax
imul   %r13,%rax
shr    $0x2d,%rax
imul   $0x2710,%eax,%r15d
add    %ebp,%r15d
mov    (%r14),%ecx
mov    %r12,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
call   1030 <fread@plt>
test   %eax,%eax
jle    1150 <main+0x30>
test   %r15d,%r15d
jne    115e <main+0x3e>
movswl 0x6(%rsp),%esi
add    $0x8000,%esi
lea    0xe58(%rip),%rdi
jmp    1159 <main+0x39>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [5 x i8] c"%d \0A\00"
@.str.1 = [7 x i8] c"%d nb\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i16
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %9
9: ; preds = %2, %29
%10 = load i32, i32* %6
%11 = add nsw i32 %10, 1
store i32 %11, i32* %6
%12 = load i32, i32* @stdin
%13 = call i32 @fread(i16* %7, i32 2, i32 2, i32 %12)
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %9
%17 = load i32, i32* %6
%18 = srem i32 %17, 10000
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i16, i16* %7
%22 = sext i16 %21 to i32
%23 = add nsw i32 %22, 32768
%24 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %20, %16
br label %29
26: ; preds = %9
%27 = load i32, i32* %8
%28 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %26, %25
br label %9
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [5 x i8] c"%d \0A\00"
@.str.1 = [7 x i8] c"%d nb\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i16
%4 = bitcast i16* %3 to i8*
br label %5
5: ; preds = %21, %2
%6 = phi i32 [ 0, %2 ], [ %7, %21 ]
%7 = add nuw nsw i32 %6, 1
%8 = load i32, i32* @stdin
%9 = call i32 @fread(i16* %3, i32 2, i32 2, i32 %8)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %5
%12 = urem i32 %7, 10000
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i16, i16* %3
%16 = sext i16 %15 to i32
%17 = add nsw i32 %16, 32768
%18 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %21
19: ; preds = %5
%20 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %21
21: ; preds = %11, %14, %19
br label %5
}