#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*/ DefaultExtension(char *, char *);
int /*<<< orphan*/ Error(char *);
int /*<<< orphan*/ LoadBSPFile(char *);
int /*<<< orphan*/ PrintBSPFileSizes();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char **argv) {
  int i;
  char source[1024];
  if (argc == 1)
    Error("usage: bspinfo bspfile [bspfiles]");
  for (i = 1; i < argc; i++) {
    printf("---------------------\n");
    strcpy(source, argv[i]);
    DefaultExtension(source, ".bsp");
    printf("%s\n", source);
    LoadBSPFile(source);
    PrintBSPFileSizes();
    printf("---------------------\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    118f <main+0x2f>
lea    0xe76(%rip),%rdi
call   1040 <Error@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121f <main+0xbf>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
lea    -0x420(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1070 <DefaultExtension@plt>
lea    -0x420(%rbp),%rsi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x420(%rbp),%rdi
call   1060 <LoadBSPFile@plt>
mov    $0x0,%al
call   1080 <PrintBSPFileSizes@plt>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1196 <main+0x36>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
cmp    $0x1,%edi
jne    1184 <main+0x24>
lea    0xe83(%rip),%rdi
call   1050 <Error@plt>
jmp    11f7 <main+0x97>
jle    11f7 <main+0x97>
mov    %rsi,%r14
mov    %edi,%r13d
mov    $0x1,%ebp
lea    0xe8f(%rip),%r15
mov    %rsp,%rbx
lea    0xe80(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
call   1040 <puts@plt>
mov    (%r14,%rbp,8),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <DefaultExtension@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1060 <LoadBSPFile@plt>
xor    %eax,%eax
call   1080 <PrintBSPFileSizes@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    11b0 <main+0x50>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"usage: bspinfo bspfile [bspfiles]\00"
@.str.1 = [23 x i8] c"---------------------\0A\00"
@.str.2 = [5 x i8] c".bsp\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @Error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
store i32 1, i32* %6
br label %13
13: ; preds = %34, %12
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %37
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%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 = call i32 @strcpy(i8* %19, i8* %24)
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%27 = call i32 @DefaultExtension(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%31 = call i32 @LoadBSPFile(i8* %30)
%32 = call i32 (...) @PrintBSPFileSizes()
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %17
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %13
37: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"usage: bspinfo bspfile [bspfiles]\00"
@.str.2 = [5 x i8] c".bsp\00"
@str.4 = [22 x i8] c"---------------------\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @Error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %25
8: ; preds = %2
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %25
10: ; preds = %8
%11 = zext i32 %0 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 1, %10 ], [ %23, %12 ]
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0))
%15 = getelementptr inbounds i8*, i8** %1, i64 %13
%16 = load i8*, i8** %15
%17 = call i32 @strcpy(i8* %4, i8* %16)
%18 = call i32 @DefaultExtension(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @puts(i8* %4)
%20 = call i32 @LoadBSPFile(i8* %4)
%21 = call i32 (...) @PrintBSPFileSizes()
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0))
%23 = add nuw nsw i64 %13, 1
%24 = icmp eq i64 %23, %11
br i1 %24, label %25, label %12
25: ; preds = %12, %6, %8
ret i32 0
}