#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;
  int /*<<< orphan*/ *mnt_type;
  int /*<<< orphan*/ *mnt_dir;
  int /*<<< orphan*/ *mnt_fsname;
};
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 *filep, struct mntent *mnt, char *buff,
                           int bufsize) {
  char *cp, *ptrptr;
  const char *sep = " \t\n";
  if (!filep || !mnt || !buff)
    return NULL;
  while ((cp = fgets(buff, bufsize, filep)) != NULL) {
    if (buff[0] == '#' || buff[0] == '\n')
      continue;
    break;
  }
  if (cp == NULL)
    return NULL;
  ptrptr = 0;
  mnt->mnt_fsname = strtok_r(buff, sep, &ptrptr);
  if (mnt->mnt_fsname == NULL)
    return NULL;
  mnt->mnt_dir = strtok_r(NULL, sep, &ptrptr);
  if (mnt->mnt_dir == NULL)
    return NULL;
  mnt->mnt_type = strtok_r(NULL, sep, &ptrptr);
  if (mnt->mnt_type == NULL)
    return NULL;
  mnt->mnt_opts = strtok_r(NULL, sep, &ptrptr);
  if (mnt->mnt_opts == NULL)
    mnt->mnt_opts = "";
  cp = strtok_r(NULL, sep, &ptrptr);
  mnt->mnt_freq = (cp != NULL) ? atoi(cp) : 0;
  cp = strtok_r(NULL, sep, &ptrptr);
  mnt->mnt_passno = (cp != NULL) ? atoi(cp) : 0;
  return mnt;
}


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)
lea    0xeb2(%rip),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1173 <getmntent_r+0x43>
cmpq   $0x0,-0x18(%rbp)
je     1173 <getmntent_r+0x43>
cmpq   $0x0,-0x20(%rbp)
jne    1180 <getmntent_r+0x50>
movq   $0x0,-0x8(%rbp)
jmp    1366 <getmntent_r+0x236>
jmp    1185 <getmntent_r+0x55>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1040 <fgets@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     11cd <getmntent_r+0x9d>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     11c3 <getmntent_r+0x93>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11c8 <getmntent_r+0x98>
jmp    1185 <getmntent_r+0x55>
jmp    11cd <getmntent_r+0x9d>
cmpq   $0x0,-0x30(%rbp)
jne    11e5 <getmntent_r+0xb5>
movq   $0x0,-0x8(%rbp)
jmp    1366 <getmntent_r+0x236>
movq   $0x0,-0x38(%rbp)
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,0x28(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x28(%rax)
jne    1225 <getmntent_r+0xf5>
movq   $0x0,-0x8(%rbp)
jmp    1366 <getmntent_r+0x236>
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,0x20(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x20(%rax)
jne    125d <getmntent_r+0x12d>
movq   $0x0,-0x8(%rbp)
jmp    1366 <getmntent_r+0x236>
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    1295 <getmntent_r+0x165>
movq   $0x0,-0x8(%rbp)
jmp    1366 <getmntent_r+0x236>
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    12cc <getmntent_r+0x19c>
mov    -0x18(%rbp),%rax
lea    0xd3a(%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)
je     12fe <getmntent_r+0x1ce>
mov    -0x30(%rbp),%rdi
call   1050 <atoi@plt>
mov    %rax,-0x48(%rbp)
jmp    1309 <getmntent_r+0x1d9>
xor    %eax,%eax
mov    %rax,-0x48(%rbp)
jmp    1309 <getmntent_r+0x1d9>
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)
je     1347 <getmntent_r+0x217>
mov    -0x30(%rbp),%rdi
call   1050 <atoi@plt>
mov    %rax,-0x50(%rbp)
jmp    1352 <getmntent_r+0x222>
xor    %eax,%eax
mov    %rax,-0x50(%rbp)
jmp    1352 <getmntent_r+0x222>
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
xor    %r15d,%r15d
test   %rdi,%rdi
je     128c <getmntent_r+0x15c>
mov    %rsi,%r14
test   %rsi,%rsi
je     128c <getmntent_r+0x15c>
mov    %rdx,%rbx
test   %rdx,%rdx
je     128c <getmntent_r+0x15c>
mov    %ecx,%r12d
mov    %rdi,%rbp
mov    %rbx,%rdi
mov    %ecx,%esi
mov    %rbp,%rdx
call   1040 <fgets@plt>
xor    %r15d,%r15d
jmp    118e <getmntent_r+0x5e>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %rbp,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     128c <getmntent_r+0x15c>
movzbl (%rbx),%eax
cmp    $0x23,%al
je     1180 <getmntent_r+0x50>
cmp    $0xa,%al
je     1180 <getmntent_r+0x50>
movq   $0x0,0x8(%rsp)
lea    0xe4e(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1030 <strtok_r@plt>
mov    %rax,0x28(%r14)
test   %rax,%rax
je     1289 <getmntent_r+0x159>
lea    0xe2d(%rip),%rsi
xor    %r15d,%r15d
lea    0x8(%rsp),%rdx
xor    %edi,%edi
call   1030 <strtok_r@plt>
mov    %rax,0x20(%r14)
test   %rax,%rax
je     128c <getmntent_r+0x15c>
lea    0xe0a(%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     128c <getmntent_r+0x15c>
lea    0xdeb(%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    0xdd0(%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     1257 <getmntent_r+0x127>
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    %rax,%rbx
mov    %rbx,0x10(%r14)
lea    0xd9e(%rip),%rsi
xor    %ebx,%ebx
lea    0x8(%rsp),%rdx
xor    %edi,%edi
call   1030 <strtok_r@plt>
test   %rax,%rax
je     1280 <getmntent_r+0x150>
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    %rax,%rbx
mov    %rbx,0x8(%r14)
mov    %r14,%r15
jmp    128c <getmntent_r+0x15c>
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*, i32*, i32*, i32* }
@.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* 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 %119
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 eq i8* %44, null
br i1 %45, label %46, label %47
46: ; preds = %43
store %struct.mntent* null, %struct.mntent** %5
br label %119
47: ; preds = %43
store i8* null, i8** %11
%48 = load i8*, i8** %8
%49 = load i8*, i8** %12
%50 = call i8* @strtok_r(i8* %48, i8* %49, i8** %11)
%51 = bitcast i8* %50 to i32*
%52 = load %struct.mntent*, %struct.mntent** %7
%53 = getelementptr inbounds %struct.mntent, %struct.mntent* %52, i32 0, i32 5
store i32* %51, i32** %53
%54 = load %struct.mntent*, %struct.mntent** %7
%55 = getelementptr inbounds %struct.mntent, %struct.mntent* %54, i32 0, i32 5
%56 = load i32*, i32** %55
%57 = icmp eq i32* %56, null
br i1 %57, label %58, label %59
58: ; preds = %47
store %struct.mntent* null, %struct.mntent** %5
br label %119
59: ; preds = %47
%60 = load i8*, i8** %12
%61 = call i8* @strtok_r(i8* null, i8* %60, i8** %11)
%62 = bitcast i8* %61 to i32*
%63 = load %struct.mntent*, %struct.mntent** %7
%64 = getelementptr inbounds %struct.mntent, %struct.mntent* %63, i32 0, i32 4
store i32* %62, i32** %64
%65 = load %struct.mntent*, %struct.mntent** %7
%66 = getelementptr inbounds %struct.mntent, %struct.mntent* %65, i32 0, i32 4
%67 = load i32*, i32** %66
%68 = icmp eq i32* %67, null
br i1 %68, label %69, label %70
69: ; preds = %59
store %struct.mntent* null, %struct.mntent** %5
br label %119
70: ; preds = %59
%71 = load i8*, i8** %12
%72 = call i8* @strtok_r(i8* null, i8* %71, i8** %11)
%73 = bitcast i8* %72 to i32*
%74 = load %struct.mntent*, %struct.mntent** %7
%75 = getelementptr inbounds %struct.mntent, %struct.mntent* %74, i32 0, i32 3
store i32* %73, i32** %75
%76 = load %struct.mntent*, %struct.mntent** %7
%77 = getelementptr inbounds %struct.mntent, %struct.mntent* %76, i32 0, i32 3
%78 = load i32*, i32** %77
%79 = icmp eq i32* %78, null
br i1 %79, label %80, label %81
80: ; preds = %70
store %struct.mntent* null, %struct.mntent** %5
br label %119
81: ; preds = %70
%82 = load i8*, i8** %12
%83 = call i8* @strtok_r(i8* null, i8* %82, i8** %11)
%84 = load %struct.mntent*, %struct.mntent** %7
%85 = getelementptr inbounds %struct.mntent, %struct.mntent* %84, i32 0, i32 0
store i8* %83, i8** %85
%86 = load %struct.mntent*, %struct.mntent** %7
%87 = getelementptr inbounds %struct.mntent, %struct.mntent* %86, i32 0, i32 0
%88 = load i8*, i8** %87
%89 = icmp eq i8* %88, null
br i1 %89, label %90, label %93
90: ; preds = %81
%91 = load %struct.mntent*, %struct.mntent** %7
%92 = getelementptr inbounds %struct.mntent, %struct.mntent* %91, i32 0, i32 0
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %92
br label %93
93: ; preds = %90, %81
%94 = load i8*, i8** %12
%95 = call i8* @strtok_r(i8* null, i8* %94, i8** %11)
store i8* %95, i8** %10
%96 = load i8*, i8** %10
%97 = icmp ne i8* %96, null
br i1 %97, label %98, label %101
98: ; preds = %93
%99 = load i8*, i8** %10
%100 = call i8* @atoi(i8* %99)
br label %102
101: ; preds = %93
br label %102
102: ; preds = %101, %98
%103 = phi i8* [ %100, %98 ], [ null, %101 ]
%104 = load %struct.mntent*, %struct.mntent** %7
%105 = getelementptr inbounds %struct.mntent, %struct.mntent* %104, i32 0, i32 2
store i8* %103, i8** %105
%106 = load i8*, i8** %12
%107 = call i8* @strtok_r(i8* null, i8* %106, i8** %11)
store i8* %107, i8** %10
%108 = load i8*, i8** %10
%109 = icmp ne i8* %108, null
br i1 %109, label %110, label %113
110: ; preds = %102
%111 = load i8*, i8** %10
%112 = call i8* @atoi(i8* %111)
br label %114
113: ; preds = %102
br label %114
114: ; preds = %113, %110
%115 = phi i8* [ %112, %110 ], [ null, %113 ]
%116 = load %struct.mntent*, %struct.mntent** %7
%117 = getelementptr inbounds %struct.mntent, %struct.mntent* %116, i32 0, i32 1
store i8* %115, i8** %117
%118 = load %struct.mntent*, %struct.mntent** %7
store %struct.mntent* %118, %struct.mntent** %5
br label %119
119: ; preds = %114, %80, %69, %58, %46, %21
%120 = load %struct.mntent*, %struct.mntent** %5
ret %struct.mntent* %120
}

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