#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*/ GPIODirection(int, int);
int GPIOWrite(int, int);
int /*<<< orphan*/ sleep(int);
int valve_close() {
  GPIODirection(17, 1);
  GPIODirection(27, 1);
  GPIODirection(22, 1);
  if ((-1 == GPIOWrite(17, 0)) || (-1 == GPIOWrite(27, 0)))
    return (-1);
  if (-1 == GPIOWrite(27, 1))
    return (-1);
  sleep(8);
  if (-1 == GPIOWrite(27, 0))
    return (-1);
  GPIOWrite(22, 0);
  return 0;
}


x86 assembly (clang, -O0):
<valve_close>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x11,%edi
mov    $0x1,%esi
call   1030 <GPIODirection@plt>
mov    $0x1b,%edi
mov    $0x1,%esi
call   1030 <GPIODirection@plt>
mov    $0x16,%edi
mov    $0x1,%esi
call   1030 <GPIODirection@plt>
mov    $0x11,%edi
xor    %esi,%esi
call   1040 <GPIOWrite@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
je     119b <valve_close+0x6b>
mov    $0x1b,%edi
xor    %esi,%esi
call   1040 <GPIOWrite@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    11a7 <valve_close+0x77>
movl   $0xffffffff,-0x4(%rbp)
jmp    1215 <valve_close+0xe5>
mov    $0x1b,%edi
mov    $0x1,%esi
call   1040 <GPIOWrite@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    11d1 <valve_close+0xa1>
movl   $0xffffffff,-0x4(%rbp)
jmp    1215 <valve_close+0xe5>
mov    $0x8,%edi
call   1050 <sleep@plt>
mov    $0x1b,%edi
xor    %esi,%esi
call   1040 <GPIOWrite@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1202 <valve_close+0xd2>
movl   $0xffffffff,-0x4(%rbp)
jmp    1215 <valve_close+0xe5>
mov    $0x16,%edi
xor    %esi,%esi
call   1040 <GPIOWrite@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valve_close>:
push   %rbx
mov    $0x11,%edi
mov    $0x1,%esi
call   1030 <GPIODirection@plt>
mov    $0x1b,%edi
mov    $0x1,%esi
call   1030 <GPIODirection@plt>
mov    $0x16,%edi
mov    $0x1,%esi
call   1030 <GPIODirection@plt>
mov    $0x11,%edi
xor    %esi,%esi
call   1040 <GPIOWrite@plt>
mov    $0xffffffff,%ebx
cmp    $0xffffffff,%eax
je     11c2 <valve_close+0x92>
mov    $0x1b,%edi
xor    %esi,%esi
call   1040 <GPIOWrite@plt>
cmp    $0xffffffff,%eax
je     11c2 <valve_close+0x92>
mov    $0x1b,%edi
mov    $0x1,%esi
call   1040 <GPIOWrite@plt>
cmp    $0xffffffff,%eax
je     11c2 <valve_close+0x92>
mov    $0x8,%edi
call   1050 <sleep@plt>
mov    $0x1b,%edi
xor    %esi,%esi
call   1040 <GPIOWrite@plt>
cmp    $0xffffffff,%eax
je     11c2 <valve_close+0x92>
mov    $0x16,%edi
xor    %esi,%esi
call   1040 <GPIOWrite@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @valve_close() {
%1 = alloca i32
%2 = call i32 @GPIODirection(i32 17, i32 1)
%3 = call i32 @GPIODirection(i32 27, i32 1)
%4 = call i32 @GPIODirection(i32 22, i32 1)
%5 = call i32 @GPIOWrite(i32 17, i32 0)
%6 = icmp eq i32 -1, %5
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = call i32 @GPIOWrite(i32 27, i32 0)
%9 = icmp eq i32 -1, %8
br i1 %9, label %10, label %11
10: ; preds = %7, %0
store i32 -1, i32* %1
br label %22
11: ; preds = %7
%12 = call i32 @GPIOWrite(i32 27, i32 1)
%13 = icmp eq i32 -1, %12
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 -1, i32* %1
br label %22
15: ; preds = %11
%16 = call i32 @sleep(i32 8)
%17 = call i32 @GPIOWrite(i32 27, i32 0)
%18 = icmp eq i32 -1, %17
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 -1, i32* %1
br label %22
20: ; preds = %15
%21 = call i32 @GPIOWrite(i32 22, i32 0)
store i32 0, i32* %1
br label %22
22: ; preds = %20, %19, %14, %10
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
define i32 @valve_close() {
%1 = tail call i32 @GPIODirection(i32 17, i32 1)
%2 = tail call i32 @GPIODirection(i32 27, i32 1)
%3 = tail call i32 @GPIODirection(i32 22, i32 1)
%4 = tail call i32 @GPIOWrite(i32 17, i32 0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %18, label %6
6: ; preds = %0
%7 = tail call i32 @GPIOWrite(i32 27, i32 0)
%8 = icmp eq i32 %7, -1
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = tail call i32 @GPIOWrite(i32 27, i32 1)
%11 = icmp eq i32 %10, -1
br i1 %11, label %18, label %12
12: ; preds = %9
%13 = tail call i32 @sleep(i32 8)
%14 = tail call i32 @GPIOWrite(i32 27, i32 0)
%15 = icmp eq i32 %14, -1
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = tail call i32 @GPIOWrite(i32 22, i32 0)
br label %18
18: ; preds = %12, %9, %0, %6, %16
%19 = phi i32 [ 0, %16 ], [ -1, %6 ], [ -1, %0 ], [ -1, %9 ], [ -1, %12 ]
ret i32 %19
}