#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 */
scalar_t__ ioperm(int, int, int);
int /*<<< orphan*/ outb(int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sleep(int);
int main() {
  int i;
  if (ioperm((0x0378), 1, 1)) {
    printf("ioperm(%x) failed.\nYou must be root to execute!\n", (0x0378));
    return 1;
  }
  for (i = 0; i < 10; i++) {
    outb(255, (0x0378));
    sleep(1);
    outb(0, (0x0378));
    sleep(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x378,%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1050 <ioperm@plt>
cmp    $0x0,%rax
je     1187 <main+0x47>
lea    0xe8f(%rip),%rdi
mov    $0x378,%esi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11dc <main+0x9c>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11d5 <main+0x95>
mov    $0xff,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118e <main+0x4e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x1,%ebx
mov    $0x378,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1050 <ioperm@plt>
test   %rax,%rax
je     1175 <main+0x35>
lea    0xe9a(%rip),%rdi
mov    $0x378,%esi
call   1030 <printf@plt>
jmp    134d <main+0x20d>
mov    $0xff,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %ebx,%ebx
xor    %edi,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    $0xff,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    $0xff,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    $0xff,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    $0xff,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    $0xff,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    $0xff,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    $0xff,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    $0xff,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    $0xff,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
mov    $0x378,%esi
call   1040 <outb@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [49 x i8] c"ioperm(%x) failed.\0AYou must be root to execute!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i64 @ioperm(i32 888, i32 1, i32 1)
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 888)
store i32 1, i32* %1
br label %20
7: ; preds = %0
store i32 0, i32* %2
br label %8
8: ; preds = %16, %7
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 10
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = call i32 @outb(i32 255, i32 888)
%13 = call i32 @sleep(i32 1)
%14 = call i32 @outb(i32 0, i32 888)
%15 = call i32 @sleep(i32 1)
br label %16
16: ; preds = %11
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %8
19: ; preds = %8
store i32 0, i32* %1
br label %20
20: ; preds = %19, %5
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [49 x i8] c"ioperm(%x) failed.\0AYou must be root to execute!\0A\00"
define i32 @main() {
%1 = tail call i64 @ioperm(i32 888, i32 1, i32 1)
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %44
3: ; preds = %0
%4 = tail call i32 @outb(i32 255, i32 888)
%5 = tail call i32 @sleep(i32 1)
%6 = tail call i32 @outb(i32 0, i32 888)
%7 = tail call i32 @sleep(i32 1)
%8 = tail call i32 @outb(i32 255, i32 888)
%9 = tail call i32 @sleep(i32 1)
%10 = tail call i32 @outb(i32 0, i32 888)
%11 = tail call i32 @sleep(i32 1)
%12 = tail call i32 @outb(i32 255, i32 888)
%13 = tail call i32 @sleep(i32 1)
%14 = tail call i32 @outb(i32 0, i32 888)
%15 = tail call i32 @sleep(i32 1)
%16 = tail call i32 @outb(i32 255, i32 888)
%17 = tail call i32 @sleep(i32 1)
%18 = tail call i32 @outb(i32 0, i32 888)
%19 = tail call i32 @sleep(i32 1)
%20 = tail call i32 @outb(i32 255, i32 888)
%21 = tail call i32 @sleep(i32 1)
%22 = tail call i32 @outb(i32 0, i32 888)
%23 = tail call i32 @sleep(i32 1)
%24 = tail call i32 @outb(i32 255, i32 888)
%25 = tail call i32 @sleep(i32 1)
%26 = tail call i32 @outb(i32 0, i32 888)
%27 = tail call i32 @sleep(i32 1)
%28 = tail call i32 @outb(i32 255, i32 888)
%29 = tail call i32 @sleep(i32 1)
%30 = tail call i32 @outb(i32 0, i32 888)
%31 = tail call i32 @sleep(i32 1)
%32 = tail call i32 @outb(i32 255, i32 888)
%33 = tail call i32 @sleep(i32 1)
%34 = tail call i32 @outb(i32 0, i32 888)
%35 = tail call i32 @sleep(i32 1)
%36 = tail call i32 @outb(i32 255, i32 888)
%37 = tail call i32 @sleep(i32 1)
%38 = tail call i32 @outb(i32 0, i32 888)
%39 = tail call i32 @sleep(i32 1)
%40 = tail call i32 @outb(i32 255, i32 888)
%41 = tail call i32 @sleep(i32 1)
%42 = tail call i32 @outb(i32 0, i32 888)
%43 = tail call i32 @sleep(i32 1)
br label %46
44: ; preds = %0
%45 = tail call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 888)
br label %46
46: ; preds = %3, %44
%47 = phi i32 [ 1, %44 ], [ 0, %3 ]
ret i32 %47
}