#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ die(char *);
int mount(char *, char *, char *, int /*<<< orphan*/, int /*<<< orphan*/ *);
int stat(char *, struct stat *);
int mount_debugfs(void) {
  struct stat st;
  int ret;
  ret = stat("/sys/kernel/debug", &st);
  if (ret < 0)
    die("debugfs is not configured on this kernel");
  ret = mount("nodev", "/sys/kernel/debug", "debugfs", 0, NULL);
  return ret;
}


x86 assembly (clang, -O0):
<mount_debugfs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <stat@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1161 <mount_debugfs+0x31>
lea    0xeb6(%rip),%rdi
call   1050 <die@plt>
lea    0xed3(%rip),%rdi
lea    0xe91(%rip),%rsi
lea    0xecb(%rip),%rdx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <mount@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mount_debugfs>:
push   %rax
lea    0xec8(%rip),%rdi
mov    %rsp,%rsi
call   1040 <stat@plt>
test   %eax,%eax
jns    1150 <mount_debugfs+0x20>
lea    0xec7(%rip),%rdi
call   1050 <die@plt>
lea    0xee4(%rip),%rdi
lea    0xea2(%rip),%rsi
lea    0xedc(%rip),%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
pop    %rax
jmp    1030 <mount@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [18 x i8] c"/sys/kernel/debug\00"
@.str.1 = [41 x i8] c"debugfs is not configured on this kernel\00"
@.str.2 = [6 x i8] c"nodev\00"
@.str.3 = [8 x i8] c"debugfs\00"
define i32 @mount_debugfs() {
%1 = alloca %struct.stat
%2 = alloca i32
%3 = call i32 @stat(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @die(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
%9 = call i32 @mount(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 0, i32* null)
store i32 %9, i32* %2
%10 = load i32, i32* %2
ret i32 %10
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [18 x i8] c"/sys/kernel/debug\00"
@.str.1 = [41 x i8] c"debugfs is not configured on this kernel\00"
@.str.2 = [6 x i8] c"nodev\00"
@.str.3 = [8 x i8] c"debugfs\00"
define i32 @mount_debugfs() {
%1 = alloca %struct.stat
%2 = bitcast %struct.stat* %1 to i8*
%3 = call i32 @stat(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @die(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = tail call i32 @mount(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 0, i32* null)
ret i32 %8
}