#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 uint16_t;
typedef int /*<<< orphan*/ tx_write;

/* Variables and functions */
int /*<<< orphan*/ transfer(int, int *, int *, int, int);
void writeRegister(int fd, uint16_t value) {
  value = value | 0x8000;
  uint16_t tx_write[] = {value, 0x0000, 0x0000, 0x0000};
  uint16_t rx_write[(sizeof(tx_write) / sizeof((tx_write)[0]))] = {
      0,
  };
  transfer(fd, tx_write, rx_write, (sizeof(tx_write) / sizeof((tx_write)[0])),
           1);
  return;
}


x86 assembly (clang, -O0):
<writeRegister>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
or     $0x8000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x4,%ecx
mov    $0x1,%r8d
call   1040 <transfer@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeRegister>:
sub    $0x28,%rsp
or     $0x8000,%esi
mov    %esi,(%rsp)
movq   $0x0,0x4(%rsp)
movl   $0x0,0xc(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
mov    %rsp,%rsi
lea    0x10(%rsp),%rdx
mov    $0x4,%ecx
mov    $0x1,%r8d
call   1030 <transfer@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
define void @writeRegister(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4 x i32]
%6 = alloca [4 x i32]
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = or i32 %7, 32768
store i32 %8, i32* %4
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%10 = load i32, i32* %4
store i32 %10, i32* %9
%11 = getelementptr inbounds i32, i32* %9, i64 1
store i32 0, i32* %11
%12 = getelementptr inbounds i32, i32* %11, i64 1
store i32 0, i32* %12
%13 = getelementptr inbounds i32, i32* %12, i64 1
store i32 0, i32* %13
%14 = bitcast [4 x i32]* %6 to i8*
%15 = load i32, i32* %3
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%18 = call i32 @transfer(i32 %15, i32* %16, i32* %17, i32 4, i32 1)
ret void
}

LLVM IR (-O2):
define void @writeRegister(i32 %0, i32 %1) {
%3 = alloca [4 x i32]
%4 = alloca [4 x i32]
%5 = or i32 %1, 32768
%6 = bitcast [4 x i32]* %3 to i8*
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
store i32 %5, i32* %7
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
store i32 0, i32* %8
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
store i32 0, i32* %9
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
store i32 0, i32* %10
%11 = bitcast [4 x i32]* %4 to i8*
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%13 = call i32 @transfer(i32 %0, i32* %7, i32* %12, i32 4, i32 1)
ret void
}