#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 */
unsigned long in_byte(int);
unsigned long read_fdc_data() {
  unsigned long i = 0;
  while (!((((in_byte(0x3f4) & 0x40) > 0) && ((in_byte(0x3f4) & 0x80) > 0)))) {
    if (i > 10000000) {
      return 0;
    }
    i++;
  }
  return in_byte(0x3f5);
}


x86 assembly (clang, -O0):
<read_fdc_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x10(%rbp)
mov    $0x3f4,%edi
call   1030 <in_byte@plt>
mov    %rax,%rcx
and    $0x40,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
jbe    115a <read_fdc_data+0x4a>
mov    $0x3f4,%edi
call   1030 <in_byte@plt>
and    $0x80,%rax
cmp    $0x0,%rax
seta   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
xor    $0xff,%al
test   $0x1,%al
jne    116c <read_fdc_data+0x5c>
jmp    1198 <read_fdc_data+0x88>
cmpq   $0x989680,-0x10(%rbp)
jbe    1187 <read_fdc_data+0x77>
movq   $0x0,-0x8(%rbp)
jmp    11a6 <read_fdc_data+0x96>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1120 <read_fdc_data+0x10>
mov    $0x3f5,%edi
call   1030 <in_byte@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_fdc_data>:
push   %rbx
mov    $0x989682,%ebx
jmp    1126 <read_fdc_data+0x16>
nopl   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rbx
je     114d <read_fdc_data+0x3d>
mov    $0x3f4,%edi
call   1030 <in_byte@plt>
test   $0x40,%al
je     1120 <read_fdc_data+0x10>
mov    $0x3f4,%edi
call   1030 <in_byte@plt>
test   $0x80,%al
je     1120 <read_fdc_data+0x10>
mov    $0x3f5,%edi
pop    %rbx
jmp    1030 <in_byte@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @read_fdc_data() {
%1 = alloca i64
%2 = alloca i64
store i64 0, i64* %2
br label %3
3: ; preds = %18, %0
%4 = call i64 @in_byte(i32 1012)
%5 = and i64 %4, 64
%6 = icmp ugt i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = call i64 @in_byte(i32 1012)
%9 = and i64 %8, 128
%10 = icmp ugt i64 %9, 0
br label %11
11: ; preds = %7, %3
%12 = phi i1 [ false, %3 ], [ %10, %7 ]
%13 = xor i1 %12, true
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i64, i64* %2
%16 = icmp ugt i64 %15, 10000000
br i1 %16, label %17, label %18
17: ; preds = %14
store i64 0, i64* %1
br label %23
18: ; preds = %14
%19 = load i64, i64* %2
%20 = add i64 %19, 1
store i64 %20, i64* %2
br label %3
21: ; preds = %11
%22 = call i64 @in_byte(i32 1013)
store i64 %22, i64* %1
br label %23
23: ; preds = %21, %17
%24 = load i64, i64* %1
ret i64 %24
}

LLVM IR (-O2):
define i64 @read_fdc_data() {
br label %1
1: ; preds = %10, %0
%2 = phi i64 [ 0, %0 ], [ %11, %10 ]
%3 = tail call i64 @in_byte(i32 1012)
%4 = and i64 %3, 64
%5 = icmp eq i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = tail call i64 @in_byte(i32 1012)
%8 = and i64 %7, 128
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1, %6
%11 = add nuw nsw i64 %2, 1
%12 = icmp eq i64 %11, 10000002
br i1 %12, label %15, label %1
13: ; preds = %6
%14 = tail call i64 @in_byte(i32 1013)
br label %15
15: ; preds = %10, %13
%16 = phi i64 [ %14, %13 ], [ 0, %10 ]
ret i64 %16
}