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

/* Variables and functions */
int realtek_mst_i2c_spi_read_register(int, int, int *);
int realtek_mst_i2c_spi_write_register(int, int, int);
int realtek_mst_i2c_spi_disable_protection(int fd) {
  int ret = 0;
  uint8_t val = 0;
  ret |= realtek_mst_i2c_spi_write_register(fd, 0xF4, 0x9F);
  ret |= realtek_mst_i2c_spi_write_register(fd, 0xF5, 0x10);
  ret |= realtek_mst_i2c_spi_write_register(fd, 0xF4, 0xAB);
  ret |= realtek_mst_i2c_spi_read_register(fd, 0xF5, &val);
  ret |= realtek_mst_i2c_spi_write_register(fd, 0xF4, 0x9F);
  ret |= realtek_mst_i2c_spi_write_register(fd, 0xF5, 0x10);
  ret |= realtek_mst_i2c_spi_write_register(fd, 0xF4, 0xAB);
  ret |= realtek_mst_i2c_spi_write_register(fd, 0xF5, (val & 0xF8) | 0x01);
  ret |= realtek_mst_i2c_spi_read_register(fd, 0xD7, &val);
  ret |= realtek_mst_i2c_spi_write_register(fd, 0xD7, (val & 0xFE) | 0x01);
  return ret;
}


