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

/* Variables and functions */
struct mntent *getmntent_r(int /*<<< orphan*/ *, struct mntent *, char *, int);
scalar_t__ strcmp(int /*<<< orphan*/, char const *);
struct mntent *find_mnt_entry(FILE *mtab, const char *dir) {
  static struct mntent mnt;
  struct mntent *m;
  char strings[4096];
  while ((m = getmntent_r(mtab, &mnt, strings, sizeof(strings)))) {
    if (strcmp(m->mnt_dir, dir) == 0)
      return m;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<find_mnt_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1020(%rbp),%rdx
lea    0x2eef(%rip),%rsi
mov    $0x1000,%ecx
call   1030 <getmntent_r@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1188 <find_mnt_entry+0x68>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1183 <find_mnt_entry+0x63>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1190 <find_mnt_entry+0x70>
jmp    1133 <find_mnt_entry+0x13>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_mnt_entry>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1000,%rsp
mov    %rsi,%r14
mov    %rdi,%r13
lea    0x2ef7(%rip),%r15
mov    %rsp,%r12
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    $0x1000,%ecx
call   1030 <getmntent_r@plt>
mov    %rax,%rbx
test   %rax,%rax
je     116a <find_mnt_entry+0x4a>
mov    (%rbx),%edi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1140 <find_mnt_entry+0x20>
mov    %rbx,%rax
add    $0x1000,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.mntent = type { i32 }
@find_mnt_entry.mnt = internal global %struct.mntent zeroinitializer
define %struct.mntent* @find_mnt_entry(i32* %0, i8* %1) {
%3 = alloca %struct.mntent*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca %struct.mntent*
%7 = alloca [4096 x i8]
store i32* %0, i32** %4
store i8* %1, i8** %5
br label %8
8: ; preds = %22, %2
%9 = load i32*, i32** %4
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%11 = call %struct.mntent* @getmntent_r(i32* %9, %struct.mntent* @find_mnt_entry.mnt, i8* %10, i32 4096)
store %struct.mntent* %11, %struct.mntent** %6
%12 = icmp ne %struct.mntent* %11, null
br i1 %12, label %13, label %23
13: ; preds = %8
%14 = load %struct.mntent*, %struct.mntent** %6
%15 = getelementptr inbounds %struct.mntent, %struct.mntent* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = load i8*, i8** %5
%18 = call i64 @strcmp(i32 %16, i8* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = load %struct.mntent*, %struct.mntent** %6
store %struct.mntent* %21, %struct.mntent** %3
br label %24
22: ; preds = %13
br label %8
23: ; preds = %8
store %struct.mntent* null, %struct.mntent** %3
br label %24
24: ; preds = %23, %20
%25 = load %struct.mntent*, %struct.mntent** %3
ret %struct.mntent* %25
}

LLVM IR (-O2):
%struct.mntent = type { i32 }
@find_mnt_entry.mnt = internal global %struct.mntent zeroinitializer
define %struct.mntent* @find_mnt_entry(i32* %0, i8* %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %8, %2
%6 = call %struct.mntent* @getmntent_r(i32* %0, %struct.mntent* @find_mnt_entry.mnt, i8* %4, i32 4096)
%7 = icmp eq %struct.mntent* %6, null
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = getelementptr inbounds %struct.mntent, %struct.mntent* %6, i64 0, i32 0
%10 = load i32, i32* %9
%11 = call i64 @strcmp(i32 %10, i8* %1)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %5
13: ; preds = %5, %8
ret %struct.mntent* %6
}