#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*/ convert_cube(char *);
int /*<<< orphan*/ convert_grid(char *);
int /*<<< orphan*/ convert_xsf(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("Invalid argument\n");
    exit(0);
  }
  for (i = 1; i < argc; i++) {
    if (strstr(argv[i], ".cube.bin") != NULL) {
      printf("converting %s\n", argv[i]);
      convert_cube(argv[i]);
    } else if (strstr(argv[i], ".xsf.bin") != NULL) {
      printf("converting %s\n", argv[i]);
      convert_xsf(argv[i]);
    } else if (strstr(argv[i], ".grid.bin") != NULL) {
      printf("converting %s\n", argv[i]);
      convert_grid(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    1195 <main+0x35>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12b6 <main+0x156>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe57(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     11fa <main+0x9a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <convert_cube@plt>
jmp    12a3 <main+0x143>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe1e(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     124c <main+0xec>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <convert_xsf@plt>
jmp    129e <main+0x13e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdd5(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     1299 <main+0x139>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <convert_grid@plt>
jmp    129e <main+0x13e>
jmp    12a3 <main+0x143>
jmp    12a8 <main+0x148>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119c <main+0x3c>
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     123c <main+0xcc>
mov    %rsi,%rbx
mov    %edi,%r12d
mov    $0x1,%r15d
lea    0xe69(%rip),%r14
lea    0xe6c(%rip),%r13
jmp    11bf <main+0x4f>
mov    %r13,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx,%r15,8),%rdi
call   1080 <convert_cube@plt>
add    $0x1,%r15
cmp    %r15,%r12
je     122b <main+0xbb>
mov    (%rbx,%r15,8),%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
jne    11a0 <main+0x30>
mov    %rbp,%rdi
lea    0xe3c(%rip),%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     11ff <main+0x8f>
mov    %r13,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx,%r15,8),%rdi
call   1060 <convert_xsf@plt>
jmp    11b6 <main+0x46>
mov    %rbp,%rdi
lea    0xe19(%rip),%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     11b6 <main+0x46>
mov    %r13,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx,%r15,8),%rdi
call   1030 <convert_grid@plt>
jmp    11b6 <main+0x46>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xde9(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Invalid argument\0A\00"
@.str.1 = [10 x i8] c".cube.bin\00"
@.str.2 = [15 x i8] c"converting %s\0A\00"
@.str.3 = [9 x i8] c".xsf.bin\00"
@.str.4 = [10 x i8] c".grid.bin\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 %12
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %2
store i32 1, i32* %6
br label %13
13: ; preds = %83, %12
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %86
17: ; preds = %13
%18 = load i8**, i8*** %5
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32* @strstr(i8* %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp ne i32* %23, null
br i1 %24, label %25, label %38
25: ; preds = %17
%26 = load i8**, i8*** %5
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = load i8**, i8*** %5
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i32 @convert_cube(i8* %36)
br label %82
38: ; preds = %17
%39 = load i8**, i8*** %5
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = call i32* @strstr(i8* %43, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%45 = icmp ne i32* %44, null
br i1 %45, label %46, label %59
46: ; preds = %38
%47 = load i8**, i8*** %5
%48 = load i32, i32* %6
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %51)
%53 = load i8**, i8*** %5
%54 = load i32, i32* %6
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
%57 = load i8*, i8** %56
%58 = call i32 @convert_xsf(i8* %57)
br label %81
59: ; preds = %38
%60 = load i8**, i8*** %5
%61 = load i32, i32* %6
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8*, i8** %60, i64 %62
%64 = load i8*, i8** %63
%65 = call i32* @strstr(i8* %64, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%66 = icmp ne i32* %65, null
br i1 %66, label %67, label %80
67: ; preds = %59
%68 = load i8**, i8*** %5
%69 = load i32, i32* %6
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8*, i8** %68, i64 %70
%72 = load i8*, i8** %71
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %72)
%74 = load i8**, i8*** %5
%75 = load i32, i32* %6
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8*, i8** %74, i64 %76
%78 = load i8*, i8** %77
%79 = call i32 @convert_grid(i8* %78)
br label %80
80: ; preds = %67, %59
br label %81
81: ; preds = %80, %46
br label %82
82: ; preds = %81, %25
br label %83
83: ; preds = %82
%84 = load i32, i32* %6
%85 = add nsw i32 %84, 1
store i32 %85, i32* %6
br label %13
86: ; preds = %13
%87 = load i32, i32* %3
ret i32 %87
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c".cube.bin\00"
@.str.2 = [15 x i8] c"converting %s\0A\00"
@.str.3 = [9 x i8] c".xsf.bin\00"
@.str.4 = [10 x i8] c".grid.bin\00"
@str = [17 x i8] c"Invalid argument\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 %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %4, %33
%10 = phi i64 [ 1, %4 ], [ %34, %33 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i32* @strstr(i8* dereferenceable(1) %12, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %19, label %15
15: ; preds = %9
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%17 = load i8*, i8** %11
%18 = tail call i32 @convert_cube(i8* %17)
br label %33
19: ; preds = %9
%20 = tail call i32* @strstr(i8* dereferenceable(1) %12, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%24 = load i8*, i8** %11
%25 = tail call i32 @convert_xsf(i8* %24)
br label %33
26: ; preds = %19
%27 = tail call i32* @strstr(i8* dereferenceable(1) %12, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %33, label %29
29: ; preds = %26
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%31 = load i8*, i8** %11
%32 = tail call i32 @convert_grid(i8* %31)
br label %33
33: ; preds = %15, %26, %29, %22
%34 = add nuw nsw i64 %10, 1
%35 = icmp eq i64 %34, %5
br i1 %35, label %36, label %9
36: ; preds = %33
ret i32 0
}