void init_pic(int offset) {
  asm volatile("outb %0, %1\n\t" ::"a"((unsigned char)((1 << 4) | (1 << 0))),
               "dN"((unsigned short)(0x20)));
  asm volatile("outb %0, %1\n\t" ::"a"((unsigned char)((1 << 4) | (1 << 0))),
               "dN"((unsigned short)(0xa0)));
  asm volatile("outb %0, %1\n\t" ::"a"((unsigned char)(offset)),
               "dN"((unsigned short)(0x21)));
  asm volatile("outb %0, %1\n\t" ::"a"((unsigned char)(offset + 8)),
               "dN"((unsigned short)(0xa1)));
  asm volatile("outb %0, %1\n\t" ::"a"((unsigned char)(4)),
               "dN"((unsigned short)(0x21)));
  asm volatile("outb %0, %1\n\t" ::"a"((unsigned char)(2)),
               "dN"((unsigned short)(0xa1)));
  asm volatile("outb %0, %1\n\t" ::"a"((unsigned char)((1 << 0))),
               "dN"((unsigned short)(0x21)));
  asm volatile("outb %0, %1\n\t" ::"a"((unsigned char)((1 << 0))),
               "dN"((unsigned short)(0xa1)));
  asm volatile("outb %0, %1\n\t" ::"a"((unsigned char)(0)),
               "dN"((unsigned short)(0x21)));
  asm volatile("outb %0, %1\n\t" ::"a"((unsigned char)(0)),
               "dN"((unsigned short)(0xa1)));
}


x86 assembly (clang, -O0):
<init_pic>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    $0x11,%al
out    %al,$0x20
mov    $0x11,%al
out    %al,$0xa0
mov    -0x4(%rbp),%eax
out    %al,$0x21
mov    -0x4(%rbp),%eax
add    $0x8,%eax
out    %al,$0xa1
mov    $0x4,%al
out    %al,$0x21
mov    $0x2,%al
out    %al,$0xa1
mov    $0x1,%al
out    %al,$0x21
mov    $0x1,%al
out    %al,$0xa1
xor    %eax,%eax
out    %al,$0x21
xor    %eax,%eax
out    %al,$0xa1
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_pic>:
mov    $0x11,%al
out    %al,$0x20
mov    $0x11,%al
out    %al,$0xa0
mov    %edi,%eax
out    %al,$0x21
lea    0x8(%rdi),%eax
out    %al,$0xa1
mov    $0x4,%al
out    %al,$0x21
mov    $0x2,%al
out    %al,$0xa1
mov    $0x1,%al
out    %al,$0x21
mov    $0x1,%al
out    %al,$0xa1
xor    %eax,%eax
out    %al,$0x21
xor    %eax,%eax
out    %al,$0xa1
ret

LLVM IR (-O0):
define void @init_pic(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = trunc i32 %3 to i8
%5 = load i32, i32* %2
%6 = add nsw i32 %5, 8
%7 = trunc i32 %6 to i8
ret void
}

LLVM IR (-O2):
define void @init_pic(i32 %0) {
tail call void asm sideeffect "outb $0, $1\0A\09", "{ax},{dx}N,~{dirflag},~{fpsr},~{flags}"(i8 17, i16 32)
tail call void asm sideeffect "outb $0, $1\0A\09", "{ax},{dx}N,~{dirflag},~{fpsr},~{flags}"(i8 17, i16 160)
%2 = trunc i32 %0 to i8
tail call void asm sideeffect "outb $0, $1\0A\09", "{ax},{dx}N,~{dirflag},~{fpsr},~{flags}"(i8 %2, i16 33)
%3 = add i8 %2, 8
tail call void asm sideeffect "outb $0, $1\0A\09", "{ax},{dx}N,~{dirflag},~{fpsr},~{flags}"(i8 %3, i16 161)
tail call void asm sideeffect "outb $0, $1\0A\09", "{ax},{dx}N,~{dirflag},~{fpsr},~{flags}"(i8 4, i16 33)
tail call void asm sideeffect "outb $0, $1\0A\09", "{ax},{dx}N,~{dirflag},~{fpsr},~{flags}"(i8 2, i16 161)
tail call void asm sideeffect "outb $0, $1\0A\09", "{ax},{dx}N,~{dirflag},~{fpsr},~{flags}"(i8 1, i16 33)
tail call void asm sideeffect "outb $0, $1\0A\09", "{ax},{dx}N,~{dirflag},~{fpsr},~{flags}"(i8 1, i16 161)
tail call void asm sideeffect "outb $0, $1\0A\09", "{ax},{dx}N,~{dirflag},~{fpsr},~{flags}"(i8 0, i16 33)
tail call void asm sideeffect "outb $0, $1\0A\09", "{ax},{dx}N,~{dirflag},~{fpsr},~{flags}"(i8 0, i16 161)
ret void
}