#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 */
scalar_t__ GPIO_Init();
int Read_IO(int);
int /*<<< orphan*/ Set_Dir(int /*<<< orphan*/, char *);
int /*<<< orphan*/ Set_IO(int /*<<< orphan*/);
int /*<<< orphan*/ Set_Pol(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int main() {
  int value = 0;
  if (GPIO_Init()) {
    printf("GPIO_Init failed\n");
    return -1;
  }
  Set_Dir(0, "O");
  Set_Pol(0, 1);
  while (1) {
    Set_IO(0);
    sleep(1);
    value = Read_IO(26);
    printf("Status: %d\n", value);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <GPIO_Init@plt>
cmp    $0x0,%rax
je     11b0 <main+0x40>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbp
ret
xor    %edi,%edi
lea    0xe59(%rip),%rsi
call   1060 <Set_Dir@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1070 <Set_Pol@plt>
xor    %edi,%edi
call   1080 <Set_IO@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    $0x1a,%edi
call   1040 <Read_IO@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11ca <main+0x5a>

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <GPIO_Init@plt>
test   %rax,%rax
je     11a0 <main+0x20>
lea    0xe7a(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
lea    0xe59(%rip),%rsi
xor    %edi,%edi
call   1070 <Set_Dir@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1080 <Set_Pol@plt>
lea    0xe41(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1090 <Set_IO@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    $0x1a,%edi
call   1050 <Read_IO@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11d0 <main+0x50>

LLVM IR (-O0):
@.str = [18 x i8] c"GPIO_Init failed\0A\00"
@.str.1 = [2 x i8] c"O\00"
@.str.2 = [12 x i8] c"Status: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = call i64 (...) @GPIO_Init()
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
ret i32 -1
7: ; preds = %0
%8 = call i32 @Set_Dir(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @Set_Pol(i32 0, i32 1)
br label %10
10: ; preds = %7, %10
%11 = call i32 @Set_IO(i32 0)
%12 = call i32 @sleep(i32 1)
%13 = call i32 @Read_IO(i32 26)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %10
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"O\00"
@.str.2 = [12 x i8] c"Status: %d\0A\00"
@str = [17 x i8] c"GPIO_Init failed\00"
define i32 @main() {
%1 = tail call i64 (...) @GPIO_Init()
%2 = icmp eq i64 %1, 0
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
ret i32 -1
5: ; preds = %0
%6 = tail call i32 @Set_Dir(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @Set_Pol(i32 0, i32 1)
br label %8
8: ; preds = %8, %5
%9 = tail call i32 @Set_IO(i32 0)
%10 = tail call i32 @sleep(i32 1)
%11 = tail call i32 @Read_IO(i32 26)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %8
}