x86 assembly (clang, -O0):
<realtek_mst_i2c_spi_disable_protection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0xf4,%esi
mov    $0x9f,%edx
call   1040 <realtek_mst_i2c_spi_write_register@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0xf5,%esi
mov    $0x10,%edx
call   1040 <realtek_mst_i2c_spi_write_register@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0xf4,%esi
mov    $0xab,%edx
call   1040 <realtek_mst_i2c_spi_write_register@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0xf5,%esi
lea    -0xc(%rbp),%rdx
call   1030 <realtek_mst_i2c_spi_read_register@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0xf4,%esi
mov    $0x9f,%edx
call   1040 <realtek_mst_i2c_spi_write_register@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0xf5,%esi
mov    $0x10,%edx
call   1040 <realtek_mst_i2c_spi_write_register@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0xf4,%esi
mov    $0xab,%edx
call   1040 <realtek_mst_i2c_spi_write_register@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%edx
and    $0xf8,%edx
or     $0x1,%edx
mov    $0xf5,%esi
call   1040 <realtek_mst_i2c_spi_write_register@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0xd7,%esi
lea    -0xc(%rbp),%rdx
call   1030 <realtek_mst_i2c_spi_read_register@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%edx
and    $0xfe,%edx
or     $0x1,%edx
mov    $0xd7,%esi
call   1040 <realtek_mst_i2c_spi_write_register@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<realtek_mst_i2c_spi_disable_protection>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r13d
movl   $0x0,0x4(%rsp)
mov    $0xf4,%esi
mov    $0x9f,%edx
call   1040 <realtek_mst_i2c_spi_write_register@plt>
mov    %eax,%ebp
mov    %r13d,%edi
mov    $0xf5,%esi
mov    $0x10,%edx
call   1040 <realtek_mst_i2c_spi_write_register@plt>
mov    %eax,%r15d
or     %ebp,%r15d
mov    %r13d,%edi
mov    $0xf4,%esi
mov    $0xab,%edx
call   1040 <realtek_mst_i2c_spi_write_register@plt>
mov    %eax,%r12d
lea    0x4(%rsp),%rdx
mov    %r13d,%edi
mov    $0xf5,%esi
call   1030 <realtek_mst_i2c_spi_read_register@plt>
mov    %eax,%r14d
or     %r12d,%r14d
or     %r15d,%r14d
mov    %r13d,%edi
mov    $0xf4,%esi
mov    $0x9f,%edx
call   1040 <realtek_mst_i2c_spi_write_register@plt>
mov    %eax,%r15d
mov    %r13d,%edi
mov    $0xf5,%esi
mov    $0x10,%edx
call   1040 <realtek_mst_i2c_spi_write_register@plt>
mov    %eax,%ebx
or     %r15d,%ebx
mov    %r13d,%edi
mov    $0xf4,%esi
mov    $0xab,%edx
call   1040 <realtek_mst_i2c_spi_write_register@plt>
mov    %eax,%ebp
or     %ebx,%ebp
or     %r14d,%ebp
mov    $0xf8,%edx
and    0x4(%rsp),%edx
or     $0x1,%edx
mov    %r13d,%edi
mov    $0xf5,%esi
call   1040 <realtek_mst_i2c_spi_write_register@plt>
mov    %eax,%r14d
mov    %r13d,%edi
mov    $0xd7,%esi
lea    0x4(%rsp),%rdx
call   1030 <realtek_mst_i2c_spi_read_register@plt>
mov    %eax,%ebx
or     %ebp,%ebx
movzbl 0x4(%rsp),%edx
or     $0x1,%edx
mov    %r13d,%edi
mov    $0xd7,%esi
call   1040 <realtek_mst_i2c_spi_write_register@plt>
or     %ebx,%eax
or     %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @realtek_mst_i2c_spi_disable_protection(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%5 = load i32, i32* %2
%6 = call i32 @realtek_mst_i2c_spi_write_register(i32 %5, i32 244, i32 159)
%7 = load i32, i32* %3
%8 = or i32 %7, %6
store i32 %8, i32* %3
%9 = load i32, i32* %2
%10 = call i32 @realtek_mst_i2c_spi_write_register(i32 %9, i32 245, i32 16)
%11 = load i32, i32* %3
%12 = or i32 %11, %10
store i32 %12, i32* %3
%13 = load i32, i32* %2
%14 = call i32 @realtek_mst_i2c_spi_write_register(i32 %13, i32 244, i32 171)
%15 = load i32, i32* %3
%16 = or i32 %15, %14
store i32 %16, i32* %3
%17 = load i32, i32* %2
%18 = call i32 @realtek_mst_i2c_spi_read_register(i32 %17, i32 245, i32* %4)
%19 = load i32, i32* %3
%20 = or i32 %19, %18
store i32 %20, i32* %3
%21 = load i32, i32* %2
%22 = call i32 @realtek_mst_i2c_spi_write_register(i32 %21, i32 244, i32 159)
%23 = load i32, i32* %3
%24 = or i32 %23, %22
store i32 %24, i32* %3
%25 = load i32, i32* %2
%26 = call i32 @realtek_mst_i2c_spi_write_register(i32 %25, i32 245, i32 16)
%27 = load i32, i32* %3
%28 = or i32 %27, %26
store i32 %28, i32* %3
%29 = load i32, i32* %2
%30 = call i32 @realtek_mst_i2c_spi_write_register(i32 %29, i32 244, i32 171)
%31 = load i32, i32* %3
%32 = or i32 %31, %30
store i32 %32, i32* %3
%33 = load i32, i32* %2
%34 = load i32, i32* %4
%35 = and i32 %34, 248
%36 = or i32 %35, 1
%37 = call i32 @realtek_mst_i2c_spi_write_register(i32 %33, i32 245, i32 %36)
%38 = load i32, i32* %3
%39 = or i32 %38, %37
store i32 %39, i32* %3
%40 = load i32, i32* %2
%41 = call i32 @realtek_mst_i2c_spi_read_register(i32 %40, i32 215, i32* %4)
%42 = load i32, i32* %3
%43 = or i32 %42, %41
store i32 %43, i32* %3
%44 = load i32, i32* %2
%45 = load i32, i32* %4
%46 = and i32 %45, 254
%47 = or i32 %46, 1
%48 = call i32 @realtek_mst_i2c_spi_write_register(i32 %44, i32 215, i32 %47)
%49 = load i32, i32* %3
%50 = or i32 %49, %48
store i32 %50, i32* %3
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
define i32 @realtek_mst_i2c_spi_disable_protection(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%4 = tail call i32 @realtek_mst_i2c_spi_write_register(i32 %0, i32 244, i32 159)
%5 = tail call i32 @realtek_mst_i2c_spi_write_register(i32 %0, i32 245, i32 16)
%6 = or i32 %5, %4
%7 = tail call i32 @realtek_mst_i2c_spi_write_register(i32 %0, i32 244, i32 171)
%8 = or i32 %6, %7
%9 = call i32 @realtek_mst_i2c_spi_read_register(i32 %0, i32 245, i32* %2)
%10 = or i32 %8, %9
%11 = call i32 @realtek_mst_i2c_spi_write_register(i32 %0, i32 244, i32 159)
%12 = or i32 %10, %11
%13 = call i32 @realtek_mst_i2c_spi_write_register(i32 %0, i32 245, i32 16)
%14 = or i32 %12, %13
%15 = call i32 @realtek_mst_i2c_spi_write_register(i32 %0, i32 244, i32 171)
%16 = or i32 %14, %15
%17 = load i32, i32* %2
%18 = and i32 %17, 248
%19 = or i32 %18, 1
%20 = call i32 @realtek_mst_i2c_spi_write_register(i32 %0, i32 245, i32 %19)
%21 = or i32 %16, %20
%22 = call i32 @realtek_mst_i2c_spi_read_register(i32 %0, i32 215, i32* %2)
%23 = or i32 %21, %22
%24 = load i32, i32* %2
%25 = and i32 %24, 254
%26 = or i32 %25, 1
%27 = call i32 @realtek_mst_i2c_spi_write_register(i32 %0, i32 215, i32 %26)
%28 = or i32 %23, %27
ret i32 %28
}