#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_read;
typedef int int16_t;

/* Variables and functions */
int /*<<< orphan*/ transfer(int, int *, int *, int, int /*<<< orphan*/);
int16_t readRegister(int fd, uint16_t value) {
  uint16_t tx_read[] = {value, 0x0000, 0x0000, 0x0000};
  uint16_t rx_read[(sizeof(tx_read) / sizeof((tx_read)[0]))] = {
      0,
  };
  transfer(fd, tx_read, rx_read, (sizeof(tx_read) / sizeof((tx_read)[0])), 0);
  return rx_read[1];
}


x86 assembly (clang, -O0):
<readRegister>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-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
xor    %r8d,%r8d
call   1040 <transfer@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readRegister>:
sub    $0x28,%rsp
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
xor    %r8d,%r8d
call   1030 <transfer@plt>
mov    0x14(%rsp),%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
define i32 @readRegister(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 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%8 = load i32, i32* %4
store i32 %8, i32* %7
%9 = getelementptr inbounds i32, i32* %7, i64 1
store i32 0, i32* %9
%10 = getelementptr inbounds i32, i32* %9, i64 1
store i32 0, i32* %10
%11 = getelementptr inbounds i32, i32* %10, i64 1
store i32 0, i32* %11
%12 = bitcast [4 x i32]* %6 to i8*
%13 = load i32, i32* %3
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%16 = call i32 @transfer(i32 %13, i32* %14, i32* %15, i32 4, i32 0)
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 1
%18 = load i32, i32* %17
ret i32 %18
}

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