#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 */
unsigned char inb(int);
int /*<<< orphan*/ outb(int, unsigned char);
void PIC_remap(int offset1, int offset2) {
  unsigned char a1, a2;
  a1 = inb((0x20 + 1));
  a2 = inb((0xA0 + 1));
  outb(0x20, 0x10 + 0x01);
  do {
  } while (0);
  outb(0xA0, 0x10 + 0x01);
  do {
  } while (0);
  outb((0x20 + 1), offset1);
  do {
  } while (0);
  outb((0xA0 + 1), offset2);
  do {
  } while (0);
  outb((0x20 + 1), 4);
  do {
  } while (0);
  outb((0xA0 + 1), 2);
  do {
  } while (0);
  outb((0x20 + 1), 0x01);
  do {
  } while (0);
  outb((0xA0 + 1), 0x01);
  do {
  } while (0);
  outb((0x20 + 1), a1);
  outb((0xA0 + 1), a2);
}


x86 assembly (clang, -O0):
<PIC_remap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x21,%edi
call   1040 <inb@plt>
mov    %al,-0x9(%rbp)
mov    $0xa1,%edi
call   1040 <inb@plt>
mov    %al,-0xa(%rbp)
mov    $0x20,%edi
mov    $0x11,%esi
call   1030 <outb@plt>
jmp    115c <PIC_remap+0x3c>
mov    $0xa0,%edi
mov    $0x11,%esi
call   1030 <outb@plt>
jmp    1170 <PIC_remap+0x50>
mov    -0x4(%rbp),%eax
mov    $0x21,%edi
movzbl %al,%esi
call   1030 <outb@plt>
jmp    1185 <PIC_remap+0x65>
mov    -0x8(%rbp),%eax
mov    $0xa1,%edi
movzbl %al,%esi
call   1030 <outb@plt>
jmp    119a <PIC_remap+0x7a>
mov    $0x21,%edi
mov    $0x4,%esi
call   1030 <outb@plt>
jmp    11ae <PIC_remap+0x8e>
mov    $0xa1,%edi
mov    $0x2,%esi
call   1030 <outb@plt>
jmp    11c2 <PIC_remap+0xa2>
mov    $0x21,%edi
mov    $0x1,%esi
call   1030 <outb@plt>
jmp    11d6 <PIC_remap+0xb6>
mov    $0xa1,%edi
mov    $0x1,%esi
call   1030 <outb@plt>
jmp    11ea <PIC_remap+0xca>
mov    $0x21,%edi
movzbl -0x9(%rbp),%esi
call   1030 <outb@plt>
mov    $0xa1,%edi
movzbl -0xa(%rbp),%esi
call   1030 <outb@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PIC_remap>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
mov    $0x21,%edi
call   1040 <inb@plt>
mov    %eax,%r14d
mov    $0xa1,%edi
call   1040 <inb@plt>
mov    %eax,%r15d
mov    $0x20,%edi
mov    $0x11,%esi
call   1030 <outb@plt>
mov    $0xa0,%edi
mov    $0x11,%esi
call   1030 <outb@plt>
movzbl %bl,%esi
mov    $0x21,%edi
call   1030 <outb@plt>
movzbl %bpl,%esi
mov    $0xa1,%edi
call   1030 <outb@plt>
mov    $0x21,%edi
mov    $0x4,%esi
call   1030 <outb@plt>
mov    $0xa1,%edi
mov    $0x2,%esi
call   1030 <outb@plt>
mov    $0x21,%edi
mov    $0x1,%esi
call   1030 <outb@plt>
mov    $0xa1,%edi
mov    $0x1,%esi
call   1030 <outb@plt>
movzbl %r14b,%esi
mov    $0x21,%edi
call   1030 <outb@plt>
movzbl %r15b,%esi
mov    $0xa1,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <outb@plt>

LLVM IR (-O0):
define void @PIC_remap(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = call zeroext i8 @inb(i32 33)
store i8 %7, i8* %5
%8 = call zeroext i8 @inb(i32 161)
store i8 %8, i8* %6
%9 = call i32 @outb(i32 32, i8 zeroext 17)
br label %10
10: ; preds = %2
br label %11
11: ; preds = %10
%12 = call i32 @outb(i32 160, i8 zeroext 17)
br label %13
13: ; preds = %11
br label %14
14: ; preds = %13
%15 = load i32, i32* %3
%16 = trunc i32 %15 to i8
%17 = call i32 @outb(i32 33, i8 zeroext %16)
br label %18
18: ; preds = %14
br label %19
19: ; preds = %18
%20 = load i32, i32* %4
%21 = trunc i32 %20 to i8
%22 = call i32 @outb(i32 161, i8 zeroext %21)
br label %23
23: ; preds = %19
br label %24
24: ; preds = %23
%25 = call i32 @outb(i32 33, i8 zeroext 4)
br label %26
26: ; preds = %24
br label %27
27: ; preds = %26
%28 = call i32 @outb(i32 161, i8 zeroext 2)
br label %29
29: ; preds = %27
br label %30
30: ; preds = %29
%31 = call i32 @outb(i32 33, i8 zeroext 1)
br label %32
32: ; preds = %30
br label %33
33: ; preds = %32
%34 = call i32 @outb(i32 161, i8 zeroext 1)
br label %35
35: ; preds = %33
br label %36
36: ; preds = %35
%37 = load i8, i8* %5
%38 = call i32 @outb(i32 33, i8 zeroext %37)
%39 = load i8, i8* %6
%40 = call i32 @outb(i32 161, i8 zeroext %39)
ret void
}

LLVM IR (-O2):
define void @PIC_remap(i32 %0, i32 %1) {
%3 = tail call zeroext i8 @inb(i32 33)
%4 = tail call zeroext i8 @inb(i32 161)
%5 = tail call i32 @outb(i32 32, i8 zeroext 17)
%6 = tail call i32 @outb(i32 160, i8 zeroext 17)
%7 = trunc i32 %0 to i8
%8 = tail call i32 @outb(i32 33, i8 zeroext %7)
%9 = trunc i32 %1 to i8
%10 = tail call i32 @outb(i32 161, i8 zeroext %9)
%11 = tail call i32 @outb(i32 33, i8 zeroext 4)
%12 = tail call i32 @outb(i32 161, i8 zeroext 2)
%13 = tail call i32 @outb(i32 33, i8 zeroext 1)
%14 = tail call i32 @outb(i32 161, i8 zeroext 1)
%15 = tail call i32 @outb(i32 33, i8 zeroext %3)
%16 = tail call i32 @outb(i32 161, i8 zeroext %4)
ret void
}