#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 {
  char *mnt_opts;
  void *mnt_passno;
  void *mnt_freq;
  void *mnt_type;
  void *mnt_fsname;
  void *mnt_dir;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
void *atoi(char *);
char *fgets(char *, int, int /*<<< orphan*/ *);
void *strtok_r(char *, char const *, char **);
struct mntent *getmntent_r(FILE *fp, struct mntent *mntbuf, char *buf,
                           int buflen) {
  char *line = NULL, *saveptr = NULL;
  const char *sep = " \t\n";
  if (!fp || !mntbuf || !buf)
    return NULL;
  while ((line = fgets(buf, buflen, fp)) != NULL) {
    if (buf[0] == '#' || buf[0] == '\n')
      continue;
    break;
  }
  if (!line)
    return NULL;
  mntbuf->mnt_fsname = strtok_r(buf, sep, &saveptr);
  if (!mntbuf->mnt_fsname)
    return NULL;
  mntbuf->mnt_dir = strtok_r(NULL, sep, &saveptr);
  if (!mntbuf->mnt_fsname)
    return NULL;
  mntbuf->mnt_type = strtok_r(NULL, sep, &saveptr);
  if (!mntbuf->mnt_type)
    return NULL;
  mntbuf->mnt_opts = strtok_r(NULL, sep, &saveptr);
  if (!mntbuf->mnt_opts)
    mntbuf->mnt_opts = "";
  line = strtok_r(NULL, sep, &saveptr);
  mntbuf->mnt_freq = !line ? 0 : atoi(line);
  line = strtok_r(NULL, sep, &saveptr);
  mntbuf->mnt_passno = !line ? 0 : atoi(line);
  return mntbuf;
}


