#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*/ O_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ write(int, char const *, int /*<<< orphan*/);
int pwm_enable() {
  int fd;
  if ((fd = open("/sys/devices/bone_capemgr.8/slots", O_WRONLY)) < 0)
    return -1;
  const char *am33xx_pwm = "am33xx_pwm";
  write(fd, am33xx_pwm, strlen(am33xx_pwm));
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<pwm_enable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
lea    0xea8(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    1175 <pwm_enable+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b4 <pwm_enable+0x74>
lea    0xea6(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pwm_enable>:
push   %r14
push   %rbx
push   %rax
mov    0x2e8d(%rip),%rax
mov    (%rax),%esi
lea    0xeac(%rip),%rdi
call   1060 <open@plt>
test   %eax,%eax
js     1185 <pwm_enable+0x45>
mov    %eax,%ebx
lea    0xebc(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
jmp    118a <pwm_enable+0x4a>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [34 x i8] c"/sys/devices/bone_capemgr.8/slots\00"
@O_WRONLY = global i32 0
@.str.1 = [11 x i8] c"am33xx_pwm\00"
define i32 @pwm_enable() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = load i32, i32* @O_WRONLY
%5 = call i32 @open(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 %5, i32* %2
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %0
store i32 -1, i32* %1
br label %16
8: ; preds = %0
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %3
%9 = load i32, i32* %2
%10 = load i8*, i8** %3
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = call i32 @write(i32 %9, i8* %10, i32 %12)
%14 = load i32, i32* %2
%15 = call i32 @close(i32 %14)
store i32 0, i32* %1
br label %16
16: ; preds = %8, %7
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str = [34 x i8] c"/sys/devices/bone_capemgr.8/slots\00"
@O_WRONLY = global i32 0
@.str.1 = [11 x i8] c"am33xx_pwm\00"
define i32 @pwm_enable() {
%1 = load i32, i32* @O_WRONLY
%2 = tail call i32 @open(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp slt i32 %2, 0
br i1 %3, label %8, label %4
4: ; preds = %0
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i32 @close(i32 %2)
br label %8
8: ; preds = %0, %4
%9 = phi i32 [ 0, %4 ], [ -1, %0 ]
ret i32 %9
}