#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 in_byte(int);
int /*<<< orphan*/ io_wait();
int /*<<< orphan*/ out_byte(int, unsigned char);
void PIC_remap() {
  unsigned char a1, a2;
  a1 = in_byte((0x20 + 1));
  a2 = in_byte((0xA0 + 1));
  out_byte(0x20, 0x10 + 0x01);
  io_wait();
  out_byte(0xA0, 0x10 + 0x01);
  io_wait();
  out_byte((0x20 + 1), 0x70);
  io_wait();
  out_byte((0xA0 + 1), 0x78);
  io_wait();
  out_byte((0x20 + 1), 4);
  io_wait();
  out_byte((0xA0 + 1), 2);
  io_wait();
  out_byte((0x20 + 1), 0x01);
  io_wait();
  out_byte((0xA0 + 1), 0x01);
  io_wait();
  out_byte((0x20 + 1), a1);
  out_byte((0xA0 + 1), a2);
}


x86 assembly (clang, -O0):
<PIC_remap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x21,%edi
call   1030 <in_byte@plt>
mov    %al,-0x1(%rbp)
mov    $0xa1,%edi
call   1030 <in_byte@plt>
mov    %al,-0x2(%rbp)
mov    $0x20,%edi
mov    $0x11,%esi
call   1050 <out_byte@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
mov    $0xa0,%edi
mov    $0x11,%esi
call   1050 <out_byte@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
mov    $0x21,%edi
mov    $0x70,%esi
call   1050 <out_byte@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
mov    $0xa1,%edi
mov    $0x78,%esi
call   1050 <out_byte@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
mov    $0x21,%edi
mov    $0x4,%esi
call   1050 <out_byte@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
mov    $0xa1,%edi
mov    $0x2,%esi
call   1050 <out_byte@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
mov    $0x21,%edi
mov    $0x1,%esi
call   1050 <out_byte@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
mov    $0xa1,%edi
mov    $0x1,%esi
call   1050 <out_byte@plt>
mov    $0x0,%al
call   1040 <io_wait@plt>
mov    $0x21,%edi
movzbl -0x1(%rbp),%esi
call   1050 <out_byte@plt>
mov    $0xa1,%edi
movzbl -0x2(%rbp),%esi
call   1050 <out_byte@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PIC_remap>:
push   %rbp
push   %rbx
push   %rax
mov    $0x21,%edi
call   1030 <in_byte@plt>
mov    %eax,%ebp
mov    $0xa1,%edi
call   1030 <in_byte@plt>
mov    %eax,%ebx
mov    $0x20,%edi
mov    $0x11,%esi
call   1050 <out_byte@plt>
xor    %eax,%eax
call   1040 <io_wait@plt>
mov    $0xa0,%edi
mov    $0x11,%esi
call   1050 <out_byte@plt>
xor    %eax,%eax
call   1040 <io_wait@plt>
mov    $0x21,%edi
mov    $0x70,%esi
call   1050 <out_byte@plt>
xor    %eax,%eax
call   1040 <io_wait@plt>
mov    $0xa1,%edi
mov    $0x78,%esi
call   1050 <out_byte@plt>
xor    %eax,%eax
call   1040 <io_wait@plt>
mov    $0x21,%edi
mov    $0x4,%esi
call   1050 <out_byte@plt>
xor    %eax,%eax
call   1040 <io_wait@plt>
mov    $0xa1,%edi
mov    $0x2,%esi
call   1050 <out_byte@plt>
xor    %eax,%eax
call   1040 <io_wait@plt>
mov    $0x21,%edi
mov    $0x1,%esi
call   1050 <out_byte@plt>
xor    %eax,%eax
call   1040 <io_wait@plt>
mov    $0xa1,%edi
mov    $0x1,%esi
call   1050 <out_byte@plt>
xor    %eax,%eax
call   1040 <io_wait@plt>
movzbl %bpl,%esi
mov    $0x21,%edi
call   1050 <out_byte@plt>
movzbl %bl,%esi
mov    $0xa1,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <out_byte@plt>

LLVM IR (-O0):
define void @PIC_remap() {
%1 = alloca i8
%2 = alloca i8
%3 = call zeroext i8 @in_byte(i32 33)
store i8 %3, i8* %1
%4 = call zeroext i8 @in_byte(i32 161)
store i8 %4, i8* %2
%5 = call i32 @out_byte(i32 32, i8 zeroext 17)
%6 = call i32 (...) @io_wait()
%7 = call i32 @out_byte(i32 160, i8 zeroext 17)
%8 = call i32 (...) @io_wait()
%9 = call i32 @out_byte(i32 33, i8 zeroext 112)
%10 = call i32 (...) @io_wait()
%11 = call i32 @out_byte(i32 161, i8 zeroext 120)
%12 = call i32 (...) @io_wait()
%13 = call i32 @out_byte(i32 33, i8 zeroext 4)
%14 = call i32 (...) @io_wait()
%15 = call i32 @out_byte(i32 161, i8 zeroext 2)
%16 = call i32 (...) @io_wait()
%17 = call i32 @out_byte(i32 33, i8 zeroext 1)
%18 = call i32 (...) @io_wait()
%19 = call i32 @out_byte(i32 161, i8 zeroext 1)
%20 = call i32 (...) @io_wait()
%21 = load i8, i8* %1
%22 = call i32 @out_byte(i32 33, i8 zeroext %21)
%23 = load i8, i8* %2
%24 = call i32 @out_byte(i32 161, i8 zeroext %23)
ret void
}

LLVM IR (-O2):
define void @PIC_remap() {
%1 = tail call zeroext i8 @in_byte(i32 33)
%2 = tail call zeroext i8 @in_byte(i32 161)
%3 = tail call i32 @out_byte(i32 32, i8 zeroext 17)
%4 = tail call i32 (...) @io_wait()
%5 = tail call i32 @out_byte(i32 160, i8 zeroext 17)
%6 = tail call i32 (...) @io_wait()
%7 = tail call i32 @out_byte(i32 33, i8 zeroext 112)
%8 = tail call i32 (...) @io_wait()
%9 = tail call i32 @out_byte(i32 161, i8 zeroext 120)
%10 = tail call i32 (...) @io_wait()
%11 = tail call i32 @out_byte(i32 33, i8 zeroext 4)
%12 = tail call i32 (...) @io_wait()
%13 = tail call i32 @out_byte(i32 161, i8 zeroext 2)
%14 = tail call i32 (...) @io_wait()
%15 = tail call i32 @out_byte(i32 33, i8 zeroext 1)
%16 = tail call i32 (...) @io_wait()
%17 = tail call i32 @out_byte(i32 161, i8 zeroext 1)
%18 = tail call i32 (...) @io_wait()
%19 = tail call i32 @out_byte(i32 33, i8 zeroext %1)
%20 = tail call i32 @out_byte(i32 161, i8 zeroext %2)
ret void
}