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

/* Variables and functions */
int /*<<< orphan*/ ERANGE;
int /*<<< orphan*/ errno;
scalar_t__ feof(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *);
int sscanf(char *, char *, int *, int *, int *, int *, int *, int *, int *,
           int *, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ strchr(char *, char);
struct mntent *getmntent_r(FILE *f, struct mntent *mnt, char *linebuf,
                           int buflen) {
  int cnt, n[8];
  mnt->mnt_freq = 0;
  mnt->mnt_passno = 0;
  do {
    fgets(linebuf, buflen, f);
    if (feof(f) || ferror(f))
      return 0;
    if (!strchr(linebuf, '\n')) {
      fscanf(f, "%*[^\n]%*[\n]");
      errno = ERANGE;
      return 0;
    }
    cnt = sscanf(linebuf, " %n%*s%n %n%*s%n %n%*s%n %n%*s%n %d %d", n, n + 1,
                 n + 2, n + 3, n + 4, n + 5, n + 6, n + 7, &mnt->mnt_freq,
                 &mnt->mnt_passno);
  } while (cnt < 2 || linebuf[n[0]] == '#');
  linebuf[n[1]] = 0;
  linebuf[n[3]] = 0;
  linebuf[n[5]] = 0;
  linebuf[n[7]] = 0;
  mnt->mnt_fsname = linebuf + n[0];
  mnt->mnt_dir = linebuf + n[2];
  mnt->mnt_type = linebuf + n[4];
  mnt->mnt_opts = linebuf + n[6];
  return mnt;
}


x86 assembly (clang, -O0):
<getmntent_r>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
mov    %ecx,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
movl   $0x0,0x24(%rax)
mov    -0x30(%rbp),%rax
movl   $0x0,0x20(%rax)
mov    -0x38(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1060 <fgets@plt>
mov    -0x28(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%rax
jne    11cb <getmntent_r+0x6b>
mov    -0x28(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     11d8 <getmntent_r+0x78>
movq   $0x0,-0x20(%rbp)
jmp    134c <getmntent_r+0x1ec>
mov    -0x38(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
cmp    $0x0,%eax
jne    121e <getmntent_r+0xbe>
mov    -0x28(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   1050 <fscanf@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%ecx
mov    0x2dc9(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x20(%rbp)
jmp    134c <getmntent_r+0x1ec>
mov    -0x38(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    -0x60(%rbp),%rcx
add    $0x4,%rcx
lea    -0x60(%rbp),%r8
add    $0x8,%r8
lea    -0x60(%rbp),%r9
add    $0xc,%r9
lea    -0x60(%rbp),%r15
add    $0x10,%r15
lea    -0x60(%rbp),%r14
add    $0x14,%r14
lea    -0x60(%rbp),%rbx
add    $0x18,%rbx
lea    -0x60(%rbp),%r11
add    $0x1c,%r11
mov    -0x30(%rbp),%r10
add    $0x24,%r10
mov    -0x30(%rbp),%rax
add    $0x20,%rax
lea    0xd97(%rip),%rsi
mov    %r15,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   1080 <sscanf@plt>
mov    %eax,-0x40(%rbp)
mov    $0x1,%al
cmpl   $0x2,-0x40(%rbp)
mov    %al,-0x61(%rbp)
jl     12be <getmntent_r+0x15e>
mov    -0x38(%rbp),%rax
movslq -0x60(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x23,%eax
sete   %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    1195 <getmntent_r+0x35>
mov    -0x38(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
movslq -0x54(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
movslq -0x44(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rcx
movslq -0x60(%rbp),%rax
add    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rcx
movslq -0x58(%rbp),%rax
add    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x38(%rbp),%rcx
movslq -0x50(%rbp),%rax
add    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x38(%rbp),%rcx
movslq -0x48(%rbp),%rax
add    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<getmntent_r>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%ebp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,0x20(%rsi)
mov    %rdx,%rdi
mov    %ecx,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %rax,%rax
je     11b0 <getmntent_r+0x50>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x24(%r14),%r13
lea    0x20(%r14),%r12
jmp    11da <getmntent_r+0x7a>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %rax,%rax
jne    119b <getmntent_r+0x3b>
mov    %rbx,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    119b <getmntent_r+0x3b>
mov    %r15,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
test   %eax,%eax
je     12ac <getmntent_r+0x14c>
mov    %r15,%rdi
lea    0xe06(%rip),%rsi
mov    %rsp,%rdx
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
lea    0xc(%rsp),%r9
push   %r12
push   %r13
lea    0x2c(%rsp),%rax
push   %rax
lea    0x30(%rsp),%rax
push   %rax
lea    0x34(%rsp),%rax
push   %rax
lea    0x38(%rsp),%rax
push   %rax
call   1080 <sscanf@plt>
add    $0x30,%rsp
cmp    $0x2,%eax
jl     11c0 <getmntent_r+0x60>
movslq (%rsp),%rax
cmpb   $0x23,(%r15,%rax,1)
je     11c0 <getmntent_r+0x60>
add    %r15,%rax
movslq 0x4(%rsp),%rcx
movb   $0x0,(%r15,%rcx,1)
movslq 0xc(%rsp),%rcx
movb   $0x0,(%r15,%rcx,1)
movslq 0x14(%rsp),%rcx
movb   $0x0,(%r15,%rcx,1)
movslq 0x1c(%rsp),%rcx
movb   $0x0,(%r15,%rcx,1)
mov    %rax,(%r14)
movslq 0x8(%rsp),%rax
add    %r15,%rax
mov    %rax,0x8(%r14)
movslq 0x10(%rsp),%rax
add    %r15,%rax
mov    %rax,0x10(%r14)
movslq 0x18(%rsp),%rax
add    %r15,%rax
mov    %rax,0x18(%r14)
jmp    119e <getmntent_r+0x3e>
lea    0xd4d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fscanf@plt>
mov    0x2d26(%rip),%rax
mov    (%rax),%eax
mov    0x2d0d(%rip),%rcx
mov    %eax,(%rcx)
jmp    119b <getmntent_r+0x3b>

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

LLVM IR (-O2):
%struct.mntent = type { i8*, i8*, i8*, i8*, i32, i32 }
@.str = [12 x i8] c"%*[^\0A]%*[\0A]\00"
@ERANGE = global i32 0
@errno = global i32 0
@.str.1 = [39 x i8] c" %n%*s%n %n%*s%n %n%*s%n %n%*s%n %d %d\00"
define %struct.mntent* @getmntent_r(i32* nocapture %0, %struct.mntent* %1, i8* %2, i32 %3) {
%5 = alloca [8 x i32]
%6 = bitcast [8 x i32]* %5 to i8*
%7 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 5
store i32 0, i32* %7
%8 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 4
store i32 0, i32* %8
%9 = call i32 @fgets(i8* %2, i32 %3, i32* %0)
%10 = call i64 @feof(i32* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %71
12: ; preds = %4
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 0
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 1
%15 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 2
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 3
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 4
%18 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 5
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 6
%20 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 7
br label %21
21: ; preds = %12, %39
%22 = call i64 @ferror(i32* %0)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %71
24: ; preds = %21
%25 = call i32 @strchr(i8* %2, i8 signext 10)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%29 = load i32, i32* @ERANGE
store i32 %29, i32* @errno
br label %71
30: ; preds = %24
%31 = call i32 @sscanf(i8* %2, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32* %13, i32* %14, i32* %15, i32* %16, i32* %17, i32* %18, i32* %19, i32* %20, i32* %7, i32* %8)
%32 = icmp slt i32 %31, 2
br i1 %32, label %39, label %33
33: ; preds = %30
%34 = load i32, i32* %13
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %2, i64 %35
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 35
br i1 %38, label %39, label %43
39: ; preds = %33, %30
%40 = call i32 @fgets(i8* %2, i32 %3, i32* %0)
%41 = call i64 @feof(i32* %0)
%42 = icmp eq i64 %41, 0
br i1 %42, label %21, label %71
43: ; preds = %33
%44 = sext i32 %34 to i64
%45 = getelementptr inbounds i8, i8* %2, i64 %44
%46 = load i32, i32* %14
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %2, i64 %47
store i8 0, i8* %48
%49 = load i32, i32* %16
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %2, i64 %50
store i8 0, i8* %51
%52 = load i32, i32* %18
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %2, i64 %53
store i8 0, i8* %54
%55 = load i32, i32* %20
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %2, i64 %56
store i8 0, i8* %57
%58 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 0
store i8* %45, i8** %58
%59 = load i32, i32* %15
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %2, i64 %60
%62 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 1
store i8* %61, i8** %62
%63 = load i32, i32* %17
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %2, i64 %64
%66 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 2
store i8* %65, i8** %66
%67 = load i32, i32* %19
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %2, i64 %68
%70 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 3
store i8* %69, i8** %70
br label %71
71: ; preds = %21, %39, %4, %43, %27
%72 = phi %struct.mntent* [ %1, %43 ], [ null, %27 ], [ null, %4 ], [ null, %39 ], [ null, %21 ]
ret %struct.mntent* %72
}