#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 *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int SettingCape(void) {
  FILE *io_fp;
  io_fp = fopen("/sys/devices/bone_capemgr.9/slots", "w");
  if (io_fp == NULL)
    printf("This cape cant enter");
  fseek(io_fp, 0, SEEK_SET);
  fprintf(io_fp, "%s", "cape-universalk");
  fflush(io_fp);
  fclose(io_fp);
  return 0;
}


x86 assembly (clang, -O0):
<SettingCape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe91(%rip),%rdi
lea    0xeac(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1196 <SettingCape+0x36>
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e3f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x8(%rbp),%rdi
lea    0xe84(%rip),%rsi
lea    0xe80(%rip),%rdx
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1060 <fflush@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SettingCape>:
push   %rbx
lea    0xe98(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1188 <SettingCape+0x28>
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <fseek@plt>
lea    0xe97(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <fflush@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"/sys/devices/bone_capemgr.9/slots\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [21 x i8] c"This cape cant enter\00"
@SEEK_SET = global i32 0
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [16 x i8] c"cape-universalk\00"
define i32 @SettingCape() {
%1 = alloca i32*
%2 = call i32* @fopen(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %2, i32** %1
%3 = load i32*, i32** %1
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = load i32*, i32** %1
%9 = load i32, i32* @SEEK_SET
%10 = call i32 @fseek(i32* %8, i32 0, i32 %9)
%11 = load i32*, i32** %1
%12 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%13 = load i32*, i32** %1
%14 = call i32 @fflush(i32* %13)
%15 = load i32*, i32** %1
%16 = call i32 @fclose(i32* %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"/sys/devices/bone_capemgr.9/slots\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [21 x i8] c"This cape cant enter\00"
@SEEK_SET = global i32 0
@.str.4 = [16 x i8] c"cape-universalk\00"
define i32 @SettingCape() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = load i32, i32* @SEEK_SET
%7 = tail call i32 @fseek(i32* %1, i32 0, i32 %6)
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i64 15, i64 1, i32* %1)
%9 = tail call i32 @fflush(i32* %1)
%10 = tail call i32 @fclose(i32* %1)
ret i32 0
}