#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int inb(int);
int /*<<< orphan*/ kb_wait();
int /*<<< orphan*/ outb(int, int);
int /*<<< orphan*/ udelay(int);
void mach_reboot(void) {
  int i;
  for (i = 0; i < 10; i++) {
    kb_wait();
    udelay(50);
    outb(0xfe, 0x64);
    udelay(50);
  }
  for (i = 0; i < 10; i++) {
    int cmd;
    outb(0x20, 0x64);
    udelay(50);
    kb_wait();
    udelay(50);
    cmd = inb(0x60);
    udelay(50);
    kb_wait();
    udelay(50);
    outb(0x60, 0x64);
    udelay(50);
    kb_wait();
    udelay(50);
    outb(cmd | 0x04, 0x60);
    udelay(50);
    kb_wait();
    udelay(50);
    outb(0xfe, 0x64);
    udelay(50);
  }
}


x86 assembly (clang, -O0):
<mach_reboot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    1191 <mach_reboot+0x51>
mov    $0x0,%al
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0xfe,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114f <mach_reboot+0xf>
movl   $0x0,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    1270 <mach_reboot+0x130>
mov    $0x20,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0x0,%al
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0x60,%edi
call   1040 <inb@plt>
mov    %eax,-0x8(%rbp)
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0x0,%al
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0x60,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0x0,%al
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    -0x8(%rbp),%edi
or     $0x4,%edi
mov    $0x60,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0x0,%al
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0xfe,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1198 <mach_reboot+0x58>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mach_reboot>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0xfe,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
xor    %eax,%eax
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0xfe,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
xor    %eax,%eax
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0xfe,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
xor    %eax,%eax
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0xfe,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
xor    %eax,%eax
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0xfe,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
xor    %eax,%eax
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0xfe,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
xor    %eax,%eax
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0xfe,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
xor    %eax,%eax
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0xfe,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
xor    %eax,%eax
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0xfe,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
xor    %eax,%eax
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0xfe,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0xa,%ebp
nopl   0x0(%rax)
mov    $0x20,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
xor    %eax,%eax
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0x60,%edi
call   1040 <inb@plt>
mov    %eax,%ebx
mov    $0x32,%edi
call   1050 <udelay@plt>
xor    %eax,%eax
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0x60,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
xor    %eax,%eax
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
or     $0x4,%ebx
mov    %ebx,%edi
mov    $0x60,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
xor    %eax,%eax
call   1060 <kb_wait@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
mov    $0xfe,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1050 <udelay@plt>
add    $0xffffffff,%ebp
jne    12f0 <mach_reboot+0x1b0>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @mach_reboot() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %11, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 10
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = call i32 (...) @kb_wait()
%8 = call i32 @udelay(i32 50)
%9 = call i32 @outb(i32 254, i32 100)
%10 = call i32 @udelay(i32 50)
br label %11
11: ; preds = %6
%12 = load i32, i32* %1
%13 = add nsw i32 %12, 1
store i32 %13, i32* %1
br label %3
14: ; preds = %3
store i32 0, i32* %1
br label %15
15: ; preds = %39, %14
%16 = load i32, i32* %1
%17 = icmp slt i32 %16, 10
br i1 %17, label %18, label %42
18: ; preds = %15
%19 = call i32 @outb(i32 32, i32 100)
%20 = call i32 @udelay(i32 50)
%21 = call i32 (...) @kb_wait()
%22 = call i32 @udelay(i32 50)
%23 = call i32 @inb(i32 96)
store i32 %23, i32* %2
%24 = call i32 @udelay(i32 50)
%25 = call i32 (...) @kb_wait()
%26 = call i32 @udelay(i32 50)
%27 = call i32 @outb(i32 96, i32 100)
%28 = call i32 @udelay(i32 50)
%29 = call i32 (...) @kb_wait()
%30 = call i32 @udelay(i32 50)
%31 = load i32, i32* %2
%32 = or i32 %31, 4
%33 = call i32 @outb(i32 %32, i32 96)
%34 = call i32 @udelay(i32 50)
%35 = call i32 (...) @kb_wait()
%36 = call i32 @udelay(i32 50)
%37 = call i32 @outb(i32 254, i32 100)
%38 = call i32 @udelay(i32 50)
br label %39
39: ; preds = %18
%40 = load i32, i32* %1
%41 = add nsw i32 %40, 1
store i32 %41, i32* %1
br label %15
42: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @mach_reboot() {
%1 = tail call i32 (...) @kb_wait()
%2 = tail call i32 @udelay(i32 50)
%3 = tail call i32 @outb(i32 254, i32 100)
%4 = tail call i32 @udelay(i32 50)
%5 = tail call i32 (...) @kb_wait()
%6 = tail call i32 @udelay(i32 50)
%7 = tail call i32 @outb(i32 254, i32 100)
%8 = tail call i32 @udelay(i32 50)
%9 = tail call i32 (...) @kb_wait()
%10 = tail call i32 @udelay(i32 50)
%11 = tail call i32 @outb(i32 254, i32 100)
%12 = tail call i32 @udelay(i32 50)
%13 = tail call i32 (...) @kb_wait()
%14 = tail call i32 @udelay(i32 50)
%15 = tail call i32 @outb(i32 254, i32 100)
%16 = tail call i32 @udelay(i32 50)
%17 = tail call i32 (...) @kb_wait()
%18 = tail call i32 @udelay(i32 50)
%19 = tail call i32 @outb(i32 254, i32 100)
%20 = tail call i32 @udelay(i32 50)
%21 = tail call i32 (...) @kb_wait()
%22 = tail call i32 @udelay(i32 50)
%23 = tail call i32 @outb(i32 254, i32 100)
%24 = tail call i32 @udelay(i32 50)
%25 = tail call i32 (...) @kb_wait()
%26 = tail call i32 @udelay(i32 50)
%27 = tail call i32 @outb(i32 254, i32 100)
%28 = tail call i32 @udelay(i32 50)
%29 = tail call i32 (...) @kb_wait()
%30 = tail call i32 @udelay(i32 50)
%31 = tail call i32 @outb(i32 254, i32 100)
%32 = tail call i32 @udelay(i32 50)
%33 = tail call i32 (...) @kb_wait()
%34 = tail call i32 @udelay(i32 50)
%35 = tail call i32 @outb(i32 254, i32 100)
%36 = tail call i32 @udelay(i32 50)
%37 = tail call i32 (...) @kb_wait()
%38 = tail call i32 @udelay(i32 50)
%39 = tail call i32 @outb(i32 254, i32 100)
%40 = tail call i32 @udelay(i32 50)
br label %41
41: ; preds = %0, %41
%42 = phi i32 [ %62, %41 ], [ 0, %0 ]
%43 = tail call i32 @outb(i32 32, i32 100)
%44 = tail call i32 @udelay(i32 50)
%45 = tail call i32 (...) @kb_wait()
%46 = tail call i32 @udelay(i32 50)
%47 = tail call i32 @inb(i32 96)
%48 = tail call i32 @udelay(i32 50)
%49 = tail call i32 (...) @kb_wait()
%50 = tail call i32 @udelay(i32 50)
%51 = tail call i32 @outb(i32 96, i32 100)
%52 = tail call i32 @udelay(i32 50)
%53 = tail call i32 (...) @kb_wait()
%54 = tail call i32 @udelay(i32 50)
%55 = or i32 %47, 4
%56 = tail call i32 @outb(i32 %55, i32 96)
%57 = tail call i32 @udelay(i32 50)
%58 = tail call i32 (...) @kb_wait()
%59 = tail call i32 @udelay(i32 50)
%60 = tail call i32 @outb(i32 254, i32 100)
%61 = tail call i32 @udelay(i32 50)
%62 = add nuw nsw i32 %42, 1
%63 = icmp eq i32 %62, 10
br i1 %63, label %64, label %41
64: ; preds = %41
ret void
}