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

/* Variables and functions */
char *calloc(scalar_t__, int);
int errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
char *strchr(char *, char);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, scalar_t__);
scalar_t__ strstr(char *, char *);
char *mu_linux_debugfs_mount_point(int *const error) {
  if (error) {
    *error = 0;
  };
  FILE *fp;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  char *mount_point = NULL;
  char *tmp_line = NULL;
  fp = fopen("/proc/mounts", "r");
  if (!fp) {
    if (error) {
      *error = errno;
    };
    return NULL;
  }
  while ((read = getline(&line, &len, fp)) != -1) {
    *strchr(strchr(strchr(line, ' ') + 1, ' ') + 1, ' ') = '\0';
    if (strstr(strchr(strchr(line, ' ') + 1, ' '), "debugfs")) {
      tmp_line = strchr(line, ' ');
      if (!tmp_line) {
        if (error) {
          *error = errno;
        };
        free(line);
        fclose(fp);
        return NULL;
      }
      tmp_line = tmp_line + 1;
      *strchr(tmp_line, ' ') = '\0';

#pragma message "May return string with escaped unicode sequences."
      mount_point = calloc(strlen(tmp_line) + 1, sizeof(char));
      strncpy(mount_point, tmp_line, strlen(tmp_line));
      free(line);
      fclose(fp);
      return mount_point;
    }
  }
  free(line);
  fclose(fp);
  return NULL;
}


