#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 TYPE_4__ {
  int gl_pathc;
  int /*<<< orphan*/ *gl_pathv;
};
typedef TYPE_1__ glob_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int glob(char *, int /*<<< orphan*/, int /*<<< orphan*/ *, TYPE_1__ *);
int /*<<< orphan*/ globfree(TYPE_1__ *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(int /*<<< orphan*/);
int main() {
  glob_t globres;
  int err, i;
  err = glob("/etc/a*.conf", 0, NULL, &globres);
  if (err) {
    printf("errcode = %d\n", err);
    exit(1);
  }
  for (i = 0; i < globres.gl_pathc; i++)
    puts(globres.gl_pathv[i]);
  globfree(&globres);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x18(%rbp),%rcx
call   1060 <glob@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     119b <main+0x4b>
mov    -0x1c(%rbp),%esi
lea    0xe81(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11cc <main+0x7c>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <puts@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a2 <main+0x52>
lea    -0x18(%rbp),%rdi
call   1030 <globfree@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rdi
mov    %rsp,%rcx
xor    %esi,%esi
xor    %edx,%edx
call   1060 <glob@plt>
test   %eax,%eax
jne    11a9 <main+0x59>
cmpl   $0x0,(%rsp)
jle    119a <main+0x4a>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rsp),%rax
mov    (%rax,%rbx,4),%edi
call   1040 <puts@plt>
add    $0x1,%rbx
movslq (%rsp),%rax
cmp    %rax,%rbx
jl     1180 <main+0x30>
mov    %rsp,%rdi
call   1030 <globfree@plt>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xe5d(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32, i32* }
@.str = [13 x i8] c"/etc/a*.conf\00"
@.str.1 = [14 x i8] c"errcode = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.TYPE_4__
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @glob(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 0, i32* null, %struct.TYPE_4__* %2)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = load i32, i32* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
store i32 0, i32* %4
br label %13
13: ; preds = %26, %12
%14 = load i32, i32* %4
%15 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %2, i32 0, i32 0
%16 = load i32, i32* %15
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %29
18: ; preds = %13
%19 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %2, i32 0, i32 1
%20 = load i32*, i32** %19
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = load i32, i32* %23
%25 = call i32 @puts(i32 %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %13
29: ; preds = %13
%30 = call i32 @globfree(%struct.TYPE_4__* %2)
%31 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32, i32* }
@.str = [13 x i8] c"/etc/a*.conf\00"
@.str.1 = [14 x i8] c"errcode = %d\0A\00"
define i32 @main() {
%1 = alloca %struct.TYPE_4__
%2 = bitcast %struct.TYPE_4__* %1 to i8*
%3 = call i32 @glob(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 0, i32* null, %struct.TYPE_4__* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %11
5: ; preds = %0
%6 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 0
%7 = load i32, i32* %6
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %5
%10 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 1
br label %14
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %9, %14
%15 = phi i64 [ 0, %9 ], [ %20, %14 ]
%16 = load i32*, i32** %10
%17 = getelementptr inbounds i32, i32* %16, i64 %15
%18 = load i32, i32* %17
%19 = call i32 @puts(i32 %18)
%20 = add nuw nsw i64 %15, 1
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %14, label %24
24: ; preds = %14, %5
%25 = call i32 @globfree(%struct.TYPE_4__* %1)
%26 = call i32 @exit(i32 0)
unreachable
}