#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 /*<<< orphan*/ outb(int, int);
void lpt_putc(int c) {
  int i;
  for (i = 0; !(inb(0x378 + 1) & 0x80) && i < 12800; i++)
    ;
  if (c == 0x100)
    c = '\b';
  outb(0x378 + 0, c);
  outb(0x378 + 2, 0x08 | 0x04 | 0x01);
  outb(0x378 + 2, 0x08);
}


x86 assembly (clang, -O0):
<lpt_putc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x379,%edi
call   1040 <inb@plt>
mov    %eax,%ecx
and    $0x80,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x9(%rbp)
jne    115f <lpt_putc+0x3f>
cmpl   $0x3200,-0x8(%rbp)
setl   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    116f <lpt_putc+0x4f>
jmp    1182 <lpt_putc+0x62>
jmp    1174 <lpt_putc+0x54>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <lpt_putc+0x12>
cmpl   $0x100,-0x4(%rbp)
jne    1196 <lpt_putc+0x76>
movl   $0x8,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    $0x378,%edi
call   1030 <outb@plt>
mov    $0x37a,%edi
mov    $0xd,%esi
call   1030 <outb@plt>
mov    $0x37a,%edi
mov    $0x8,%esi
call   1030 <outb@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lpt_putc>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x379,%edi
call   1040 <inb@plt>
test   $0x80,%al
jne    114b <lpt_putc+0x2b>
lea    0x1(%rbx),%eax
cmp    $0x3200,%ebx
mov    %eax,%ebx
jb     1130 <lpt_putc+0x10>
cmp    $0x100,%ebp
mov    $0x8,%eax
cmove  %eax,%ebp
mov    $0x378,%edi
mov    %ebp,%esi
call   1030 <outb@plt>
mov    $0x37a,%edi
mov    $0xd,%esi
call   1030 <outb@plt>
mov    $0x37a,%edi
mov    $0x8,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <outb@plt>

LLVM IR (-O0):
define void @lpt_putc(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %14, %1
%5 = call i32 @inb(i32 889)
%6 = and i32 %5, 128
%7 = icmp ne i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 12800
br label %11
11: ; preds = %8, %4
%12 = phi i1 [ false, %4 ], [ %10, %8 ]
br i1 %12, label %13, label %17
13: ; preds = %11
br label %14
14: ; preds = %13
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %4
17: ; preds = %11
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 256
br i1 %19, label %20, label %21
20: ; preds = %17
store i32 8, i32* %2
br label %21
21: ; preds = %20, %17
%22 = load i32, i32* %2
%23 = call i32 @outb(i32 888, i32 %22)
%24 = call i32 @outb(i32 890, i32 13)
%25 = call i32 @outb(i32 890, i32 8)
ret void
}

LLVM IR (-O2):
define void @lpt_putc(i32 %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i32 [ 0, %1 ], [ %9, %2 ]
%4 = tail call i32 @inb(i32 889)
%5 = and i32 %4, 128
%6 = icmp eq i32 %5, 0
%7 = icmp ult i32 %3, 12800
%8 = select i1 %6, i1 %7, i1 false
%9 = add nuw nsw i32 %3, 1
br i1 %8, label %2, label %10
10: ; preds = %2
%11 = icmp eq i32 %0, 256
%12 = select i1 %11, i32 8, i32 %0
%13 = tail call i32 @outb(i32 888, i32 %12)
%14 = tail call i32 @outb(i32 890, i32 13)
%15 = tail call i32 @outb(i32 890, i32 8)
ret void
}