#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 */
scalar_t__ pwm_enable_pin(char const *);
scalar_t__ pwm_get_key(char const *, char **);
int /*<<< orphan*/ pwm_set_period(char *, int);
int /*<<< orphan*/ pwm_set_polarity(char *, int /*<<< orphan*/);
int pwm_export(const char *pin, char **pwm_key) {
  if (pwm_enable_pin(pin) < 0)
    return -1;
  if (pwm_get_key(pin, pwm_key) < 0)
    return -1;
  pwm_set_polarity(*pwm_key, 0);
  pwm_set_period(*pwm_key, 500000);
  return 0;
}


x86 assembly (clang, -O0):
<pwm_export>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <pwm_enable_pin@plt>
cmp    $0x0,%rax
jge    116f <pwm_export+0x2f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b8 <pwm_export+0x78>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <pwm_get_key@plt>
cmp    $0x0,%rax
jge    1192 <pwm_export+0x52>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b8 <pwm_export+0x78>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
xor    %esi,%esi
call   1050 <pwm_set_polarity@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    $0x7a120,%esi
call   1060 <pwm_set_period@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pwm_export>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1030 <pwm_enable_pin@plt>
mov    $0xffffffff,%r14d
test   %rax,%rax
js     1184 <pwm_export+0x44>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <pwm_get_key@plt>
test   %rax,%rax
js     1184 <pwm_export+0x44>
mov    (%rbx),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
call   1050 <pwm_set_polarity@plt>
mov    (%rbx),%rdi
mov    $0x7a120,%esi
call   1060 <pwm_set_period@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @pwm_export(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
store i8* %0, i8** %4
store i8** %1, i8*** %5
%6 = load i8*, i8** %4
%7 = call i64 @pwm_enable_pin(i8* %6)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 -1, i32* %3
br label %23
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = load i8**, i8*** %5
%13 = call i64 @pwm_get_key(i8* %11, i8** %12)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10
store i32 -1, i32* %3
br label %23
16: ; preds = %10
%17 = load i8**, i8*** %5
%18 = load i8*, i8** %17
%19 = call i32 @pwm_set_polarity(i8* %18, i32 0)
%20 = load i8**, i8*** %5
%21 = load i8*, i8** %20
%22 = call i32 @pwm_set_period(i8* %21, i32 500000)
store i32 0, i32* %3
br label %23
23: ; preds = %16, %15, %9
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
define i32 @pwm_export(i8* %0, i8** %1) {
%3 = tail call i64 @pwm_enable_pin(i8* %0)
%4 = icmp slt i64 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = tail call i64 @pwm_get_key(i8* %0, i8** %1)
%7 = icmp slt i64 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = load i8*, i8** %1
%10 = tail call i32 @pwm_set_polarity(i8* %9, i32 0)
%11 = load i8*, i8** %1
%12 = tail call i32 @pwm_set_period(i8* %11, i32 500000)
br label %13
13: ; preds = %5, %2, %8
%14 = phi i32 [ 0, %8 ], [ -1, %2 ], [ -1, %5 ]
ret i32 %14
}