#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*/ a;
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_r(int /*<<< orphan*/ *, struct mntent *, char *, int);
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, e;
  FILE *fp;
  char a[4096 + 1024];
  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/Lax/aufs-util/refs/heads/aufs3.2/proc_mnt.c",
        79, "/proc/self/mounts");
  memset(rent, 0, sizeof(*rent));
  found = 0;
  while ((p = getmntent_r(fp, &e, a, sizeof(a))))
    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/Lax/aufs-util/refs/heads/aufs3.2/proc_mnt.c",
        96, "%s", mntpnt);
  }
  return 0;
}


x86 assembly (clang, -O0):
<au_proc_getmntent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe76(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1090 <setmntent@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11d1 <au_proc_getmntent+0x61>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
lea    0xe56(%rip),%rdx
mov    $0x4f,%ecx
lea    0xe36(%rip),%r8
mov    $0x0,%al
call   1040 <error_at_line@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1070 <memset@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x30(%rbp),%rdi
lea    -0x1430(%rbp),%rdx
lea    -0x28(%rbp),%rsi
mov    $0x1400,%ecx
call   1050 <getmntent_r@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     124a <au_proc_getmntent+0xda>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1245 <au_proc_getmntent+0xd5>
jmp    122c <au_proc_getmntent+0xbc>
jmp    1231 <au_proc_getmntent+0xc1>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <copy_ent@plt>
movl   $0x1,-0x14(%rbp)
jmp    11e8 <au_proc_getmntent+0x78>
mov    -0x30(%rbp),%rdi
call   1030 <endmntent@plt>
cmpl   $0x0,-0x14(%rbp)
jne    129f <au_proc_getmntent+0x12f>
mov    0x2d74(%rip),%rax
mov    (%rax),%ecx
mov    0x2d73(%rip),%rax
mov    %ecx,(%rax)
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
mov    0x2d61(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%r9
lea    0xd88(%rip),%rdx
mov    $0x60,%ecx
lea    0xe02(%rip),%r8
mov    $0x0,%al
call   1040 <error_at_line@plt>
xor    %eax,%eax
add    $0x1430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<au_proc_getmntent>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1418,%rsp
mov    %rsi,%r12
mov    %rdi,%r15
lea    0xe72(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1090 <setmntent@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11c7 <au_proc_getmntent+0x57>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%rip),%rdx
lea    0xe47(%rip),%r8
mov    %edi,%esi
mov    $0x4f,%ecx
xor    %eax,%eax
call   1040 <error_at_line@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1070 <memset@plt>
mov    %rsp,%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x1400,%ecx
call   1050 <getmntent_r@plt>
test   %rax,%rax
je     125e <au_proc_getmntent+0xee>
mov    %rax,%rbp
xor    %r14d,%r14d
mov    %r12,0x8(%rsp)
mov    %rsp,%r12
lea    0x10(%rsp),%r13
jmp    122b <au_proc_getmntent+0xbb>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    $0x1400,%ecx
call   1050 <getmntent_r@plt>
mov    %rax,%rbp
test   %rax,%rax
je     124f <au_proc_getmntent+0xdf>
mov    0x0(%rbp),%edi
mov    %r15,%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
jne    1210 <au_proc_getmntent+0xa0>
mov    0x8(%rsp),%rdi
mov    %rbp,%rsi
call   1060 <copy_ent@plt>
mov    $0x1,%r14d
jmp    1210 <au_proc_getmntent+0xa0>
mov    %rbx,%rdi
call   1030 <endmntent@plt>
test   %r14d,%r14d
jne    1297 <au_proc_getmntent+0x127>
jmp    1266 <au_proc_getmntent+0xf6>
mov    %rbx,%rdi
call   1030 <endmntent@plt>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
mov    0x2d6a(%rip),%rax
mov    %edi,(%rax)
lea    0xd95(%rip),%rdx
lea    0xe14(%rip),%r8
mov    %edi,%esi
mov    $0x60,%ecx
mov    %r15,%r9
xor    %eax,%eax
call   1040 <error_at_line@plt>
xor    %eax,%eax
add    $0x1418,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 = [134 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Lax/aufs-util/refs/heads/aufs3.2/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 %struct.mntent
%8 = alloca i32*
%9 = alloca [5120 x i8]
store i8* %0, i8** %3
store %struct.mntent* %1, %struct.mntent** %4
%10 = 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* %10, i32** %8
%11 = load i32*, i32** %8
%12 = icmp ne i32* %11, null
br i1 %12, label %17, label %13
13: ; preds = %2
%14 = load i32, i32* @errno
%15 = load i32, i32* @errno
%16 = call i32 (i32, i32, i8*, i32, i8*, ...) @error_at_line(i32 %14, i32 %15, i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.2, i64 0, i64 0), i32 79, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %13, %2
%18 = load %struct.mntent*, %struct.mntent** %4
%19 = call i32 @memset(%struct.mntent* %18, i32 0, i32 4)
store i32 0, i32* %5
br label %20
20: ; preds = %38, %17
%21 = load i32*, i32** %8
%22 = getelementptr inbounds [5120 x i8], [5120 x i8]* %9, i64 0, i64 0
%23 = call %struct.mntent* @getmntent_r(i32* %21, %struct.mntent* %7, i8* %22, i32 5120)
store %struct.mntent* %23, %struct.mntent** %6
%24 = icmp ne %struct.mntent* %23, null
br i1 %24, label %25, label %39
25: ; preds = %20
%26 = load %struct.mntent*, %struct.mntent** %6
%27 = getelementptr inbounds %struct.mntent, %struct.mntent* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = load i8*, i8** %3
%30 = call i32 @strcmp(i32 %28, i8* %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %38, label %32
32: ; preds = %25
br label %33
33: ; preds = %32
br label %34
34: ; preds = %33
%35 = load %struct.mntent*, %struct.mntent** %4
%36 = load %struct.mntent*, %struct.mntent** %6
%37 = call i32 @copy_ent(%struct.mntent* %35, %struct.mntent* %36)
store i32 1, i32* %5
br label %38
38: ; preds = %34, %25
br label %20
39: ; preds = %20
%40 = load i32*, i32** %8
%41 = call i32 @endmntent(i32* %40)
%42 = load i32, i32* %5
%43 = icmp ne i32 %42, 0
br i1 %43, label %50, label %44
44: ; preds = %39
%45 = load i32, i32* @EINVAL
store i32 %45, i32* @errno
%46 = load i32, i32* @errno
%47 = load i32, i32* @errno
%48 = load i8*, i8** %3
%49 = call i32 (i32, i32, i8*, i32, i8*, ...) @error_at_line(i32 %46, i32 %47, i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.2, i64 0, i64 0), i32 96, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %44, %39
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 = [134 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Lax/aufs-util/refs/heads/aufs3.2/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 %struct.mntent
%4 = alloca [5120 x i8]
%5 = bitcast %struct.mntent* %3 to i8*
%6 = getelementptr inbounds [5120 x i8], [5120 x i8]* %4, i64 0, i64 0
%7 = 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))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @errno
%11 = tail call i32 (i32, i32, i8*, i32, i8*, ...) @error_at_line(i32 %10, i32 %10, i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.2, i64 0, i64 0), i32 79, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %9, %2
%13 = tail call i32 @memset(%struct.mntent* %1, i32 0, i32 4)
%14 = call %struct.mntent* @getmntent_r(i32* %7, %struct.mntent* %3, i8* %6, i32 5120)
%15 = icmp eq %struct.mntent* %14, null
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @endmntent(i32* %7)
br label %34
18: ; preds = %12, %27
%19 = phi %struct.mntent* [ %29, %27 ], [ %14, %12 ]
%20 = phi i32 [ %28, %27 ], [ 0, %12 ]
%21 = getelementptr inbounds %struct.mntent, %struct.mntent* %19, i64 0, i32 0
%22 = load i32, i32* %21
%23 = call i32 @strcmp(i32 %22, i8* %0)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %18
%26 = call i32 @copy_ent(%struct.mntent* %1, %struct.mntent* %19)
br label %27
27: ; preds = %25, %18
%28 = phi i32 [ %20, %18 ], [ 1, %25 ]
%29 = call %struct.mntent* @getmntent_r(i32* %7, %struct.mntent* %3, i8* %6, i32 5120)
%30 = icmp eq %struct.mntent* %29, null
br i1 %30, label %31, label %18
31: ; preds = %27
%32 = call i32 @endmntent(i32* %7)
%33 = icmp eq i32 %28, 0
br i1 %33, label %34, label %37
34: ; preds = %16, %31
%35 = load i32, i32* @EINVAL
store i32 %35, i32* @errno
%36 = call i32 (i32, i32, i8*, i32, i8*, ...) @error_at_line(i32 %35, i32 %35, i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.2, i64 0, i64 0), i32 96, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %37
37: ; preds = %34, %31
ret i32 0
}