#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*/ IOPi_init(int, int);
int /*<<< orphan*/ _IONBF;
int /*<<< orphan*/ clearscreen();
int /*<<< orphan*/ invert_port(int, int, int);
int /*<<< orphan*/ printf(char *, int);
int read_pin(int, int);
int /*<<< orphan*/ set_port_direction(int, int, int);
int /*<<< orphan*/ set_port_pullups(int, int, int);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usleep(int);
int main(int argc, char **argv) {
  setvbuf(stdout, NULL, _IONBF, 0);
  IOPi_init(0x20, 1);
  set_port_direction(0x20, 0, 0xFF);
  set_port_direction(0x20, 1, 0xFF);
  set_port_pullups(0x20, 0, 0xFF);
  invert_port(0x20, 0, 0xFF);
  set_port_pullups(0x20, 1, 0xFF);
  invert_port(0x20, 1, 0xFF);
  while (1) {
    clearscreen();
    printf("Port 0 Pin 1: %x \n", read_pin(0x20, 1));
    printf("Port 0 Pin 2: %x \n", read_pin(0x20, 2));
    printf("Port 0 Pin 3: %x \n", read_pin(0x20, 3));
    printf("Port 0 Pin 4: %x \n", read_pin(0x20, 4));
    printf("Port 0 Pin 5: %x \n", read_pin(0x20, 5));
    printf("Port 0 Pin 6: %x \n", read_pin(0x20, 6));
    printf("Port 0 Pin 7: %x \n", read_pin(0x20, 7));
    printf("Port 0 Pin 8: %x \n", read_pin(0x20, 8));
    printf("Port 0 Pin 9: %x \n", read_pin(0x20, 9));
    printf("Port 0 Pin 10: %x \n", read_pin(0x20, 10));
    printf("Port 0 Pin 11: %x \n", read_pin(0x20, 11));
    printf("Port 0 Pin 12: %x \n", read_pin(0x20, 12));
    printf("Port 0 Pin 13: %x \n", read_pin(0x20, 13));
    printf("Port 0 Pin 14: %x \n", read_pin(0x20, 14));
    printf("Port 0 Pin 15: %x \n", read_pin(0x20, 15));
    printf("Port 0 Pin 16: %x \n", read_pin(0x20, 16));
    usleep(200000);
  }
  (void)argc;
  (void)argv;
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    0x2e32(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1080 <setvbuf@plt>
mov    $0x20,%edi
mov    $0x1,%esi
call   1090 <IOPi_init@plt>
mov    $0x20,%edi
xor    %esi,%esi
mov    $0xff,%edx
call   10a0 <set_port_direction@plt>
mov    $0x20,%edi
mov    $0x1,%esi
mov    $0xff,%edx
call   10a0 <set_port_direction@plt>
mov    $0x20,%edi
xor    %esi,%esi
mov    $0xff,%edx
call   1030 <set_port_pullups@plt>
mov    $0x20,%edi
xor    %esi,%esi
mov    $0xff,%edx
call   1070 <invert_port@plt>
mov    $0x20,%edi
mov    $0x1,%esi
mov    $0xff,%edx
call   1030 <set_port_pullups@plt>
mov    $0x20,%edi
mov    $0x1,%esi
mov    $0xff,%edx
call   1070 <invert_port@plt>
mov    $0x0,%al
call   1040 <clearscreen@plt>
mov    $0x20,%edi
mov    $0x1,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xda0(%rip),%rdi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x2,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xd96(%rip),%rdi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x3,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xd8c(%rip),%rdi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x4,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xd82(%rip),%rdi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x5,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xd78(%rip),%rdi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x6,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xd6e(%rip),%rdi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x7,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xd64(%rip),%rdi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x8,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xd5a(%rip),%rdi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x9,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xd50(%rip),%rdi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0xa,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xd46(%rip),%rdi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0xb,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xd3d(%rip),%rdi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0xc,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xd34(%rip),%rdi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0xd,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xd2b(%rip),%rdi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0xe,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xd22(%rip),%rdi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0xf,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xd19(%rip),%rdi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x10,%esi
call   1060 <read_pin@plt>
mov    %eax,%esi
lea    0xd10(%rip),%rdi
call   1050 <printf@plt>
mov    $0x30d40,%edi
call   10b0 <usleep@plt>
jmp    1241 <main+0xb1>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    0x2e3d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1080 <setvbuf@plt>
mov    $0x20,%edi
mov    $0x1,%esi
call   1090 <IOPi_init@plt>
mov    $0x20,%edi
xor    %esi,%esi
mov    $0xff,%edx
call   10a0 <set_port_direction@plt>
mov    $0x20,%edi
mov    $0x1,%esi
mov    $0xff,%edx
call   10a0 <set_port_direction@plt>
mov    $0x20,%edi
xor    %esi,%esi
mov    $0xff,%edx
call   1030 <set_port_pullups@plt>
mov    $0x20,%edi
xor    %esi,%esi
mov    $0xff,%edx
call   1070 <invert_port@plt>
mov    $0x20,%edi
mov    $0x1,%esi
mov    $0xff,%edx
call   1030 <set_port_pullups@plt>
mov    $0x20,%edi
mov    $0x1,%esi
mov    $0xff,%edx
call   1070 <invert_port@plt>
lea    0xe84(%rip),%rbx
lea    0xe91(%rip),%rbp
lea    0xe9e(%rip),%r14
lea    0xeab(%rip),%r15
lea    0xeb8(%rip),%r12
lea    0xec5(%rip),%r13
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <clearscreen@plt>
mov    $0x20,%edi
mov    $0x1,%esi
call   1060 <read_pin@plt>
lea    0xd83(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x2,%esi
call   1060 <read_pin@plt>
lea    0xd79(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x3,%esi
call   1060 <read_pin@plt>
lea    0xd6f(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x4,%esi
call   1060 <read_pin@plt>
lea    0xd65(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x5,%esi
call   1060 <read_pin@plt>
lea    0xd5b(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x6,%esi
call   1060 <read_pin@plt>
lea    0xd51(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x7,%esi
call   1060 <read_pin@plt>
lea    0xd47(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x8,%esi
call   1060 <read_pin@plt>
lea    0xd3d(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x9,%esi
call   1060 <read_pin@plt>
lea    0xd33(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0xa,%esi
call   1060 <read_pin@plt>
lea    0xd29(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0xb,%esi
call   1060 <read_pin@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0xc,%esi
call   1060 <read_pin@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0xd,%esi
call   1060 <read_pin@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0xe,%esi
call   1060 <read_pin@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0xf,%esi
call   1060 <read_pin@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x20,%edi
mov    $0x10,%esi
call   1060 <read_pin@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x30d40,%edi
call   10b0 <usleep@plt>
jmp    1260 <main+0xd0>

LLVM IR (-O0):
@stdout = global i32 0
@_IONBF = global i32 0
@.str = [19 x i8] c"Port 0 Pin 1: %x \0A\00"
@.str.1 = [19 x i8] c"Port 0 Pin 2: %x \0A\00"
@.str.2 = [19 x i8] c"Port 0 Pin 3: %x \0A\00"
@.str.3 = [19 x i8] c"Port 0 Pin 4: %x \0A\00"
@.str.4 = [19 x i8] c"Port 0 Pin 5: %x \0A\00"
@.str.5 = [19 x i8] c"Port 0 Pin 6: %x \0A\00"
@.str.6 = [19 x i8] c"Port 0 Pin 7: %x \0A\00"
@.str.7 = [19 x i8] c"Port 0 Pin 8: %x \0A\00"
@.str.8 = [19 x i8] c"Port 0 Pin 9: %x \0A\00"
@.str.9 = [20 x i8] c"Port 0 Pin 10: %x \0A\00"
@.str.10 = [20 x i8] c"Port 0 Pin 11: %x \0A\00"
@.str.11 = [20 x i8] c"Port 0 Pin 12: %x \0A\00"
@.str.12 = [20 x i8] c"Port 0 Pin 13: %x \0A\00"
@.str.13 = [20 x i8] c"Port 0 Pin 14: %x \0A\00"
@.str.14 = [20 x i8] c"Port 0 Pin 15: %x \0A\00"
@.str.15 = [20 x i8] c"Port 0 Pin 16: %x \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* @stdout
%7 = load i32, i32* @_IONBF
%8 = call i32 @setvbuf(i32 %6, i32* null, i32 %7, i32 0)
%9 = call i32 @IOPi_init(i32 32, i32 1)
%10 = call i32 @set_port_direction(i32 32, i32 0, i32 255)
%11 = call i32 @set_port_direction(i32 32, i32 1, i32 255)
%12 = call i32 @set_port_pullups(i32 32, i32 0, i32 255)
%13 = call i32 @invert_port(i32 32, i32 0, i32 255)
%14 = call i32 @set_port_pullups(i32 32, i32 1, i32 255)
%15 = call i32 @invert_port(i32 32, i32 1, i32 255)
br label %16
16: ; preds = %2, %16
%17 = call i32 (...) @clearscreen()
%18 = call i32 @read_pin(i32 32, i32 1)
%19 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = call i32 @read_pin(i32 32, i32 2)
%21 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = call i32 @read_pin(i32 32, i32 3)
%23 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = call i32 @read_pin(i32 32, i32 4)
%25 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = call i32 @read_pin(i32 32, i32 5)
%27 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = call i32 @read_pin(i32 32, i32 6)
%29 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %28)
%30 = call i32 @read_pin(i32 32, i32 7)
%31 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %30)
%32 = call i32 @read_pin(i32 32, i32 8)
%33 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %32)
%34 = call i32 @read_pin(i32 32, i32 9)
%35 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %34)
%36 = call i32 @read_pin(i32 32, i32 10)
%37 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %36)
%38 = call i32 @read_pin(i32 32, i32 11)
%39 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %38)
%40 = call i32 @read_pin(i32 32, i32 12)
%41 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i32 %40)
%42 = call i32 @read_pin(i32 32, i32 13)
%43 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i32 %42)
%44 = call i32 @read_pin(i32 32, i32 14)
%45 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i32 %44)
%46 = call i32 @read_pin(i32 32, i32 15)
%47 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0), i32 %46)
%48 = call i32 @read_pin(i32 32, i32 16)
%49 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0), i32 %48)
%50 = call i32 @usleep(i32 200000)
br label %16
}

