#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__ {
  char **gl_pathv;
};
typedef TYPE_1__ glob_t;

/* Variables and functions */
int EXIT_FAILURE;
#define GLOB_ABORTED 130
int GLOB_APPEND;
int GLOB_NOCHECK;
#define GLOB_NOMATCH 129
#define GLOB_NOSPACE 128
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int glob(char *, int, int /*<<< orphan*/ *, TYPE_1__ *);
int /*<<< orphan*/ stderr;
scalar_t__ strchr(char *, char);
int main(int argc, char **argv) {
  int i;
  glob_t g;
  if (argc < 2) {
    fprintf(stderr, "glob: invoked with no arguments\n");
    return EXIT_FAILURE;
  }
  for (i = 1; i < argc; i++)
    switch (glob(argv[i],
                 (i - 1 ? GLOB_APPEND : 0) |
                     (strchr(argv[i], '*') ? 0 : GLOB_NOCHECK),
                 NULL, &g)) {
    case GLOB_NOSPACE:
      fprintf(stderr, "glob: running out of memory\n");
    case GLOB_ABORTED:
      fprintf(stderr, "glob: read error\n");
    case GLOB_NOMATCH:
      fprintf(stderr, "glob: no matches\n");
      return EXIT_FAILURE;
    }
  if (!g.gl_pathv[0]) {
    fprintf(stderr, "glob: NULL\n");
    return EXIT_FAILURE;
  }
  execvp(g.gl_pathv[0], g.gl_pathv);
  fprintf(stderr, "glob: could not execute %s\n", g.gl_pathv[0]);
  return EXIT_FAILURE;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1188 <main+0x48>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    133e <main+0x1fe>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12ce <main+0x18e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cmp    $0x0,%eax
je     11cb <main+0x8b>
mov    0x2e17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    11d5 <main+0x95>
xor    %eax,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d5 <main+0x95>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x2a,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     1205 <main+0xc5>
xor    %eax,%eax
mov    %eax,-0x34(%rbp)
jmp    1211 <main+0xd1>
mov    0x2dc4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%eax
or     %eax,%esi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x20(%rbp),%rcx
call   1060 <glob@plt>
mov    %eax,%ecx
mov    %ecx,-0x38(%rbp)
sub    $0x80,%eax
je     1265 <main+0x125>
jmp    123f <main+0xff>
mov    -0x38(%rbp),%eax
sub    $0x81,%eax
je     1293 <main+0x153>
jmp    1252 <main+0x112>
mov    -0x38(%rbp),%eax
sub    $0x82,%eax
je     127c <main+0x13c>
jmp    12bb <main+0x17b>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
lea    0xdac(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
lea    0xdb2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
lea    0xdad(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    133e <main+0x1fe>
jmp    12c0 <main+0x180>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118f <main+0x4f>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1304 <main+0x1c4>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
lea    0xd76(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2cce(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    133e <main+0x1fe>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <execvp@plt>
mov    0x2cc5(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    0xd43(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2c8f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jge    1165 <main+0x25>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
jmp    1258 <main+0x118>
mov    %rsi,%r15
mov    %edi,%r12d
add    $0xffffffffffffffff,%r12
xor    %ebx,%ebx
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x0,%ebp
test   %rbx,%rbx
je     1193 <main+0x53>
mov    0x2e47(%rip),%rax
mov    (%rax),%ebp
mov    0x8(%r15,%rbx,8),%r13
mov    %r13,%rdi
mov    $0x2a,%esi
call   1030 <strchr@plt>
mov    $0x0,%esi
test   %rax,%rax
jne    11b8 <main+0x78>
mov    0x2e1a(%rip),%rax
mov    (%rax),%esi
or     %ebp,%esi
mov    %r13,%rdi
xor    %edx,%edx
mov    %r14,%rcx
call   1060 <glob@plt>
cmp    $0x82,%eax
je     1231 <main+0xf1>
cmp    $0x81,%eax
je     1248 <main+0x108>
cmp    $0x80,%eax
je     121a <main+0xda>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1180 <main+0x40>
mov    (%rsp),%rsi
mov    (%rsi),%rdi
test   %rdi,%rdi
je     1277 <main+0x137>
call   1050 <execvp@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rax
mov    (%rax),%rdx
lea    0xe5d(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    125f <main+0x11f>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
lea    0xdf7(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xdfd(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
lea    0xdf8(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0xddb(%rip),%rsi
jmp    1258 <main+0x118>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i8** }
@stderr = global i32 0
@.str = [33 x i8] c"glob: invoked with no arguments\0A\00"
@EXIT_FAILURE = global i32 0
@GLOB_APPEND = global i32 0
@GLOB_NOCHECK = global i32 0
@.str.1 = [29 x i8] c"glob: running out of memory\0A\00"
@.str.2 = [18 x i8] c"glob: read error\0A\00"
@.str.3 = [18 x i8] c"glob: no matches\0A\00"
@.str.4 = [12 x i8] c"glob: NULL\0A\00"
@.str.5 = [28 x i8] c"glob: could not execute %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.TYPE_3__
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %3
br label %86
14: ; preds = %2
store i32 1, i32* %6
br label %15
15: ; preds = %58, %14
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %61
19: ; preds = %15
%20 = load i8**, i8*** %5
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = load i32, i32* %6
%26 = sub nsw i32 %25, 1
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %19
%29 = load i32, i32* @GLOB_APPEND
br label %31
30: ; preds = %19
br label %31
31: ; preds = %30, %28
%32 = phi i32 [ %29, %28 ], [ 0, %30 ]
%33 = load i8**, i8*** %5
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = call i64 @strchr(i8* %37, i8 signext 42)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %31
br label %43
41: ; preds = %31
%42 = load i32, i32* @GLOB_NOCHECK
br label %43
43: ; preds = %41, %40
%44 = phi i32 [ 0, %40 ], [ %42, %41 ]
%45 = or i32 %32, %44
%46 = call i32 @glob(i8* %24, i32 %45, i32* null, %struct.TYPE_3__* %7)
switch i32 %46, label %57 [
i32 128, label %47
i32 130, label %50
i32 129, label %53
]
47: ; preds = %43
%48 = load i32, i32* @stderr
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %50
50: ; preds = %43, %47
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %53
53: ; preds = %43, %50
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%56 = load i32, i32* @EXIT_FAILURE
store i32 %56, i32* %3
br label %86
57: ; preds = %43
br label %58
58: ; preds = %57
%59 = load i32, i32* %6
%60 = add nsw i32 %59, 1
store i32 %60, i32* %6
br label %15
61: ; preds = %15
%62 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 0
%63 = load i8**, i8*** %62
%64 = getelementptr inbounds i8*, i8** %63, i64 0
%65 = load i8*, i8** %64
%66 = icmp ne i8* %65, null
br i1 %66, label %71, label %67
67: ; preds = %61
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%70 = load i32, i32* @EXIT_FAILURE
store i32 %70, i32* %3
br label %86
71: ; preds = %61
%72 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 0
%73 = load i8**, i8*** %72
%74 = getelementptr inbounds i8*, i8** %73, i64 0
%75 = load i8*, i8** %74
%76 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 0
%77 = load i8**, i8*** %76
%78 = call i32 @execvp(i8* %75, i8** %77)
%79 = load i32, i32* @stderr
%80 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 0
%81 = load i8**, i8*** %80
%82 = getelementptr inbounds i8*, i8** %81, i64 0
%83 = load i8*, i8** %82
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %83)
%85 = load i32, i32* @EXIT_FAILURE
store i32 %85, i32* %3
br label %86
86: ; preds = %71, %67, %53, %10
%87 = load i32, i32* %3
ret i32 %87
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i8** }
@stderr = global i32 0
@.str = [33 x i8] c"glob: invoked with no arguments\0A\00"
@EXIT_FAILURE = global i32 0
@GLOB_APPEND = global i32 0
@GLOB_NOCHECK = global i32 0
@.str.1 = [29 x i8] c"glob: running out of memory\0A\00"
@.str.2 = [18 x i8] c"glob: read error\0A\00"
@.str.3 = [18 x i8] c"glob: no matches\0A\00"
@.str.4 = [12 x i8] c"glob: NULL\0A\00"
@.str.5 = [28 x i8] c"glob: could not execute %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.TYPE_3__
%4 = bitcast %struct.TYPE_3__* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %11
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %51
11: ; preds = %6, %33
%12 = phi i64 [ 1, %6 ], [ %34, %33 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = icmp eq i64 %12, 1
%16 = load i32, i32* @GLOB_APPEND
%17 = select i1 %15, i32 0, i32 %16
%18 = call i64 @strchr(i8* %14, i8 signext 42)
%19 = icmp eq i64 %18, 0
%20 = load i32, i32* @GLOB_NOCHECK
%21 = select i1 %19, i32 %20, i32 0
%22 = or i32 %21, %17
%23 = call i32 @glob(i8* %14, i32 %22, i32* null, %struct.TYPE_3__* %3)
switch i32 %23, label %33 [
i32 128, label %24
i32 130, label %27
i32 129, label %30
]
24: ; preds = %11
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %11, %24
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %11, %27
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %51
33: ; preds = %11
%34 = add nuw nsw i64 %12, 1
%35 = icmp eq i64 %34, %7
br i1 %35, label %36, label %11
36: ; preds = %33
%37 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 0
%38 = load i8**, i8*** %37
%39 = load i8*, i8** %38
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = load i32, i32* @stderr
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %51
44: ; preds = %36
%45 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 0
%46 = call i32 @execvp(i8* %39, i8** %38)
%47 = load i32, i32* @stderr
%48 = load i8**, i8*** %45
%49 = load i8*, i8** %48
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %44, %41, %30, %8
%52 = load i32, i32* @EXIT_FAILURE
ret i32 %52
}