#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);
scalar_t__ ioperm(int, int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ respond();
int /*<<< orphan*/ sleep(int);
int main() {
  if (ioperm(0x378, 1, 1)) {
    printf("Couldn't get the port.\n");
    perror("ioperm problem:");
  }
  if (ioperm(0x378 + 1, 1, 1)) {
    printf("Couldn't get the port.\n");
    perror("ioperm problem:");
  }
  for (;;) {
    sleep(1);
    unsigned int high = 0x7F;
    unsigned int low = 0x6F;
    printf("Low = %X  High = %X\n", low, high);
    printf("status port register value %X\n", inb(0x378 + 1));
    respond();
  }
  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     11a4 <main+0x44>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe79(%rip),%rdi
call   1070 <perror@plt>
mov    $0x379,%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1050 <ioperm@plt>
cmp    $0x0,%rax
je     11d9 <main+0x79>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe44(%rip),%rdi
call   1070 <perror@plt>
jmp    11de <main+0x7e>
mov    $0x1,%edi
call   1080 <sleep@plt>
movl   $0x7f,-0x8(%rbp)
movl   $0x6f,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x379,%edi
call   1060 <inb@plt>
mov    %eax,%esi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <respond@plt>
jmp    11de <main+0x7e>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x378,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1060 <ioperm@plt>
test   %rax,%rax
jne    11fd <main+0x8d>
mov    $0x379,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1060 <ioperm@plt>
test   %rax,%rax
jne    121a <main+0xaa>
lea    0xe63(%rip),%r14
lea    0xe71(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    %r14,%rdi
mov    $0x6f,%esi
mov    $0x7f,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x379,%edi
call   1070 <inb@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <respond@plt>
jmp    11c0 <main+0x50>
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
lea    0xdf0(%rip),%rdi
call   1080 <perror@plt>
jmp    118d <main+0x1d>
lea    0xe23(%rip),%rdi
call   1040 <puts@plt>
lea    0xdd3(%rip),%rdi
call   1080 <perror@plt>
jmp    11a6 <main+0x36>

LLVM IR (-O0):
@.str = [24 x i8] c"Couldn't get the port.\0A\00"
@.str.1 = [16 x i8] c"ioperm problem:\00"
@.str.2 = [21 x i8] c"Low = %X High = %X\0A\00"
@.str.3 = [31 x i8] c"status port register value %X\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i64 @ioperm(i32 888, i32 1, i32 1)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %6, %0
%10 = call i64 @ioperm(i32 889, i32 1, i32 1)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %12, %9
br label %16
16: ; preds = %16, %15
%17 = call i32 @sleep(i32 1)
store i32 127, i32* %2
store i32 111, i32* %3
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19)
%21 = call i32 @inb(i32 889)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = call i32 (...) @respond()
br label %16
}

LLVM IR (-O2):
@.str.1 = [16 x i8] c"ioperm problem:\00"
@.str.2 = [21 x i8] c"Low = %X High = %X\0A\00"
@.str.3 = [31 x i8] c"status port register value %X\0A\00"
@str.4 = [23 x i8] c"Couldn't get the port.\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 %6, label %3
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.4, i64 0, i64 0))
%5 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %3, %0
%7 = tail call i64 @ioperm(i32 889, i32 1, i32 1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.4, i64 0, i64 0))
%11 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %9, %6
br label %13
13: ; preds = %12, %13
%14 = tail call i32 @sleep(i32 1)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 111, i32 127)
%16 = tail call i32 @inb(i32 889)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = tail call i32 (...) @respond()
br label %13
}