#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 inb(int);
int ADFIFOregister(void) {
  int lec1, lec2;
  int res;
  int MASK = 128;
  int MASKCLEAR = 0x000000FF;
  if ((0x004 & inb(0x0260)) >> 2) {
    return 5000;
  } else if ((0x002 & inb(0x0260)) >> 1) {
    return -5000;
  } else {
    lec1 = (MASKCLEAR & inb(0x0260 + 0x000A));
    lec2 = (MASKCLEAR & inb(0x0260 + 0x000A));
    if ((lec2 & MASK) == 128) {
      lec2 = (0xFFFFF000 | (lec2 << 8));
    } else {
      lec2 = (lec2 << 8);
    }
    res = (lec1 | lec2);
    return res;
  }
}


x86 assembly (clang, -O0):
<ADFIFOregister>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x80,-0x14(%rbp)
movl   $0xff,-0x18(%rbp)
mov    $0x260,%edi
call   1030 <inb@plt>
and    $0x4,%eax
sar    $0x2,%eax
cmp    $0x0,%eax
je     114b <ADFIFOregister+0x3b>
movl   $0x1388,-0x4(%rbp)
jmp    11e0 <ADFIFOregister+0xd0>
mov    $0x260,%edi
call   1030 <inb@plt>
and    $0x2,%eax
sar    $0x1,%eax
cmp    $0x0,%eax
je     1170 <ADFIFOregister+0x60>
movl   $0xffffec78,-0x4(%rbp)
jmp    11e0 <ADFIFOregister+0xd0>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0x26a,%edi
call   1030 <inb@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x26a,%edi
call   1030 <inb@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    -0x14(%rbp),%eax
cmp    $0x80,%eax
jne    11c8 <ADFIFOregister+0xb8>
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
or     $0xfffff000,%eax
mov    %eax,-0xc(%rbp)
jmp    11d1 <ADFIFOregister+0xc1>
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ADFIFOregister>:
push   %rbx
mov    $0x260,%edi
call   1030 <inb@plt>
mov    %eax,%ecx
mov    $0x1388,%eax
test   $0x4,%cl
jne    116c <ADFIFOregister+0x5c>
mov    $0x260,%edi
call   1030 <inb@plt>
mov    %eax,%ecx
mov    $0xffffec78,%eax
test   $0x2,%cl
jne    116c <ADFIFOregister+0x5c>
mov    $0x26a,%edi
call   1030 <inb@plt>
movzbl %al,%ebx
mov    $0x26a,%edi
call   1030 <inb@plt>
mov    %eax,%ecx
mov    %eax,%edx
shl    $0x8,%edx
movzwl %dx,%eax
or     $0xfffff000,%edx
test   $0x80,%cl
cmovne %edx,%eax
or     %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @ADFIFOregister() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 128, i32* %5
store i32 255, i32* %6
%7 = call i32 @inb(i32 608)
%8 = and i32 4, %7
%9 = ashr i32 %8, 2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 5000, i32* %1
br label %41
12: ; preds = %0
%13 = call i32 @inb(i32 608)
%14 = and i32 2, %13
%15 = ashr i32 %14, 1
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 -5000, i32* %1
br label %41
18: ; preds = %12
%19 = load i32, i32* %6
%20 = call i32 @inb(i32 618)
%21 = and i32 %19, %20
store i32 %21, i32* %2
%22 = load i32, i32* %6
%23 = call i32 @inb(i32 618)
%24 = and i32 %22, %23
store i32 %24, i32* %3
%25 = load i32, i32* %3
%26 = load i32, i32* %5
%27 = and i32 %25, %26
%28 = icmp eq i32 %27, 128
br i1 %28, label %29, label %33
29: ; preds = %18
%30 = load i32, i32* %3
%31 = shl i32 %30, 8
%32 = or i32 -4096, %31
store i32 %32, i32* %3
br label %36
33: ; preds = %18
%34 = load i32, i32* %3
%35 = shl i32 %34, 8
store i32 %35, i32* %3
br label %36
36: ; preds = %33, %29
%37 = load i32, i32* %2
%38 = load i32, i32* %3
%39 = or i32 %37, %38
store i32 %39, i32* %4
%40 = load i32, i32* %4
store i32 %40, i32* %1
br label %41
41: ; preds = %36, %17, %11
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
define i32 @ADFIFOregister() {
%1 = tail call i32 @inb(i32 608)
%2 = and i32 %1, 4
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %19
4: ; preds = %0
%5 = tail call i32 @inb(i32 608)
%6 = and i32 %5, 2
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %4
%9 = tail call i32 @inb(i32 618)
%10 = and i32 %9, 255
%11 = tail call i32 @inb(i32 618)
%12 = and i32 %11, 128
%13 = icmp eq i32 %12, 0
%14 = shl i32 %11, 8
%15 = and i32 %14, 65280
%16 = or i32 %14, -4096
%17 = select i1 %13, i32 %15, i32 %16
%18 = or i32 %17, %10
br label %19
19: ; preds = %4, %0, %8
%20 = phi i32 [ %18, %8 ], [ 5000, %0 ], [ -5000, %4 ]
ret i32 %20
}