#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 */
typedef int /*<<< orphan*/ str;

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int inb(int);
scalar_t__ ioperm(int, int, int);
int /*<<< orphan*/ outb(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int);
int main(int ac, char **av) {
  char str[80];
  int port;
  int inval;
  int val;
  int i, v;
  if (ac > 1)
    sscanf(av[1], "%x", &port);
  else
    port = 0x3BC;
  printf("\nFPAC Parallel port remote control. Address is %x (hex).\n", port);
  if (ioperm(port, 3, 1)) {
    printf("open port : %s\n", strerror(errno));
    return 1;
  }
  for (;;) {
    inval = inb(port);
    printf("\nOuputs :                          Inputs:\n");
    for (i = 0; i < 8; i++) {
      printf("B%d  ", i);
    }
    printf("  ER  SL  PA  AC  BU\n");
    for (i = 0; i < 8; i++) {
      printf("%d   ", (inval >> i) & 1);
    }
    printf("  ");
    val = inb(port + 1);
    for (i = 3; i < 8; i++) {
      if (i == 7)
        printf("%d   ", !(val >> i) & 1);
      else
        printf("%d   ", (val >> i) & 1);
    }
    printf("\n\nCommand C(bit), S(bit), H, ?, Q\n");
    fgets(str, sizeof(str), stdin);
    if ((*str == 'q') || (*str == 'Q'))
      break;
    if ((*str == 'c') || (*str == 'C')) {
      v = str[1] - '0';
      if ((v < 0) || (v > 7)) {
        printf("Error : Command is c0 to c7\n");
        continue;
      }
      v = 1 << v;
      inval &= (~v);
      outb(inval, port);
      usleep(100000);
      inval = inb(port);
    } else if ((*str == 's') || (*str == 'S')) {
      v = str[1] - '0';
      if ((v < 0) || (v > 7)) {
        printf("Error : Command is s0 to s7\n");
        continue;
      }
      v = 1 << v;
      inval |= v;
      outb(inval, port);
      usleep(100000);
      inval = inb(port);
    } else if ((*str == 'h') || (*str == 'H') || (*str == '?')) {
      printf("Valid command are :\n"
             "c0 : Clear output bit 0\n"
             "s5 : Set   output bit 5\n"
             "h,?: This help\n"
             "q  : Quit\n\n");
    } else {
      printf("Error : Command is C(bit) S(bit) or Q\n");
    }
  }
  if (ioperm(port, 3, 0)) {
    printf("close port : %s\n", strerror(errno));
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11c0 <main+0x40>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4e(%rip),%rsi
lea    -0x64(%rbp),%rdx
call   1080 <sscanf@plt>
jmp    11c7 <main+0x47>
movl   $0x3bc,-0x64(%rbp)
mov    -0x64(%rbp),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x64(%rbp),%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1060 <ioperm@plt>
cmp    $0x0,%rax
je     121f <main+0x9f>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %rax,%rsi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1536 <main+0x3b6>
jmp    1224 <main+0xa4>
mov    -0x64(%rbp),%edi
call   1070 <inb@plt>
mov    %eax,-0x68(%rbp)
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x70(%rbp)
cmpl   $0x8,-0x70(%rbp)
jge    126d <main+0xed>
mov    -0x70(%rbp),%esi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    1244 <main+0xc4>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x70(%rbp)
cmpl   $0x8,-0x70(%rbp)
jge    12b3 <main+0x133>
mov    -0x68(%rbp),%esi
mov    -0x70(%rbp),%ecx
sar    %cl,%esi
and    $0x1,%esi
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    1282 <main+0x102>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x64(%rbp),%edi
add    $0x1,%edi
call   1070 <inb@plt>
mov    %eax,-0x6c(%rbp)
movl   $0x3,-0x70(%rbp)
cmpl   $0x8,-0x70(%rbp)
jge    1341 <main+0x1c1>
cmpl   $0x7,-0x70(%rbp)
jne    1315 <main+0x195>
mov    -0x6c(%rbp),%eax
mov    -0x70(%rbp),%ecx
sar    %cl,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%esi
and    $0x1,%esi
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    132e <main+0x1ae>
mov    -0x6c(%rbp),%esi
mov    -0x70(%rbp),%ecx
sar    %cl,%esi
and    $0x1,%esi
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1333 <main+0x1b3>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    12d6 <main+0x156>
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    0x2c8e(%rip),%rax
mov    (%rax),%edx
mov    $0x50,%esi
call   1050 <fgets@plt>
movsbl -0x60(%rbp),%eax
cmp    $0x71,%eax
je     1380 <main+0x200>
movsbl -0x60(%rbp),%eax
cmp    $0x51,%eax
jne    1385 <main+0x205>
jmp    14eb <main+0x36b>
movsbl -0x60(%rbp),%eax
cmp    $0x63,%eax
je     139f <main+0x21f>
movsbl -0x60(%rbp),%eax
cmp    $0x43,%eax
jne    140e <main+0x28e>
movsbl -0x5f(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jl     13bd <main+0x23d>
cmpl   $0x7,-0x74(%rbp)
jle    13d0 <main+0x250>
lea    0xcfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1224 <main+0xa4>
mov    -0x74(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
xor    $0xffffffff,%eax
and    -0x68(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%edi
mov    -0x64(%rbp),%esi
call   1040 <outb@plt>
mov    $0x186a0,%edi
call   10a0 <usleep@plt>
mov    -0x64(%rbp),%edi
call   1070 <inb@plt>
mov    %eax,-0x68(%rbp)
jmp    14e6 <main+0x366>
movsbl -0x60(%rbp),%eax
cmp    $0x73,%eax
je     1428 <main+0x2a8>
movsbl -0x60(%rbp),%eax
cmp    $0x53,%eax
jne    1494 <main+0x314>
movsbl -0x5f(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jl     1446 <main+0x2c6>
cmpl   $0x7,-0x74(%rbp)
jle    1459 <main+0x2d9>
lea    0xc8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1224 <main+0xa4>
mov    -0x74(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
or     -0x68(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%edi
mov    -0x64(%rbp),%esi
call   1040 <outb@plt>
mov    $0x186a0,%edi
call   10a0 <usleep@plt>
mov    -0x64(%rbp),%edi
call   1070 <inb@plt>
mov    %eax,-0x68(%rbp)
jmp    14e1 <main+0x361>
movsbl -0x60(%rbp),%eax
cmp    $0x68,%eax
je     14bb <main+0x33b>
movsbl -0x60(%rbp),%eax
cmp    $0x48,%eax
je     14bb <main+0x33b>
movsbl -0x60(%rbp),%eax
cmp    $0x3f,%eax
jne    14ce <main+0x34e>
lea    0xc36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14dc <main+0x35c>
lea    0xc82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14e1 <main+0x361>
jmp    14e6 <main+0x366>
jmp    1224 <main+0xa4>
mov    -0x64(%rbp),%edi
mov    $0x3,%esi
xor    %edx,%edx
call   1060 <ioperm@plt>
cmp    $0x0,%rax
je     152f <main+0x3af>
mov    0x2acd(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %rax,%rsi
lea    0xc62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1536 <main+0x3b6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
cmp    $0x2,%edi
jl     11be <main+0x2e>
mov    0x8(%rsi),%rdi
lea    0xe52(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1090 <sscanf@plt>
mov    0xc(%rsp),%esi
jmp    11cb <main+0x3b>
movl   $0x3bc,0xc(%rsp)
mov    $0x3bc,%esi
lea    0xe31(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1070 <ioperm@plt>
test   %rax,%rax
je     11fd <main+0x6d>
lea    0xe45(%rip),%rbx
jmp    14d2 <main+0x342>
lea    0xe49(%rip),%r12
lea    0xe48(%rip),%rbx
lea    0x10(%rsp),%r14
jmp    1220 <main+0x90>
lea    0xf37(%rip),%rdi
call   1030 <puts@plt>
xchg   %ax,%ax
mov    0xc(%rsp),%edi
call   1080 <inb@plt>
mov    %eax,%r15d
lea    0xe37(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xde1(%rip),%rdi
call   1030 <puts@plt>
mov    %r15d,%esi
and    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%esi
shr    %esi
and    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%esi
shr    $0x2,%esi
and    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%esi
shr    $0x3,%esi
and    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%esi
shr    $0x4,%esi
and    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%esi
shr    $0x5,%esi
and    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%esi
shr    $0x6,%esi
and    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%esi
shr    $0x7,%esi
and    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd02(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%edi
add    $0x1,%edi
call   1080 <inb@plt>
mov    %eax,%ebp
xor    %r13d,%r13d
cmp    $0x80,%eax
setb   %r13b
mov    %eax,%esi
shr    $0x3,%esi
and    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%esi
shr    $0x4,%esi
and    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%esi
shr    $0x5,%esi
and    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
shr    $0x6,%ebp
and    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xcd9(%rip),%rdi
call   1030 <puts@plt>
mov    0x2c0b(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x50,%esi
call   1060 <fgets@plt>
movzbl 0x10(%rsp),%eax
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0x43,%cl
je     1440 <main+0x2b0>
cmp    $0x53,%cl
je     1460 <main+0x2d0>
cmp    $0x51,%cl
je     14b4 <main+0x324>
add    $0xc1,%al
cmp    $0x29,%al
ja     14a3 <main+0x313>
movzbl %al,%eax
movabs $0x20000000201,%rcx
bt     %rax,%rcx
jae    14a3 <main+0x313>
lea    0xcc5(%rip),%rdi
call   1030 <puts@plt>
jmp    1220 <main+0x90>
nopw   0x0(%rax,%rax,1)
movzbl 0x11(%rsp),%eax
lea    -0x38(%rax),%ecx
cmp    $0xf7,%cl
ja     1479 <main+0x2e9>
lea    0xd18(%rip),%rdi
call   1030 <puts@plt>
jmp    1220 <main+0x90>
xchg   %ax,%ax
movzbl 0x11(%rsp),%eax
lea    -0x38(%rax),%ecx
cmp    $0xf7,%cl
jbe    1212 <main+0x82>
add    $0xd0,%al
bts    %eax,%r15d
jmp    147f <main+0x2ef>
add    $0xd0,%al
btr    %eax,%r15d
mov    0xc(%rsp),%esi
mov    %r15d,%edi
call   1050 <outb@plt>
mov    $0x186a0,%edi
call   10b0 <usleep@plt>
mov    0xc(%rsp),%edi
call   1080 <inb@plt>
jmp    1220 <main+0x90>
lea    0xc22(%rip),%rdi
call   1030 <puts@plt>
jmp    1220 <main+0x90>
mov    0xc(%rsp),%edi
xor    %ebx,%ebx
mov    $0x3,%esi
xor    %edx,%edx
call   1070 <ioperm@plt>
test   %rax,%rax
je     14f2 <main+0x362>
lea    0xb87(%rip),%rbx
mov    0x2aff(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%x\00"
@.str.1 = [58 x i8] c"\0AFPAC Parallel port remote control. Address is %x (hex).\0A\00"
@.str.2 = [16 x i8] c"open port : %s\0A\00"
@errno = global i32 0
@.str.3 = [44 x i8] c"\0AOuputs : Inputs:\0A\00"
@.str.4 = [6 x i8] c"B%d \00"
@.str.5 = [22 x i8] c" ER SL PA AC BU\0A\00"
@.str.6 = [6 x i8] c"%d \00"
@.str.7 = [3 x i8] c" \00"
@.str.8 = [35 x i8] c"\0A\0ACommand C(bit), S(bit), H, ?, Q\0A\00"
@stdin = global i32 0
@.str.9 = [29 x i8] c"Error : Command is c0 to c7\0A\00"
@.str.10 = [29 x i8] c"Error : Command is s0 to s7\0A\00"
@.str.11 = [95 x i8] c"Valid command are :\0Ac0 : Clear output bit 0\0As5 : Set output bit 5\0Ah,?: This help\0Aq : Quit\0A\0A\00"
@.str.12 = [39 x i8] c"Error : Command is C(bit) S(bit) or Q\0A\00"
@.str.13 = [17 x i8] c"close port : %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [80 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 1
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
br label %20
19: ; preds = %2
store i32 956, i32* %7
br label %20
20: ; preds = %19, %14
%21 = load i32, i32* %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %7
%24 = call i64 @ioperm(i32 %23, i32 3, i32 1)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %20
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %28)
store i32 1, i32* %3
br label %203
30: ; preds = %20
br label %31
31: ; preds = %193, %158, %123, %30
%32 = load i32, i32* %7
%33 = call i32 @inb(i32 %32)
store i32 %33, i32* %8
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %10
br label %35
35: ; preds = %41, %31
%36 = load i32, i32* %10
%37 = icmp slt i32 %36, 8
br i1 %37, label %38, label %44
38: ; preds = %35
%39 = load i32, i32* %10
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %38
%42 = load i32, i32* %10
%43 = add nsw i32 %42, 1
store i32 %43, i32* %10
br label %35
44: ; preds = %35
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %10
br label %46
46: ; preds = %55, %44
%47 = load i32, i32* %10
%48 = icmp slt i32 %47, 8
br i1 %48, label %49, label %58
49: ; preds = %46
%50 = load i32, i32* %8
%51 = load i32, i32* %10
%52 = ashr i32 %50, %51
%53 = and i32 %52, 1
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %49
%56 = load i32, i32* %10
%57 = add nsw i32 %56, 1
store i32 %57, i32* %10
br label %46
58: ; preds = %46
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%60 = load i32, i32* %7
%61 = add nsw i32 %60, 1
%62 = call i32 @inb(i32 %61)
store i32 %62, i32* %9
store i32 3, i32* %10
br label %63
63: ; preds = %85, %58
%64 = load i32, i32* %10
%65 = icmp slt i32 %64, 8
br i1 %65, label %66, label %88
66: ; preds = %63
%67 = load i32, i32* %10
%68 = icmp eq i32 %67, 7
br i1 %68, label %69, label %78
69: ; preds = %66
%70 = load i32, i32* %9
%71 = load i32, i32* %10
%72 = ashr i32 %70, %71
%73 = icmp ne i32 %72, 0
%74 = xor i1 %73, true
%75 = zext i1 %74 to i32
%76 = and i32 %75, 1
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %76)
br label %84
78: ; preds = %66
%79 = load i32, i32* %9
%80 = load i32, i32* %10
%81 = ashr i32 %79, %80
%82 = and i32 %81, 1
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %82)
br label %84
84: ; preds = %78, %69
br label %85
85: ; preds = %84
%86 = load i32, i32* %10
%87 = add nsw i32 %86, 1
store i32 %87, i32* %10
br label %63
88: ; preds = %63
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
%90 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%91 = load i32, i32* @stdin
%92 = call i32 @fgets(i8* %90, i32 80, i32 %91)
%93 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 113
br i1 %96, label %102, label %97
97: ; preds = %88
%98 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%99 = load i8, i8* %98
%100 = sext i8 %99 to i32
%101 = icmp eq i32 %100, 81
br i1 %101, label %102, label %103
102: ; preds = %97, %88
br label %194
103: ; preds = %97
%104 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%105 = load i8, i8* %104
%106 = sext i8 %105 to i32
%107 = icmp eq i32 %106, 99
br i1 %107, label %113, label %108
108: ; preds = %103
%109 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%110 = load i8, i8* %109
%111 = sext i8 %110 to i32
%112 = icmp eq i32 %111, 67
br i1 %112, label %113, label %138
113: ; preds = %108, %103
%114 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 1
%115 = load i8, i8* %114
%116 = sext i8 %115 to i32
%117 = sub nsw i32 %116, 48
store i32 %117, i32* %11
%118 = load i32, i32* %11
%119 = icmp slt i32 %118, 0
br i1 %119, label %123, label %120
120: ; preds = %113
%121 = load i32, i32* %11
%122 = icmp sgt i32 %121, 7
br i1 %122, label %123, label %125
123: ; preds = %120, %113
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
br label %31
125: ; preds = %120
%126 = load i32, i32* %11
%127 = shl i32 1, %126
store i32 %127, i32* %11
%128 = load i32, i32* %11
%129 = xor i32 %128, -1
%130 = load i32, i32* %8
%131 = and i32 %130, %129
store i32 %131, i32* %8
%132 = load i32, i32* %8
%133 = load i32, i32* %7
%134 = call i32 @outb(i32 %132, i32 %133)
%135 = call i32 @usleep(i32 100000)
%136 = load i32, i32* %7
%137 = call i32 @inb(i32 %136)
store i32 %137, i32* %8
br label %193
138: ; preds = %108
%139 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%140 = load i8, i8* %139
%141 = sext i8 %140 to i32
%142 = icmp eq i32 %141, 115
br i1 %142, label %148, label %143
143: ; preds = %138
%144 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%145 = load i8, i8* %144
%146 = sext i8 %145 to i32
%147 = icmp eq i32 %146, 83
br i1 %147, label %148, label %172
148: ; preds = %143, %138
%149 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 1
%150 = load i8, i8* %149
%151 = sext i8 %150 to i32
%152 = sub nsw i32 %151, 48
store i32 %152, i32* %11
%153 = load i32, i32* %11
%154 = icmp slt i32 %153, 0
br i1 %154, label %158, label %155
155: ; preds = %148
%156 = load i32, i32* %11
%157 = icmp sgt i32 %156, 7
br i1 %157, label %158, label %160
158: ; preds = %155, %148
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
br label %31
160: ; preds = %155
%161 = load i32, i32* %11
%162 = shl i32 1, %161
store i32 %162, i32* %11
%163 = load i32, i32* %11
%164 = load i32, i32* %8
%165 = or i32 %164, %163
store i32 %165, i32* %8
%166 = load i32, i32* %8
%167 = load i32, i32* %7
%168 = call i32 @outb(i32 %166, i32 %167)
%169 = call i32 @usleep(i32 100000)
%170 = load i32, i32* %7
%171 = call i32 @inb(i32 %170)
store i32 %171, i32* %8
br label %192
172: ; preds = %143
%173 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%174 = load i8, i8* %173
%175 = sext i8 %174 to i32
%176 = icmp eq i32 %175, 104
br i1 %176, label %187, label %177
177: ; preds = %172
%178 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%179 = load i8, i8* %178
%180 = sext i8 %179 to i32
%181 = icmp eq i32 %180, 72
br i1 %181, label %187, label %182
182: ; preds = %177
%183 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%184 = load i8, i8* %183
%185 = sext i8 %184 to i32
%186 = icmp eq i32 %185, 63
br i1 %186, label %187, label %189
187: ; preds = %182, %177, %172
%188 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([95 x i8], [95 x i8]* @.str.11, i64 0, i64 0))
br label %191
189: ; preds = %182
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0))
br label %191
191: ; preds = %189, %187
br label %192
192: ; preds = %191, %160
br label %193
193: ; preds = %192, %125
br label %31
194: ; preds = %102
%195 = load i32, i32* %7
%196 = call i64 @ioperm(i32 %195, i32 3, i32 0)
%197 = icmp ne i64 %196, 0
br i1 %197, label %198, label %202
198: ; preds = %194
%199 = load i32, i32* @errno
%200 = call i8* @strerror(i32 %199)
%201 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i8* %200)
store i32 1, i32* %3
br label %203
202: ; preds = %194
store i32 0, i32* %3
br label %203
203: ; preds = %202, %198, %26
%204 = load i32, i32* %3
ret i32 %204
}

LLVM IR (-O2):
@.str = [3 x i8] c"%x\00"
@.str.1 = [58 x i8] c"\0AFPAC Parallel port remote control. Address is %x (hex).\0A\00"
@.str.2 = [16 x i8] c"open port : %s\0A\00"
@errno = global i32 0
@.str.4 = [6 x i8] c"B%d \00"
@.str.6 = [6 x i8] c"%d \00"
@.str.7 = [3 x i8] c" \00"
@stdin = global i32 0
@.str.13 = [17 x i8] c"close port : %s\0A\00"
@str = [43 x i8] c"\0AOuputs : Inputs:\00"
@str.14 = [21 x i8] c" ER SL PA AC BU\00"
@str.15 = [34 x i8] c"\0A\0ACommand C(bit), S(bit), H, ?, Q\00"
@str.16 = [38 x i8] c"Error : Command is C(bit) S(bit) or Q\00"
@str.17 = [94 x i8] c"Valid command are :\0Ac0 : Clear output bit 0\0As5 : Set output bit 5\0Ah,?: This help\0Aq : Quit\0A\00"
@str.18 = [28 x i8] c"Error : Command is s0 to s7\00"
@str.19 = [28 x i8] c"Error : Command is c0 to c7\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%12 = load i32, i32* %4
br label %14
13: ; preds = %2
store i32 956, i32* %4
br label %14
14: ; preds = %13, %8
%15 = phi i32 [ 956, %13 ], [ %12, %8 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %4
%18 = call i64 @ioperm(i32 %17, i32 3, i32 1)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %125
20: ; preds = %14
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 1
br label %22
22: ; preds = %99, %20
%23 = load i32, i32* %4
%24 = call i32 @inb(i32 %23)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 0)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 1)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 2)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 3)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 4)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 6)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 7)
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.14, i64 0, i64 0))
%35 = and i32 %24, 1
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %35)
%37 = lshr i32 %24, 1
%38 = and i32 %37, 1
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %38)
%40 = lshr i32 %24, 2
%41 = and i32 %40, 1
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %41)
%43 = lshr i32 %24, 3
%44 = and i32 %43, 1
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %44)
%46 = lshr i32 %24, 4
%47 = and i32 %46, 1
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %47)
%49 = lshr i32 %24, 5
%50 = and i32 %49, 1
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %50)
%52 = lshr i32 %24, 6
%53 = and i32 %52, 1
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %53)
%55 = lshr i32 %24, 7
%56 = and i32 %55, 1
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%59 = load i32, i32* %4
%60 = add nsw i32 %59, 1
%61 = call i32 @inb(i32 %60)
%62 = icmp ult i32 %61, 128
%63 = zext i1 %62 to i32
%64 = lshr i32 %61, 3
%65 = and i32 %64, 1
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %65)
%67 = lshr i32 %61, 4
%68 = and i32 %67, 1
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %68)
%70 = lshr i32 %61, 5
%71 = and i32 %70, 1
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %71)
%73 = lshr i32 %61, 6
%74 = and i32 %73, 1
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %74)
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %63)
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.15, i64 0, i64 0))
%78 = load i32, i32* @stdin
%79 = call i32 @fgets(i8* %5, i32 80, i32 %78)
%80 = load i8, i8* %5
%81 = and i8 %80, -33
switch i8 %81, label %116 [
i8 81, label %121
i8 67, label %82
i8 83, label %100
]
82: ; preds = %22
%83 = load i8, i8* %21
%84 = add i8 %83, -56
%85 = icmp ult i8 %84, -8
br i1 %85, label %86, label %88
86: ; preds = %82
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.19, i64 0, i64 0))
br label %99
88: ; preds = %82
%89 = zext i8 %83 to i32
%90 = add nsw i32 %89, -48
%91 = shl nuw nsw i32 1, %90
%92 = xor i32 %91, -1
%93 = and i32 %24, %92
%94 = load i32, i32* %4
%95 = call i32 @outb(i32 %93, i32 %94)
%96 = call i32 @usleep(i32 100000)
%97 = load i32, i32* %4
%98 = call i32 @inb(i32 %97)
br label %99
99: ; preds = %88, %117, %119, %106, %86, %104
br label %22
100: ; preds = %22
%101 = load i8, i8* %21
%102 = add i8 %101, -56
%103 = icmp ult i8 %102, -8
br i1 %103, label %104, label %106
104: ; preds = %100
%105 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.18, i64 0, i64 0))
br label %99
106: ; preds = %100
%107 = zext i8 %101 to i32
%108 = add nsw i32 %107, -48
%109 = shl nuw nsw i32 1, %108
%110 = or i32 %109, %24
%111 = load i32, i32* %4
%112 = call i32 @outb(i32 %110, i32 %111)
%113 = call i32 @usleep(i32 100000)
%114 = load i32, i32* %4
%115 = call i32 @inb(i32 %114)
br label %99
116: ; preds = %22
switch i8 %80, label %119 [
i8 104, label %117
i8 72, label %117
i8 63, label %117
]
117: ; preds = %116, %116, %116
%118 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([94 x i8], [94 x i8]* @str.17, i64 0, i64 0))
br label %99
119: ; preds = %116
%120 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.16, i64 0, i64 0))
br label %99
121: ; preds = %22
%122 = load i32, i32* %4
%123 = call i64 @ioperm(i32 %122, i32 3, i32 0)
%124 = icmp eq i64 %123, 0
br i1 %124, label %130, label %125
125: ; preds = %121, %14
%126 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), %14 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), %121 ]
%127 = load i32, i32* @errno
%128 = call i8* @strerror(i32 %127)
%129 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %126, i8* %128)
br label %130
130: ; preds = %125, %121
%131 = phi i32 [ 0, %121 ], [ 1, %125 ]
ret i32 %131
}