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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ wordexp(char const *, TYPE_1__ *, int);
int /*<<< orphan*/ wordfree(TYPE_1__ *);
void test(const char *s, int flags) {
  wordexp_t p;
  size_t i;
  wordexp(s, &p, flags);
  printf("%s ->\n", s);
  for (i = 0; i < p.we_wordc; i++) {
    printf("\t%s\n", p.we_wordv[i]);
  }
  wordfree(&p);
  printf("\n");
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    -0x20(%rbp),%rsi
call   1050 <wordexp@plt>
mov    -0x8(%rbp),%rsi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11a2 <test+0x72>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1169 <test+0x39>
lea    -0x20(%rbp),%rdi
call   1040 <wordfree@plt>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%edx
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1060 <wordexp@plt>
lea    0xea3(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmpq   $0x0,0x8(%rsp)
je     119e <test+0x5e>
lea    0xe91(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rax
mov    (%rax,%rbx,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    0x8(%rsp),%rbx
jb     1180 <test+0x40>
lea    0x8(%rsp),%rdi
call   1050 <wordfree@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.TYPE_4__ = type { i64, i8** }
@.str = [7 x i8] c"%s ->\0A\00"
@.str.1 = [5 x i8] c"\09%s\0A\00"
define void @test(i8* %0, i32 %1) {
%3 = alloca %struct.TYPE_4__
%4 = bitcast %struct.TYPE_4__* %3 to i8*
%5 = call i32 @wordexp(i8* %0, %struct.TYPE_4__* %3, i32 %1)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i64 0, i32 0
%8 = load i64, i64* %7
%9 = icmp eq i64 %8, 0
br i1 %9, label %21, label %10
10: ; preds = %2
%11 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i64 0, i32 1
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %18, %12 ]
%14 = load i8**, i8*** %11
%15 = getelementptr inbounds i8*, i8** %14, i64 %13
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = add nuw i64 %13, 1
%19 = load i64, i64* %7
%20 = icmp ult i64 %18, %19
br i1 %20, label %12, label %21
21: ; preds = %12, %2
%22 = call i32 @wordfree(%struct.TYPE_4__* %3)
%23 = call i32 @putchar(i32 10)
ret void
}