#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 */
char inb(int);
int /*<<< orphan*/ outb(int, int);
void send_EOI(unsigned char irq) {
  if (irq >= 0x20)
    irq -= 0x20;
  if (irq == 7) {
    outb(0x20, 0x0A);
    char irr = inb(0x20);
    if ((irr & 0x80) == false)
      return;
  }
  if (irq >= 8)
    outb(0xA0, 0x20);
  outb(0x20, 0x20);
}


x86 assembly (clang, -O0):
<send_EOI>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x20,%eax
jl     1145 <send_EOI+0x25>
movzbl -0x1(%rbp),%eax
sub    $0x20,%eax
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x7,%eax
jne    118a <send_EOI+0x6a>
mov    $0x20,%edi
mov    $0xa,%esi
call   1030 <outb@plt>
mov    $0x20,%edi
call   1040 <inb@plt>
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    1185 <send_EOI+0x65>
jmp    11b2 <send_EOI+0x92>
jmp    118a <send_EOI+0x6a>
movzbl -0x1(%rbp),%eax
cmp    $0x8,%eax
jl     11a6 <send_EOI+0x86>
mov    $0xa0,%edi
mov    $0x20,%esi
call   1030 <outb@plt>
mov    $0x20,%esi
mov    %esi,%edi
call   1030 <outb@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_EOI>:
push   %rax
lea    -0x20(%rdi),%eax
cmp    $0x20,%dil
movzbl %al,%eax
cmovb  %edi,%eax
cmp    $0x7,%al
jne    1151 <send_EOI+0x31>
mov    $0x20,%edi
mov    $0xa,%esi
call   1030 <outb@plt>
mov    $0x20,%edi
call   1040 <inb@plt>
test   %al,%al
js     1162 <send_EOI+0x42>
pop    %rax
ret
jbe    1162 <send_EOI+0x42>
mov    $0xa0,%edi
mov    $0x20,%esi
call   1030 <outb@plt>
mov    $0x20,%edi
mov    $0x20,%esi
pop    %rax
jmp    1030 <outb@plt>

LLVM IR (-O0):
define void @send_EOI(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %2
%4 = load i8, i8* %2
%5 = zext i8 %4 to i32
%6 = icmp sge i32 %5, 32
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i8, i8* %2
%9 = zext i8 %8 to i32
%10 = sub nsw i32 %9, 32
%11 = trunc i32 %10 to i8
store i8 %11, i8* %2
br label %12
12: ; preds = %7, %1
%13 = load i8, i8* %2
%14 = zext i8 %13 to i32
%15 = icmp eq i32 %14, 7
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = call i32 @outb(i32 32, i32 10)
%18 = call signext i8 @inb(i32 32)
store i8 %18, i8* %3
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = and i32 %20, 128
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %16
br label %33
24: ; preds = %16
br label %25
25: ; preds = %24, %12
%26 = load i8, i8* %2
%27 = zext i8 %26 to i32
%28 = icmp sge i32 %27, 8
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 @outb(i32 160, i32 32)
br label %31
31: ; preds = %29, %25
%32 = call i32 @outb(i32 32, i32 32)
br label %33
33: ; preds = %31, %23
ret void
}

LLVM IR (-O2):
define void @send_EOI(i8 zeroext %0) {
%2 = icmp ugt i8 %0, 31
%3 = add i8 %0, -32
%4 = select i1 %2, i8 %3, i8 %0
%5 = icmp eq i8 %4, 7
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = tail call i32 @outb(i32 32, i32 10)
%8 = tail call signext i8 @inb(i32 32)
%9 = icmp slt i8 %8, 0
br i1 %9, label %14, label %16
10: ; preds = %1
%11 = icmp ugt i8 %4, 7
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = tail call i32 @outb(i32 160, i32 32)
br label %14
14: ; preds = %6, %12, %10
%15 = tail call i32 @outb(i32 32, i32 32)
br label %16
16: ; preds = %6, %14
ret void
}