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


x86 assembly (clang, -O0):
<write_fdc_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x3f4,%edi
call   1030 <in_byte@plt>
mov    %eax,%ecx
and    $0x40,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
jne    116b <write_fdc_data+0x4b>
mov    $0x3f4,%edi
call   1030 <in_byte@plt>
and    $0x80,%eax
cmp    $0x0,%eax
setg   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
xor    $0xff,%al
test   $0x1,%al
jne    117d <write_fdc_data+0x5d>
jmp    11a1 <write_fdc_data+0x81>
cmpq   $0x989680,-0x10(%rbp)
jbe    1190 <write_fdc_data+0x70>
jmp    11af <write_fdc_data+0x8f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1136 <write_fdc_data+0x16>
mov    $0x3f5,%edi
movzbl -0x1(%rbp),%esi
call   1040 <out_byte@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_fdc_data>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x989682,%ebx
jmp    1136 <write_fdc_data+0x16>
nopl   0x0(%rax)
add    $0xffffffffffffffff,%rbx
je     1166 <write_fdc_data+0x46>
mov    $0x3f4,%edi
call   1030 <in_byte@plt>
test   $0x40,%al
jne    1130 <write_fdc_data+0x10>
mov    $0x3f4,%edi
call   1030 <in_byte@plt>
test   $0x80,%al
je     1130 <write_fdc_data+0x10>
movzbl %bpl,%esi
mov    $0x3f5,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <out_byte@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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