#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*/ printf(char *);
int /*<<< orphan*/ write_attr_file(char *, int);
int libid2_power(int on_off) {
  if (1 == on_off) {
    write_attr_file("/sys/class/gpio/gpio45/value", 1);
  } else if (0 == on_off) {
    write_attr_file("/sys/class/gpio/gpio45/value", 0);
  } else {
    printf("int parm is err\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<libid2_power>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jne    114f <libid2_power+0x2f>
lea    0xec0(%rip),%rdi
mov    $0x1,%esi
call   1040 <write_attr_file@plt>
jmp    118a <libid2_power+0x6a>
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jne    116d <libid2_power+0x4d>
lea    0xe9f(%rip),%rdi
xor    %esi,%esi
call   1040 <write_attr_file@plt>
jmp    1185 <libid2_power+0x65>
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1191 <libid2_power+0x71>
jmp    118a <libid2_power+0x6a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libid2_power>:
push   %rbx
test   %edi,%edi
je     113f <libid2_power+0x1f>
cmp    $0x1,%edi
jne    1151 <libid2_power+0x31>
lea    0xecf(%rip),%rdi
mov    $0x1,%esi
call   1040 <write_attr_file@plt>
xor    %ebx,%ebx
jmp    1162 <libid2_power+0x42>
lea    0xeba(%rip),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1040 <write_attr_file@plt>
jmp    1162 <libid2_power+0x42>
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"/sys/class/gpio/gpio45/value\00"
@.str.1 = [17 x i8] c"int parm is err\0A\00"
define i32 @libid2_power(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 1, %4
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @write_attr_file(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 1)
br label %16
8: ; preds = %1
%9 = load i32, i32* %3
%10 = icmp eq i32 0, %9
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @write_attr_file(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 0)
br label %15
13: ; preds = %8
%14 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %17
15: ; preds = %11
br label %16
16: ; preds = %15, %6
store i32 0, i32* %2
br label %17
17: ; preds = %16, %13
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@.str = [29 x i8] c"/sys/class/gpio/gpio45/value\00"
@str = [16 x i8] c"int parm is err\00"
define i32 @libid2_power(i32 %0) {
switch i32 %0, label %6 [
i32 1, label %2
i32 0, label %4
]
2: ; preds = %1
%3 = tail call i32 @write_attr_file(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 1)
br label %8
4: ; preds = %1
%5 = tail call i32 @write_attr_file(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 0)
br label %8
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %2, %4, %6
%9 = phi i32 [ -1, %6 ], [ 0, %4 ], [ 0, %2 ]
ret i32 %9
}