#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 {
  struct mntent *mnt_opts;
  struct mntent *mnt_type;
  struct mntent *mnt_dir;
  struct mntent *mnt_fsname;
};

/* Variables and functions */
int /*<<< orphan*/ free(struct mntent *);
void free_mntent_array(struct mntent *entries, size_t num_entries) {
  if (entries != NULL) {
    for (size_t i = 0; i < num_entries; ++i) {
      struct mntent *me = entries + i;
      free(me->mnt_fsname);
      free(me->mnt_dir);
      free(me->mnt_type);
      free(me->mnt_opts);
    }
    free(entries);
  }
}


x86 assembly (clang, -O0):
<free_mntent_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11a1 <free_mntent_array+0x91>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1198 <free_mntent_array+0x88>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1133 <free_mntent_array+0x23>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_mntent_array>:
test   %rdi,%rdi
je     116a <free_mntent_array+0x5a>
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
test   %rsi,%rsi
je     115d <free_mntent_array+0x4d>
lea    0x18(%r14),%rbx
nopl   0x0(%rax)
mov    (%rbx),%rdi
call   1030 <free@plt>
mov    -0x8(%rbx),%rdi
call   1030 <free@plt>
mov    -0x10(%rbx),%rdi
call   1030 <free@plt>
mov    -0x18(%rbx),%rdi
call   1030 <free@plt>
add    $0x20,%rbx
add    $0xffffffffffffffff,%r15
jne    1130 <free_mntent_array+0x20>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>
ret

LLVM IR (-O0):
%struct.mntent = type { %struct.mntent*, %struct.mntent*, %struct.mntent*, %struct.mntent* }
define void @free_mntent_array(%struct.mntent* %0, i64 %1) {
%3 = alloca %struct.mntent*
%4 = alloca i64
%5 = alloca i64
%6 = alloca %struct.mntent*
store %struct.mntent* %0, %struct.mntent** %3
store i64 %1, i64* %4
%7 = load %struct.mntent*, %struct.mntent** %3
%8 = icmp ne %struct.mntent* %7, null
br i1 %8, label %9, label %40
9: ; preds = %2
store i64 0, i64* %5
br label %10
10: ; preds = %34, %9
%11 = load i64, i64* %5
%12 = load i64, i64* %4
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %37
14: ; preds = %10
%15 = load %struct.mntent*, %struct.mntent** %3
%16 = load i64, i64* %5
%17 = getelementptr inbounds %struct.mntent, %struct.mntent* %15, i64 %16
store %struct.mntent* %17, %struct.mntent** %6
%18 = load %struct.mntent*, %struct.mntent** %6
%19 = getelementptr inbounds %struct.mntent, %struct.mntent* %18, i32 0, i32 3
%20 = load %struct.mntent*, %struct.mntent** %19
%21 = call i32 @free(%struct.mntent* %20)
%22 = load %struct.mntent*, %struct.mntent** %6
%23 = getelementptr inbounds %struct.mntent, %struct.mntent* %22, i32 0, i32 2
%24 = load %struct.mntent*, %struct.mntent** %23
%25 = call i32 @free(%struct.mntent* %24)
%26 = load %struct.mntent*, %struct.mntent** %6
%27 = getelementptr inbounds %struct.mntent, %struct.mntent* %26, i32 0, i32 1
%28 = load %struct.mntent*, %struct.mntent** %27
%29 = call i32 @free(%struct.mntent* %28)
%30 = load %struct.mntent*, %struct.mntent** %6
%31 = getelementptr inbounds %struct.mntent, %struct.mntent* %30, i32 0, i32 0
%32 = load %struct.mntent*, %struct.mntent** %31
%33 = call i32 @free(%struct.mntent* %32)
br label %34
34: ; preds = %14
%35 = load i64, i64* %5
%36 = add i64 %35, 1
store i64 %36, i64* %5
br label %10
37: ; preds = %10
%38 = load %struct.mntent*, %struct.mntent** %3
%39 = call i32 @free(%struct.mntent* %38)
br label %40
40: ; preds = %37, %2
ret void
}

LLVM IR (-O2):
%struct.mntent = type { %struct.mntent*, %struct.mntent*, %struct.mntent*, %struct.mntent* }
define void @free_mntent_array(%struct.mntent* %0, i64 %1) {
%3 = icmp eq %struct.mntent* %0, null
br i1 %3, label %24, label %4
4: ; preds = %2
%5 = icmp eq i64 %1, 0
br i1 %5, label %6, label %8
6: ; preds = %8, %4
%7 = tail call i32 @free(%struct.mntent* %0)
br label %24
8: ; preds = %4, %8
%9 = phi i64 [ %22, %8 ], [ 0, %4 ]
%10 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 %9, i32 3
%11 = load %struct.mntent*, %struct.mntent** %10
%12 = tail call i32 @free(%struct.mntent* %11)
%13 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 %9, i32 2
%14 = load %struct.mntent*, %struct.mntent** %13
%15 = tail call i32 @free(%struct.mntent* %14)
%16 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 %9, i32 1
%17 = load %struct.mntent*, %struct.mntent** %16
%18 = tail call i32 @free(%struct.mntent* %17)
%19 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 %9, i32 0
%20 = load %struct.mntent*, %struct.mntent** %19
%21 = tail call i32 @free(%struct.mntent* %20)
%22 = add nuw i64 %9, 1
%23 = icmp eq i64 %22, %1
br i1 %23, label %6, label %8
24: ; preds = %6, %2
ret void
}