#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*/ cube2xsf(char *);
int /*<<< orphan*/ cube2xsf_bin(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *strstr(char *, char *);
int main(int argc, char *argv[]) {
  int i;
  if (argc < 2) {
    printf("\nUsage : \n");
    printf("$ cube2xsf {prefix1}.cube {prefix2}.cube {prefix3}.cube ... \n");
    printf("$ cube2xsf {prefix1}.cube.bin {prefix2}.cube.bin, "
           "{prefix3}.cube.bin ... \n\n");
    printf("Then {prefix1}.xsf, {prefix2}.xsf, {prefix3}.xsf ... are "
           "generated. \n\n");
    exit(0);
  }
  for (i = 1; i < argc; i++) {
    if (strstr(argv[i], ".cube.bin") != NULL) {
      printf("converting %s\n", argv[i]);
      cube2xsf_bin(argv[i]);
    } else if (strstr(argv[i], ".cube") != NULL) {
      printf("converting %s\n", argv[i]);
      cube2xsf(argv[i]);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11af <main+0x5f>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1279 <main+0x129>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xf07(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     1214 <main+0xc4>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <cube2xsf_bin@plt>
jmp    1266 <main+0x116>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xece(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     1261 <main+0x111>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <cube2xsf@plt>
jmp    1266 <main+0x116>
jmp    126b <main+0x11b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b6 <main+0x66>
mov    -0x4(%rbp),%eax
add    $0x20,%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
jl     1203 <main+0xa3>
mov    %rsi,%r13
mov    %edi,%ebp
mov    $0x1,%r15d
lea    0xe7a(%rip),%r14
lea    0xe7d(%rip),%r12
jmp    11b0 <main+0x50>
nop
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13,%r15,8),%rdi
call   1060 <cube2xsf_bin@plt>
add    $0x1,%r15
cmp    %r15,%rbp
je     11f2 <main+0x92>
mov    0x0(%r13,%r15,8),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strstr@plt>
test   %rax,%rax
jne    1190 <main+0x30>
mov    %rbx,%rdi
lea    0xe4a(%rip),%rsi
call   1080 <strstr@plt>
test   %rax,%rax
je     11a7 <main+0x47>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13,%r15,8),%rdi
call   1050 <cube2xsf@plt>
jmp    11a7 <main+0x47>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe15(%rip),%rdi
call   1030 <puts@plt>
lea    0xe13(%rip),%rdi
call   1030 <puts@plt>
lea    0xe44(%rip),%rdi
call   1030 <puts@plt>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"\0AUsage : \0A\00"
@.str.1 = [62 x i8] c"$ cube2xsf {prefix1}.cube {prefix2}.cube {prefix3}.cube ... \0A\00"
@.str.2 = [76 x i8] c"$ cube2xsf {prefix1}.cube.bin {prefix2}.cube.bin, {prefix3}.cube.bin ... \0A\0A\00"
@.str.3 = [71 x i8] c"Then {prefix1}.xsf, {prefix2}.xsf, {prefix3}.xsf ... are generated. \0A\0A\00"
@.str.4 = [10 x i8] c".cube.bin\00"
@.str.5 = [15 x i8] c"converting %s\0A\00"
@.str.6 = [6 x i8] c".cube\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %2
store i32 1, i32* %6
br label %16
16: ; preds = %64, %15
%17 = load i32, i32* %6
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %67
20: ; preds = %16
%21 = load i8**, i8*** %5
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i32* @strstr(i8* %25, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %41
28: ; preds = %20
%29 = load i8**, i8*** %5
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %33)
%35 = load i8**, i8*** %5
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 @cube2xsf_bin(i8* %39)
br label %63
41: ; preds = %20
%42 = load i8**, i8*** %5
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = call i32* @strstr(i8* %46, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%48 = icmp ne i32* %47, null
br i1 %48, label %49, label %62
49: ; preds = %41
%50 = load i8**, i8*** %5
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %54)
%56 = load i8**, i8*** %5
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i32 @cube2xsf(i8* %60)
br label %62
62: ; preds = %49, %41
br label %63
63: ; preds = %62, %28
br label %64
64: ; preds = %63
%65 = load i32, i32* %6
%66 = add nsw i32 %65, 1
store i32 %66, i32* %6
br label %16
67: ; preds = %16
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@.str.4 = [10 x i8] c".cube.bin\00"
@.str.5 = [15 x i8] c"converting %s\0A\00"
@.str.6 = [6 x i8] c".cube\00"
@str = [10 x i8] c"\0AUsage : \00"
@str.7 = [61 x i8] c"$ cube2xsf {prefix1}.cube {prefix2}.cube {prefix3}.cube ... \00"
@str.8 = [75 x i8] c"$ cube2xsf {prefix1}.cube.bin {prefix2}.cube.bin, {prefix3}.cube.bin ... \0A\00"
@str.9 = [70 x i8] c"Then {prefix1}.xsf, {prefix2}.xsf, {prefix3}.xsf ... are generated. \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %12
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.7, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @str.8, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.9, i64 0, i64 0))
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %4, %29
%13 = phi i64 [ 1, %4 ], [ %30, %29 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32* @strstr(i8* dereferenceable(1) %15, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %22, label %18
18: ; preds = %12
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %15)
%20 = load i8*, i8** %14
%21 = tail call i32 @cube2xsf_bin(i8* %20)
br label %29
22: ; preds = %12
%23 = tail call i32* @strstr(i8* dereferenceable(1) %15, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %29, label %25
25: ; preds = %22
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %15)
%27 = load i8*, i8** %14
%28 = tail call i32 @cube2xsf(i8* %27)
br label %29
29: ; preds = %18, %25, %22
%30 = add nuw nsw i64 %13, 1
%31 = icmp eq i64 %30, %5
br i1 %31, label %32, label %12
32: ; preds = %29
ret i32 0
}