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

/* Variables and functions */
char *flagstr(int);
int /*<<< orphan*/ printf(char *, char const *, char const *);
int /*<<< orphan*/ puts(char *);
scalar_t__ strcmp(char const *, char const *);
int test_result(const char *fmt, int flags, glob_t *gl, const char *str[]) {
  size_t cnt;
  int result = 0;
  printf("results for glob (\"%s\", %s)\n", fmt, flagstr(flags));
  for (cnt = 0; cnt < gl->gl_pathc && str[cnt] != NULL; ++cnt) {
    int ok = strcmp(gl->gl_pathv[cnt], str[cnt]) == 0;
    const char *errstr = "";
    if (!ok) {
      size_t inner;
      for (inner = 0; str[inner] != NULL; ++inner)
        if (strcmp(gl->gl_pathv[cnt], str[inner]) == 0)
          break;
      if (str[inner] == NULL)
        errstr = ok ? "" : " *** WRONG";
      else
        errstr = ok ? "" : " * wrong position";
      result = 1;
    }
    printf("  %s%s\n", gl->gl_pathv[cnt], errstr);
  }
  puts("");
  if (str[cnt] != NULL || cnt < gl->gl_pathc) {
    puts("  *** incorrect number of entries");
    result = 1;
  }
  return result;
}


