#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int ClosePWMPin(int GPIO_num) {
  FILE *PWM_unexport;
  PWM_unexport = fopen("/sys/class/pwm/unexport", "w");
  if (PWM_unexport == NULL)
    printf("PWM Failed to initialize_ClosePWMPin\n");
  fseek(PWM_unexport, 0, SEEK_SET);
  fprintf(PWM_unexport, "%d", GPIO_num);
  fflush(PWM_unexport);
  fclose(PWM_unexport);
  return 0;
}


x86 assembly (clang, -O0):
<ClosePWMPin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe8e(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1199 <ClosePWMPin+0x39>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    0x2e3c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe85(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <fflush@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ClosePWMPin>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0xe94(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    118c <ClosePWMPin+0x2c>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <fseek@plt>
lea    0xe74(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1060 <fflush@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"/sys/class/pwm/unexport\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [38 x i8] c"PWM Failed to initialize_ClosePWMPin\0A\00"
@SEEK_SET = global i32 0
@.str.3 = [3 x i8] c"%d\00"
define i32 @ClosePWMPin(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
store i32 %0, i32* %2
%4 = call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %3
%5 = load i32*, i32** %3
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %1
%10 = load i32*, i32** %3
%11 = load i32, i32* @SEEK_SET
%12 = call i32 @fseek(i32* %10, i32 0, i32 %11)
%13 = load i32*, i32** %3
%14 = load i32, i32* %2
%15 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = load i32*, i32** %3
%17 = call i32 @fflush(i32* %16)
%18 = load i32*, i32** %3
%19 = call i32 @fclose(i32* %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"/sys/class/pwm/unexport\00"
@.str.1 = [2 x i8] c"w\00"
@SEEK_SET = global i32 0
@.str.3 = [3 x i8] c"%d\00"
@str = [37 x i8] c"PWM Failed to initialize_ClosePWMPin\00"
define i32 @ClosePWMPin(i32 %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = load i32, i32* @SEEK_SET
%8 = tail call i32 @fseek(i32* %2, i32 0, i32 %7)
%9 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %0)
%10 = tail call i32 @fflush(i32* %2)
%11 = tail call i32 @fclose(i32* %2)
ret i32 0
}