x86 assembly (clang, -O0):
<getmntent_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
lea    0xea2(%rip),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1183 <getmntent_r+0x53>
cmpq   $0x0,-0x18(%rbp)
je     1183 <getmntent_r+0x53>
cmpq   $0x0,-0x20(%rbp)
jne    1190 <getmntent_r+0x60>
movq   $0x0,-0x8(%rbp)
jmp    1364 <getmntent_r+0x234>
jmp    1195 <getmntent_r+0x65>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1040 <fgets@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     11dd <getmntent_r+0xad>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     11d3 <getmntent_r+0xa3>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11d8 <getmntent_r+0xa8>
jmp    1195 <getmntent_r+0x65>
jmp    11dd <getmntent_r+0xad>
cmpq   $0x0,-0x30(%rbp)
jne    11f5 <getmntent_r+0xc5>
movq   $0x0,-0x8(%rbp)
jmp    1364 <getmntent_r+0x234>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x20(%rax)
jne    122d <getmntent_r+0xfd>
movq   $0x0,-0x8(%rbp)
jmp    1364 <getmntent_r+0x234>
mov    -0x40(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x38(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x28(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x20(%rax)
jne    1265 <getmntent_r+0x135>
movq   $0x0,-0x8(%rbp)
jmp    1364 <getmntent_r+0x234>
mov    -0x40(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x38(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x18(%rax)
jne    129d <getmntent_r+0x16d>
movq   $0x0,-0x8(%rbp)
jmp    1364 <getmntent_r+0x234>
mov    -0x40(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x38(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    12d4 <getmntent_r+0x1a4>
mov    -0x18(%rbp),%rax
lea    0xd32(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x38(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12ff <getmntent_r+0x1cf>
xor    %eax,%eax
mov    %rax,-0x48(%rbp)
jmp    130c <getmntent_r+0x1dc>
mov    -0x30(%rbp),%rdi
call   1050 <atoi@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x40(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x38(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1343 <getmntent_r+0x213>
xor    %eax,%eax
mov    %rax,-0x50(%rbp)
jmp    1350 <getmntent_r+0x220>
mov    -0x30(%rbp),%rdi
call   1050 <atoi@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getmntent_r>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
xor    %r15d,%r15d
test   %rdi,%rdi
je     1295 <getmntent_r+0x165>
mov    %rsi,%r14
test   %rsi,%rsi
je     1295 <getmntent_r+0x165>
mov    %rdx,%rbx
test   %rdx,%rdx
je     1295 <getmntent_r+0x165>
mov    %ecx,%r12d
mov    %rdi,%rbp
mov    %rbx,%rdi
mov    %ecx,%esi
mov    %rbp,%rdx
call   1040 <fgets@plt>
xor    %r15d,%r15d
jmp    119e <getmntent_r+0x6e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %rbp,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1295 <getmntent_r+0x165>
movzbl (%rbx),%eax
cmp    $0x23,%al
je     1190 <getmntent_r+0x60>
cmp    $0xa,%al
je     1190 <getmntent_r+0x60>
lea    0xe47(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1030 <strtok_r@plt>
mov    %rax,0x20(%r14)
test   %rax,%rax
je     1292 <getmntent_r+0x162>
lea    0xe26(%rip),%rsi
xor    %r15d,%r15d
lea    0x8(%rsp),%rdx
xor    %edi,%edi
call   1030 <strtok_r@plt>
mov    %rax,0x28(%r14)
cmpq   $0x0,0x20(%r14)
je     1295 <getmntent_r+0x165>
lea    0xe01(%rip),%rsi
xor    %r15d,%r15d
lea    0x8(%rsp),%rdx
xor    %edi,%edi
call   1030 <strtok_r@plt>
mov    %rax,0x18(%r14)
test   %rax,%rax
je     1295 <getmntent_r+0x165>
lea    0xde2(%rip),%r15
xor    %ebx,%ebx
lea    0x8(%rsp),%rbp
xor    %edi,%edi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1030 <strtok_r@plt>
test   %rax,%rax
lea    0xdc7(%rip),%rcx
cmovne %rax,%rcx
mov    %rcx,(%r14)
xor    %edi,%edi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1030 <strtok_r@plt>
test   %rax,%rax
je     1260 <getmntent_r+0x130>
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    %rax,%rbx
mov    %rbx,0x10(%r14)
lea    0xd95(%rip),%rsi
xor    %ebx,%ebx
lea    0x8(%rsp),%rdx
xor    %edi,%edi
call   1030 <strtok_r@plt>
test   %rax,%rax
je     1289 <getmntent_r+0x159>
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    %rax,%rbx
mov    %rbx,0x8(%r14)
mov    %r14,%r15
jmp    1295 <getmntent_r+0x165>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mntent = type { i8*, i8*, i8*, i8*, i8*, i8* }
@.str = [4 x i8] c" \09\0A\00"
@.str.1 = [1 x i8] zeroinitializer
define %struct.mntent* @getmntent_r(i32* %0, %struct.mntent* %1, i8* %2, i32 %3) {
%5 = alloca %struct.mntent*
%6 = alloca i32*
%7 = alloca %struct.mntent*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i32* %0, i32** %6
store %struct.mntent* %1, %struct.mntent** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i8* null, i8** %10
store i8* null, i8** %11
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %12
%13 = load i32*, i32** %6
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %21
15: ; preds = %4
%16 = load %struct.mntent*, %struct.mntent** %7
%17 = icmp ne %struct.mntent* %16, null
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i8*, i8** %8
%20 = icmp ne i8* %19, null
br i1 %20, label %22, label %21
21: ; preds = %18, %15, %4
store %struct.mntent* null, %struct.mntent** %5
br label %116
22: ; preds = %18
br label %23
23: ; preds = %41, %22
%24 = load i8*, i8** %8
%25 = load i32, i32* %9
%26 = load i32*, i32** %6
%27 = call i8* @fgets(i8* %24, i32 %25, i32* %26)
store i8* %27, i8** %10
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %43
29: ; preds = %23
%30 = load i8*, i8** %8
%31 = getelementptr inbounds i8, i8* %30, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 35
br i1 %34, label %41, label %35
35: ; preds = %29
%36 = load i8*, i8** %8
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 10
br i1 %40, label %41, label %42
41: ; preds = %35, %29
br label %23
42: ; preds = %35
br label %43
43: ; preds = %42, %23
%44 = load i8*, i8** %10
%45 = icmp ne i8* %44, null
br i1 %45, label %47, label %46
46: ; preds = %43
store %struct.mntent* null, %struct.mntent** %5
br label %116
47: ; preds = %43
%48 = load i8*, i8** %8
%49 = load i8*, i8** %12
%50 = call i8* @strtok_r(i8* %48, i8* %49, i8** %11)
%51 = load %struct.mntent*, %struct.mntent** %7
%52 = getelementptr inbounds %struct.mntent, %struct.mntent* %51, i32 0, i32 4
store i8* %50, i8** %52
%53 = load %struct.mntent*, %struct.mntent** %7
%54 = getelementptr inbounds %struct.mntent, %struct.mntent* %53, i32 0, i32 4
%55 = load i8*, i8** %54
%56 = icmp ne i8* %55, null
br i1 %56, label %58, label %57
57: ; preds = %47
store %struct.mntent* null, %struct.mntent** %5
br label %116
58: ; preds = %47
%59 = load i8*, i8** %12
%60 = call i8* @strtok_r(i8* null, i8* %59, i8** %11)
%61 = load %struct.mntent*, %struct.mntent** %7
%62 = getelementptr inbounds %struct.mntent, %struct.mntent* %61, i32 0, i32 5
store i8* %60, i8** %62
%63 = load %struct.mntent*, %struct.mntent** %7
%64 = getelementptr inbounds %struct.mntent, %struct.mntent* %63, i32 0, i32 4
%65 = load i8*, i8** %64
%66 = icmp ne i8* %65, null
br i1 %66, label %68, label %67
67: ; preds = %58
store %struct.mntent* null, %struct.mntent** %5
br label %116
68: ; preds = %58
%69 = load i8*, i8** %12
%70 = call i8* @strtok_r(i8* null, i8* %69, i8** %11)
%71 = load %struct.mntent*, %struct.mntent** %7
%72 = getelementptr inbounds %struct.mntent, %struct.mntent* %71, i32 0, i32 3
store i8* %70, i8** %72
%73 = load %struct.mntent*, %struct.mntent** %7
%74 = getelementptr inbounds %struct.mntent, %struct.mntent* %73, i32 0, i32 3
%75 = load i8*, i8** %74
%76 = icmp ne i8* %75, null
br i1 %76, label %78, label %77
77: ; preds = %68
store %struct.mntent* null, %struct.mntent** %5
br label %116
78: ; preds = %68
%79 = load i8*, i8** %12
%80 = call i8* @strtok_r(i8* null, i8* %79, i8** %11)
%81 = load %struct.mntent*, %struct.mntent** %7
%82 = getelementptr inbounds %struct.mntent, %struct.mntent* %81, i32 0, i32 0
store i8* %80, i8** %82
%83 = load %struct.mntent*, %struct.mntent** %7
%84 = getelementptr inbounds %struct.mntent, %struct.mntent* %83, i32 0, i32 0
%85 = load i8*, i8** %84
%86 = icmp ne i8* %85, null
br i1 %86, label %90, label %87
87: ; preds = %78
%88 = load %struct.mntent*, %struct.mntent** %7
%89 = getelementptr inbounds %struct.mntent, %struct.mntent* %88, i32 0, i32 0
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %89
br label %90
90: ; preds = %87, %78
%91 = load i8*, i8** %12
%92 = call i8* @strtok_r(i8* null, i8* %91, i8** %11)
store i8* %92, i8** %10
%93 = load i8*, i8** %10
%94 = icmp ne i8* %93, null
br i1 %94, label %96, label %95
95: ; preds = %90
br label %99
96: ; preds = %90
%97 = load i8*, i8** %10
%98 = call i8* @atoi(i8* %97)
br label %99
99: ; preds = %96, %95
%100 = phi i8* [ null, %95 ], [ %98, %96 ]
%101 = load %struct.mntent*, %struct.mntent** %7
%102 = getelementptr inbounds %struct.mntent, %struct.mntent* %101, i32 0, i32 2
store i8* %100, i8** %102
%103 = load i8*, i8** %12
%104 = call i8* @strtok_r(i8* null, i8* %103, i8** %11)
store i8* %104, i8** %10
%105 = load i8*, i8** %10
%106 = icmp ne i8* %105, null
br i1 %106, label %108, label %107
107: ; preds = %99
br label %111
108: ; preds = %99
%109 = load i8*, i8** %10
%110 = call i8* @atoi(i8* %109)
br label %111
111: ; preds = %108, %107
%112 = phi i8* [ null, %107 ], [ %110, %108 ]
%113 = load %struct.mntent*, %struct.mntent** %7
%114 = getelementptr inbounds %struct.mntent, %struct.mntent* %113, i32 0, i32 1
store i8* %112, i8** %114
%115 = load %struct.mntent*, %struct.mntent** %7
store %struct.mntent* %115, %struct.mntent** %5
br label %116
116: ; preds = %111, %77, %67, %57, %46, %21
%117 = load %struct.mntent*, %struct.mntent** %5
ret %struct.mntent* %117
}

LLVM IR (-O2):
%struct.mntent = type { i8*, i8*, i8*, i8*, i8*, i8* }
@.str = [4 x i8] c" \09\0A\00"
@.str.1 = [1 x i8] zeroinitializer
define %struct.mntent* @getmntent_r(i32* %0, %struct.mntent* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%7 = icmp ne i32* %0, null
%8 = icmp ne %struct.mntent* %1, null
%9 = and i1 %7, %8
%10 = icmp ne i8* %2, null
%11 = and i1 %9, %10
br i1 %11, label %12, label %52
12: ; preds = %4
%13 = tail call i8* @fgets(i8* %2, i32 %3, i32* %0)
%14 = icmp eq i8* %13, null
br i1 %14, label %52, label %15
15: ; preds = %12, %17
%16 = load i8, i8* %2
switch i8 %16, label %20 [
i8 35, label %17
i8 10, label %17
]
17: ; preds = %15, %15
%18 = tail call i8* @fgets(i8* %2, i32 %3, i32* %0)
%19 = icmp eq i8* %18, null
br i1 %19, label %52, label %15
20: ; preds = %15
%21 = call i8* @strtok_r(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %5)
%22 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 4
store i8* %21, i8** %22
%23 = icmp eq i8* %21, null
br i1 %23, label %52, label %24
24: ; preds = %20
%25 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %5)
%26 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 5
store i8* %25, i8** %26
%27 = load i8*, i8** %22
%28 = icmp eq i8* %27, null
br i1 %28, label %52, label %29
29: ; preds = %24
%30 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %5)
%31 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 3
store i8* %30, i8** %31
%32 = icmp eq i8* %30, null
br i1 %32, label %52, label %33
33: ; preds = %29
%34 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %5)
%35 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 0
%36 = icmp eq i8* %34, null
%37 = select i1 %36, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* %34
store i8* %37, i8** %35
%38 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %5)
%39 = icmp eq i8* %38, null
br i1 %39, label %42, label %40
40: ; preds = %33
%41 = call i8* @atoi(i8* %38)
br label %42
42: ; preds = %33, %40
%43 = phi i8* [ %41, %40 ], [ null, %33 ]
%44 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 2
store i8* %43, i8** %44
%45 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %5)
%46 = icmp eq i8* %45, null
br i1 %46, label %49, label %47
47: ; preds = %42
%48 = call i8* @atoi(i8* %45)
br label %49
49: ; preds = %42, %47
%50 = phi i8* [ %48, %47 ], [ null, %42 ]
%51 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 1
store i8* %50, i8** %51
br label %52
52: ; preds = %17, %12, %29, %24, %20, %4, %49
%53 = phi %struct.mntent* [ %1, %49 ], [ null, %4 ], [ null, %20 ], [ null, %24 ], [ null, %29 ], [ null, %12 ], [ null, %17 ]
ret %struct.mntent* %53
}