#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 *iterator(char *, int /*<<< orphan*/ **);
int /*<<< orphan*/ iterator_end(int /*<<< orphan*/ **);
int /*<<< orphan*/ umount(int /*<<< orphan*/);
void unmount_regular(void) {
  struct mntent *mnt;
  FILE *fp = NULL;
  while ((mnt = iterator("/proc/mounts", &fp))) {
    if (!umount(mnt->mnt_dir))
      iterator_end(&fp);
  }
}


x86 assembly (clang, -O0):
<unmount_regular>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x10(%rbp)
lea    0xeb9(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <iterator@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     1180 <unmount_regular+0x50>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <umount@plt>
cmp    $0x0,%eax
jne    117b <unmount_regular+0x4b>
lea    -0x10(%rbp),%rdi
call   1050 <iterator_end@plt>
jmp    1140 <unmount_regular+0x10>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unmount_regular>:
push   %r14
push   %rbx
push   %rax
movq   $0x0,(%rsp)
lea    0xebd(%rip),%rdi
mov    %rsp,%rsi
call   1040 <iterator@plt>
test   %rax,%rax
je     1185 <unmount_regular+0x55>
mov    %rsp,%rbx
lea    0xea6(%rip),%r14
jmp    1170 <unmount_regular+0x40>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <iterator@plt>
test   %rax,%rax
je     1185 <unmount_regular+0x55>
mov    (%rax),%edi
call   1030 <umount@plt>
test   %eax,%eax
jne    1160 <unmount_regular+0x30>
mov    %rbx,%rdi
call   1050 <iterator_end@plt>
jmp    1160 <unmount_regular+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.mntent = type { i32 }
@.str = [13 x i8] c"/proc/mounts\00"
define void @unmount_regular() {
%1 = alloca %struct.mntent*
%2 = alloca i32*
store i32* null, i32** %2
br label %3
3: ; preds = %14, %0
%4 = call %struct.mntent* @iterator(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32** %2)
store %struct.mntent* %4, %struct.mntent** %1
%5 = icmp ne %struct.mntent* %4, null
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = load %struct.mntent*, %struct.mntent** %1
%8 = getelementptr inbounds %struct.mntent, %struct.mntent* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = call i32 @umount(i32 %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %6
%13 = call i32 @iterator_end(i32** %2)
br label %14
14: ; preds = %12, %6
br label %3
15: ; preds = %3
ret void
}

LLVM IR (-O2):
%struct.mntent = type { i32 }
@.str = [13 x i8] c"/proc/mounts\00"
define void @unmount_regular() {
%1 = alloca i32*
%2 = bitcast i32** %1 to i8*
store i32* null, i32** %1
%3 = call %struct.mntent* @iterator(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32** %1)
%4 = icmp eq %struct.mntent* %3, null
br i1 %4, label %16, label %5
5: ; preds = %0, %13
%6 = phi %struct.mntent* [ %14, %13 ], [ %3, %0 ]
%7 = getelementptr inbounds %struct.mntent, %struct.mntent* %6, i64 0, i32 0
%8 = load i32, i32* %7
%9 = call i32 @umount(i32 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = call i32 @iterator_end(i32** %1)
br label %13
13: ; preds = %11, %5
%14 = call %struct.mntent* @iterator(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32** %1)
%15 = icmp eq %struct.mntent* %14, null
br i1 %15, label %16, label %5
16: ; preds = %13, %0
ret void
}