#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 */
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int sscanf(char *, char *, int *, int *, int *, int *, int *, int *, int *,
           int *, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
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))
      return NULL;
    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   1030 <fgets@plt>
mov    -0x28(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%rax
je     1195 <getmntent_r+0x65>
movq   $0x0,-0x20(%rbp)
jmp    12c3 <getmntent_r+0x193>
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    0xe14(%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   1050 <sscanf@plt>
mov    %eax,-0x40(%rbp)
mov    $0x1,%al
cmpl   $0x2,-0x40(%rbp)
mov    %al,-0x61(%rbp)
jl     1235 <getmntent_r+0x105>
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    1165 <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,%r15d
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%rbp
movq   $0x0,0x20(%rsi)
mov    %rdx,%rdi
mov    %ecx,%esi
mov    %rbp,%rdx
call   1030 <fgets@plt>
mov    %rbp,%rdi
call   1040 <feof@plt>
test   %rax,%rax
je     117d <getmntent_r+0x4d>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x24(%r12),%r14
mov    %r12,0x20(%rsp)
add    $0x20,%r12
mov    %rsp,%r13
jmp    11ab <getmntent_r+0x7b>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %rbp,%rdx
call   1030 <fgets@plt>
mov    %rbp,%rdi
call   1040 <feof@plt>
test   %rax,%rax
jne    116c <getmntent_r+0x3c>
mov    %rbx,%rdi
lea    0xe4b(%rip),%rsi
mov    %r13,%rdx
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
lea    0xc(%rsp),%r9
push   %r12
push   %r14
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   1050 <sscanf@plt>
add    $0x30,%rsp
cmp    $0x2,%eax
jl     1190 <getmntent_r+0x60>
movslq (%rsp),%rdx
cmpb   $0x23,(%rbx,%rdx,1)
je     1190 <getmntent_r+0x60>
add    %rbx,%rdx
movslq 0x4(%rsp),%rcx
movb   $0x0,(%rbx,%rcx,1)
movslq 0xc(%rsp),%rcx
movb   $0x0,(%rbx,%rcx,1)
movslq 0x14(%rsp),%rcx
movb   $0x0,(%rbx,%rcx,1)
movslq 0x1c(%rsp),%rcx
movb   $0x0,(%rbx,%rcx,1)
mov    0x20(%rsp),%rax
mov    %rdx,(%rax)
movslq 0x8(%rsp),%rcx
add    %rbx,%rcx
mov    %rcx,0x8(%rax)
movslq 0x10(%rsp),%rcx
add    %rbx,%rcx
mov    %rcx,0x10(%rax)
movslq 0x18(%rsp),%rcx
add    %rbx,%rcx
mov    %rcx,0x18(%rax)
jmp    116e <getmntent_r+0x3e>

LLVM IR (-O0):
%struct.mntent = type { i8*, i8*, i8*, i8*, i32, i32 }
@.str = [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 = %59, %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 %24, label %25
24: ; preds = %16
store %struct.mntent* null, %struct.mntent** %5
br label %111
25: ; preds = %16
%26 = load i8*, i8** %8
%27 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 0
%28 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 0
%29 = getelementptr inbounds i32, i32* %28, i64 1
%30 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 0
%31 = getelementptr inbounds i32, i32* %30, i64 2
%32 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 0
%33 = getelementptr inbounds i32, i32* %32, i64 3
%34 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 0
%35 = getelementptr inbounds i32, i32* %34, i64 4
%36 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 0
%37 = getelementptr inbounds i32, i32* %36, i64 5
%38 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 0
%39 = getelementptr inbounds i32, i32* %38, i64 6
%40 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 0
%41 = getelementptr inbounds i32, i32* %40, i64 7
%42 = load %struct.mntent*, %struct.mntent** %7
%43 = getelementptr inbounds %struct.mntent, %struct.mntent* %42, i32 0, i32 5
%44 = load %struct.mntent*, %struct.mntent** %7
%45 = getelementptr inbounds %struct.mntent, %struct.mntent* %44, i32 0, i32 4
%46 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32* %27, i32* %29, i32* %31, i32* %33, i32* %35, i32* %37, i32* %39, i32* %41, i32* %43, i32* %45)
store i32 %46, i32* %10
br label %47
47: ; preds = %25
%48 = load i32, i32* %10
%49 = icmp slt i32 %48, 2
br i1 %49, label %59, label %50
50: ; preds = %47
%51 = load i8*, i8** %8
%52 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 0
%53 = load i32, i32* %52
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %51, i64 %54
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 35
br label %59
59: ; preds = %50, %47
%60 = phi i1 [ true, %47 ], [ %58, %50 ]
br i1 %60, label %16, label %61
61: ; preds = %59
%62 = load i8*, i8** %8
%63 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 1
%64 = load i32, i32* %63
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %62, i64 %65
store i8 0, i8* %66
%67 = load i8*, i8** %8
%68 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 3
%69 = load i32, i32* %68
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %67, i64 %70
store i8 0, i8* %71
%72 = load i8*, i8** %8
%73 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 5
%74 = load i32, i32* %73
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %72, i64 %75
store i8 0, i8* %76
%77 = load i8*, i8** %8
%78 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 7
%79 = load i32, i32* %78
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %77, i64 %80
store i8 0, i8* %81
%82 = load i8*, i8** %8
%83 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 0
%84 = load i32, i32* %83
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %82, i64 %85
%87 = load %struct.mntent*, %struct.mntent** %7
%88 = getelementptr inbounds %struct.mntent, %struct.mntent* %87, i32 0, i32 0
store i8* %86, i8** %88
%89 = load i8*, i8** %8
%90 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 2
%91 = load i32, i32* %90
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %89, i64 %92
%94 = load %struct.mntent*, %struct.mntent** %7
%95 = getelementptr inbounds %struct.mntent, %struct.mntent* %94, i32 0, i32 1
store i8* %93, i8** %95
%96 = load i8*, i8** %8
%97 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 4
%98 = load i32, i32* %97
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i8, i8* %96, i64 %99
%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** %8
%104 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 6
%105 = load i32, i32* %104
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8, i8* %103, i64 %106
%108 = load %struct.mntent*, %struct.mntent** %7
%109 = getelementptr inbounds %struct.mntent, %struct.mntent* %108, i32 0, i32 3
store i8* %107, i8** %109
%110 = load %struct.mntent*, %struct.mntent** %7
store %struct.mntent* %110, %struct.mntent** %5
br label %111
111: ; preds = %61, %24
%112 = load %struct.mntent*, %struct.mntent** %5
ret %struct.mntent* %112
}

LLVM IR (-O2):
%struct.mntent = type { i8*, i8*, i8*, i8*, i32, i32 }
@.str = [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 %62
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, %30
%22 = call i32 @sscanf(i8* %2, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32* %13, i32* %14, i32* %15, i32* %16, i32* %17, i32* %18, i32* %19, i32* %20, i32* %7, i32* %8)
%23 = icmp slt i32 %22, 2
br i1 %23, label %30, label %24
24: ; preds = %21
%25 = load i32, i32* %13
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %2, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 35
br i1 %29, label %30, label %34
30: ; preds = %24, %21
%31 = call i32 @fgets(i8* %2, i32 %3, i32* %0)
%32 = call i64 @feof(i32* %0)
%33 = icmp eq i64 %32, 0
br i1 %33, label %21, label %62
34: ; preds = %24
%35 = sext i32 %25 to i64
%36 = getelementptr inbounds i8, i8* %2, i64 %35
%37 = load i32, i32* %14
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %2, i64 %38
store i8 0, i8* %39
%40 = load i32, i32* %16
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %2, i64 %41
store i8 0, i8* %42
%43 = load i32, i32* %18
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %2, i64 %44
store i8 0, i8* %45
%46 = load i32, i32* %20
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %2, i64 %47
store i8 0, i8* %48
%49 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 0
store i8* %36, i8** %49
%50 = load i32, i32* %15
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %2, i64 %51
%53 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 1
store i8* %52, i8** %53
%54 = load i32, i32* %17
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %2, i64 %55
%57 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 2
store i8* %56, i8** %57
%58 = load i32, i32* %19
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %2, i64 %59
%61 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 3
store i8* %60, i8** %61
br label %62
62: ; preds = %30, %4, %34
%63 = phi %struct.mntent* [ %1, %34 ], [ null, %4 ], [ null, %30 ]
ret %struct.mntent* %63
}