#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 {
  int /*<<< orphan*/ mnt_dir;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
struct mntent *getmntent(int /*<<< orphan*/ *);
scalar_t__ is_protected(int /*<<< orphan*/);
int /*<<< orphan*/ iterator_end(int /*<<< orphan*/ **);
int /*<<< orphan*/ *setmntent(char *, char *);
struct mntent *iterator(char *fstab, FILE **fp) {
  static struct mntent *mnt;
  if (!*fp && fstab) {
    *fp = setmntent(fstab, "r");
    if (!*fp)
      return NULL;
  }
  while ((mnt = getmntent(*fp))) {
    if (is_protected(mnt->mnt_dir))
      continue;
    return mnt;
  }
  iterator_end(fp);
  return NULL;
}


x86 assembly (clang, -O0):
<iterator>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11a3 <iterator+0x63>
cmpq   $0x0,-0x10(%rbp)
je     11a3 <iterator+0x63>
mov    -0x10(%rbp),%rdi
lea    0xe8c(%rip),%rsi
call   1040 <setmntent@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    119e <iterator+0x5e>
movq   $0x0,-0x8(%rbp)
jmp    1203 <iterator+0xc3>
jmp    11a3 <iterator+0x63>
jmp    11a8 <iterator+0x68>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <getmntent@plt>
mov    %rax,0x2e8d(%rip)
cmp    $0x0,%rax
je     11f2 <iterator+0xb2>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
call   1060 <is_protected@plt>
cmp    $0x0,%rax
je     11e2 <iterator+0xa2>
jmp    11a8 <iterator+0x68>
mov    0x2e5f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1203 <iterator+0xc3>
mov    -0x18(%rbp),%rdi
call   1050 <iterator_end@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iterator>:
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rax
mov    (%rsi),%rdi
test   %rax,%rax
je     117f <iterator+0x3f>
test   %rdi,%rdi
jne    117f <iterator+0x3f>
lea    0xea5(%rip),%rsi
mov    %rax,%rdi
call   1040 <setmntent@plt>
mov    %rax,%rdi
mov    %rax,(%rbx)
test   %rax,%rax
jne    117f <iterator+0x3f>
jmp    1198 <iterator+0x58>
mov    (%rax),%edi
call   1060 <is_protected@plt>
test   %rax,%rax
je     119c <iterator+0x5c>
mov    (%rbx),%rdi
call   1030 <getmntent@plt>
mov    %rax,0x2ebd(%rip)
test   %rax,%rax
jne    1170 <iterator+0x30>
mov    %rbx,%rdi
call   1050 <iterator_end@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2ea5(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
%struct.mntent = type { i32 }
@iterator.mnt = internal global %struct.mntent* null
@.str = [2 x i8] c"r\00"
define %struct.mntent* @iterator(i8* %0, i32** %1) {
%3 = alloca %struct.mntent*
%4 = alloca i8*
%5 = alloca i32**
store i8* %0, i8** %4
store i32** %1, i32*** %5
%6 = load i32**, i32*** %5
%7 = load i32*, i32** %6
%8 = icmp ne i32* %7, null
br i1 %8, label %21, label %9
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = load i8*, i8** %4
%14 = call i32* @setmntent(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = load i32**, i32*** %5
store i32* %14, i32** %15
%16 = load i32**, i32*** %5
%17 = load i32*, i32** %16
%18 = icmp ne i32* %17, null
br i1 %18, label %20, label %19
19: ; preds = %12
store %struct.mntent* null, %struct.mntent** %3
br label %39
20: ; preds = %12
br label %21
21: ; preds = %20, %9, %2
br label %22
22: ; preds = %33, %21
%23 = load i32**, i32*** %5
%24 = load i32*, i32** %23
%25 = call %struct.mntent* @getmntent(i32* %24)
store %struct.mntent* %25, %struct.mntent** @iterator.mnt
%26 = icmp ne %struct.mntent* %25, null
br i1 %26, label %27, label %36
27: ; preds = %22
%28 = load %struct.mntent*, %struct.mntent** @iterator.mnt
%29 = getelementptr inbounds %struct.mntent, %struct.mntent* %28, i32 0, i32 0
%30 = load i32, i32* %29
%31 = call i64 @is_protected(i32 %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %27
br label %22
34: ; preds = %27
%35 = load %struct.mntent*, %struct.mntent** @iterator.mnt
store %struct.mntent* %35, %struct.mntent** %3
br label %39
36: ; preds = %22
%37 = load i32**, i32*** %5
%38 = call i32 @iterator_end(i32** %37)
store %struct.mntent* null, %struct.mntent** %3
br label %39
39: ; preds = %36, %34, %19
%40 = load %struct.mntent*, %struct.mntent** %3
ret %struct.mntent* %40
}

LLVM IR (-O2):
%struct.mntent = type { i32 }
@iterator.mnt = internal unnamed_addr global %struct.mntent* null
@.str = [2 x i8] c"r\00"
define %struct.mntent* @iterator(i8* %0, i32** %1) {
%3 = load i32*, i32** %1
%4 = icmp eq i32* %3, null
%5 = icmp ne i8* %0, null
%6 = and i1 %5, %4
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32* @setmntent(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %1
%9 = icmp eq i32* %8, null
br i1 %9, label %28, label %10
10: ; preds = %7, %2
%11 = phi i32* [ %8, %7 ], [ %3, %2 ]
%12 = tail call %struct.mntent* @getmntent(i32* %11)
store %struct.mntent* %12, %struct.mntent** @iterator.mnt
%13 = icmp eq %struct.mntent* %12, null
br i1 %13, label %26, label %14
14: ; preds = %10, %20
%15 = phi %struct.mntent* [ %22, %20 ], [ %12, %10 ]
%16 = getelementptr inbounds %struct.mntent, %struct.mntent* %15, i64 0, i32 0
%17 = load i32, i32* %16
%18 = tail call i64 @is_protected(i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %14
%21 = load i32*, i32** %1
%22 = tail call %struct.mntent* @getmntent(i32* %21)
store %struct.mntent* %22, %struct.mntent** @iterator.mnt
%23 = icmp eq %struct.mntent* %22, null
br i1 %23, label %26, label %14
24: ; preds = %14
%25 = load %struct.mntent*, %struct.mntent** @iterator.mnt
br label %28
26: ; preds = %20, %10
%27 = tail call i32 @iterator_end(i32** %1)
br label %28
28: ; preds = %7, %26, %24
%29 = phi %struct.mntent* [ %25, %24 ], [ null, %26 ], [ null, %7 ]
ret %struct.mntent* %29
}