#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 /*<<< orphan*/);
int /*<<< orphan*/ _IONBF;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ set_bus_direction(int, int);
int /*<<< orphan*/ set_pin_direction(int, int, int);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  setvbuf(stdout, NULL, _IONBF, 0);
  IOPi_init(0x20, 0);
  printf("Logic output Started \n");
  set_bus_direction(0x20, 0x0000);
  for (int x = 1; x < 17; x++) {
    set_pin_direction(0x20, x, 1);
  }
  printf("Logic output Ended \n");
  (void)argc;
  (void)argv;
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
mov    0x2e72(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1060 <setvbuf@plt>
mov    $0x20,%edi
xor    %esi,%esi
call   1070 <IOPi_init@plt>
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x20,%edi
xor    %esi,%esi
call   1050 <set_bus_direction@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0x11,-0x14(%rbp)
jge    11d8 <main+0x88>
mov    -0x14(%rbp),%esi
mov    $0x20,%edi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ae <main+0x5e>
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
mov    0x2e87(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1060 <setvbuf@plt>
mov    $0x20,%edi
xor    %esi,%esi
call   1070 <IOPi_init@plt>
lea    0xe81(%rip),%rdi
call   1040 <puts@plt>
mov    $0x20,%edi
xor    %esi,%esi
call   1050 <set_bus_direction@plt>
mov    $0x20,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    $0x20,%edi
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    $0x20,%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    $0x20,%edi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    $0x20,%edi
mov    $0x5,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    $0x20,%edi
mov    $0x6,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    $0x20,%edi
mov    $0x7,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    $0x20,%edi
mov    $0x8,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    $0x20,%edi
mov    $0x9,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    $0x20,%edi
mov    $0xa,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    $0x20,%edi
mov    $0xb,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    $0x20,%edi
mov    $0xc,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    $0x20,%edi
mov    $0xd,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    $0x20,%edi
mov    $0xe,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    $0x20,%edi
mov    $0xf,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
mov    $0x20,%edi
mov    $0x10,%esi
mov    $0x1,%edx
call   1030 <set_pin_direction@plt>
lea    0xd3f(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stdout = global i32 0
@_IONBF = global i32 0
@.str = [23 x i8] c"Logic output Started \0A\00"
@.str.1 = [21 x i8] c"Logic output Ended \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @stdout
%8 = load i32, i32* @_IONBF
%9 = call i32 @setvbuf(i32 %7, i32* null, i32 %8, i32 0)
%10 = call i32 @IOPi_init(i32 32, i32 0)
%11 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @set_bus_direction(i32 32, i32 0)
store i32 1, i32* %6
br label %13
13: ; preds = %19, %2
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 17
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i32, i32* %6
%18 = call i32 @set_pin_direction(i32 32, i32 %17, i32 1)
br label %19
19: ; preds = %16
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %13
22: ; preds = %13
%23 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* %4
%25 = load i8**, i8*** %5
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@_IONBF = global i32 0
@str = [22 x i8] c"Logic output Started \00"
@str.2 = [20 x i8] c"Logic output Ended \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 0)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @set_bus_direction(i32 32, i32 0)
%9 = tail call i32 @set_pin_direction(i32 32, i32 1, i32 1)
%10 = tail call i32 @set_pin_direction(i32 32, i32 2, i32 1)
%11 = tail call i32 @set_pin_direction(i32 32, i32 3, i32 1)
%12 = tail call i32 @set_pin_direction(i32 32, i32 4, i32 1)
%13 = tail call i32 @set_pin_direction(i32 32, i32 5, i32 1)
%14 = tail call i32 @set_pin_direction(i32 32, i32 6, i32 1)
%15 = tail call i32 @set_pin_direction(i32 32, i32 7, i32 1)
%16 = tail call i32 @set_pin_direction(i32 32, i32 8, i32 1)
%17 = tail call i32 @set_pin_direction(i32 32, i32 9, i32 1)
%18 = tail call i32 @set_pin_direction(i32 32, i32 10, i32 1)
%19 = tail call i32 @set_pin_direction(i32 32, i32 11, i32 1)
%20 = tail call i32 @set_pin_direction(i32 32, i32 12, i32 1)
%21 = tail call i32 @set_pin_direction(i32 32, i32 13, i32 1)
%22 = tail call i32 @set_pin_direction(i32 32, i32 14, i32 1)
%23 = tail call i32 @set_pin_direction(i32 32, i32 15, i32 1)
%24 = tail call i32 @set_pin_direction(i32 32, i32 16, i32 1)
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.2, i64 0, i64 0))
ret i32 0
}