x86 assembly (clang, -O0):
<test_result>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <flagstr@plt>
mov    -0x48(%rbp),%rsi
mov    %rax,%rdx
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rdx
xor    %eax,%eax
cmp    (%rdx),%rcx
mov    %al,-0x49(%rbp)
jae    11b2 <test_result+0x72>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
setne  %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
test   $0x1,%al
jne    11c2 <test_result+0x82>
jmp    12f0 <test_result+0x1b0>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x30(%rbp)
lea    0xe23(%rip),%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x0,-0x30(%rbp)
jne    12bf <test_result+0x17f>
movq   $0x0,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x40(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1268 <test_result+0x128>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1252 <test_result+0x112>
jmp    1268 <test_result+0x128>
jmp    1257 <test_result+0x117>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    120f <test_result+0xcf>
mov    -0x20(%rbp),%rax
mov    -0x40(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    129c <test_result+0x15c>
mov    -0x30(%rbp),%edx
lea    0xd98(%rip),%rax
lea    0xd90(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x38(%rbp)
jmp    12b8 <test_result+0x178>
mov    -0x30(%rbp),%edx
lea    0xd82(%rip),%rax
lea    0xd6f(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x38(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x38(%rbp),%rdx
lea    0xd60(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1189 <test_result+0x49>
lea    0xd25(%rip),%rdi
call   1030 <puts@plt>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1320 <test_result+0x1e0>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
jae    1333 <test_result+0x1f3>
lea    0xd1b(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_result>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r13
mov    %rdi,%r15
mov    %esi,%edi
call   1060 <flagstr@plt>
lea    0xe8e(%rip),%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1050 <printf@plt>
cmpq   $0x0,0x0(%r13)
je     124f <test_result+0xff>
lea    0x8(%r14),%rax
mov    %rax,(%rsp)
xor    %ebx,%ebx
lea    0xe83(%rip),%rbp
lea    0xe9a(%rip),%r15
xor    %r12d,%r12d
jmp    11e7 <test_result+0x97>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
test   %rax,%rax
lea    0xe6c(%rip),%rdx
lea    0xe5a(%rip),%rax
cmove  %rax,%rdx
mov    $0x1,%r12d
mov    0x8(%r13),%rax
mov    (%rax,%rbx,8),%rsi
mov    %r15,%rdi
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    0x0(%r13),%rbx
jae    1254 <test_result+0x104>
mov    (%r14,%rbx,8),%rsi
test   %rsi,%rsi
je     1254 <test_result+0x104>
mov    0x8(%r13),%rax
mov    (%rax,%rbx,8),%rdi
call   1070 <strcmp@plt>
mov    %rbp,%rdx
test   %rax,%rax
je     11cd <test_result+0x7d>
mov    (%r14),%rsi
test   %rsi,%rsi
je     11b0 <test_result+0x60>
mov    %rbp,%r12
mov    (%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%r13),%rax
mov    (%rax,%rbx,8),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1243 <test_result+0xf3>
mov    0x0(%rbp),%rsi
add    $0x8,%rbp
test   %rsi,%rsi
jne    1220 <test_result+0xd0>
xor    %eax,%eax
jmp    1247 <test_result+0xf7>
mov    -0x8(%rbp),%rax
mov    %r12,%rbp
jmp    11b2 <test_result+0x62>
xor    %r12d,%r12d
xor    %ebx,%ebx
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpq   $0x0,(%r14,%rbx,8)
jne    126b <test_result+0x11b>
cmp    0x0(%r13),%rbx
jae    127d <test_result+0x12d>
lea    0xdd0(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i8** }
@.str = [29 x i8] c"results for glob (\22%s\22, %s)\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [11 x i8] c" *** WRONG\00"
@.str.3 = [18 x i8] c" * wrong position\00"
@.str.4 = [8 x i8] c" %s%s\0A\00"
@.str.5 = [34 x i8] c" *** incorrect number of entries\00"
define i32 @test_result(i8* %0, i32 %1, %struct.TYPE_3__* %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.TYPE_3__*
%8 = alloca i8**
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
store i8* %0, i8** %5
store i32 %1, i32* %6
store %struct.TYPE_3__* %2, %struct.TYPE_3__** %7
store i8** %3, i8*** %8
store i32 0, i32* %10
%14 = load i8*, i8** %5
%15 = load i32, i32* %6
%16 = call i8* @flagstr(i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %16)
store i64 0, i64* %9
br label %18
18: ; preds = %99, %4
%19 = load i64, i64* %9
%20 = load %struct.TYPE_3__*, %struct.TYPE_3__** %7
%21 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %20, i32 0, i32 0
%22 = load i64, i64* %21
%23 = icmp ult i64 %19, %22
br i1 %23, label %24, label %30
24: ; preds = %18
%25 = load i8**, i8*** %8
%26 = load i64, i64* %9
%27 = getelementptr inbounds i8*, i8** %25, i64 %26
%28 = load i8*, i8** %27
%29 = icmp ne i8* %28, null
br label %30
30: ; preds = %24, %18
%31 = phi i1 [ false, %18 ], [ %29, %24 ]
br i1 %31, label %32, label %102
32: ; preds = %30
%33 = load %struct.TYPE_3__*, %struct.TYPE_3__** %7
%34 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %33, i32 0, i32 1
%35 = load i8**, i8*** %34
%36 = load i64, i64* %9
%37 = getelementptr inbounds i8*, i8** %35, i64 %36
%38 = load i8*, i8** %37
%39 = load i8**, i8*** %8
%40 = load i64, i64* %9
%41 = getelementptr inbounds i8*, i8** %39, i64 %40
%42 = load i8*, i8** %41
%43 = call i64 @strcmp(i8* %38, i8* %42)
%44 = icmp eq i64 %43, 0
%45 = zext i1 %44 to i32
store i32 %45, i32* %11
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %12
%46 = load i32, i32* %11
%47 = icmp ne i32 %46, 0
br i1 %47, label %90, label %48
48: ; preds = %32
store i64 0, i64* %13
br label %49
49: ; preds = %70, %48
%50 = load i8**, i8*** %8
%51 = load i64, i64* %13
%52 = getelementptr inbounds i8*, i8** %50, i64 %51
%53 = load i8*, i8** %52
%54 = icmp ne i8* %53, null
br i1 %54, label %55, label %73
55: ; preds = %49
%56 = load %struct.TYPE_3__*, %struct.TYPE_3__** %7
%57 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %56, i32 0, i32 1
%58 = load i8**, i8*** %57
%59 = load i64, i64* %9
%60 = getelementptr inbounds i8*, i8** %58, i64 %59
%61 = load i8*, i8** %60
%62 = load i8**, i8*** %8
%63 = load i64, i64* %13
%64 = getelementptr inbounds i8*, i8** %62, i64 %63
%65 = load i8*, i8** %64
%66 = call i64 @strcmp(i8* %61, i8* %65)
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %69
68: ; preds = %55
br label %73
69: ; preds = %55
br label %70
70: ; preds = %69
%71 = load i64, i64* %13
%72 = add i64 %71, 1
store i64 %72, i64* %13
br label %49
73: ; preds = %68, %49
%74 = load i8**, i8*** %8
%75 = load i64, i64* %13
%76 = getelementptr inbounds i8*, i8** %74, i64 %75
%77 = load i8*, i8** %76
%78 = icmp eq i8* %77, null
br i1 %78, label %79, label %84
79: ; preds = %73
%80 = load i32, i32* %11
%81 = icmp ne i32 %80, 0
%82 = zext i1 %81 to i64
%83 = select i1 %81, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0)
store i8* %83, i8** %12
br label %89
84: ; preds = %73
%85 = load i32, i32* %11
%86 = icmp ne i32 %85, 0
%87 = zext i1 %86 to i64
%88 = select i1 %86, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0)
store i8* %88, i8** %12
br label %89
89: ; preds = %84, %79
store i32 1, i32* %10
br label %90
90: ; preds = %89, %32
%91 = load %struct.TYPE_3__*, %struct.TYPE_3__** %7
%92 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %91, i32 0, i32 1
%93 = load i8**, i8*** %92
%94 = load i64, i64* %9
%95 = getelementptr inbounds i8*, i8** %93, i64 %94
%96 = load i8*, i8** %95
%97 = load i8*, i8** %12
%98 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %96, i8* %97)
br label %99
99: ; preds = %90
%100 = load i64, i64* %9
%101 = add i64 %100, 1
store i64 %101, i64* %9
br label %18
102: ; preds = %30
%103 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%104 = load i8**, i8*** %8
%105 = load i64, i64* %9
%106 = getelementptr inbounds i8*, i8** %104, i64 %105
%107 = load i8*, i8** %106
%108 = icmp ne i8* %107, null
br i1 %108, label %115, label %109
109: ; preds = %102
%110 = load i64, i64* %9
%111 = load %struct.TYPE_3__*, %struct.TYPE_3__** %7
%112 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %111, i32 0, i32 0
%113 = load i64, i64* %112
%114 = icmp ult i64 %110, %113
br i1 %114, label %115, label %117
115: ; preds = %109, %102
%116 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %10
br label %117
117: ; preds = %115, %109
%118 = load i32, i32* %10
ret i32 %118
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i8** }
@.str = [29 x i8] c"results for glob (\22%s\22, %s)\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [11 x i8] c" *** WRONG\00"
@.str.3 = [18 x i8] c" * wrong position\00"
@.str.4 = [8 x i8] c" %s%s\0A\00"
@.str.5 = [34 x i8] c" *** incorrect number of entries\00"
define i32 @test_result(i8* %0, i32 %1, %struct.TYPE_3__* nocapture %2, i8** nocapture %3) {
%5 = tail call i8* @flagstr(i32 %1)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %5)
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 0
%8 = load i64, i64* %7
%9 = icmp eq i64 %8, 0
br i1 %9, label %57, label %10
10: ; preds = %4
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 1
br label %12
12: ; preds = %10, %47
%13 = phi i64 [ 0, %10 ], [ %54, %47 ]
%14 = phi i32 [ 0, %10 ], [ %48, %47 ]
%15 = getelementptr inbounds i8*, i8** %3, i64 %13
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %57, label %18
18: ; preds = %12
%19 = load i8**, i8*** %11
%20 = getelementptr inbounds i8*, i8** %19, i64 %13
%21 = load i8*, i8** %20
%22 = tail call i64 @strcmp(i8* %21, i8* %16)
%23 = icmp eq i64 %22, 0
br i1 %23, label %47, label %24
24: ; preds = %18
%25 = load i8*, i8** %3
%26 = icmp eq i8* %25, null
br i1 %26, label %43, label %27
27: ; preds = %24, %38
%28 = phi i8* [ %41, %38 ], [ %25, %24 ]
%29 = phi i64 [ %39, %38 ], [ 0, %24 ]
%30 = load i8**, i8*** %11
%31 = getelementptr inbounds i8*, i8** %30, i64 %13
%32 = load i8*, i8** %31
%33 = tail call i64 @strcmp(i8* %32, i8* %28)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %27
%36 = getelementptr inbounds i8*, i8** %3, i64 %29
%37 = load i8*, i8** %36
br label %43
38: ; preds = %27
%39 = add i64 %29, 1
%40 = getelementptr inbounds i8*, i8** %3, i64 %39
%41 = load i8*, i8** %40
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %27
43: ; preds = %38, %35, %24
%44 = phi i8* [ null, %24 ], [ %37, %35 ], [ null, %38 ]
%45 = icmp eq i8* %44, null
%46 = select i1 %45, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0)
br label %47
47: ; preds = %43, %18
%48 = phi i32 [ %14, %18 ], [ 1, %43 ]
%49 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %18 ], [ %46, %43 ]
%50 = load i8**, i8*** %11
%51 = getelementptr inbounds i8*, i8** %50, i64 %13
%52 = load i8*, i8** %51
%53 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %52, i8* %49)
%54 = add nuw i64 %13, 1
%55 = load i64, i64* %7
%56 = icmp ult i64 %54, %55
br i1 %56, label %12, label %57
57: ; preds = %12, %47, %4
%58 = phi i32 [ 0, %4 ], [ %48, %47 ], [ %14, %12 ]
%59 = phi i64 [ 0, %4 ], [ %54, %47 ], [ %13, %12 ]
%60 = tail call i32 @putchar(i32 10)
%61 = getelementptr inbounds i8*, i8** %3, i64 %59
%62 = load i8*, i8** %61
%63 = icmp eq i8* %62, null
br i1 %63, label %64, label %67
64: ; preds = %57
%65 = load i64, i64* %7
%66 = icmp ult i64 %59, %65
br i1 %66, label %67, label %69
67: ; preds = %64, %57
%68 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
br label %69
69: ; preds = %67, %64
%70 = phi i32 [ 1, %67 ], [ %58, %64 ]
ret i32 %70
}