void __attribute__((noreturn)) panic(int cnt) {
  volatile long *red = (void *)0xc0220134;
  int i;
  for (; cnt > 0; cnt--) {
    *red = 0x46;
    for (i = 0; i < 0x200000; i++) {
      asm("nop\n");
      asm("nop\n");
    }
    *red = 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    $0xc0220134,%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    $0xc0220134,%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 3223454004 to i64*), i64** %3
br label %5
5: ; preds = %27, %1
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %30
8: ; preds = %5
%9 = load i64*, i64** %3
store volatile i64 70, i64* %9
store i32 0, i32* %4
br label %10
10: ; preds = %14, %8
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2097152
br i1 %12, label %13, label %17
13: ; preds = %10
br label %14
14: ; preds = %13
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %10
17: ; preds = %10
%18 = load i64*, i64** %3
store volatile i64 68, i64* %18
store i32 0, i32* %4
br label %19
19: ; preds = %23, %17
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 2097152
br i1 %21, label %22, label %26
22: ; preds = %19
br label %23
23: ; preds = %22
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %19
26: ; preds = %19
br label %27
27: ; preds = %26
%28 = load i32, i32* %2
%29 = add nsw i32 %28, -1
store i32 %29, i32* %2
br label %5
30: ; preds = %5
%31 = 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 3223454004 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 3223454004 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
}