#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 */
scalar_t__ feof(int /*<<< orphan*/);
unsigned int fread(unsigned char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  unsigned char c[2];
  unsigned int i;
  while (1) {
    if (fread(&(c[0]), 1, 2, stdin) != 2U) {
      if (feof(stdin)) {
        return 0;
      } else {
        return 1;
      }
    }
    printf(" 0x%04XU,", (((unsigned int)(c[0])) << 8) + ((unsigned int)(c[1])));
    i++;
    if (i == 8U) {
      printf("\n");
      i = 0U;
    }
  }
}


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)
lea    -0x12(%rbp),%rdi
mov    0x2e97(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <fread@plt>
cmp    $0x2,%eax
je     119b <main+0x6b>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
call   1050 <feof@plt>
cmp    $0x0,%rax
je     118f <main+0x5f>
movl   $0x0,-0x4(%rbp)
jmp    11e3 <main+0xb3>
movl   $0x1,-0x4(%rbp)
jmp    11e3 <main+0xb3>
movzbl -0x12(%rbp),%esi
shl    $0x8,%esi
movzbl -0x11(%rbp),%eax
add    %eax,%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jne    11de <main+0xae>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
jmp    1146 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e9a(%rip),%r15
mov    (%r15),%ecx
lea    0x6(%rsp),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1040 <fread@plt>
cmp    $0x2,%eax
jne    11c4 <main+0x84>
lea    0xe8f(%rip),%r14
lea    0x6(%rsp),%rbx
jmp    119a <main+0x5a>
nopl   0x0(%rax,%rax,1)
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1040 <fread@plt>
cmp    $0x2,%eax
jne    11c4 <main+0x84>
movzwl 0x6(%rsp),%esi
shl    $0x10,%esi
bswap  %esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    $0x8,%ebp
jne    1180 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
jmp    1180 <main+0x40>
mov    (%r15),%edi
call   1060 <feof@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@stdin = global i32 0
@.str = [10 x i8] c" 0x%04XU,\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2 x i8]
%4 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32 @fread(i8* %4, i32 1, i32 2, i32 %5)
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
br label %15
10: ; preds = %28, %2
%11 = load i32, i32* @stdin
%12 = call i64 @feof(i32 %11)
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
ret i32 %14
15: ; preds = %8, %28
%16 = phi i32 [ undef, %8 ], [ %29, %28 ]
%17 = load i8, i8* %4
%18 = zext i8 %17 to i32
%19 = shl nuw nsw i32 %18, 8
%20 = load i8, i8* %9
%21 = zext i8 %20 to i32
%22 = or i32 %19, %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = add i32 %16, 1
%25 = icmp eq i32 %24, 8
br i1 %25, label %26, label %28
26: ; preds = %15
%27 = call i32 @putchar(i32 10)
br label %28
28: ; preds = %26, %15
%29 = phi i32 [ 0, %26 ], [ %24, %15 ]
%30 = load i32, i32* @stdin
%31 = call i32 @fread(i8* %4, i32 1, i32 2, i32 %30)
%32 = icmp eq i32 %31, 2
br i1 %32, label %15, label %10
}