#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*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ write_bus(int, int);
int /*<<< orphan*/ write_pin(int, int, int);
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);
  write_bus(0x20, 0x0000);
  for (int x = 1; x < 17; x++) {
    write_pin(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    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    0x2e62(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1070 <setvbuf@plt>
mov    $0x20,%edi
xor    %esi,%esi
call   1080 <IOPi_init@plt>
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x20,%edi
xor    %esi,%esi
call   1060 <set_bus_direction@plt>
mov    $0x20,%edi
xor    %esi,%esi
call   1040 <write_bus@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0x11,-0x14(%rbp)
jge    11f4 <main+0x94>
mov    -0x14(%rbp),%esi
mov    $0x20,%edi
mov    $0x1,%edx
call   1050 <write_pin@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ca <main+0x6a>
lea    0xe1b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@stdout = global i32 0
@_IONBF = global i32 0
@.str = [22 x i8] c"Logic output Started\0A\00"
@.str.1 = [20 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 ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @set_bus_direction(i32 32, i32 0)
%13 = call i32 @write_bus(i32 32, i32 0)
store i32 1, i32* %6
br label %14
14: ; preds = %20, %2
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 17
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = load i32, i32* %6
%19 = call i32 @write_pin(i32 32, i32 %18, i32 1)
br label %20
20: ; preds = %17
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %14
23: ; preds = %14
%24 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* %4
%26 = load i8**, i8*** %5
ret i32 0
}

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