#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  size_t gl_pathc;
  size_t gl_offs;
  int /*<<< orphan*/ **gl_pathv;
};
typedef TYPE_1__ glob_t;

/* Variables and functions */
int /*<<< orphan*/ free(void *);
void globfree(glob_t *pglob) {
  if (pglob->gl_pathv != NULL) {
    size_t i;
    for (i = 0; i < pglob->gl_pathc; i++)
      if (pglob->gl_pathv[pglob->gl_offs + i] != NULL)
        free((void *)pglob->gl_pathv[pglob->gl_offs + i]);
    free((void *)pglob->gl_pathv);
  }
}


x86 assembly (clang, -O0):
<globfree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     11a3 <globfree+0x93>
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%rax
jae    1196 <globfree+0x86>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%rcx
add    -0x10(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1180 <globfree+0x70>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%rcx
add    -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
jmp    1185 <globfree+0x75>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1133 <globfree+0x23>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<globfree>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x10(%rdi),%rdi
test   %rdi,%rdi
je     1158 <globfree+0x48>
mov    (%r14),%rax
test   %rax,%rax
je     1164 <globfree+0x54>
mov    $0x1,%ebx
nopl   (%rax)
mov    0x8(%r14),%rcx
add    %rbx,%rcx
mov    -0x8(%rdi,%rcx,8),%rdi
test   %rdi,%rdi
je     1149 <globfree+0x39>
call   1030 <free@plt>
mov    (%r14),%rax
cmp    %rax,%rbx
jae    1160 <globfree+0x50>
mov    0x10(%r14),%rdi
add    $0x1,%rbx
jmp    1130 <globfree+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x10(%r14),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

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

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i64, i32** }
define void @globfree(%struct.TYPE_3__* nocapture %0) {
%2 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 2
%3 = load i32**, i32*** %2
%4 = icmp eq i32** %3, null
br i1 %4, label %37, label %5
5: ; preds = %1
%6 = bitcast i32** %3 to i8*
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%8 = load i64, i64* %7
%9 = icmp eq i64 %8, 0
br i1 %9, label %34, label %10
10: ; preds = %5
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
br label %12
12: ; preds = %29, %10
%13 = phi i64 [ %8, %10 ], [ %26, %29 ]
%14 = phi i32** [ %3, %10 ], [ %30, %29 ]
%15 = phi i64 [ 0, %10 ], [ %27, %29 ]
%16 = load i64, i64* %11
%17 = add i64 %16, %15
%18 = getelementptr inbounds i32*, i32** %14, i64 %17
%19 = load i32*, i32** %18
%20 = icmp eq i32* %19, null
br i1 %20, label %25, label %21
21: ; preds = %12
%22 = bitcast i32* %19 to i8*
%23 = tail call i32 @free(i8* %22)
%24 = load i64, i64* %7
br label %25
25: ; preds = %12, %21
%26 = phi i64 [ %13, %12 ], [ %24, %21 ]
%27 = add nuw i64 %15, 1
%28 = icmp ult i64 %27, %26
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = load i32**, i32*** %2
br label %12
31: ; preds = %25
%32 = bitcast i32*** %2 to i8**
%33 = load i8*, i8** %32
br label %34
34: ; preds = %5, %31
%35 = phi i8* [ %33, %31 ], [ %6, %5 ]
%36 = tail call i32 @free(i8* %35)
br label %37
37: ; preds = %34, %1
ret void
}