#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 GPIORead(int);
int /*<<< orphan*/ GPIOUnexport(int);
int /*<<< orphan*/ GPIOWrite(int, int);
int /*<<< orphan*/ GPIOdirection(int, int);
int /*<<< orphan*/ GPIOexport(int);
int main(void) {
  GPIOexport(14);
  GPIOexport(15);
  GPIOexport(18);
  GPIOexport(23);
  GPIOexport(25);
  GPIOdirection(14, 0);
  GPIOdirection(15, 0);
  GPIOdirection(18, 0);
  GPIOdirection(23, 0);
  GPIOdirection(25, 1);
  int decimal = 0, binario[4], resto = 0;
  while (1) {
    for (int cont = 0; cont < 4; cont++)
      binario[cont] = 0;
    int cont = 0;
    while (decimal != 0) {
      resto = decimal % 2;
      binario[cont] = resto == 0 ? 0 : 1;
      decimal = decimal / 2;
      cont++;
    }
    if (GPIORead(25) == 1) {
      GPIOWrite(14, binario[0]);
      GPIOWrite(15, binario[1]);
      GPIOWrite(18, binario[2]);
      GPIOWrite(23, binario[3]);
      decimal++;
    }
  }
  GPIOUnexport(14);
  GPIOUnexport(15);
  GPIOUnexport(18);
  GPIOUnexport(23);
  GPIOUnexport(25);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xe,%edi
call   1030 <GPIOexport@plt>
mov    $0xf,%edi
call   1030 <GPIOexport@plt>
mov    $0x12,%edi
call   1030 <GPIOexport@plt>
mov    $0x17,%edi
call   1030 <GPIOexport@plt>
mov    $0x19,%edi
call   1030 <GPIOexport@plt>
mov    $0xe,%edi
xor    %esi,%esi
call   1060 <GPIOdirection@plt>
mov    $0xf,%edi
xor    %esi,%esi
call   1060 <GPIOdirection@plt>
mov    $0x12,%edi
xor    %esi,%esi
call   1060 <GPIOdirection@plt>
mov    $0x17,%edi
xor    %esi,%esi
call   1060 <GPIOdirection@plt>
mov    $0x19,%edi
mov    $0x1,%esi
call   1060 <GPIOdirection@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    11f9 <main+0xb9>
movslq -0x28(%rbp),%rax
movl   $0x0,-0x20(%rbp,%rax,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11d5 <main+0x95>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     124c <main+0x10c>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    -0x24(%rbp),%edx
mov    $0x1,%ecx
xor    %eax,%eax
cmp    $0x0,%edx
cmove  %eax,%ecx
movslq -0x2c(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1200 <main+0xc0>
mov    $0x19,%edi
call   1050 <GPIORead@plt>
cmp    $0x1,%eax
jne    129c <main+0x15c>
mov    -0x20(%rbp),%esi
mov    $0xe,%edi
call   1040 <GPIOWrite@plt>
mov    -0x1c(%rbp),%esi
mov    $0xf,%edi
call   1040 <GPIOWrite@plt>
mov    -0x18(%rbp),%esi
mov    $0x12,%edi
call   1040 <GPIOWrite@plt>
mov    -0x14(%rbp),%esi
mov    $0x17,%edi
call   1040 <GPIOWrite@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ce <main+0x8e>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0xe,%edi
call   1030 <GPIOexport@plt>
mov    $0xf,%edi
call   1030 <GPIOexport@plt>
mov    $0x12,%edi
call   1030 <GPIOexport@plt>
mov    $0x17,%edi
call   1030 <GPIOexport@plt>
mov    $0x19,%edi
call   1030 <GPIOexport@plt>
xor    %ebp,%ebp
mov    $0xe,%edi
xor    %esi,%esi
call   1060 <GPIOdirection@plt>
mov    $0xf,%edi
xor    %esi,%esi
call   1060 <GPIOdirection@plt>
mov    $0x12,%edi
xor    %esi,%esi
call   1060 <GPIOdirection@plt>
mov    $0x17,%edi
xor    %esi,%esi
call   1060 <GPIOdirection@plt>
mov    $0x19,%edi
mov    $0x1,%esi
call   1060 <GPIOdirection@plt>
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%ebx
mov    $0x19,%edi
call   1050 <GPIORead@plt>
mov    $0x0,%ebp
cmp    $0x1,%eax
jne    11c0 <main+0x80>
mov    $0xe,%edi
mov    %ebx,%esi
call   1040 <GPIOWrite@plt>
mov    $0xf,%edi
xor    %esi,%esi
call   1040 <GPIOWrite@plt>
mov    $0x12,%edi
xor    %esi,%esi
call   1040 <GPIOWrite@plt>
mov    $0x17,%edi
xor    %esi,%esi
call   1040 <GPIOWrite@plt>
mov    $0x1,%ebp
jmp    11c0 <main+0x80>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [4 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @GPIOexport(i32 14)
%8 = call i32 @GPIOexport(i32 15)
%9 = call i32 @GPIOexport(i32 18)
%10 = call i32 @GPIOexport(i32 23)
%11 = call i32 @GPIOexport(i32 25)
%12 = call i32 @GPIOdirection(i32 14, i32 0)
%13 = call i32 @GPIOdirection(i32 15, i32 0)
%14 = call i32 @GPIOdirection(i32 18, i32 0)
%15 = call i32 @GPIOdirection(i32 23, i32 0)
%16 = call i32 @GPIOdirection(i32 25, i32 1)
store i32 0, i32* %2
store i32 0, i32* %4
br label %17
17: ; preds = %0, %64
store i32 0, i32* %5
br label %18
18: ; preds = %25, %17
%19 = load i32, i32* %5
%20 = icmp slt i32 %19, 4
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %23
store i32 0, i32* %24
br label %25
25: ; preds = %21
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %18
28: ; preds = %18
store i32 0, i32* %6
br label %29
29: ; preds = %32, %28
%30 = load i32, i32* %2
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %46
32: ; preds = %29
%33 = load i32, i32* %2
%34 = srem i32 %33, 2
store i32 %34, i32* %4
%35 = load i32, i32* %4
%36 = icmp eq i32 %35, 0
%37 = zext i1 %36 to i64
%38 = select i1 %36, i32 0, i32 1
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %40
store i32 %38, i32* %41
%42 = load i32, i32* %2
%43 = sdiv i32 %42, 2
store i32 %43, i32* %2
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %29
46: ; preds = %29
%47 = call i32 @GPIORead(i32 25)
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %64
49: ; preds = %46
%50 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%51 = load i32, i32* %50
%52 = call i32 @GPIOWrite(i32 14, i32 %51)
%53 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
%54 = load i32, i32* %53
%55 = call i32 @GPIOWrite(i32 15, i32 %54)
%56 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
%57 = load i32, i32* %56
%58 = call i32 @GPIOWrite(i32 18, i32 %57)
%59 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
%60 = load i32, i32* %59
%61 = call i32 @GPIOWrite(i32 23, i32 %60)
%62 = load i32, i32* %2
%63 = add nsw i32 %62, 1
store i32 %63, i32* %2
br label %64
64: ; preds = %49, %46
br label %17
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @GPIOexport(i32 14)
%2 = tail call i32 @GPIOexport(i32 15)
%3 = tail call i32 @GPIOexport(i32 18)
%4 = tail call i32 @GPIOexport(i32 23)
%5 = tail call i32 @GPIOexport(i32 25)
%6 = tail call i32 @GPIOdirection(i32 14, i32 0)
%7 = tail call i32 @GPIOdirection(i32 15, i32 0)
%8 = tail call i32 @GPIOdirection(i32 18, i32 0)
%9 = tail call i32 @GPIOdirection(i32 23, i32 0)
%10 = tail call i32 @GPIOdirection(i32 25, i32 1)
br label %11
11: ; preds = %20, %0
%12 = phi i32 [ 0, %0 ], [ %21, %20 ]
%13 = tail call i32 @GPIORead(i32 25)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = tail call i32 @GPIOWrite(i32 14, i32 %12)
%17 = tail call i32 @GPIOWrite(i32 15, i32 0)
%18 = tail call i32 @GPIOWrite(i32 18, i32 0)
%19 = tail call i32 @GPIOWrite(i32 23, i32 0)
br label %20
20: ; preds = %15, %11
%21 = phi i32 [ 0, %11 ], [ 1, %15 ]
br label %11
}