x86 assembly (clang, -O0):
<mu_linux_debugfs_mount_point>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b1 <mu_linux_debugfs_mount_point+0x21>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
lea    0xe28(%rip),%rdi
lea    0xe2e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    121a <mu_linux_debugfs_mount_point+0x8a>
cmpq   $0x0,-0x10(%rbp)
je     120d <mu_linux_debugfs_mount_point+0x7d>
mov    0x2ddb(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    139f <mu_linux_debugfs_mount_point+0x20f>
jmp    121f <mu_linux_debugfs_mount_point+0x8f>
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   10a0 <getline@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     1385 <mu_linux_debugfs_mount_point+0x1f5>
mov    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,%rdi
lea    0xd77(%rip),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     1380 <mu_linux_debugfs_mount_point+0x1f0>
mov    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    12fd <mu_linux_debugfs_mount_point+0x16d>
cmpq   $0x0,-0x10(%rbp)
je     12de <mu_linux_debugfs_mount_point+0x14e>
mov    0x2d0a(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movq   $0x0,-0x8(%rbp)
jmp    139f <mu_linux_debugfs_mount_point+0x20f>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    139f <mu_linux_debugfs_mount_point+0x20f>
jmp    121f <mu_linux_debugfs_mount_point+0x8f>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mu_linux_debugfs_mount_point>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
test   %rdi,%rdi
je     11ac <mu_linux_debugfs_mount_point+0x1c>
movl   $0x0,(%r14)
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xe3c(%rip),%rdi
lea    0xe42(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12cf <mu_linux_debugfs_mount_point+0x13f>
mov    %rax,%rbx
mov    %rsp,%r15
lea    0x8(%rsp),%r12
lea    0xe24(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   10a0 <getline@plt>
mov    (%rsp),%rdi
cmp    $0xffffffff,%eax
je     12f6 <mu_linux_debugfs_mount_point+0x166>
mov    $0x20,%esi
call   1070 <strchr@plt>
lea    0x1(%rax),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
lea    0x1(%rax),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
movb   $0x0,(%rax)
mov    (%rsp),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
lea    0x1(%rax),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,%rdi
mov    %r13,%rsi
call   10b0 <strstr@plt>
test   %rax,%rax
je     11f0 <mu_linux_debugfs_mount_point+0x60>
mov    (%rsp),%r12
mov    %r12,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     12e2 <mu_linux_debugfs_mount_point+0x152>
mov    %rax,%r15
add    $0x1,%r15
mov    %r15,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
movb   $0x0,(%rax)
mov    %r15,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
jmp    1306 <mu_linux_debugfs_mount_point+0x176>
test   %r14,%r14
je     1303 <mu_linux_debugfs_mount_point+0x173>
mov    0x2d05(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%r14)
jmp    1303 <mu_linux_debugfs_mount_point+0x173>
test   %r14,%r14
je     12f3 <mu_linux_debugfs_mount_point+0x163>
mov    0x2cf2(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%r14)
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/proc/mounts\00"
@.str.1 = [2 x i8] c"r\00"
@errno = global i32 0
@.str.2 = [8 x i8] c"debugfs\00"
define i8* @mu_linux_debugfs_mount_point(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i32* %0, i32** %3
%10 = load i32*, i32** %3
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = load i32*, i32** %3
store i32 0, i32* %13
br label %14
14: ; preds = %12, %1
store i8* null, i8** %5
store i64 0, i64* %6
store i8* null, i8** %8
store i8* null, i8** %9
%15 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %4
%16 = load i32*, i32** %4
%17 = icmp ne i32* %16, null
br i1 %17, label %25, label %18
18: ; preds = %14
%19 = load i32*, i32** %3
%20 = icmp ne i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* @errno
%23 = load i32*, i32** %3
store i32 %22, i32* %23
br label %24
24: ; preds = %21, %18
store i8* null, i8** %2
br label %84
25: ; preds = %14
br label %26
26: ; preds = %78, %25
%27 = load i32*, i32** %4
%28 = call i32 @getline(i8** %5, i64* %6, i32* %27)
store i32 %28, i32* %7
%29 = icmp ne i32 %28, -1
br i1 %29, label %30, label %79
30: ; preds = %26
%31 = load i8*, i8** %5
%32 = call i8* @strchr(i8* %31, i8 signext 32)
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = call i8* @strchr(i8* %33, i8 signext 32)
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = call i8* @strchr(i8* %35, i8 signext 32)
store i8 0, i8* %36
%37 = load i8*, i8** %5
%38 = call i8* @strchr(i8* %37, i8 signext 32)
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = call i8* @strchr(i8* %39, i8 signext 32)
%41 = call i64 @strstr(i8* %40, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %78
43: ; preds = %30
%44 = load i8*, i8** %5
%45 = call i8* @strchr(i8* %44, i8 signext 32)
store i8* %45, i8** %9
%46 = load i8*, i8** %9
%47 = icmp ne i8* %46, null
br i1 %47, label %59, label %48
48: ; preds = %43
%49 = load i32*, i32** %3
%50 = icmp ne i32* %49, null
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = load i32, i32* @errno
%53 = load i32*, i32** %3
store i32 %52, i32* %53
br label %54
54: ; preds = %51, %48
%55 = load i8*, i8** %5
%56 = call i32 @free(i8* %55)
%57 = load i32*, i32** %4
%58 = call i32 @fclose(i32* %57)
store i8* null, i8** %2
br label %84
59: ; preds = %43
%60 = load i8*, i8** %9
%61 = getelementptr inbounds i8, i8* %60, i64 1
store i8* %61, i8** %9
%62 = load i8*, i8** %9
%63 = call i8* @strchr(i8* %62, i8 signext 32)
store i8 0, i8* %63
%64 = load i8*, i8** %9
%65 = call i64 @strlen(i8* %64)
%66 = add nsw i64 %65, 1
%67 = call i8* @calloc(i64 %66, i32 1)
store i8* %67, i8** %8
%68 = load i8*, i8** %8
%69 = load i8*, i8** %9
%70 = load i8*, i8** %9
%71 = call i64 @strlen(i8* %70)
%72 = call i32 @strncpy(i8* %68, i8* %69, i64 %71)
%73 = load i8*, i8** %5
%74 = call i32 @free(i8* %73)
%75 = load i32*, i32** %4
%76 = call i32 @fclose(i32* %75)
%77 = load i8*, i8** %8
store i8* %77, i8** %2
br label %84
78: ; preds = %30
br label %26
79: ; preds = %26
%80 = load i8*, i8** %5
%81 = call i32 @free(i8* %80)
%82 = load i32*, i32** %4
%83 = call i32 @fclose(i32* %82)
store i8* null, i8** %2
br label %84
84: ; preds = %79, %59, %54, %24
%85 = load i8*, i8** %2
ret i8* %85
}

LLVM IR (-O2):
@.str = [13 x i8] c"/proc/mounts\00"
@.str.1 = [2 x i8] c"r\00"
@errno = global i32 0
@.str.2 = [8 x i8] c"debugfs\00"
define i8* @mu_linux_debugfs_mount_point(i32* writeonly %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = icmp eq i32* %0, null
br i1 %4, label %6, label %5
5: ; preds = %1
store i32 0, i32* %0
br label %6
6: ; preds = %5, %1
%7 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%8 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %6
br i1 %4, label %54, label %12
12: ; preds = %11
%13 = load i32, i32* @errno
store i32 %13, i32* %0
br label %54
14: ; preds = %6, %18
%15 = call i32 @getline(i8** %2, i64* %3, i32* %9)
%16 = icmp eq i32 %15, -1
%17 = load i8*, i8** %2
br i1 %16, label %51, label %18
18: ; preds = %14
%19 = call i8* @strchr(i8* dereferenceable(1) %17, i8 signext 32)
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = call i8* @strchr(i8* %20, i8 signext 32)
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = call i8* @strchr(i8* %22, i8 signext 32)
store i8 0, i8* %23
%24 = load i8*, i8** %2
%25 = call i8* @strchr(i8* dereferenceable(1) %24, i8 signext 32)
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = call i8* @strchr(i8* %26, i8 signext 32)
%28 = call i64 @strstr(i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %14, label %30
30: ; preds = %18
%31 = load i8*, i8** %2
%32 = call i8* @strchr(i8* dereferenceable(1) %31, i8 signext 32)
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %40
34: ; preds = %30
br i1 %4, label %37, label %35
35: ; preds = %34
%36 = load i32, i32* @errno
store i32 %36, i32* %0
br label %37
37: ; preds = %35, %34
%38 = call i32 @free(i8* %31)
%39 = call i32 @fclose(i32* %9)
br label %54
40: ; preds = %30
%41 = getelementptr inbounds i8, i8* %32, i64 1
%42 = call i8* @strchr(i8* %41, i8 signext 32)
store i8 0, i8* %42
%43 = call i64 @strlen(i8* %41)
%44 = add nsw i64 %43, 1
%45 = call i8* @calloc(i64 %44, i32 1)
%46 = call i64 @strlen(i8* %41)
%47 = call i32 @strncpy(i8* %45, i8* %41, i64 %46)
%48 = load i8*, i8** %2
%49 = call i32 @free(i8* %48)
%50 = call i32 @fclose(i32* %9)
br label %54
51: ; preds = %14
%52 = call i32 @free(i8* %17)
%53 = call i32 @fclose(i32* %9)
br label %54
54: ; preds = %11, %12, %51, %40, %37
%55 = phi i8* [ %45, %40 ], [ null, %37 ], [ null, %51 ], [ null, %12 ], [ null, %11 ]
ret i8* %55
}