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

/* Variables and functions */
int FALSE;
int TRUE;
int /*<<< orphan*/ XdmcpWriteCARD8(int /*<<< orphan*/, unsigned int);
int XdmcpWriteCARD16(XdmcpBufferPtr buffer, unsigned value) {
  if (!XdmcpWriteCARD8(buffer, value >> 8))
    return FALSE;
  if (!XdmcpWriteCARD8(buffer, value & 0xff))
    return FALSE;
  return TRUE;
}


x86 assembly (clang, -O0):
<XdmcpWriteCARD16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
shr    $0x8,%esi
call   1030 <XdmcpWriteCARD8@plt>
cmp    $0x0,%eax
jne    1146 <XdmcpWriteCARD16+0x36>
mov    0x2e9c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    117d <XdmcpWriteCARD16+0x6d>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
and    $0xff,%esi
call   1030 <XdmcpWriteCARD8@plt>
cmp    $0x0,%eax
jne    1171 <XdmcpWriteCARD16+0x61>
mov    0x2e71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    117d <XdmcpWriteCARD16+0x6d>
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XdmcpWriteCARD16>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
shr    $0x8,%esi
call   1030 <XdmcpWriteCARD8@plt>
test   %eax,%eax
je     1132 <XdmcpWriteCARD16+0x22>
movzbl %bpl,%esi
mov    %ebx,%edi
call   1030 <XdmcpWriteCARD8@plt>
test   %eax,%eax
jne    113b <XdmcpWriteCARD16+0x2b>
mov    0x2e9f(%rip),%rax
jmp    1142 <XdmcpWriteCARD16+0x32>
mov    0x2ea6(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@FALSE = global i32 0
@TRUE = global i32 0
define i32 @XdmcpWriteCARD16(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = load i32, i32* %5
%8 = lshr i32 %7, 8
%9 = call i32 @XdmcpWriteCARD8(i32 %6, i32 %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = load i32, i32* @FALSE
store i32 %12, i32* %3
br label %23
13: ; preds = %2
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = and i32 %15, 255
%17 = call i32 @XdmcpWriteCARD8(i32 %14, i32 %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %13
%20 = load i32, i32* @FALSE
store i32 %20, i32* %3
br label %23
21: ; preds = %13
%22 = load i32, i32* @TRUE
store i32 %22, i32* %3
br label %23
23: ; preds = %21, %19, %11
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@FALSE = global i32 0
@TRUE = global i32 0
define i32 @XdmcpWriteCARD16(i32 %0, i32 %1) {
%3 = lshr i32 %1, 8
%4 = tail call i32 @XdmcpWriteCARD8(i32 %0, i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = and i32 %1, 255
%8 = tail call i32 @XdmcpWriteCARD8(i32 %0, i32 %7)
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i32* @FALSE, i32* @TRUE
br label %11
11: ; preds = %6, %2
%12 = phi i32* [ @FALSE, %2 ], [ %10, %6 ]
%13 = load i32, i32* %12
ret i32 %13
}