#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *mntread(int /*<<< orphan*/ *);
scalar_t__ strcmp(char const *, char const *);
char *strtok(int /*<<< orphan*/ *, char *);
const char *mntpoint(const char *mount) {
  FILE *fp;
  const char *dev;
  const char *mntpt;
  fp = fopen("/etc/fstab", "r");
  if (fp) {
    while (dev = mntread(fp)) {
      mntpt = strtok(NULL, " \t");
      if (mntpt == NULL)
        continue;
      if (strcmp(mntpt, mount) == 0) {
        fclose(fp);
        return dev;
      }
    }
    fclose(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 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11f9 <mntpoint+0xa9>
jmp    1183 <mntpoint+0x33>
mov    -0x18(%rbp),%rdi
call   1040 <mntread@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11f0 <mntpoint+0xa0>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe68(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11be <mntpoint+0x6e>
jmp    1183 <mntpoint+0x33>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11eb <mntpoint+0x9b>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1201 <mntpoint+0xb1>
jmp    1183 <mntpoint+0x33>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@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   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe9e(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11cd <mntpoint+0x7d>
mov    %rax,%r15
mov    %rax,%rdi
call   1040 <mntread@plt>
test   %rax,%rax
je     11c1 <mntpoint+0x71>
mov    %rax,%rbx
lea    0xe80(%rip),%r12
jmp    11a0 <mntpoint+0x50>
nop
mov    %r15,%rdi
call   1040 <mntread@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11c1 <mntpoint+0x71>
xor    %edi,%edi
mov    %r12,%rsi
call   1070 <strtok@plt>
test   %rax,%rax
je     1190 <mntpoint+0x40>
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1190 <mntpoint+0x40>
jmp    11c3 <mntpoint+0x73>
xor    %ebx,%ebx
mov    %r15,%rdi
call   1030 <fclose@plt>
jmp    11cf <mntpoint+0x7f>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"/etc/fstab\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c" \09\00"
define i8* @mntpoint(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
%7 = call i32* @fopen(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 %33
10: ; preds = %1
br label %11
11: ; preds = %29, %19, %10
%12 = load i32*, i32** %4
%13 = call i8* @mntread(i32* %12)
store i8* %13, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %30
15: ; preds = %11
%16 = call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %20
19: ; preds = %15
br label %11
20: ; preds = %15
%21 = load i8*, i8** %6
%22 = load i8*, i8** %3
%23 = call i64 @strcmp(i8* %21, i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %20
%26 = load i32*, i32** %4
%27 = call i32 @fclose(i32* %26)
%28 = load i8*, i8** %5
store i8* %28, i8** %2
br label %34
29: ; preds = %20
br label %11
30: ; preds = %11
%31 = load i32*, i32** %4
%32 = call i32 @fclose(i32* %31)
br label %33
33: ; preds = %30, %1
store i8* null, i8** %2
br label %34
34: ; preds = %33, %25
%35 = load i8*, i8** %2
ret i8* %35
}

LLVM IR (-O2):
@.str = [11 x i8] c"/etc/fstab\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c" \09\00"
define i8* @mntpoint(i8* %0) {
%2 = tail call i32* @fopen(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 %20, label %4
4: ; preds = %1
%5 = tail call i8* @mntread(i32* %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %17, label %7
7: ; preds = %4, %11
%8 = phi i8* [ %12, %11 ], [ %5, %4 ]
%9 = tail call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %7, %14
%12 = tail call i8* @mntread(i32* %2)
%13 = icmp eq i8* %12, null
br i1 %13, label %17, label %7
14: ; preds = %7
%15 = tail call i64 @strcmp(i8* %9, i8* %0)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %11
17: ; preds = %11, %14, %4
%18 = phi i8* [ null, %4 ], [ %8, %14 ], [ null, %11 ]
%19 = tail call i32 @fclose(i32* %2)
br label %20
20: ; preds = %17, %1
%21 = phi i8* [ null, %1 ], [ %18, %17 ]
ret i8* %21
}