#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 /*<<< orphan*/ out8(int, int);
int /*<<< orphan*/ printf(char *, int);
void send_eoi(int interrupt_id) {
  if (((interrupt_id) >= 0x20 && (interrupt_id) < 0x20 + 8)) {
    out8(0x20, 0x20);
  } else if (((interrupt_id) >= 0x28 && (interrupt_id) < 0x28 + 8)) {
    out8(0x20, 0x20);
    out8(0xA0, 0x20);
  } else {
    printf("Invalid call: send_eoi(%d)", interrupt_id);
  }
}


x86 assembly (clang, -O0):
<send_eoi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x20,-0x4(%rbp)
jl     1150 <send_eoi+0x30>
cmpl   $0x28,-0x4(%rbp)
jge    1150 <send_eoi+0x30>
mov    $0x20,%esi
mov    %esi,%edi
call   1040 <out8@plt>
jmp    1198 <send_eoi+0x78>
cmpl   $0x28,-0x4(%rbp)
jl     1184 <send_eoi+0x64>
cmpl   $0x30,-0x4(%rbp)
jge    1184 <send_eoi+0x64>
mov    $0x20,%esi
mov    %esi,%edi
call   1040 <out8@plt>
mov    $0xa0,%edi
mov    $0x20,%esi
call   1040 <out8@plt>
jmp    1193 <send_eoi+0x73>
mov    -0x4(%rbp),%esi
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
jmp    1198 <send_eoi+0x78>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_eoi>:
mov    %edi,%eax
and    $0xfffffff8,%eax
cmp    $0x28,%eax
je     113e <send_eoi+0x1e>
cmp    $0x20,%eax
jne    115e <send_eoi+0x3e>
mov    $0x20,%edi
mov    $0x20,%esi
jmp    1040 <out8@plt>
push   %rax
mov    $0x20,%edi
mov    $0x20,%esi
call   1040 <out8@plt>
mov    $0xa0,%edi
mov    $0x20,%esi
pop    %rax
jmp    1040 <out8@plt>
mov    %edi,%esi
lea    0xe99(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"Invalid call: send_eoi(%d)\00"
define void @send_eoi(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sge i32 %3, 32
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 40
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = call i32 @out8(i32 32, i32 32)
br label %23
10: ; preds = %5, %1
%11 = load i32, i32* %2
%12 = icmp sge i32 %11, 40
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 48
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = call i32 @out8(i32 32, i32 32)
%18 = call i32 @out8(i32 160, i32 32)
br label %22
19: ; preds = %13, %10
%20 = load i32, i32* %2
%21 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %16
br label %23
23: ; preds = %22, %8
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"Invalid call: send_eoi(%d)\00"
define void @send_eoi(i32 %0) {
%2 = and i32 %0, -8
switch i32 %2, label %8 [
i32 32, label %3
i32 40, label %5
]
3: ; preds = %1
%4 = tail call i32 @out8(i32 32, i32 32)
br label %10
5: ; preds = %1
%6 = tail call i32 @out8(i32 32, i32 32)
%7 = tail call i32 @out8(i32 160, i32 32)
br label %10
8: ; preds = %1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %10
10: ; preds = %5, %8, %3
ret void
}