void PIC_remap(int offset1, int offset2) {
  unsigned char a1, a2;
  a1 = inb(0x21);
  a2 = inb(0xA1);
  outb(0x20, 0x10 + 0x01);
  __asm__("nop;");
  outb(0xA0, 0x10 + 0x01);
  __asm__("nop;");
  outb(0x21, offset1);
  __asm__("nop;");
  outb(0xA1, offset2);
  __asm__("nop;");
  outb(0x21, 4);
  __asm__("nop;");
  outb(0xA1, 2);
  __asm__("nop;");
  outb(0x21, 0x01);
  __asm__("nop;");
  outb(0xA1, 0x01);
  __asm__("nop;");
  outb(0x21, a1);
  outb(0xA1, 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
mov    $0x0,%al
call   1040 <inb@plt>
mov    %al,-0x9(%rbp)
mov    $0xa1,%edi
mov    $0x0,%al
call   1040 <inb@plt>
mov    %al,-0xa(%rbp)
mov    $0x20,%edi
mov    $0x11,%esi
mov    $0x0,%al
call   1030 <outb@plt>
nop
mov    $0xa0,%edi
mov    $0x11,%esi
mov    $0x0,%al
call   1030 <outb@plt>
nop
mov    -0x4(%rbp),%esi
mov    $0x21,%edi
mov    $0x0,%al
call   1030 <outb@plt>
nop
mov    -0x8(%rbp),%esi
mov    $0xa1,%edi
mov    $0x0,%al
call   1030 <outb@plt>
nop
mov    $0x21,%edi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <outb@plt>
nop
mov    $0xa1,%edi
mov    $0x2,%esi
mov    $0x0,%al
call   1030 <outb@plt>
nop
mov    $0x21,%edi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <outb@plt>
nop
mov    $0xa1,%edi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <outb@plt>
nop
movzbl -0x9(%rbp),%esi
mov    $0x21,%edi
mov    $0x0,%al
call   1030 <outb@plt>
movzbl -0xa(%rbp),%esi
mov    $0xa1,%edi
mov    $0x0,%al
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,%ebx
mov    %edi,%ebp
mov    $0x21,%edi
xor    %eax,%eax
call   1040 <inb@plt>
mov    %eax,%r15d
mov    $0xa1,%edi
xor    %eax,%eax
call   1040 <inb@plt>
mov    %eax,%r14d
mov    $0x20,%edi
mov    $0x11,%esi
xor    %eax,%eax
call   1030 <outb@plt>
nop
mov    $0xa0,%edi
mov    $0x11,%esi
xor    %eax,%eax
call   1030 <outb@plt>
nop
mov    $0x21,%edi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <outb@plt>
nop
mov    $0xa1,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <outb@plt>
nop
mov    $0x21,%edi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <outb@plt>
nop
mov    $0xa1,%edi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <outb@plt>
nop
mov    $0x21,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <outb@plt>
nop
mov    $0xa1,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <outb@plt>
nop
movzbl %r15b,%esi
mov    $0x21,%edi
xor    %eax,%eax
call   1030 <outb@plt>
movzbl %r14b,%esi
mov    $0xa1,%edi
xor    %eax,%eax
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 i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 33)
%8 = trunc i32 %7 to i8
store i8 %8, i8* %5
%9 = call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 161)
%10 = trunc i32 %9 to i8
store i8 %10, i8* %6
%11 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 32, i32 17)
%12 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 160, i32 17)
%13 = load i32, i32* %3
%14 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 33, i32 %13)
%15 = load i32, i32* %4
%16 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 161, i32 %15)
%17 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 33, i32 4)
%18 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 161, i32 2)
%19 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 33, i32 1)
%20 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 161, i32 1)
%21 = load i8, i8* %5
%22 = zext i8 %21 to i32
%23 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 33, i32 %22)
%24 = load i8, i8* %6
%25 = zext i8 %24 to i32
%26 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 161, i32 %25)
ret void
}

LLVM IR (-O2):
define void @PIC_remap(i32 %0, i32 %1) {
%3 = tail call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 33)
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 161)
%5 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 32, i32 17)
tail call void asm sideeffect "nop;", "~{dirflag},~{fpsr},~{flags}"()
%6 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 160, i32 17)
tail call void asm sideeffect "nop;", "~{dirflag},~{fpsr},~{flags}"()
%7 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 33, i32 %0)
tail call void asm sideeffect "nop;", "~{dirflag},~{fpsr},~{flags}"()
%8 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 161, i32 %1)
tail call void asm sideeffect "nop;", "~{dirflag},~{fpsr},~{flags}"()
%9 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 33, i32 4)
tail call void asm sideeffect "nop;", "~{dirflag},~{fpsr},~{flags}"()
%10 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 161, i32 2)
tail call void asm sideeffect "nop;", "~{dirflag},~{fpsr},~{flags}"()
%11 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 33, i32 1)
tail call void asm sideeffect "nop;", "~{dirflag},~{fpsr},~{flags}"()
%12 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 161, i32 1)
tail call void asm sideeffect "nop;", "~{dirflag},~{fpsr},~{flags}"()
%13 = and i32 %3, 255
%14 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 33, i32 %13)
%15 = and i32 %4, 255
%16 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 161, i32 %15)
ret void
}