void __attribute__((noreturn)) panic(int cnt) {
  volatile long *p = (void *)0xc02200E4;
  int i;
  for (; cnt > 0; cnt--) {
    p[0] = 0x46;
    for (i = 0; i < 0x200000; i++) {
      asm("nop\n");
      asm("nop\n");
    }
    p[0] = 0x44;
    for (i = 0; i < 0x200000; i++) {
      asm("nop\n");
      asm("nop\n");
    }
  }
  shutdown();
}


x86 assembly (clang, -O0):
<panic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0xc02200e4,%eax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    119f <panic+0x8f>
mov    -0x10(%rbp),%rax
movq   $0x46,(%rax)
movl   $0x0,-0x14(%rbp)
cmpl   $0x200000,-0x14(%rbp)
jge    115d <panic+0x4d>
nop
nop
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1140 <panic+0x30>
mov    -0x10(%rbp),%rax
movq   $0x44,(%rax)
movl   $0x0,-0x14(%rbp)
cmpl   $0x200000,-0x14(%rbp)
jge    118c <panic+0x7c>
nop
nop
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116f <panic+0x5f>
jmp    1191 <panic+0x81>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1124 <panic+0x14>
mov    $0x0,%al
call   1030 <shutdown@plt>

x86 assembly (clang, -O2):
<panic>:
push   %rax
test   %edi,%edi
jle    1161 <panic+0x51>
mov    $0xc02200e4,%eax
nopw   0x0(%rax,%rax,1)
movq   $0x46,(%rax)
mov    $0x200000,%ecx
nopl   0x0(%rax)
nop
nop
add    $0xffffffff,%ecx
jne    1130 <panic+0x20>
movq   $0x44,(%rax)
mov    $0x200000,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
nop
nop
add    $0xffffffff,%ecx
jne    1150 <panic+0x40>
lea    -0x1(%rdi),%ecx
cmp    $0x1,%edi
mov    %ecx,%edi
jg     1120 <panic+0x10>
xor    %eax,%eax
call   1030 <shutdown@plt>

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

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