#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*/ io_wait();
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);
  io_wait();
  outb(0xA0, 0x10 + 0x01);
  io_wait();
  outb((0x20 + 1), offset1);
  io_wait();
  outb((0xA0 + 1), offset2);
  io_wait();
  outb((0x20 + 1), 4);
  io_wait();
  outb((0xA0 + 1), 2);
  io_wait();
  outb((0x20 + 1), 0x01);
  io_wait();
  outb((0xA0 + 1), 0x01);
  io_wait();
  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   1050 <inb@plt>
mov    %al,-0x9(%rbp)
mov    $0xa1,%edi
call   1050 <inb@plt>
mov    %al,-0xa(%rbp)
mov    $0x20,%edi
mov    $0x11,%esi
call   1030 <outb@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
mov    $0xa0,%edi
mov    $0x11,%esi
call   1030 <outb@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
mov    -0x4(%rbp),%eax
mov    $0x21,%edi
movzbl %al,%esi
call   1030 <outb@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
mov    -0x8(%rbp),%eax
mov    $0xa1,%edi
movzbl %al,%esi
call   1030 <outb@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
mov    $0x21,%edi
mov    $0x4,%esi
call   1030 <outb@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
mov    $0xa1,%edi
mov    $0x2,%esi
call   1030 <outb@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
mov    $0x21,%edi
mov    $0x1,%esi
call   1030 <outb@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
mov    $0xa1,%edi
mov    $0x1,%esi
call   1030 <outb@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
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   1050 <inb@plt>
mov    %eax,%r14d
mov    $0xa1,%edi
call   1050 <inb@plt>
mov    %eax,%r15d
mov    $0x20,%edi
mov    $0x11,%esi
call   1030 <outb@plt>
xor    %eax,%eax
call   1040 <io_wait@plt>
mov    $0xa0,%edi
mov    $0x11,%esi
call   1030 <outb@plt>
xor    %eax,%eax
call   1040 <io_wait@plt>
movzbl %bl,%esi
mov    $0x21,%edi
call   1030 <outb@plt>
xor    %eax,%eax
call   1040 <io_wait@plt>
movzbl %bpl,%esi
mov    $0xa1,%edi
call   1030 <outb@plt>
xor    %eax,%eax
call   1040 <io_wait@plt>
mov    $0x21,%edi
mov    $0x4,%esi
call   1030 <outb@plt>
xor    %eax,%eax
call   1040 <io_wait@plt>
mov    $0xa1,%edi
mov    $0x2,%esi
call   1030 <outb@plt>
xor    %eax,%eax
call   1040 <io_wait@plt>
mov    $0x21,%edi
mov    $0x1,%esi
call   1030 <outb@plt>
xor    %eax,%eax
call   1040 <io_wait@plt>
mov    $0xa1,%edi
mov    $0x1,%esi
call   1030 <outb@plt>
xor    %eax,%eax
call   1040 <io_wait@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)
%10 = call i32 (...) @io_wait()
%11 = call i32 @outb(i32 160, i8 zeroext 17)
%12 = call i32 (...) @io_wait()
%13 = load i32, i32* %3
%14 = trunc i32 %13 to i8
%15 = call i32 @outb(i32 33, i8 zeroext %14)
%16 = call i32 (...) @io_wait()
%17 = load i32, i32* %4
%18 = trunc i32 %17 to i8
%19 = call i32 @outb(i32 161, i8 zeroext %18)
%20 = call i32 (...) @io_wait()
%21 = call i32 @outb(i32 33, i8 zeroext 4)
%22 = call i32 (...) @io_wait()
%23 = call i32 @outb(i32 161, i8 zeroext 2)
%24 = call i32 (...) @io_wait()
%25 = call i32 @outb(i32 33, i8 zeroext 1)
%26 = call i32 (...) @io_wait()
%27 = call i32 @outb(i32 161, i8 zeroext 1)
%28 = call i32 (...) @io_wait()
%29 = load i8, i8* %5
%30 = call i32 @outb(i32 33, i8 zeroext %29)
%31 = load i8, i8* %6
%32 = call i32 @outb(i32 161, i8 zeroext %31)
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 (...) @io_wait()
%7 = tail call i32 @outb(i32 160, i8 zeroext 17)
%8 = tail call i32 (...) @io_wait()
%9 = trunc i32 %0 to i8
%10 = tail call i32 @outb(i32 33, i8 zeroext %9)
%11 = tail call i32 (...) @io_wait()
%12 = trunc i32 %1 to i8
%13 = tail call i32 @outb(i32 161, i8 zeroext %12)
%14 = tail call i32 (...) @io_wait()
%15 = tail call i32 @outb(i32 33, i8 zeroext 4)
%16 = tail call i32 (...) @io_wait()
%17 = tail call i32 @outb(i32 161, i8 zeroext 2)
%18 = tail call i32 (...) @io_wait()
%19 = tail call i32 @outb(i32 33, i8 zeroext 1)
%20 = tail call i32 (...) @io_wait()
%21 = tail call i32 @outb(i32 161, i8 zeroext 1)
%22 = tail call i32 (...) @io_wait()
%23 = tail call i32 @outb(i32 33, i8 zeroext %3)
%24 = tail call i32 @outb(i32 161, i8 zeroext %4)
ret void
}