#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 */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ get_dir_count(char *, int *, int *);
int /*<<< orphan*/ get_names(char ***, char *, int, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ write_packagedata(char **, int *);
int main(int argc, char **argv) {
  int nfiles = 0;
  int filelen = 0;
  char **names = NULL;
  int i;
  int npackages = 0;
  if (argc < 3) {
    fprintf(stderr, "Usage: makeam directory installdatapath\n");
    exit(-1);
  }
  get_dir_count(argv[1], &nfiles, &filelen);
  get_names(&names, argv[1], nfiles, filelen);
  write_packagedata(names, &npackages);
  fprintf(stdout, "\n");
  for (i = 0; i < npackages; ++i) {
    if (!i)
      fprintf(stdout, "pkgdatadir=$(prefix)/share/$(PACKAGE)/%s\n", argv[2]);
    else
      fprintf(stdout, "pkgdata%ddir=$(prefix)/share/$(PACKAGE)/%s\n", i + 1,
              argv[2]);
  }
  i = 0;
  while (names[i])
    free((void *)names[i++]);
  free((void *)names);
  return 0;
}


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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11be <main+0x5e>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <get_dir_count@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    -0x20(%rbp),%rdi
call   1070 <get_names@plt>
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <write_packagedata@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    0xe20(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1287 <main+0x127>
cmpl   $0x0,-0x24(%rbp)
jne    124f <main+0xef>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xde6(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1274 <main+0x114>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xde6(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1279 <main+0x119>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1215 <main+0xb5>
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     12c1 <main+0x161>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
jmp    128e <main+0x12e>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
movl   $0x0,0x4(%rsp)
cmp    $0x2,%edi
jle    127c <main+0x11c>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <get_dir_count@plt>
mov    0x8(%rbx),%rsi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0x10(%rsp),%rdi
call   1070 <get_names@plt>
mov    0x10(%rsp),%rdi
lea    0x4(%rsp),%rsi
call   1040 <write_packagedata@plt>
mov    0x2e02(%rip),%r15
mov    (%r15),%edi
lea    0xe47(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
cmpl   $0x0,0x4(%rsp)
jle    123c <main+0xdc>
mov    (%r15),%edi
mov    0x10(%rbx),%rdx
lea    0xe2d(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
cmpl   $0x2,0x4(%rsp)
jl     123c <main+0xdc>
mov    $0x1,%ebp
lea    0xe3d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    (%r15),%edi
add    $0x1,%ebp
mov    0x10(%rbx),%rcx
mov    %r14,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
cmp    0x4(%rsp),%ebp
jl     1220 <main+0xc0>
mov    0x10(%rsp),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     1267 <main+0x107>
mov    $0x8,%ebx
xchg   %ax,%ax
call   1030 <free@plt>
mov    0x10(%rsp),%rax
mov    (%rax,%rbx,1),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1250 <main+0xf0>
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
lea    0xd74(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [41 x i8] c"Usage: makeam directory installdatapath\0A\00"
@stdout = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [42 x i8] c"pkgdatadir=$(prefix)/share/$(PACKAGE)/%s\0A\00"
@.str.3 = [44 x i8] c"pkgdata%ddir=$(prefix)/share/$(PACKAGE)/%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i8** null, i8*** %8
store i32 0, i32* %10
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @get_dir_count(i8* %20, i32* %6, i32* %7)
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = call i32 @get_names(i8*** %8, i8* %24, i32 %25, i32 %26)
%28 = load i8**, i8*** %8
%29 = call i32 @write_packagedata(i8** %28, i32* %10)
%30 = load i32, i32* @stdout
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %9
br label %32
32: ; preds = %54, %17
%33 = load i32, i32* %9
%34 = load i32, i32* %10
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %57
36: ; preds = %32
%37 = load i32, i32* %9
%38 = icmp ne i32 %37, 0
br i1 %38, label %45, label %39
39: ; preds = %36
%40 = load i32, i32* @stdout
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %43)
br label %53
45: ; preds = %36
%46 = load i32, i32* @stdout
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %48, i8* %51)
br label %53
53: ; preds = %45, %39
br label %54
54: ; preds = %53
%55 = load i32, i32* %9
%56 = add nsw i32 %55, 1
store i32 %56, i32* %9
br label %32
57: ; preds = %32
store i32 0, i32* %9
br label %58
58: ; preds = %65, %57
%59 = load i8**, i8*** %8
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
%63 = load i8*, i8** %62
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %73
65: ; preds = %58
%66 = load i8**, i8*** %8
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
store i32 %68, i32* %9
%69 = sext i32 %67 to i64
%70 = getelementptr inbounds i8*, i8** %66, i64 %69
%71 = load i8*, i8** %70
%72 = call i32 @free(i8* %71)
br label %58
73: ; preds = %58
%74 = load i8**, i8*** %8
%75 = bitcast i8** %74 to i8*
%76 = call i32 @free(i8* %75)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"Usage: makeam directory installdatapath\0A\00"
@stdout = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [42 x i8] c"pkgdatadir=$(prefix)/share/$(PACKAGE)/%s\0A\00"
@.str.3 = [44 x i8] c"pkgdata%ddir=$(prefix)/share/$(PACKAGE)/%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = bitcast i8*** %5 to i8*
store i8** null, i8*** %5
%10 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%11 = icmp slt i32 %0, 3
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 -1)
unreachable
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @get_dir_count(i8* %18, i32* %3, i32* %4)
%20 = load i8*, i8** %17
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 @get_names(i8*** %5, i8* %20, i32 %21, i32 %22)
%24 = load i8**, i8*** %5
%25 = call i32 @write_packagedata(i8** %24, i32* %6)
%26 = load i32, i32* @stdout
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* %6
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %37
30: ; preds = %16
%31 = getelementptr inbounds i8*, i8** %1, i64 2
%32 = load i32, i32* @stdout
%33 = load i8*, i8** %31
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = load i32, i32* %6
%36 = icmp sgt i32 %35, 1
br i1 %36, label %41, label %37
37: ; preds = %41, %30, %16
%38 = load i8**, i8*** %5
%39 = load i8*, i8** %38
%40 = icmp eq i8* %39, null
br i1 %40, label %58, label %49
41: ; preds = %30, %41
%42 = phi i32 [ %44, %41 ], [ 1, %30 ]
%43 = load i32, i32* @stdout
%44 = add nuw nsw i32 %42, 1
%45 = load i8*, i8** %31
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %44, i8* %45)
%47 = load i32, i32* %6
%48 = icmp slt i32 %44, %47
br i1 %48, label %41, label %37
49: ; preds = %37, %49
%50 = phi i64 [ %52, %49 ], [ 0, %37 ]
%51 = phi i8* [ %56, %49 ], [ %39, %37 ]
%52 = add nuw nsw i64 %50, 1
%53 = call i32 @free(i8* %51)
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 %52
%56 = load i8*, i8** %55
%57 = icmp eq i8* %56, null
br i1 %57, label %58, label %49
58: ; preds = %49, %37
%59 = phi i8** [ %38, %37 ], [ %54, %49 ]
%60 = bitcast i8** %59 to i8*
%61 = call i32 @free(i8* %60)
ret i32 0
}