#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 kbdreset(void) {
  unsigned char c;
  while (inb(0x64) & 0x02)
    ;
  outb(0x64, 0x60);
  while (inb(0x64) & 0x02)
    ;
  outb(0x60, 0x4D);
  while (inb(0x64) & 0x02)
    ;
  outb(0x60, 0xFF);
  while ((c = inb(0x60)) != 0xFA)
    ;
}


x86 assembly (clang, -O0):
<kbdreset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x64,%edi
call   1040 <inb@plt>
and    $0x2,%eax
cmp    $0x0,%eax
je     1143 <kbdreset+0x23>
jmp    1128 <kbdreset+0x8>
mov    $0x64,%edi
mov    $0x60,%esi
call   1030 <outb@plt>
mov    $0x64,%edi
call   1040 <inb@plt>
and    $0x2,%eax
cmp    $0x0,%eax
je     116d <kbdreset+0x4d>
jmp    1152 <kbdreset+0x32>
mov    $0x60,%edi
mov    $0x4d,%esi
call   1030 <outb@plt>
mov    $0x64,%edi
call   1040 <inb@plt>
and    $0x2,%eax
cmp    $0x0,%eax
je     1197 <kbdreset+0x77>
jmp    117c <kbdreset+0x5c>
mov    $0x60,%edi
mov    $0xff,%esi
call   1030 <outb@plt>
mov    $0x60,%edi
call   1040 <inb@plt>
mov    %al,-0x1(%rbp)
movzbl %al,%eax
cmp    $0xfa,%eax
je     11c6 <kbdreset+0xa6>
jmp    11a6 <kbdreset+0x86>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kbdreset>:
push   %rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x64,%edi
call   1040 <inb@plt>
test   $0x2,%al
jne    1130 <kbdreset+0x10>
mov    $0x64,%edi
mov    $0x60,%esi
call   1030 <outb@plt>
nopl   (%rax)
mov    $0x64,%edi
call   1040 <inb@plt>
test   $0x2,%al
jne    1150 <kbdreset+0x30>
mov    $0x60,%edi
mov    $0x4d,%esi
call   1030 <outb@plt>
nopl   (%rax)
mov    $0x64,%edi
call   1040 <inb@plt>
test   $0x2,%al
jne    1170 <kbdreset+0x50>
mov    $0x60,%edi
mov    $0xff,%esi
call   1030 <outb@plt>
nopl   (%rax)
mov    $0x60,%edi
call   1040 <inb@plt>
cmp    $0xfa,%al
jne    1190 <kbdreset+0x70>
pop    %rax
ret

LLVM IR (-O0):
define void @kbdreset() {
%1 = alloca i8
br label %2
2: ; preds = %6, %0
%3 = call i32 @inb(i32 100)
%4 = and i32 %3, 2
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %2
br label %2
7: ; preds = %2
%8 = call i32 @outb(i32 100, i32 96)
br label %9
9: ; preds = %13, %7
%10 = call i32 @inb(i32 100)
%11 = and i32 %10, 2
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
br label %9
14: ; preds = %9
%15 = call i32 @outb(i32 96, i32 77)
br label %16
16: ; preds = %20, %14
%17 = call i32 @inb(i32 100)
%18 = and i32 %17, 2
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
br label %16
21: ; preds = %16
%22 = call i32 @outb(i32 96, i32 255)
br label %23
23: ; preds = %28, %21
%24 = call i32 @inb(i32 96)
%25 = trunc i32 %24 to i8
store i8 %25, i8* %1
%26 = zext i8 %25 to i32
%27 = icmp ne i32 %26, 250
br i1 %27, label %28, label %29
28: ; preds = %23
br label %23
29: ; preds = %23
ret void
}

LLVM IR (-O2):
define void @kbdreset() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 @inb(i32 100)
%3 = and i32 %2, 2
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %1
5: ; preds = %1
%6 = tail call i32 @outb(i32 100, i32 96)
br label %7
7: ; preds = %7, %5
%8 = tail call i32 @inb(i32 100)
%9 = and i32 %8, 2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %7
11: ; preds = %7
%12 = tail call i32 @outb(i32 96, i32 77)
br label %13
13: ; preds = %13, %11
%14 = tail call i32 @inb(i32 100)
%15 = and i32 %14, 2
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %13
17: ; preds = %13
%18 = tail call i32 @outb(i32 96, i32 255)
br label %19
19: ; preds = %19, %17
%20 = tail call i32 @inb(i32 96)
%21 = and i32 %20, 255
%22 = icmp eq i32 %21, 250
br i1 %22, label %23, label %19
23: ; preds = %19
ret void
}