#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 we_wordc;
  char **we_wordv;
};
typedef TYPE_1__ wordexp_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ wordexp(char *, TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ wordfree(TYPE_1__ *);
int main(int argc, char *argv[]) {
  wordexp_t we;
  wordexp("../mnemo/*.c ~/surf", &we, 0);
  for (int i = 0; i < we.we_wordc; i++) {
    printf("%d - %s\n", i, we.we_wordv[i]);
  }
  wordfree(&we);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1050 <wordexp@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1194 <main+0x64>
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115f <main+0x2f>
lea    -0x20(%rbp),%rdi
call   1040 <wordfree@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xec2(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1050 <wordexp@plt>
cmpl   $0x0,0x8(%rsp)
jle    1181 <main+0x51>
xor    %ebx,%ebx
lea    0xeba(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rax
mov    (%rax,%rbx,8),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
cmp    %rax,%rbx
jl     1160 <main+0x30>
lea    0x8(%rsp),%rdi
call   1040 <wordfree@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32, i8** }
@.str = [20 x i8] c"../mnemo/*.c ~/surf\00"
@.str.1 = [9 x i8] c"%d - %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.TYPE_4__
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @wordexp(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), %struct.TYPE_4__* %6, i32 0)
store i32 0, i32* %7
br label %9
9: ; preds = %23, %2
%10 = load i32, i32* %7
%11 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %6, i32 0, i32 0
%12 = load i32, i32* %11
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %26
14: ; preds = %9
%15 = load i32, i32* %7
%16 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %6, i32 0, i32 1
%17 = load i8**, i8*** %16
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8* %21)
br label %23
23: ; preds = %14
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %9
26: ; preds = %9
%27 = call i32 @wordfree(%struct.TYPE_4__* %6)
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32, i8** }
@.str = [20 x i8] c"../mnemo/*.c ~/surf\00"
@.str.1 = [9 x i8] c"%d - %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.TYPE_4__
%4 = bitcast %struct.TYPE_4__* %3 to i8*
%5 = call i32 @wordexp(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), %struct.TYPE_4__* %3, i32 0)
%6 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i64 0, i32 0
%7 = load i32, i32* %6
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i64 0, i32 1
br label %13
11: ; preds = %13, %2
%12 = call i32 @wordfree(%struct.TYPE_4__* %3)
ret i32 0
13: ; preds = %9, %13
%14 = phi i64 [ 0, %9 ], [ %20, %13 ]
%15 = load i8**, i8*** %10
%16 = getelementptr inbounds i8*, i8** %15, i64 %14
%17 = load i8*, i8** %16
%18 = trunc i64 %14 to i32
%19 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %18, i8* %17)
%20 = add nuw nsw i64 %14, 1
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %13, label %11
}