LLVM IR (-O2):
@stdout = global i32 0
@_IONBF = global i32 0
@.str = [19 x i8] c"Port 0 Pin 1: %x \0A\00"
@.str.1 = [19 x i8] c"Port 0 Pin 2: %x \0A\00"
@.str.2 = [19 x i8] c"Port 0 Pin 3: %x \0A\00"
@.str.3 = [19 x i8] c"Port 0 Pin 4: %x \0A\00"
@.str.4 = [19 x i8] c"Port 0 Pin 5: %x \0A\00"
@.str.5 = [19 x i8] c"Port 0 Pin 6: %x \0A\00"
@.str.6 = [19 x i8] c"Port 0 Pin 7: %x \0A\00"
@.str.7 = [19 x i8] c"Port 0 Pin 8: %x \0A\00"
@.str.8 = [19 x i8] c"Port 0 Pin 9: %x \0A\00"
@.str.9 = [20 x i8] c"Port 0 Pin 10: %x \0A\00"
@.str.10 = [20 x i8] c"Port 0 Pin 11: %x \0A\00"
@.str.11 = [20 x i8] c"Port 0 Pin 12: %x \0A\00"
@.str.12 = [20 x i8] c"Port 0 Pin 13: %x \0A\00"
@.str.13 = [20 x i8] c"Port 0 Pin 14: %x \0A\00"
@.str.14 = [20 x i8] c"Port 0 Pin 15: %x \0A\00"
@.str.15 = [20 x i8] c"Port 0 Pin 16: %x \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @stdout
%4 = load i32, i32* @_IONBF
%5 = tail call i32 @setvbuf(i32 %3, i32* null, i32 %4, i32 0)
%6 = tail call i32 @IOPi_init(i32 32, i32 1)
%7 = tail call i32 @set_port_direction(i32 32, i32 0, i32 255)
%8 = tail call i32 @set_port_direction(i32 32, i32 1, i32 255)
%9 = tail call i32 @set_port_pullups(i32 32, i32 0, i32 255)
%10 = tail call i32 @invert_port(i32 32, i32 0, i32 255)
%11 = tail call i32 @set_port_pullups(i32 32, i32 1, i32 255)
%12 = tail call i32 @invert_port(i32 32, i32 1, i32 255)
br label %13
13: ; preds = %2, %13
%14 = tail call i32 (...) @clearscreen()
%15 = tail call i32 @read_pin(i32 32, i32 1)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = tail call i32 @read_pin(i32 32, i32 2)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = tail call i32 @read_pin(i32 32, i32 3)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = tail call i32 @read_pin(i32 32, i32 4)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = tail call i32 @read_pin(i32 32, i32 5)
%24 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = tail call i32 @read_pin(i32 32, i32 6)
%26 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %25)
%27 = tail call i32 @read_pin(i32 32, i32 7)
%28 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %27)
%29 = tail call i32 @read_pin(i32 32, i32 8)
%30 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %29)
%31 = tail call i32 @read_pin(i32 32, i32 9)
%32 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %31)
%33 = tail call i32 @read_pin(i32 32, i32 10)
%34 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %33)
%35 = tail call i32 @read_pin(i32 32, i32 11)
%36 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %35)
%37 = tail call i32 @read_pin(i32 32, i32 12)
%38 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i32 %37)
%39 = tail call i32 @read_pin(i32 32, i32 13)
%40 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i32 %39)
%41 = tail call i32 @read_pin(i32 32, i32 14)
%42 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i32 %41)
%43 = tail call i32 @read_pin(i32 32, i32 15)
%44 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0), i32 %43)
%45 = tail call i32 @read_pin(i32 32, i32 16)
%46 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0), i32 %45)
%47 = tail call i32 @usleep(i32 200000)
br label %13
}