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

/* Variables and functions */
int /*<<< orphan*/ gfx_delay_microseconds(int);
unsigned long gfx_pci_config_read(int);
int /*<<< orphan*/ gfx_pci_config_write(int, unsigned long);
void I2CAL_output_clock(int inState) {
  unsigned short reg;
  unsigned long value;
  value = gfx_pci_config_read(
      (0x80000000 | (0x00 << 16) | (0x12 << 11) | (0 << 8) | 0x90));
  reg = (unsigned short)value;
  if (inState) {
    reg |= 0x0400;
  } else {
    reg &= ~0x0400;
  }
  value = reg;
  gfx_pci_config_write(
      (0x80000000 | (0x00 << 16) | (0x12 << 11) | (0 << 8) | 0x90), value);
  gfx_delay_microseconds(5);
}


x86 assembly (clang, -O0):
<I2CAL_output_clock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x80009090,%edi
call   1040 <gfx_pci_config_read@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %ax,-0x6(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     116d <I2CAL_output_clock+0x3d>
movzwl -0x6(%rbp),%eax
or     $0x400,%eax
mov    %ax,-0x6(%rbp)
jmp    117a <I2CAL_output_clock+0x4a>
movzwl -0x6(%rbp),%eax
and    $0xfffffbff,%eax
mov    %ax,-0x6(%rbp)
movzwl -0x6(%rbp),%eax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0x80009090,%edi
call   1030 <gfx_pci_config_write@plt>
mov    $0x5,%edi
call   1050 <gfx_delay_microseconds@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<I2CAL_output_clock>:
push   %rbx
mov    %edi,%ebx
mov    $0x80009090,%edi
call   1040 <gfx_pci_config_read@plt>
and    $0xfbff,%eax
lea    0x400(%rax),%rsi
test   %ebx,%ebx
cmove  %rax,%rsi
mov    $0x80009090,%edi
call   1030 <gfx_pci_config_write@plt>
mov    $0x5,%edi
pop    %rbx
jmp    1050 <gfx_delay_microseconds@plt>

LLVM IR (-O0):
define void @I2CAL_output_clock(i32 %0) {
%2 = alloca i32
%3 = alloca i16
%4 = alloca i64
store i32 %0, i32* %2
%5 = call i64 @gfx_pci_config_read(i32 -2147446640)
store i64 %5, i64* %4
%6 = load i64, i64* %4
%7 = trunc i64 %6 to i16
store i16 %7, i16* %3
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i16, i16* %3
%12 = zext i16 %11 to i32
%13 = or i32 %12, 1024
%14 = trunc i32 %13 to i16
store i16 %14, i16* %3
br label %20
15: ; preds = %1
%16 = load i16, i16* %3
%17 = zext i16 %16 to i32
%18 = and i32 %17, -1025
%19 = trunc i32 %18 to i16
store i16 %19, i16* %3
br label %20
20: ; preds = %15, %10
%21 = load i16, i16* %3
%22 = zext i16 %21 to i64
store i64 %22, i64* %4
%23 = load i64, i64* %4
%24 = call i32 @gfx_pci_config_write(i32 -2147446640, i64 %23)
%25 = call i32 @gfx_delay_microseconds(i32 5)
ret void
}

LLVM IR (-O2):
define void @I2CAL_output_clock(i32 %0) {
%2 = tail call i64 @gfx_pci_config_read(i32 -2147446640)
%3 = icmp eq i32 %0, 0
%4 = and i64 %2, 64511
%5 = or i64 %4, 1024
%6 = select i1 %3, i64 %4, i64 %5
%7 = tail call i32 @gfx_pci_config_write(i32 -2147446640, i64 %6)
%8 = tail call i32 @gfx_delay_microseconds(i32 5)
ret void
}