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

/* Variables and functions */
int realtek_mst_i2c_spi_read_data(int, int, int /*<<< orphan*/ *, int);
int realtek_mst_i2c_spi_write_data(int, int, int /*<<< orphan*/ *, int);
int realtek_mst_i2c_spi_read_register(int fd, uint8_t reg, uint8_t *value) {
  uint8_t command[] = {reg};
  int ret = realtek_mst_i2c_spi_write_data(fd, (0x94 >> 1), command, 1);
  ret |= realtek_mst_i2c_spi_read_data(fd, (0x94 >> 1), value, 1);
  return ret ? -1 : 0;
}


x86 assembly (clang, -O0):
<realtek_mst_i2c_spi_read_register>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x14(%rbp),%rdx
mov    $0x4a,%esi
mov    $0x1,%ecx
call   1030 <realtek_mst_i2c_spi_write_data@plt>
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    $0x4a,%esi
mov    $0x1,%ecx
call   1040 <realtek_mst_i2c_spi_read_data@plt>
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edx
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<realtek_mst_i2c_spi_read_register>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %edi,%ebp
mov    %esi,0xc(%rsp)
lea    0xc(%rsp),%rdx
mov    $0x4a,%esi
mov    $0x1,%ecx
call   1030 <realtek_mst_i2c_spi_write_data@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    $0x4a,%esi
mov    %r14,%rdx
mov    $0x1,%ecx
call   1040 <realtek_mst_i2c_spi_read_data@plt>
xor    %ecx,%ecx
or     %ebx,%eax
setne  %cl
neg    %ecx
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @realtek_mst_i2c_spi_read_register(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca [1 x i32]
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%9 = getelementptr inbounds [1 x i32], [1 x i32]* %7, i64 0, i64 0
%10 = load i32, i32* %5
store i32 %10, i32* %9
%11 = load i32, i32* %4
%12 = getelementptr inbounds [1 x i32], [1 x i32]* %7, i64 0, i64 0
%13 = call i32 @realtek_mst_i2c_spi_write_data(i32 %11, i32 74, i32* %12, i32 1)
store i32 %13, i32* %8
%14 = load i32, i32* %4
%15 = load i32*, i32** %6
%16 = call i32 @realtek_mst_i2c_spi_read_data(i32 %14, i32 74, i32* %15, i32 1)
%17 = load i32, i32* %8
%18 = or i32 %17, %16
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 -1, i32 0
ret i32 %22
}

LLVM IR (-O2):
define i32 @realtek_mst_i2c_spi_read_register(i32 %0, i32 %1, i32* %2) {
%4 = alloca [1 x i32]
%5 = bitcast [1 x i32]* %4 to i8*
%6 = getelementptr inbounds [1 x i32], [1 x i32]* %4, i64 0, i64 0
store i32 %1, i32* %6
%7 = call i32 @realtek_mst_i2c_spi_write_data(i32 %0, i32 74, i32* %6, i32 1)
%8 = call i32 @realtek_mst_i2c_spi_read_data(i32 %0, i32 74, i32* %2, i32 1)
%9 = or i32 %8, %7
%10 = icmp ne i32 %9, 0
%11 = sext i1 %10 to i32
ret i32 %11
}