#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_export(int);
int /*<<< orphan*/ gpio_setDirection(int, int /*<<< orphan*/);
int /*<<< orphan*/ gpio_setValue(int, int);
int /*<<< orphan*/ printf(char *, ...);
int reset_gpio(int pin) {
  if (!gpio_export(pin)) {
    printf("ERROR: Exporting gpio port: %d\n", pin);
    return 0;
  }
  if (!gpio_export(66)) {
    printf("ERROR: Exporting gpio port: %d\n", 35);
    return 0;
  }
  if (!gpio_setDirection(66, 0)) {
    printf("ERROR: Set gpio port direction.\n");
    return 0;
  }
  if (!gpio_setValue(66, 0)) {
    printf("ERROR: Exporting gpio port.");
    return 0;
  }
  if (!gpio_setDirection(pin, 0)) {
    printf("ERROR: Set gpio port direction\n");
    return 0;
  }
  if (!gpio_setValue(pin, 0)) {
    printf("ERROR: Set gpio port state low\n");
    return 0;
  }
  if (!gpio_setValue(pin, 1)) {
    printf("ERROR: Set gpio port state high\n");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<reset_gpio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <gpio_export@plt>
cmp    $0x0,%eax
jne    1179 <reset_gpio+0x39>
mov    -0x8(%rbp),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129a <reset_gpio+0x15a>
mov    $0x42,%edi
call   1040 <gpio_export@plt>
cmp    $0x0,%eax
jne    11ab <reset_gpio+0x6b>
lea    0xe6d(%rip),%rdi
mov    $0x23,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129a <reset_gpio+0x15a>
mov    $0x42,%edi
xor    %esi,%esi
call   1060 <gpio_setDirection@plt>
cmp    $0x0,%eax
jne    11da <reset_gpio+0x9a>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129a <reset_gpio+0x15a>
mov    $0x42,%edi
xor    %esi,%esi
call   1050 <gpio_setValue@plt>
cmp    $0x0,%eax
jne    1209 <reset_gpio+0xc9>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129a <reset_gpio+0x15a>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1060 <gpio_setDirection@plt>
cmp    $0x0,%eax
jne    1236 <reset_gpio+0xf6>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129a <reset_gpio+0x15a>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1050 <gpio_setValue@plt>
cmp    $0x0,%eax
jne    1263 <reset_gpio+0x123>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129a <reset_gpio+0x15a>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1050 <gpio_setValue@plt>
cmp    $0x0,%eax
jne    1293 <reset_gpio+0x153>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129a <reset_gpio+0x15a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reset_gpio>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
call   1050 <gpio_export@plt>
test   %eax,%eax
je     11d7 <reset_gpio+0x87>
mov    $0x42,%edi
call   1050 <gpio_export@plt>
test   %eax,%eax
je     11e4 <reset_gpio+0x94>
xor    %ebx,%ebx
mov    $0x42,%edi
xor    %esi,%esi
call   1070 <gpio_setDirection@plt>
test   %eax,%eax
je     1202 <reset_gpio+0xb2>
xor    %ebx,%ebx
mov    $0x42,%edi
xor    %esi,%esi
call   1060 <gpio_setValue@plt>
test   %eax,%eax
je     1210 <reset_gpio+0xc0>
xor    %ebx,%ebx
mov    %ebp,%edi
xor    %esi,%esi
call   1070 <gpio_setDirection@plt>
test   %eax,%eax
je     1220 <reset_gpio+0xd0>
xor    %ebx,%ebx
mov    %ebp,%edi
xor    %esi,%esi
call   1060 <gpio_setValue@plt>
test   %eax,%eax
je     122e <reset_gpio+0xde>
mov    $0x1,%ebx
mov    %ebp,%edi
mov    $0x1,%esi
call   1060 <gpio_setValue@plt>
test   %eax,%eax
jne    11f9 <reset_gpio+0xa9>
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    11f9 <reset_gpio+0xa9>
lea    0xe22(%rip),%rdi
xor    %ebx,%ebx
mov    %ebp,%esi
jmp    11f2 <reset_gpio+0xa2>
lea    0xe15(%rip),%rdi
xor    %ebx,%ebx
mov    $0x23,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe33(%rip),%rdi
call   1030 <puts@plt>
jmp    11f9 <reset_gpio+0xa9>
lea    0xe09(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11f9 <reset_gpio+0xa9>
lea    0xe35(%rip),%rdi
call   1030 <puts@plt>
jmp    11f9 <reset_gpio+0xa9>
lea    0xe46(%rip),%rdi
call   1030 <puts@plt>
jmp    11f9 <reset_gpio+0xa9>

LLVM IR (-O0):
@.str = [32 x i8] c"ERROR: Exporting gpio port: %d\0A\00"
@.str.1 = [33 x i8] c"ERROR: Set gpio port direction.\0A\00"
@.str.2 = [28 x i8] c"ERROR: Exporting gpio port.\00"
@.str.3 = [32 x i8] c"ERROR: Set gpio port direction\0A\00"
@.str.4 = [32 x i8] c"ERROR: Set gpio port state low\0A\00"
@.str.5 = [33 x i8] c"ERROR: Set gpio port state high\0A\00"
define i32 @reset_gpio(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = call i32 @gpio_export(i32 %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %8)
store i32 0, i32* %2
br label %44
10: ; preds = %1
%11 = call i32 @gpio_export(i32 66)
%12 = icmp ne i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 35)
store i32 0, i32* %2
br label %44
15: ; preds = %10
%16 = call i32 @gpio_setDirection(i32 66, i32 0)
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %44
20: ; preds = %15
%21 = call i32 @gpio_setValue(i32 66, i32 0)
%22 = icmp ne i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %44
25: ; preds = %20
%26 = load i32, i32* %3
%27 = call i32 @gpio_setDirection(i32 %26, i32 0)
%28 = icmp ne i32 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %44
31: ; preds = %25
%32 = load i32, i32* %3
%33 = call i32 @gpio_setValue(i32 %32, i32 0)
%34 = icmp ne i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %2
br label %44
37: ; preds = %31
%38 = load i32, i32* %3
%39 = call i32 @gpio_setValue(i32 %38, i32 1)
%40 = icmp ne i32 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %37
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %2
br label %44
43: ; preds = %37
store i32 1, i32* %2
br label %44
44: ; preds = %43, %41, %35, %29, %23, %18, %13, %7
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
@.str = [32 x i8] c"ERROR: Exporting gpio port: %d\0A\00"
@.str.2 = [28 x i8] c"ERROR: Exporting gpio port.\00"
@str = [32 x i8] c"ERROR: Set gpio port direction.\00"
@str.6 = [31 x i8] c"ERROR: Set gpio port direction\00"
@str.7 = [31 x i8] c"ERROR: Set gpio port state low\00"
@str.8 = [32 x i8] c"ERROR: Set gpio port state high\00"
define i32 @reset_gpio(i32 %0) {
%2 = tail call i32 @gpio_export(i32 %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %36
6: ; preds = %1
%7 = tail call i32 @gpio_export(i32 66)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 35)
br label %36
11: ; preds = %6
%12 = tail call i32 @gpio_setDirection(i32 66, i32 0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %36
16: ; preds = %11
%17 = tail call i32 @gpio_setValue(i32 66, i32 0)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %36
21: ; preds = %16
%22 = tail call i32 @gpio_setDirection(i32 %0, i32 0)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.6, i64 0, i64 0))
br label %36
26: ; preds = %21
%27 = tail call i32 @gpio_setValue(i32 %0, i32 0)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.7, i64 0, i64 0))
br label %36
31: ; preds = %26
%32 = tail call i32 @gpio_setValue(i32 %0, i32 1)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.8, i64 0, i64 0))
br label %36
36: ; preds = %31, %34, %29, %24, %19, %14, %9, %4
%37 = phi i32 [ 0, %34 ], [ 0, %29 ], [ 0, %24 ], [ 0, %19 ], [ 0, %14 ], [ 0, %9 ], [ 0, %4 ], [ 1, %31 ]
ret i32 %37
}