#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 */
scalar_t__ EOF;
scalar_t__ putc(int, int /*<<< orphan*/ *);
int put_hilo16(unsigned short word, FILE *fp) {
  if (putc((int)(word >> 8), fp) == EOF)
    return EOF;
  if (putc((int)(word & 0xFF), fp) == EOF)
    return EOF;
  return 0;
}


x86 assembly (clang, -O0):
<put_hilo16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x6(%rbp)
mov    %rsi,-0x10(%rbp)
movzwl -0x6(%rbp),%edi
sar    $0x8,%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    0x2eae(%rip),%rcx
cmp    (%rcx),%rax
jne    1155 <put_hilo16+0x45>
mov    0x2e9e(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    1191 <put_hilo16+0x81>
movzwl -0x6(%rbp),%edi
and    $0xff,%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    0x2e79(%rip),%rcx
cmp    (%rcx),%rax
jne    118a <put_hilo16+0x7a>
mov    0x2e69(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    1191 <put_hilo16+0x81>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_hilo16>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
shr    $0x8,%edi
call   1030 <putc@plt>
mov    0x2ec0(%rip),%r14
cmp    (%r14),%rax
je     1147 <put_hilo16+0x37>
movzbl %bpl,%edi
mov    %rbx,%rsi
call   1030 <putc@plt>
mov    %rax,%rcx
mov    (%r14),%rax
xor    %edx,%edx
cmp    %rax,%rcx
cmovne %edx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i64 0
define i32 @put_hilo16(i16 zeroext %0, i32* %1) {
%3 = alloca i32
%4 = alloca i16
%5 = alloca i32*
store i16 %0, i16* %4
store i32* %1, i32** %5
%6 = load i16, i16* %4
%7 = zext i16 %6 to i32
%8 = ashr i32 %7, 8
%9 = load i32*, i32** %5
%10 = call i64 @putc(i32 %8, i32* %9)
%11 = load i64, i64* @EOF
%12 = icmp eq i64 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i64, i64* @EOF
%15 = trunc i64 %14 to i32
store i32 %15, i32* %3
br label %28
16: ; preds = %2
%17 = load i16, i16* %4
%18 = zext i16 %17 to i32
%19 = and i32 %18, 255
%20 = load i32*, i32** %5
%21 = call i64 @putc(i32 %19, i32* %20)
%22 = load i64, i64* @EOF
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %16
%25 = load i64, i64* @EOF
%26 = trunc i64 %25 to i32
store i32 %26, i32* %3
br label %28
27: ; preds = %16
store i32 0, i32* %3
br label %28
28: ; preds = %27, %24, %13
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@EOF = global i64 0
define i32 @put_hilo16(i16 zeroext %0, i32* nocapture %1) {
%3 = zext i16 %0 to i32
%4 = lshr i32 %3, 8
%5 = tail call i64 @putc(i32 %4, i32* %1)
%6 = load i64, i64* @EOF
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = trunc i64 %5 to i32
br label %17
10: ; preds = %2
%11 = and i32 %3, 255
%12 = tail call i64 @putc(i32 %11, i32* %1)
%13 = load i64, i64* @EOF
%14 = icmp eq i64 %12, %13
%15 = trunc i64 %13 to i32
%16 = select i1 %14, i32 %15, i32 0
br label %17
17: ; preds = %10, %8
%18 = phi i32 [ %9, %8 ], [ %16, %10 ]
ret i32 %18
}