#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 mntent {
  int /*<<< orphan*/ mnt_dir;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ endmntent(int /*<<< orphan*/ *);
struct mntent *getmntent(int /*<<< orphan*/ *);
char *mnt_device_path(struct mntent *);
int /*<<< orphan*/ *setmntent(char *, char *);
scalar_t__ strcmp(int /*<<< orphan*/, char const *);
const char *mntpoint(const char *mount) {
  FILE *fp;
  struct mntent *mnt;
  const char *p;
  fp = setmntent("/etc/fstab", "r");
  if (fp) {
    while (mnt = getmntent(fp)) {
      p = mnt_device_path(mnt);
      if (strcmp(mnt->mnt_dir, mount) == 0) {
        endmntent(fp);
        return p;
      }
    }
    endmntent(fp);
  }
  return NULL;
}


x86 assembly (clang, -O0):
<mntpoint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe9d(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1060 <setmntent@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11e4 <mntpoint+0x94>
jmp    1183 <mntpoint+0x33>
mov    -0x18(%rbp),%rdi
call   1050 <getmntent@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11db <mntpoint+0x8b>
mov    -0x20(%rbp),%rdi
call   1070 <mnt_device_path@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11d6 <mntpoint+0x86>
mov    -0x18(%rbp),%rdi
call   1030 <endmntent@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ec <mntpoint+0x9c>
jmp    1183 <mntpoint+0x33>
mov    -0x18(%rbp),%rdi
call   1030 <endmntent@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mntpoint>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r15
lea    0xe9d(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1060 <setmntent@plt>
test   %rax,%rax
je     11b7 <mntpoint+0x67>
mov    %rax,%r12
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1050 <getmntent@plt>
test   %rax,%rax
je     11ad <mntpoint+0x5d>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <mnt_device_path@plt>
mov    %rax,%r13
mov    (%rbx),%edi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1180 <mntpoint+0x30>
mov    %r13,%r14
mov    %r12,%rdi
call   1030 <endmntent@plt>
jmp    11ba <mntpoint+0x6a>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.mntent = type { i32 }
@.str = [11 x i8] c"/etc/fstab\00"
@.str.1 = [2 x i8] c"r\00"
define i8* @mntpoint(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca %struct.mntent*
%6 = alloca i8*
store i8* %0, i8** %3
%7 = call i32* @setmntent(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %4
%8 = load i32*, i32** %4
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %32
10: ; preds = %1
br label %11
11: ; preds = %28, %10
%12 = load i32*, i32** %4
%13 = call %struct.mntent* @getmntent(i32* %12)
store %struct.mntent* %13, %struct.mntent** %5
%14 = icmp ne %struct.mntent* %13, null
br i1 %14, label %15, label %29
15: ; preds = %11
%16 = load %struct.mntent*, %struct.mntent** %5
%17 = call i8* @mnt_device_path(%struct.mntent* %16)
store i8* %17, i8** %6
%18 = load %struct.mntent*, %struct.mntent** %5
%19 = getelementptr inbounds %struct.mntent, %struct.mntent* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = load i8*, i8** %3
%22 = call i64 @strcmp(i32 %20, i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %15
%25 = load i32*, i32** %4
%26 = call i32 @endmntent(i32* %25)
%27 = load i8*, i8** %6
store i8* %27, i8** %2
br label %33
28: ; preds = %15
br label %11
29: ; preds = %11
%30 = load i32*, i32** %4
%31 = call i32 @endmntent(i32* %30)
br label %32
32: ; preds = %29, %1
store i8* null, i8** %2
br label %33
33: ; preds = %32, %24
%34 = load i8*, i8** %2
ret i8* %34
}

LLVM IR (-O2):
%struct.mntent = type { i32 }
@.str = [11 x i8] c"/etc/fstab\00"
@.str.1 = [2 x i8] c"r\00"
define i8* @mntpoint(i8* %0) {
%2 = tail call i32* @setmntent(i8* getelementptr inbounds ([11 x i8], [11 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 %16, label %4
4: ; preds = %1, %7
%5 = tail call %struct.mntent* @getmntent(i32* %2)
%6 = icmp eq %struct.mntent* %5, null
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = tail call i8* @mnt_device_path(%struct.mntent* %5)
%9 = getelementptr inbounds %struct.mntent, %struct.mntent* %5, i64 0, i32 0
%10 = load i32, i32* %9
%11 = tail call i64 @strcmp(i32 %10, i8* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %4
13: ; preds = %4, %7
%14 = phi i8* [ %8, %7 ], [ null, %4 ]
%15 = tail call i32 @endmntent(i32* %2)
br label %16
16: ; preds = %13, %1
%17 = phi i8* [ null, %1 ], [ %14, %13 ]
ret i8* %17
}