#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_4__ TYPE_1__;

/* Type definitions */
struct Parameters {
  int dummy;
};
struct TYPE_4__ {
  char **gl_pathv;
  int gl_pathc;
};
typedef TYPE_1__ glob_t;

/* Variables and functions */
int /*<<< orphan*/ GLOB_NOCHECK;
int /*<<< orphan*/ build_input_file_chain(char *, struct Parameters *);
int /*<<< orphan*/ glob(char *, int /*<<< orphan*/, int /*<<< orphan*/,
                        TYPE_1__ *);
int /*<<< orphan*/ globfree(TYPE_1__ *);
void glob_filenames(char *pPattern, struct Parameters *pParam) {
  glob_t globResults;
  char **ppFileNameVector;
  int i;
  glob(pPattern, GLOB_NOCHECK, 0, &globResults);
  ppFileNameVector = globResults.gl_pathv;
  for (i = 0; i < globResults.gl_pathc; i++) {
    build_input_file_chain(ppFileNameVector[i], pParam);
  }
  globfree(&globResults);
}


x86 assembly (clang, -O0):
<glob_filenames>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e95(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
lea    -0x20(%rbp),%rcx
call   1050 <glob@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1196 <glob_filenames+0x66>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <build_input_file_chain@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1167 <glob_filenames+0x37>
lea    -0x20(%rbp),%rdi
call   1030 <globfree@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glob_filenames>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    0x2e9d(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rcx
xor    %edx,%edx
call   1050 <glob@plt>
cmpl   $0x0,0x8(%rsp)
jle    117a <glob_filenames+0x4a>
mov    (%rsp),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r15,%rbx,8),%rdi
mov    %r14,%rsi
call   1040 <build_input_file_chain@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
cmp    %rax,%rbx
jl     1160 <glob_filenames+0x30>
mov    %rsp,%rdi
call   1030 <globfree@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.Parameters = type { i32 }
%struct.TYPE_4__ = type { i8**, i32 }
@GLOB_NOCHECK = global i32 0
define void @glob_filenames(i8* %0, %struct.Parameters* %1) {
%3 = alloca i8*
%4 = alloca %struct.Parameters*
%5 = alloca %struct.TYPE_4__
%6 = alloca i8**
%7 = alloca i32
store i8* %0, i8** %3
store %struct.Parameters* %1, %struct.Parameters** %4
%8 = load i8*, i8** %3
%9 = load i32, i32* @GLOB_NOCHECK
%10 = call i32 @glob(i8* %8, i32 %9, i32 0, %struct.TYPE_4__* %5)
%11 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %5, i32 0, i32 0
%12 = load i8**, i8*** %11
store i8** %12, i8*** %6
store i32 0, i32* %7
br label %13
13: ; preds = %26, %2
%14 = load i32, i32* %7
%15 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %5, i32 0, i32 1
%16 = load i32, i32* %15
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %29
18: ; preds = %13
%19 = load i8**, i8*** %6
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = load %struct.Parameters*, %struct.Parameters** %4
%25 = call i32 @build_input_file_chain(i8* %23, %struct.Parameters* %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %13
29: ; preds = %13
%30 = call i32 @globfree(%struct.TYPE_4__* %5)
ret void
}

LLVM IR (-O2):
%struct.Parameters = type { i32 }
%struct.TYPE_4__ = type { i8**, i32 }
@GLOB_NOCHECK = global i32 0
define void @glob_filenames(i8* %0, %struct.Parameters* %1) {
%3 = alloca %struct.TYPE_4__
%4 = bitcast %struct.TYPE_4__* %3 to i8*
%5 = load i32, i32* @GLOB_NOCHECK
%6 = call i32 @glob(i8* %0, i32 %5, i32 0, %struct.TYPE_4__* %3)
%7 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i64 0, i32 0
%8 = load i8**, i8*** %7
%9 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i64 0, i32 1
%10 = load i32, i32* %9
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %2, %12
%13 = phi i64 [ %17, %12 ], [ 0, %2 ]
%14 = getelementptr inbounds i8*, i8** %8, i64 %13
%15 = load i8*, i8** %14
%16 = call i32 @build_input_file_chain(i8* %15, %struct.Parameters* %1)
%17 = add nuw nsw i64 %13, 1
%18 = load i32, i32* %9
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %12, label %21
21: ; preds = %12, %2
%22 = call i32 @globfree(%struct.TYPE_4__* %3)
ret void
}