void __attribute__((noreturn)) panic(int cnt) {
  int i;
  for (; cnt > 0; cnt--) {
    port_on(0xc0220084);
    for (i = 0; i < 0x200000; i++) {
      asm("nop\n");
      asm("nop\n");
    }
    port_off(0xc0220084);
    for (i = 0; i < 0x200000; i++) {
      asm("nop\n");
      asm("nop\n");
    }
  }
  shutdown();
}


x86 assembly (clang, -O0):
<panic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    11b8 <panic+0x88>
mov    $0xc0220084,%edi
mov    $0x0,%al
call   1030 <port_on@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x200000,-0x8(%rbp)
jge    1175 <panic+0x45>
nop
nop
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1158 <panic+0x28>
mov    $0xc0220084,%edi
mov    $0x0,%al
call   1050 <port_off@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x200000,-0x8(%rbp)
jge    11a5 <panic+0x75>
nop
nop
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1188 <panic+0x58>
jmp    11aa <panic+0x7a>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    113b <panic+0xb>
mov    $0x0,%al
call   1040 <shutdown@plt>

x86 assembly (clang, -O2):
<panic>:
push   %rbx
test   %edi,%edi
jle    1191 <panic+0x61>
mov    %edi,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0xc0220084,%edi
xor    %eax,%eax
call   1030 <port_on@plt>
mov    $0x200000,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
nop
nop
add    $0xffffffff,%eax
jne    1160 <panic+0x30>
mov    $0xc0220084,%edi
xor    %eax,%eax
call   1050 <port_off@plt>
mov    $0x200000,%eax
nopl   0x0(%rax,%rax,1)
nop
nop
add    $0xffffffff,%eax
jne    1180 <panic+0x50>
lea    -0x1(%rbx),%eax
cmp    $0x1,%ebx
mov    %eax,%ebx
jg     1140 <panic+0x10>
xor    %eax,%eax
call   1040 <shutdown@plt>

LLVM IR (-O0):
define void @panic(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
br label %4
4: ; preds = %26, %1
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %29
7: ; preds = %4
%8 = call i32 (i32, ...) bitcast (i32 (...)* @port_on to i32 (i32, ...)*)(i32 -1071513468)
store i32 0, i32* %3
br label %9
9: ; preds = %13, %7
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 2097152
br i1 %11, label %12, label %16
12: ; preds = %9
br label %13
13: ; preds = %12
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %9
16: ; preds = %9
%17 = call i32 (i32, ...) bitcast (i32 (...)* @port_off to i32 (i32, ...)*)(i32 -1071513468)
store i32 0, i32* %3
br label %18
18: ; preds = %22, %16
%19 = load i32, i32* %3
%20 = icmp slt i32 %19, 2097152
br i1 %20, label %21, label %25
21: ; preds = %18
br label %22
22: ; preds = %21
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %18
25: ; preds = %18
br label %26
26: ; preds = %25
%27 = load i32, i32* %2
%28 = add nsw i32 %27, -1
store i32 %28, i32* %2
br label %4
29: ; preds = %4
%30 = call i32 (...) @shutdown()
unreachable
}

LLVM IR (-O2):
define void @panic(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %19
3: ; preds = %1, %16
%4 = phi i32 [ %17, %16 ], [ %0, %1 ]
%5 = tail call i32 (i32, ...) bitcast (i32 (...)* @port_on to i32 (i32, ...)*)(i32 -1071513468)
br label %6
6: ; preds = %3, %6
%7 = phi i32 [ 0, %3 ], [ %8, %6 ]
tail call void asm sideeffect "nop\0A", "~{dirflag},~{fpsr},~{flags}"()
tail call void asm sideeffect "nop\0A", "~{dirflag},~{fpsr},~{flags}"()
%8 = add nuw nsw i32 %7, 1
%9 = icmp eq i32 %8, 2097152
br i1 %9, label %10, label %6
10: ; preds = %6
%11 = tail call i32 (i32, ...) bitcast (i32 (...)* @port_off to i32 (i32, ...)*)(i32 -1071513468)
br label %12
12: ; preds = %10, %12
%13 = phi i32 [ 0, %10 ], [ %14, %12 ]
tail call void asm sideeffect "nop\0A", "~{dirflag},~{fpsr},~{flags}"()
tail call void asm sideeffect "nop\0A", "~{dirflag},~{fpsr},~{flags}"()
%14 = add nuw nsw i32 %13, 1
%15 = icmp eq i32 %14, 2097152
br i1 %15, label %16, label %12
16: ; preds = %12
%17 = add nsw i32 %4, -1
%18 = icmp sgt i32 %4, 1
br i1 %18, label %3, label %19
19: ; preds = %16, %1
%20 = tail call i32 (...) @shutdown()
unreachable
}