#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 */
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ copy_ent(struct mntent *, struct mntent *);
int /*<<< orphan*/ endmntent(int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error_at_line(int /*<<< orphan*/, int /*<<< orphan*/, char *,
                                 int, char *, ...);
struct mntent *getmntent(int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(struct mntent *, int /*<<< orphan*/, int);
int /*<<< orphan*/ *setmntent(char *, char *);
int /*<<< orphan*/ strcmp(int /*<<< orphan*/, char *);
int au_proc_getmntent(char *mntpnt, struct mntent *rent) {
  int found;
  struct mntent *p;
  FILE *fp;
  fp = setmntent("/proc/self/mounts", "r");
  if (!fp)
    error_at_line(errno, errno,
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/cvmfs/aufs2-util/refs/"
                  "heads/master/proc_mnt.c",
                  64, "/proc/self/mounts");
  memset(rent, 0, sizeof(*rent));
  found = 0;
  while ((p = getmntent(fp)))
    if (!strcmp(p->mnt_dir, mntpnt)) {
      do {
      } while (0);
      copy_ent(rent, p);
      found = 1;
    }
  endmntent(fp);
  if (!found) {
    errno = EINVAL;
    error_at_line(errno, errno,
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/cvmfs/aufs2-util/refs/"
                  "heads/master/proc_mnt.c",
                  81, "%s", mntpnt);
  }
  return 0;
}


x86 assembly (clang, -O0):
<au_proc_getmntent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe79(%rip),%rdi
lea    0xe84(%rip),%rsi
call   1090 <setmntent@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11ce <au_proc_getmntent+0x5e>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
mov    0x2e2e(%rip),%rax
mov    (%rax),%esi
lea    0xe59(%rip),%rdx
mov    $0x40,%ecx
lea    0xe39(%rip),%r8
mov    $0x0,%al
call   1040 <error_at_line@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <memset@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <getmntent@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1237 <au_proc_getmntent+0xc7>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1232 <au_proc_getmntent+0xc2>
jmp    1219 <au_proc_getmntent+0xa9>
jmp    121e <au_proc_getmntent+0xae>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <copy_ent@plt>
movl   $0x1,-0x14(%rbp)
jmp    11e5 <au_proc_getmntent+0x75>
mov    -0x28(%rbp),%rdi
call   1030 <endmntent@plt>
cmpl   $0x0,-0x14(%rbp)
jne    128c <au_proc_getmntent+0x11c>
mov    0x2d87(%rip),%rax
mov    (%rax),%ecx
mov    0x2d86(%rip),%rax
mov    %ecx,(%rax)
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
mov    0x2d74(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%r9
lea    0xd9b(%rip),%rdx
mov    $0x51,%ecx
lea    0xe17(%rip),%r8
mov    $0x0,%al
call   1040 <error_at_line@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<au_proc_getmntent>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe7b(%rip),%rdi
lea    0xe86(%rip),%rsi
call   1090 <setmntent@plt>
mov    %rax,%r12
test   %rax,%rax
jne    11be <au_proc_getmntent+0x4e>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rdx
lea    0xe50(%rip),%r8
mov    %edi,%esi
mov    $0x40,%ecx
xor    %eax,%eax
call   1040 <error_at_line@plt>
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <memset@plt>
mov    %r12,%rdi
call   1080 <getmntent@plt>
test   %rax,%rax
je     122e <au_proc_getmntent+0xbe>
mov    %rax,%rbx
jmp    1200 <au_proc_getmntent+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1080 <getmntent@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1220 <au_proc_getmntent+0xb0>
mov    (%rbx),%edi
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    11f0 <au_proc_getmntent+0x80>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <copy_ent@plt>
mov    $0x1,%ebp
jmp    11f0 <au_proc_getmntent+0x80>
mov    %r12,%rdi
call   1030 <endmntent@plt>
test   %ebp,%ebp
jne    1267 <au_proc_getmntent+0xf7>
jmp    1236 <au_proc_getmntent+0xc6>
mov    %r12,%rdi
call   1030 <endmntent@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
mov    0x2d9a(%rip),%rax
mov    %edi,(%rax)
lea    0xdc5(%rip),%rdx
lea    0xe46(%rip),%r8
mov    %edi,%esi
mov    $0x51,%ecx
mov    %r15,%r9
xor    %eax,%eax
call   1040 <error_at_line@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mntent = type { i32 }
@.str = [18 x i8] c"/proc/self/mounts\00"
@.str.1 = [2 x i8] c"r\00"
@errno = global i32 0
@.str.2 = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/cvmfs/aufs2-util/refs/heads/master/proc_mnt.c\00"
@EINVAL = global i32 0
@.str.3 = [3 x i8] c"%s\00"
define i32 @au_proc_getmntent(i8* %0, %struct.mntent* %1) {
%3 = alloca i8*
%4 = alloca %struct.mntent*
%5 = alloca i32
%6 = alloca %struct.mntent*
%7 = alloca i32*
store i8* %0, i8** %3
store %struct.mntent* %1, %struct.mntent** %4
%8 = call i32* @setmntent(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %7
%9 = load i32*, i32** %7
%10 = icmp ne i32* %9, null
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = load i32, i32* @errno
%13 = load i32, i32* @errno
%14 = call i32 (i32, i32, i8*, i32, i8*, ...) @error_at_line(i32 %12, i32 %13, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.2, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %11, %2
%16 = load %struct.mntent*, %struct.mntent** %4
%17 = call i32 @memset(%struct.mntent* %16, i32 0, i32 4)
store i32 0, i32* %5
br label %18
18: ; preds = %35, %15
%19 = load i32*, i32** %7
%20 = call %struct.mntent* @getmntent(i32* %19)
store %struct.mntent* %20, %struct.mntent** %6
%21 = icmp ne %struct.mntent* %20, null
br i1 %21, label %22, label %36
22: ; preds = %18
%23 = load %struct.mntent*, %struct.mntent** %6
%24 = getelementptr inbounds %struct.mntent, %struct.mntent* %23, i32 0, i32 0
%25 = load i32, i32* %24
%26 = load i8*, i8** %3
%27 = call i32 @strcmp(i32 %25, i8* %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %22
br label %30
30: ; preds = %29
br label %31
31: ; preds = %30
%32 = load %struct.mntent*, %struct.mntent** %4
%33 = load %struct.mntent*, %struct.mntent** %6
%34 = call i32 @copy_ent(%struct.mntent* %32, %struct.mntent* %33)
store i32 1, i32* %5
br label %35
35: ; preds = %31, %22
br label %18
36: ; preds = %18
%37 = load i32*, i32** %7
%38 = call i32 @endmntent(i32* %37)
%39 = load i32, i32* %5
%40 = icmp ne i32 %39, 0
br i1 %40, label %47, label %41
41: ; preds = %36
%42 = load i32, i32* @EINVAL
store i32 %42, i32* @errno
%43 = load i32, i32* @errno
%44 = load i32, i32* @errno
%45 = load i8*, i8** %3
%46 = call i32 (i32, i32, i8*, i32, i8*, ...) @error_at_line(i32 %43, i32 %44, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.2, i64 0, i64 0), i32 81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %41, %36
ret i32 0
}

LLVM IR (-O2):
%struct.mntent = type { i32 }
@.str = [18 x i8] c"/proc/self/mounts\00"
@.str.1 = [2 x i8] c"r\00"
@errno = global i32 0
@.str.2 = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/cvmfs/aufs2-util/refs/heads/master/proc_mnt.c\00"
@EINVAL = global i32 0
@.str.3 = [3 x i8] c"%s\00"
define i32 @au_proc_getmntent(i8* %0, %struct.mntent* %1) {
%3 = tail call i32* @setmntent(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @errno
%7 = tail call i32 (i32, i32, i8*, i32, i8*, ...) @error_at_line(i32 %6, i32 %6, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.2, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %5, %2
%9 = tail call i32 @memset(%struct.mntent* %1, i32 0, i32 4)
%10 = tail call %struct.mntent* @getmntent(i32* %3)
%11 = icmp eq %struct.mntent* %10, null
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32 @endmntent(i32* %3)
br label %30
14: ; preds = %8, %23
%15 = phi %struct.mntent* [ %25, %23 ], [ %10, %8 ]
%16 = phi i32 [ %24, %23 ], [ 0, %8 ]
%17 = getelementptr inbounds %struct.mntent, %struct.mntent* %15, i64 0, i32 0
%18 = load i32, i32* %17
%19 = tail call i32 @strcmp(i32 %18, i8* %0)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = tail call i32 @copy_ent(%struct.mntent* %1, %struct.mntent* %15)
br label %23
23: ; preds = %21, %14
%24 = phi i32 [ %16, %14 ], [ 1, %21 ]
%25 = tail call %struct.mntent* @getmntent(i32* %3)
%26 = icmp eq %struct.mntent* %25, null
br i1 %26, label %27, label %14
27: ; preds = %23
%28 = tail call i32 @endmntent(i32* %3)
%29 = icmp eq i32 %24, 0
br i1 %29, label %30, label %33
30: ; preds = %12, %27
%31 = load i32, i32* @EINVAL
store i32 %31, i32* @errno
%32 = tail call i32 (i32, i32, i8*, i32, i8*, ...) @error_at_line(i32 %31, i32 %31, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.2, i64 0, i64 0), i32 81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %33
33: ; preds = %30, %27
ret i32 0
}