#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 /*<<< orphan*/ kb_wait();
int /*<<< orphan*/ outb(int, int);
int /*<<< orphan*/ udelay(int);
void mach_reboot(void) {
  int i;
  for (i = 0; i < 100; i++) {
    kb_wait();
    udelay(50);
    outb(0x60, 0x64);
    udelay(50);
    kb_wait();
    udelay(50);
    outb(0x14, 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   $0x64,-0x4(%rbp)
jge    11d5 <mach_reboot+0xa5>
mov    $0x0,%al
call   1050 <kb_wait@plt>
mov    $0x32,%edi
call   1040 <udelay@plt>
mov    $0x60,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1040 <udelay@plt>
mov    $0x0,%al
call   1050 <kb_wait@plt>
mov    $0x32,%edi
call   1040 <udelay@plt>
mov    $0x14,%edi
mov    $0x60,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1040 <udelay@plt>
mov    $0x0,%al
call   1050 <kb_wait@plt>
mov    $0x32,%edi
call   1040 <udelay@plt>
mov    $0xfe,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1040 <udelay@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113f <mach_reboot+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mach_reboot>:
push   %rbx
mov    $0x64,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <kb_wait@plt>
mov    $0x32,%edi
call   1040 <udelay@plt>
mov    $0x60,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1040 <udelay@plt>
xor    %eax,%eax
call   1050 <kb_wait@plt>
mov    $0x32,%edi
call   1040 <udelay@plt>
mov    $0x14,%edi
mov    $0x60,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1040 <udelay@plt>
xor    %eax,%eax
call   1050 <kb_wait@plt>
mov    $0x32,%edi
call   1040 <udelay@plt>
mov    $0xfe,%edi
mov    $0x64,%esi
call   1030 <outb@plt>
mov    $0x32,%edi
call   1040 <udelay@plt>
add    $0xffffffff,%ebx
jne    1140 <mach_reboot+0x10>
pop    %rbx
ret

LLVM IR (-O0):
define void @mach_reboot() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %18, %0
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 100
br i1 %4, label %5, label %21
5: ; preds = %2
%6 = call i32 (...) @kb_wait()
%7 = call i32 @udelay(i32 50)
%8 = call i32 @outb(i32 96, i32 100)
%9 = call i32 @udelay(i32 50)
%10 = call i32 (...) @kb_wait()
%11 = call i32 @udelay(i32 50)
%12 = call i32 @outb(i32 20, i32 96)
%13 = call i32 @udelay(i32 50)
%14 = call i32 (...) @kb_wait()
%15 = call i32 @udelay(i32 50)
%16 = call i32 @outb(i32 254, i32 100)
%17 = call i32 @udelay(i32 50)
br label %18
18: ; preds = %5
%19 = load i32, i32* %1
%20 = add nsw i32 %19, 1
store i32 %20, i32* %1
br label %2
21: ; preds = %2
ret void
}

LLVM IR (-O2):
define void @mach_reboot() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %15, %1 ]
%3 = tail call i32 (...) @kb_wait()
%4 = tail call i32 @udelay(i32 50)
%5 = tail call i32 @outb(i32 96, i32 100)
%6 = tail call i32 @udelay(i32 50)
%7 = tail call i32 (...) @kb_wait()
%8 = tail call i32 @udelay(i32 50)
%9 = tail call i32 @outb(i32 20, i32 96)
%10 = tail call i32 @udelay(i32 50)
%11 = tail call i32 (...) @kb_wait()
%12 = tail call i32 @udelay(i32 50)
%13 = tail call i32 @outb(i32 254, i32 100)
%14 = tail call i32 @udelay(i32 50)
%15 = add nuw nsw i32 %2, 1
%16 = icmp eq i32 %15, 100
br i1 %16, label %17, label %1
17: ; preds = %1
ret void
}