#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*/ gpio_close(int);
scalar_t__ gpio_open(int, int);
int gpio_write(int, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ sleep(int);
int main(void) {
  int error = 0;
  if (gpio_open(157, 1) < 0) {
    puts("Unable to open PIN file");
    return -1;
  }
  while (!error) {
    error = gpio_write(157, 1);
    sleep(1);
    error = gpio_write(157, 0);
    sleep(1);
  }
  gpio_close(157);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x9d,%edi
mov    $0x1,%esi
call   1060 <gpio_open@plt>
cmp    $0x0,%rax
jge    1197 <main+0x47>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fd <main+0xad>
jmp    119c <main+0x4c>
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b2 <main+0x62>
jmp    11ec <main+0x9c>
mov    $0x9d,%edi
mov    $0x1,%esi
call   1040 <gpio_write@plt>
mov    %eax,-0x8(%rbp)
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    $0x9d,%edi
xor    %esi,%esi
call   1040 <gpio_write@plt>
mov    %eax,-0x8(%rbp)
mov    $0x1,%edi
call   1070 <sleep@plt>
jmp    119c <main+0x4c>
mov    $0x9d,%edi
call   1050 <gpio_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x9d,%edi
mov    $0x1,%esi
call   1060 <gpio_open@plt>
test   %rax,%rax
js     11b3 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x9d,%edi
mov    $0x1,%esi
call   1040 <gpio_write@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    $0x9d,%edi
xor    %esi,%esi
call   1040 <gpio_write@plt>
mov    %eax,%ebx
mov    $0x1,%edi
call   1070 <sleep@plt>
test   %ebx,%ebx
je     1170 <main+0x20>
mov    $0x9d,%edi
call   1050 <gpio_close@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe46(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Unable to open PIN file\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = call i64 @gpio_open(i32 157, i32 1)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %19
7: ; preds = %0
br label %8
8: ; preds = %12, %7
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
%11 = xor i1 %10, true
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = call i32 @gpio_write(i32 157, i32 1)
store i32 %13, i32* %2
%14 = call i32 @sleep(i32 1)
%15 = call i32 @gpio_write(i32 157, i32 0)
store i32 %15, i32* %2
%16 = call i32 @sleep(i32 1)
br label %8
17: ; preds = %8
%18 = call i32 @gpio_close(i32 157)
store i32 0, i32* %1
br label %19
19: ; preds = %17, %5
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [24 x i8] c"Unable to open PIN file\00"
define i32 @main() {
%1 = tail call i64 @gpio_open(i32 157, i32 1)
%2 = icmp slt i64 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %13
5: ; preds = %0, %5
%6 = tail call i32 @gpio_write(i32 157, i32 1)
%7 = tail call i32 @sleep(i32 1)
%8 = tail call i32 @gpio_write(i32 157, i32 0)
%9 = tail call i32 @sleep(i32 1)
%10 = icmp eq i32 %8, 0
br i1 %10, label %5, label %11
11: ; preds = %5
%12 = tail call i32 @gpio_close(i32 157)
br label %13
13: ; preds = %11, %3
%14 = phi i32 [ -1, %3 ], [ 0, %11 ]
ret i32 %14
}