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

/* Variables and functions */
int EOF;
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int get_hilo16(unsigned short *wordpointer, FILE *fp) {
  unsigned char two_bytes[2];
  if (fread(two_bytes, 1, 2, fp) != 2)
    return EOF;
  *wordpointer =
      ((unsigned short)two_bytes[0] << 8) | (unsigned short)two_bytes[1];
  return 0;
}


x86 assembly (clang, -O0):
<get_hilo16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x1a(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <fread@plt>
cmp    $0x2,%eax
je     1151 <get_hilo16+0x41>
mov    0x2ea1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1175 <get_hilo16+0x65>
movzbl -0x1a(%rbp),%eax
movzwl %ax,%eax
shl    $0x8,%eax
movzbl -0x19(%rbp),%ecx
movzwl %cx,%ecx
or     %ecx,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_hilo16>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rcx
mov    %rdi,%rbx
lea    0xe(%rsp),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <fread@plt>
cmp    $0x2,%eax
jne    1144 <get_hilo16+0x34>
movzwl 0xe(%rsp),%eax
rol    $0x8,%ax
mov    %ax,(%rbx)
xor    %eax,%eax
jmp    114d <get_hilo16+0x3d>
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @get_hilo16(i16* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i16*
%5 = alloca i32*
%6 = alloca [2 x i8]
store i16* %0, i16** %4
store i32* %1, i32** %5
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%8 = load i32*, i32** %5
%9 = call i32 @fread(i8* %7, i32 1, i32 2, i32* %8)
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i32, i32* @EOF
store i32 %12, i32* %3
br label %26
13: ; preds = %2
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%15 = load i8, i8* %14
%16 = zext i8 %15 to i16
%17 = zext i16 %16 to i32
%18 = shl i32 %17, 8
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 1
%20 = load i8, i8* %19
%21 = zext i8 %20 to i16
%22 = zext i16 %21 to i32
%23 = or i32 %18, %22
%24 = trunc i32 %23 to i16
%25 = load i16*, i16** %4
store i16 %24, i16* %25
store i32 0, i32* %3
br label %26
26: ; preds = %13, %11
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @get_hilo16(i16* nocapture writeonly %0, i32* nocapture %1) {
%3 = alloca [2 x i8]
%4 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%5 = call i32 @fread(i8* %4, i32 1, i32 2, i32* %1)
%6 = icmp eq i32 %5, 2
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = load i32, i32* @EOF
br label %17
9: ; preds = %2
%10 = load i8, i8* %4
%11 = zext i8 %10 to i16
%12 = shl nuw i16 %11, 8
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
%14 = load i8, i8* %13
%15 = zext i8 %14 to i16
%16 = or i16 %12, %15
store i16 %16, i16* %0
br label %17
17: ; preds = %9, %7
%18 = phi i32 [ %8, %7 ], [ 0, %9 ]
ret i32 %18
}