#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 */
typedef int uint8_t;

/* Variables and functions */
int gpio_direction(int, int);
int gpio_export(int);
int /*<<< orphan*/ write_byte_data(int, int, int);
int servopi_init(uint8_t address, uint8_t use_oe_pin) {
  write_byte_data(address, 0x00, 0x00);
  if (use_oe_pin == 1) {
    if (-1 == gpio_export(4))
      return (1);
    if (-1 == gpio_direction(4, 1))
      return (2);
  }
  return (0);
}


x86 assembly (clang, -O0):
<servopi_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <write_byte_data@plt>
cmpl   $0x1,-0xc(%rbp)
jne    11a8 <servopi_init+0x78>
mov    $0x4,%edi
call   1030 <gpio_export@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1179 <servopi_init+0x49>
movl   $0x1,-0x4(%rbp)
jmp    11af <servopi_init+0x7f>
mov    $0x4,%edi
mov    $0x1,%esi
call   1040 <gpio_direction@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    11a3 <servopi_init+0x73>
movl   $0x2,-0x4(%rbp)
jmp    11af <servopi_init+0x7f>
jmp    11a8 <servopi_init+0x78>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<servopi_init>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
xor    %ebx,%ebx
xor    %esi,%esi
xor    %edx,%edx
call   1050 <write_byte_data@plt>
cmp    $0x1,%ebp
jne    1174 <servopi_init+0x44>
mov    $0x4,%edi
call   1030 <gpio_export@plt>
cmp    $0xffffffff,%eax
je     116f <servopi_init+0x3f>
mov    $0x4,%edi
mov    $0x1,%esi
call   1040 <gpio_direction@plt>
cmp    $0xffffffff,%eax
jne    1174 <servopi_init+0x44>
mov    $0x2,%ebx
jmp    1174 <servopi_init+0x44>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @servopi_init(i32 %0, i32 %1) {
%3 = tail call i32 @write_byte_data(i32 %0, i32 0, i32 0)
%4 = icmp eq i32 %1, 1
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = tail call i32 @gpio_export(i32 4)
%7 = icmp eq i32 %6, -1
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = tail call i32 @gpio_direction(i32 4, i32 1)
%10 = icmp eq i32 %9, -1
br i1 %10, label %12, label %11
11: ; preds = %8, %2
br label %12
12: ; preds = %8, %5, %11
%13 = phi i32 [ 0, %11 ], [ 1, %5 ], [ 2, %8 ]
ret i32 %13
}