#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_port_pullups(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");
  for (int x = 0; x < 256; x++) {
    set_port_pullups(0x20, 0, x);
    set_port_pullups(0x20, 1, x);
  }
  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    0x2e7b(%rip),%rax
mov    (%rax),%edi
mov    0x2e82(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1050 <setvbuf@plt>
mov    $0x20,%edi
xor    %esi,%esi
call   1060 <IOPi_init@plt>
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    11ce <main+0x8e>
mov    -0x14(%rbp),%edx
mov    $0x20,%edi
xor    %esi,%esi
call   1030 <set_port_pullups@plt>
mov    -0x14(%rbp),%edx
mov    $0x20,%edi
mov    $0x1,%esi
call   1030 <set_port_pullups@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1192 <main+0x52>
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
mov    0x2e97(%rip),%rax
mov    (%rax),%edx
xor    %ebx,%ebx
xor    %esi,%esi
xor    %ecx,%ecx
call   1050 <setvbuf@plt>
mov    $0x20,%edi
xor    %esi,%esi
call   1060 <IOPi_init@plt>
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
mov    $0x20,%edi
xor    %esi,%esi
mov    %ebx,%edx
call   1040 <set_port_pullups@plt>
mov    $0x20,%edi
mov    $0x1,%esi
mov    %ebx,%edx
call   1040 <set_port_pullups@plt>
add    $0x1,%ebx
cmp    $0x100,%ebx
jne    1180 <main+0x40>
lea    0xe64(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
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))
store i32 0, i32* %6
br label %12
12: ; preds = %20, %2
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 256
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load i32, i32* %6
%17 = call i32 @set_port_pullups(i32 32, i32 0, i32 %16)
%18 = load i32, i32* %6
%19 = call i32 @set_port_pullups(i32 32, i32 1, i32 %18)
br label %20
20: ; preds = %15
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %12
23: ; preds = %12
%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))
br label %10
8: ; preds = %10
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.2, i64 0, i64 0))
ret i32 0
10: ; preds = %2, %10
%11 = phi i32 [ 0, %2 ], [ %14, %10 ]
%12 = tail call i32 @set_port_pullups(i32 32, i32 0, i32 %11)
%13 = tail call i32 @set_port_pullups(i32 32, i32 1, i32 %11)
%14 = add nuw nsw i32 %11, 1
%15 = icmp eq i32 %14, 256
br i1 %15, label %8, label %10
}