#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
scalar_t__ ioperm(int, int, int);
int /*<<< orphan*/ outb(unsigned char, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usleep(int);
int main() {
  unsigned char a, c;
  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:");
  }
  if (ioperm(0x378 + 2, 1, 1)) {
    printf("Couldn't get the port.\n");
    perror("ioperm problem:");
  }
  printf("\n");
  c = 0x00;
  a = 0x00;
  outb(c ^ 0x0b, 0x378 + 2);
  outb(a, 0x378);
  fputs("\r", stdout);
  printf("Present values are c = %X    a = %2X        Total: %4d               "
         "           ",
         c, a, 256 * (int)c + (int)a);
  fflush(stdout);
  usleep(100000);
  printf("\n");
  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   1060 <ioperm@plt>
cmp    $0x0,%rax
je     11b4 <main+0x44>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe69(%rip),%rdi
call   1080 <perror@plt>
mov    $0x379,%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1060 <ioperm@plt>
cmp    $0x0,%rax
je     11e9 <main+0x79>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe34(%rip),%rdi
call   1080 <perror@plt>
mov    $0x37a,%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1060 <ioperm@plt>
cmp    $0x0,%rax
je     121e <main+0xae>
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdff(%rip),%rdi
call   1080 <perror@plt>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x0,-0x6(%rbp)
movb   $0x0,-0x5(%rbp)
movzbl -0x6(%rbp),%eax
xor    $0xb,%eax
mov    $0x37a,%esi
movzbl %al,%edi
call   1050 <outb@plt>
mov    $0x378,%esi
movzbl -0x5(%rbp),%edi
call   1050 <outb@plt>
mov    0x2d83(%rip),%rax
mov    (%rax),%esi
lea    0xdc2(%rip),%rdi
call   1040 <fputs@plt>
movzbl -0x6(%rbp),%esi
movzbl -0x5(%rbp),%edx
movzbl -0x6(%rbp),%ecx
shl    $0x8,%ecx
movzbl -0x5(%rbp),%eax
add    %eax,%ecx
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x186a0,%edi
call   1090 <usleep@plt>
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x378,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1080 <ioperm@plt>
test   %rax,%rax
jne    1255 <main+0xc5>
mov    $0x379,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1080 <ioperm@plt>
test   %rax,%rax
jne    1272 <main+0xe2>
mov    $0x37a,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1080 <ioperm@plt>
test   %rax,%rax
jne    128f <main+0xff>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xb,%edi
mov    $0x37a,%esi
call   1070 <outb@plt>
xor    %edi,%edi
mov    $0x378,%esi
call   1070 <outb@plt>
mov    0x2dcc(%rip),%rbx
mov    (%rbx),%esi
lea    0xdf3(%rip),%rdi
call   1060 <fputs@plt>
lea    0xde9(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%edi
call   1090 <fflush@plt>
mov    $0x186a0,%edi
call   10b0 <usleep@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe07(%rip),%rdi
call   1040 <puts@plt>
lea    0xd98(%rip),%rdi
call   10a0 <perror@plt>
jmp    11ae <main+0x1e>
lea    0xdea(%rip),%rdi
call   1040 <puts@plt>
lea    0xd7b(%rip),%rdi
call   10a0 <perror@plt>
jmp    11cb <main+0x3b>
lea    0xdcd(%rip),%rdi
call   1040 <puts@plt>
lea    0xd5e(%rip),%rdi
call   10a0 <perror@plt>
jmp    11e8 <main+0x58>

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 = [2 x i8] c"\0A\00"
@.str.3 = [2 x i8] c"\0D\00"
@stdout = global i32 0
@.str.4 = [81 x i8] c"Present values are c = %X a = %2X Total: %4d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
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
%16 = call i64 @ioperm(i32 890, i32 1, i32 1)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %18, %15
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8 0, i8* %3
store i8 0, i8* %2
%23 = load i8, i8* %3
%24 = zext i8 %23 to i32
%25 = xor i32 %24, 11
%26 = trunc i32 %25 to i8
%27 = call i32 @outb(i8 zeroext %26, i32 890)
%28 = load i8, i8* %2
%29 = call i32 @outb(i8 zeroext %28, i32 888)
%30 = load i32, i32* @stdout
%31 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = load i8, i8* %3
%33 = zext i8 %32 to i32
%34 = load i8, i8* %2
%35 = zext i8 %34 to i32
%36 = load i8, i8* %3
%37 = zext i8 %36 to i32
%38 = mul nsw i32 256, %37
%39 = load i8, i8* %2
%40 = zext i8 %39 to i32
%41 = add nsw i32 %38, %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.4, i64 0, i64 0), i32 %33, i32 %35, i32 %41)
%43 = load i32, i32* @stdout
%44 = call i32 @fflush(i32 %43)
%45 = call i32 @usleep(i32 100000)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [16 x i8] c"ioperm problem:\00"
@.str.3 = [2 x i8] c"\0D\00"
@stdout = global i32 0
@.str.4 = [81 x i8] c"Present values are c = %X a = %2X Total: %4d \00"
@str.6 = [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.6, 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.6, 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
%13 = tail call i64 @ioperm(i32 890, i32 1, i32 1)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
%17 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %15, %12
%19 = tail call i32 @putchar(i32 10)
%20 = tail call i32 @outb(i8 zeroext 11, i32 890)
%21 = tail call i32 @outb(i8 zeroext 0, i32 888)
%22 = load i32, i32* @stdout
%23 = tail call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.4, i64 0, i64 0), i32 0, i32 0, i32 0)
%25 = load i32, i32* @stdout
%26 = tail call i32 @fflush(i32 %25)
%27 = tail call i32 @usleep(i32 100000)
%28 = tail call i32 @putchar(i32 10)
ret i32 0
}