#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;

/* Variables and functions */
int realtek_mst_i2c_spi_write_register(int, int, int);
int realtek_mst_i2c_spi_select_indexed_register(int fd, uint16_t address) {
  int ret = 0;
  ret |= realtek_mst_i2c_spi_write_register(fd, 0xF4, 0x9F);
  ret |= realtek_mst_i2c_spi_write_register(fd, 0xF5, address >> 8);
  ret |= realtek_mst_i2c_spi_write_register(fd, 0xF4, address & 0xFF);
  return ret;
}


x86 assembly (clang, -O0):
<realtek_mst_i2c_spi_select_indexed_register>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0xf4,%esi
mov    $0x9f,%edx
call   1030 <realtek_mst_i2c_spi_write_register@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
sar    $0x8,%edx
mov    $0xf5,%esi
call   1030 <realtek_mst_i2c_spi_write_register@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
and    $0xff,%edx
mov    $0xf4,%esi
call   1030 <realtek_mst_i2c_spi_write_register@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<realtek_mst_i2c_spi_select_indexed_register>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%ebp
mov    $0xf4,%esi
mov    $0x9f,%edx
call   1030 <realtek_mst_i2c_spi_write_register@plt>
mov    %eax,%r14d
mov    %r15d,%edx
sar    $0x8,%edx
mov    %ebp,%edi
mov    $0xf5,%esi
call   1030 <realtek_mst_i2c_spi_write_register@plt>
mov    %eax,%ebx
or     %r14d,%ebx
movzbl %r15b,%edx
mov    %ebp,%edi
mov    $0xf4,%esi
call   1030 <realtek_mst_i2c_spi_write_register@plt>
or     %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @realtek_mst_i2c_spi_select_indexed_register(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %3
%7 = call i32 @realtek_mst_i2c_spi_write_register(i32 %6, i32 244, i32 159)
%8 = load i32, i32* %5
%9 = or i32 %8, %7
store i32 %9, i32* %5
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = ashr i32 %11, 8
%13 = call i32 @realtek_mst_i2c_spi_write_register(i32 %10, i32 245, i32 %12)
%14 = load i32, i32* %5
%15 = or i32 %14, %13
store i32 %15, i32* %5
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = and i32 %17, 255
%19 = call i32 @realtek_mst_i2c_spi_write_register(i32 %16, i32 244, i32 %18)
%20 = load i32, i32* %5
%21 = or i32 %20, %19
store i32 %21, i32* %5
%22 = load i32, i32* %5
ret i32 %22
}

LLVM IR (-O2):
define i32 @realtek_mst_i2c_spi_select_indexed_register(i32 %0, i32 %1) {
%3 = tail call i32 @realtek_mst_i2c_spi_write_register(i32 %0, i32 244, i32 159)
%4 = ashr i32 %1, 8
%5 = tail call i32 @realtek_mst_i2c_spi_write_register(i32 %0, i32 245, i32 %4)
%6 = or i32 %5, %3
%7 = and i32 %1, 255
%8 = tail call i32 @realtek_mst_i2c_spi_write_register(i32 %0, i32 244, i32 %7)
%9 = or i32 %6, %8
ret i32 %9
}