#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*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
char *get_debugfileprefix();
int /*<<< orphan*/ info(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
scalar_t__ strlen(char *);
int system(char *);
int mount_debugfs(char *path) {
  char *mountpoint = path;
  char cmd[256];
  char *prefix;
  int ret;
  prefix = get_debugfileprefix();
  if (strlen(prefix) != 0) {
    info("debugfs mountpoint: %s\n", prefix);
    return 0;
  }
  if (!mountpoint)
    mountpoint = "/sys/kernel/debug";
  sprintf(cmd, "mount -t debugfs debugfs %s", mountpoint);
  ret = system(cmd);
  if (ret != 0) {
    fprintf(stderr, "Error mounting debugfs at %s: %s\n", mountpoint,
            strerror(errno));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<mount_debugfs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <get_debugfileprefix@plt>
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
je     11ca <mount_debugfs+0x5a>
mov    -0x128(%rbp),%rsi
lea    0xe47(%rip),%rdi
call   1090 <info@plt>
movl   $0x0,-0x4(%rbp)
jmp    126d <mount_debugfs+0xfd>
cmpq   $0x0,-0x18(%rbp)
jne    11e0 <mount_debugfs+0x70>
lea    0xe3c(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe38(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0x12c(%rbp)
cmpl   $0x0,-0x12c(%rbp)
je     1266 <mount_debugfs+0xf6>
mov    0x2dc3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x13c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x13c(%rbp),%edi
mov    -0x138(%rbp),%rdx
mov    %rax,%rcx
lea    0xdf1(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    126d <mount_debugfs+0xfd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mount_debugfs>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <get_debugfileprefix@plt>
cmpb   $0x0,(%rax)
je     118d <mount_debugfs+0x2d>
lea    0xe7d(%rip),%rdi
mov    %rax,%rsi
call   1080 <info@plt>
jmp    11ec <mount_debugfs+0x8c>
test   %rbx,%rbx
lea    0xe81(%rip),%r14
cmovne %rbx,%r14
lea    0xe88(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
test   %eax,%eax
je     11ec <mount_debugfs+0x8c>
mov    0x2e1d(%rip),%rax
mov    (%rax),%ebx
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe6c(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
call   1040 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"debugfs mountpoint: %s\0A\00"
@.str.1 = [18 x i8] c"/sys/kernel/debug\00"
@.str.2 = [28 x i8] c"mount -t debugfs debugfs %s\00"
@stderr = global i32 0
@.str.3 = [34 x i8] c"Error mounting debugfs at %s: %s\0A\00"
@errno = global i32 0
define i32 @mount_debugfs(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [256 x i8]
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i8*, i8** %3
store i8* %8, i8** %4
%9 = call i8* (...) @get_debugfileprefix()
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = call i64 @strlen(i8* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i8*, i8** %6
%15 = call i32 @info(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 0, i32* %2
br label %35
16: ; preds = %1
%17 = load i8*, i8** %4
%18 = icmp ne i8* %17, null
br i1 %18, label %20, label %19
19: ; preds = %16
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %20
20: ; preds = %19, %16
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%22 = load i8*, i8** %4
%23 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%25 = call i32 @system(i8* %24)
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %20
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %4
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %30, i8* %32)
store i32 -1, i32* %2
br label %35
34: ; preds = %20
store i32 0, i32* %2
br label %35
35: ; preds = %34, %28, %13
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
@.str = [24 x i8] c"debugfs mountpoint: %s\0A\00"
@.str.1 = [18 x i8] c"/sys/kernel/debug\00"
@.str.2 = [28 x i8] c"mount -t debugfs debugfs %s\00"
@stderr = global i32 0
@.str.3 = [34 x i8] c"Error mounting debugfs at %s: %s\0A\00"
@errno = global i32 0
define i32 @mount_debugfs(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = tail call i8* (...) @get_debugfileprefix()
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = tail call i32 @info(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %20
9: ; preds = %1
%10 = icmp eq i8* %0, null
%11 = select i1 %10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %0
%12 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = call i32 @system(i8* %3)
%14 = icmp eq i32 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %9
%16 = load i32, i32* @stderr
%17 = load i32, i32* @errno
%18 = tail call i8* @strerror(i32 %17)
%19 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %11, i8* %18)
br label %20
20: ; preds = %9, %15, %7
%21 = phi i32 [ 0, %7 ], [ -1, %15 ], [ 0, %9 ]
ret i32 %21
}