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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ glob(char *, int /*<<< orphan*/, int /*<<< orphan*/,
                        TYPE_1__ *);
int /*<<< orphan*/ globfree(TYPE_1__ *);
char *malloc(scalar_t__);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
void show_existing_tuning_data_files(void) {
  static const char *prefixlist[] = {"/usr/local/share"
                                     "/dvb",
                                     "/etc/dvb",
                                     "/usr/local/share"
                                     "/doc/packages/dvb",
                                     0};
  unsigned int i;
  const char **prefix;
  fprintf(stderr, "initial tuning data files:\n");
  for (prefix = prefixlist; *prefix; prefix++) {
    glob_t globbuf;
    char *globspec = malloc(strlen(*prefix) + 9);
    strcpy(globspec, *prefix);
    strcat(globspec, "/dvb-?/*");
    if (!glob(globspec, 0, 0, &globbuf)) {
      for (i = 0; i < globbuf.gl_pathc; i++)
        fprintf(stderr, " file: %s\n", globbuf.gl_pathv[i]);
    }
    free(globspec);
    globfree(&globbuf);
  }
}


x86 assembly (clang, -O0):
<show_existing_tuning_data_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xea8(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    0x2eca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1279 <show_existing_tuning_data_files+0xf9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x9,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1050 <strcpy@plt>
mov    -0x28(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1090 <strcat@plt>
mov    -0x28(%rbp),%rdi
xor    %edx,%edx
lea    -0x20(%rbp),%rcx
mov    %edx,%esi
call   10a0 <glob@plt>
cmp    $0x0,%eax
jne    1256 <show_existing_tuning_data_files+0xd6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x20(%rbp),%eax
jae    1251 <show_existing_tuning_data_files+0xd1>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
mov    (%rax,%rcx,8),%rdx
lea    0xe29(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1215 <show_existing_tuning_data_files+0x95>
jmp    1256 <show_existing_tuning_data_files+0xd6>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
lea    -0x20(%rbp),%rdi
call   1030 <globfree@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    11aa <show_existing_tuning_data_files+0x2a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_existing_tuning_data_files>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e5e(%rip),%r15
mov    (%r15),%edi
lea    0xeb4(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1d,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0xe59(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcpy@plt>
lea    0xea6(%rip),%rsi
mov    %r14,%rdi
call   1080 <strcat@plt>
lea    0x8(%rsp),%rcx
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <glob@plt>
test   %eax,%eax
jne    1213 <show_existing_tuning_data_files+0xa3>
cmpl   $0x0,0x8(%rsp)
je     1213 <show_existing_tuning_data_files+0xa3>
lea    0xe84(%rip),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15),%edi
mov    0x10(%rsp),%rax
mov    (%rax,%rbx,8),%rdx
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x1,%rbx
mov    0x8(%rsp),%eax
cmp    %rax,%rbx
jb     11f0 <show_existing_tuning_data_files+0x80>
mov    %r14,%rdi
call   1040 <free@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <globfree@plt>
mov    $0x11,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0xdd9(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcpy@plt>
lea    0xe11(%rip),%rsi
mov    %r14,%rdi
call   1080 <strcat@plt>
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %rbx,%rcx
call   1090 <glob@plt>
test   %eax,%eax
jne    12a3 <show_existing_tuning_data_files+0x133>
cmpl   $0x0,0x8(%rsp)
je     12a3 <show_existing_tuning_data_files+0x133>
lea    0xdf1(%rip),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r15),%edi
mov    0x10(%rsp),%rax
mov    (%rax,%rbx,8),%rdx
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x1,%rbx
mov    0x8(%rsp),%eax
cmp    %rax,%rbx
jb     1280 <show_existing_tuning_data_files+0x110>
mov    %r14,%rdi
call   1040 <free@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <globfree@plt>
mov    $0x2a,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0xd52(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcpy@plt>
lea    0xd81(%rip),%rsi
mov    %r14,%rdi
call   1080 <strcat@plt>
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %rbx,%rcx
call   1090 <glob@plt>
test   %eax,%eax
jne    1333 <show_existing_tuning_data_files+0x1c3>
cmpl   $0x0,0x8(%rsp)
je     1333 <show_existing_tuning_data_files+0x1c3>
lea    0xd61(%rip),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r15),%edi
mov    0x10(%rsp),%rax
mov    (%rax,%rbx,8),%rdx
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x1,%rbx
mov    0x8(%rsp),%eax
cmp    %rax,%rbx
jb     1310 <show_existing_tuning_data_files+0x1a0>
mov    %r14,%rdi
call   1040 <free@plt>
lea    0x8(%rsp),%rdi
call   1030 <globfree@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32, i8** }
@show_existing_tuning_data_files.prefixlist = internal global [4 x i8*] [i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str = [21 x i8] c"/usr/local/share/dvb\00"
@.str.1 = [9 x i8] c"/etc/dvb\00"
@.str.2 = [34 x i8] c"/usr/local/share/doc/packages/dvb\00"
@stderr = global i32 0
@.str.3 = [28 x i8] c"initial tuning data files:\0A\00"
@.str.4 = [9 x i8] c"/dvb-?/*\00"
@.str.5 = [11 x i8] c" file: %s\0A\00"
define void @show_existing_tuning_data_files() {
%1 = alloca i32
%2 = alloca i8**
%3 = alloca %struct.TYPE_4__
%4 = alloca i8*
%5 = load i32, i32* @stderr
%6 = call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
store i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @show_existing_tuning_data_files.prefixlist, i64 0, i64 0), i8*** %2
br label %7
7: ; preds = %49, %0
%8 = load i8**, i8*** %2
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %52
11: ; preds = %7
%12 = load i8**, i8*** %2
%13 = load i8*, i8** %12
%14 = call i64 @strlen(i8* %13)
%15 = add nsw i64 %14, 9
%16 = call i8* @malloc(i64 %15)
store i8* %16, i8** %4
%17 = load i8*, i8** %4
%18 = load i8**, i8*** %2
%19 = load i8*, i8** %18
%20 = call i32 @strcpy(i8* %17, i8* %19)
%21 = load i8*, i8** %4
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%23 = load i8*, i8** %4
%24 = call i32 @glob(i8* %23, i32 0, i32 0, %struct.TYPE_4__* %3)
%25 = icmp ne i32 %24, 0
br i1 %25, label %45, label %26
26: ; preds = %11
store i32 0, i32* %1
br label %27
27: ; preds = %41, %26
%28 = load i32, i32* %1
%29 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i32 0, i32 0
%30 = load i32, i32* %29
%31 = icmp ult i32 %28, %30
br i1 %31, label %32, label %44
32: ; preds = %27
%33 = load i32, i32* @stderr
%34 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i32 0, i32 1
%35 = load i8**, i8*** %34
%36 = load i32, i32* %1
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %32
%42 = load i32, i32* %1
%43 = add i32 %42, 1
store i32 %43, i32* %1
br label %27
44: ; preds = %27
br label %45
45: ; preds = %44, %11
%46 = load i8*, i8** %4
%47 = call i32 @free(i8* %46)
%48 = call i32 @globfree(%struct.TYPE_4__* %3)
br label %49
49: ; preds = %45
%50 = load i8**, i8*** %2
%51 = getelementptr inbounds i8*, i8** %50, i32 1
store i8** %51, i8*** %2
br label %7
52: ; preds = %7
ret void
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32, i8** }
@.str = [21 x i8] c"/usr/local/share/dvb\00"
@.str.1 = [9 x i8] c"/etc/dvb\00"
@.str.2 = [34 x i8] c"/usr/local/share/doc/packages/dvb\00"
@stderr = global i32 0
@.str.3 = [28 x i8] c"initial tuning data files:\0A\00"
@.str.4 = [9 x i8] c"/dvb-?/*\00"
@.str.5 = [11 x i8] c" file: %s\0A\00"
define void @show_existing_tuning_data_files() {
%1 = alloca %struct.TYPE_4__
%2 = load i32, i32* @stderr
%3 = tail call i32 (i32, i8*, ...) @fprintf(i32 %2, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%4 = bitcast %struct.TYPE_4__* %1 to i8*
%5 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 0
%6 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 1
%7 = call dereferenceable_or_null(29) i8* @malloc(i64 29)
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @glob(i8* %7, i32 0, i32 0, %struct.TYPE_4__* %1)
%11 = icmp eq i32 %10, 0
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 0
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %15, label %26
15: ; preds = %0, %15
%16 = phi i64 [ %22, %15 ], [ 0, %0 ]
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %6
%19 = getelementptr inbounds i8*, i8** %18, i64 %16
%20 = load i8*, i8** %19
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %20)
%22 = add nuw nsw i64 %16, 1
%23 = load i32, i32* %5
%24 = zext i32 %23 to i64
%25 = icmp ult i64 %22, %24
br i1 %25, label %15, label %26
26: ; preds = %15, %0
%27 = call i32 @free(i8* %7)
%28 = call i32 @globfree(%struct.TYPE_4__* %1)
%29 = call dereferenceable_or_null(17) i8* @malloc(i64 17)
%30 = call i32 @strcpy(i8* %29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 @strcat(i8* %29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%32 = call i32 @glob(i8* %29, i32 0, i32 0, %struct.TYPE_4__* %1)
%33 = icmp eq i32 %32, 0
%34 = load i32, i32* %5
%35 = icmp ne i32 %34, 0
%36 = select i1 %33, i1 %35, i1 false
br i1 %36, label %37, label %48
37: ; preds = %26, %37
%38 = phi i64 [ %44, %37 ], [ 0, %26 ]
%39 = load i32, i32* @stderr
%40 = load i8**, i8*** %6
%41 = getelementptr inbounds i8*, i8** %40, i64 %38
%42 = load i8*, i8** %41
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %42)
%44 = add nuw nsw i64 %38, 1
%45 = load i32, i32* %5
%46 = zext i32 %45 to i64
%47 = icmp ult i64 %44, %46
br i1 %47, label %37, label %48
48: ; preds = %37, %26
%49 = call i32 @free(i8* %29)
%50 = call i32 @globfree(%struct.TYPE_4__* %1)
%51 = call dereferenceable_or_null(42) i8* @malloc(i64 42)
%52 = call i32 @strcpy(i8* %51, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%53 = call i32 @strcat(i8* %51, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%54 = call i32 @glob(i8* %51, i32 0, i32 0, %struct.TYPE_4__* %1)
%55 = icmp eq i32 %54, 0
%56 = load i32, i32* %5
%57 = icmp ne i32 %56, 0
%58 = select i1 %55, i1 %57, i1 false
br i1 %58, label %59, label %70
59: ; preds = %48, %59
%60 = phi i64 [ %66, %59 ], [ 0, %48 ]
%61 = load i32, i32* @stderr
%62 = load i8**, i8*** %6
%63 = getelementptr inbounds i8*, i8** %62, i64 %60
%64 = load i8*, i8** %63
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %64)
%66 = add nuw nsw i64 %60, 1
%67 = load i32, i32* %5
%68 = zext i32 %67 to i64
%69 = icmp ult i64 %66, %68
br i1 %69, label %59, label %70
70: ; preds = %59, %48
%71 = call i32 @free(i8* %51)
%72 = call i32 @globfree(%struct.TYPE_4__* %1)
ret void
}