void kshutdown() {
  { __asm__ __volatile__("cli"); };
  for (;;) {
    outportw(0xB004, 0x2000);
    const char *s = "Shutdown";
    for (; *s; ++s) {
      outportw(0x8900, *s);
    }
    { __asm__ __volatile__("cli"); };
    { __asm__ __volatile__("hlt"); };
  }
}


x86 assembly (clang, -O0):
<kshutdown>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cli
mov    $0xb004,%edi
mov    $0x2000,%esi
mov    $0x0,%al
call   1030 <outportw@plt>
lea    0xecf(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1166 <kshutdown+0x56>
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
mov    $0x8900,%edi
mov    $0x0,%al
call   1030 <outportw@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1135 <kshutdown+0x25>
cli
hlt
jmp    1119 <kshutdown+0x9>

x86 assembly (clang, -O2):
<kshutdown>:
push   %rax
cli
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xb004,%edi
mov    $0x2000,%esi
xor    %eax,%eax
call   1030 <outportw@plt>
mov    $0x8900,%edi
mov    $0x53,%esi
xor    %eax,%eax
call   1030 <outportw@plt>
mov    $0x8900,%edi
mov    $0x68,%esi
xor    %eax,%eax
call   1030 <outportw@plt>
mov    $0x8900,%edi
mov    $0x75,%esi
xor    %eax,%eax
call   1030 <outportw@plt>
mov    $0x8900,%edi
mov    $0x74,%esi
xor    %eax,%eax
call   1030 <outportw@plt>
mov    $0x8900,%edi
mov    $0x64,%esi
xor    %eax,%eax
call   1030 <outportw@plt>
mov    $0x8900,%edi
mov    $0x6f,%esi
xor    %eax,%eax
call   1030 <outportw@plt>
mov    $0x8900,%edi
mov    $0x77,%esi
xor    %eax,%eax
call   1030 <outportw@plt>
mov    $0x8900,%edi
mov    $0x6e,%esi
xor    %eax,%eax
call   1030 <outportw@plt>
cli
hlt
jmp    1120 <kshutdown+0x10>

LLVM IR (-O0):
@.str = [9 x i8] c"Shutdown\00"
define void @kshutdown() {
%1 = alloca i8*
br label %2
2: ; preds = %16, %0
%3 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outportw to i32 (i32, i32, ...)*)(i32 45060, i32 8192)
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %1
br label %4
4: ; preds = %13, %2
%5 = load i8*, i8** %1
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %4
%9 = load i8*, i8** %1
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outportw to i32 (i32, i32, ...)*)(i32 35072, i32 %11)
br label %13
13: ; preds = %8
%14 = load i8*, i8** %1
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %1
br label %4
16: ; preds = %4
br label %2
}

LLVM IR (-O2):
define void @kshutdown() {
tail call void asm sideeffect "cli", "~{dirflag},~{fpsr},~{flags}"()
br label %1
1: ; preds = %1, %0
%2 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outportw to i32 (i32, i32, ...)*)(i32 45060, i32 8192)
%3 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outportw to i32 (i32, i32, ...)*)(i32 35072, i32 83)
%4 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outportw to i32 (i32, i32, ...)*)(i32 35072, i32 104)
%5 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outportw to i32 (i32, i32, ...)*)(i32 35072, i32 117)
%6 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outportw to i32 (i32, i32, ...)*)(i32 35072, i32 116)
%7 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outportw to i32 (i32, i32, ...)*)(i32 35072, i32 100)
%8 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outportw to i32 (i32, i32, ...)*)(i32 35072, i32 111)
%9 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outportw to i32 (i32, i32, ...)*)(i32 35072, i32 119)
%10 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outportw to i32 (i32, i32, ...)*)(i32 35072, i32 110)
tail call void asm sideeffect "cli", "~{dirflag},~{fpsr},~{flags}"()
tail call void asm sideeffect "hlt", "~{dirflag},~{fpsr},~{flags}"()
br label %1
}