#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 */
typedef int /*<<< orphan*/ buff;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/ *);
int /*<<< orphan*/ csv_to_ades(char *, int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sscanf(char const *, char *, int *, int *);
int main(const int argc, const char **argv) {
  FILE *hdr_file = fopen("gaia.hdr", "rb");
  char buff[800];
  int i, low_num = 1, high_num = 1000000;
  assert(hdr_file);
  for (i = 1; i < argc; i++)
    if (argv[i][0] == '-')
      sscanf(argv[i] + 1, "%d,%d", &low_num, &high_num);
  while (fgets(buff, sizeof(buff), hdr_file))
    if (*buff != '*')
      printf("%s", buff);
    else
      for (i = 1; i < argc; i++)
        if (argv[i][0] != '-') {
          FILE *ifile = fopen(argv[i], "rb");
          assert(ifile);
          if (fgets(buff, sizeof(buff), ifile))
            while (fgets(buff, sizeof(buff), ifile))
              csv_to_ades(buff, low_num, high_num);
          fclose(ifile);
        }
  fclose(hdr_file);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x360,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe70(%rip),%rdi
lea    0xe72(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x348(%rbp)
movl   $0xf4240,-0x34c(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <assert@plt>
movl   $0x1,-0x344(%rbp)
mov    -0x344(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1237 <main+0xc7>
mov    -0x10(%rbp),%rax
movslq -0x344(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    121e <main+0xae>
mov    -0x10(%rbp),%rax
movslq -0x344(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
add    $0x1,%rdi
lea    0xe01(%rip),%rsi
lea    -0x348(%rbp),%rdx
lea    -0x34c(%rbp),%rcx
call   1070 <sscanf@plt>
jmp    1223 <main+0xb3>
mov    -0x344(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x344(%rbp)
jmp    11c7 <main+0x57>
jmp    123c <main+0xcc>
lea    -0x340(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x320,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     137f <main+0x20f>
movsbl -0x340(%rbp),%eax
cmp    $0x2a,%eax
je     1283 <main+0x113>
lea    -0x340(%rbp),%rsi
lea    0xd99(%rip),%rdi
call   1040 <printf@plt>
jmp    137a <main+0x20a>
movl   $0x1,-0x344(%rbp)
mov    -0x344(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1375 <main+0x205>
mov    -0x10(%rbp),%rax
movslq -0x344(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     135c <main+0x1ec>
mov    -0x10(%rbp),%rax
movslq -0x344(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd3c(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x358(%rbp)
mov    -0x358(%rbp),%rdi
call   1060 <assert@plt>
lea    -0x340(%rbp),%rdi
mov    -0x358(%rbp),%rdx
mov    $0x320,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1350 <main+0x1e0>
jmp    130c <main+0x19c>
lea    -0x340(%rbp),%rdi
mov    -0x358(%rbp),%rdx
mov    $0x320,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     134b <main+0x1db>
lea    -0x340(%rbp),%rdi
mov    -0x348(%rbp),%esi
mov    -0x34c(%rbp),%edx
call   1080 <csv_to_ades@plt>
jmp    130c <main+0x19c>
jmp    1350 <main+0x1e0>
mov    -0x358(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1361 <main+0x1f1>
mov    -0x344(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x344(%rbp)
jmp    128d <main+0x11d>
jmp    137a <main+0x20a>
jmp    123c <main+0xcc>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x360,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x348,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe73(%rip),%rdi
lea    0xe75(%rip),%rsi
call   1090 <fopen@plt>
movl   $0x1,0xc(%rsp)
movl   $0xf4240,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    %rax,%rdi
call   1060 <assert@plt>
mov    %ebp,%r14d
mov    %ebp,0x1c(%rsp)
cmp    $0x2,%ebp
jl     1206 <main+0x96>
mov    $0x1,%ebp
lea    0xe3e(%rip),%r12
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%r15
jmp    11e9 <main+0x79>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r14
je     1206 <main+0x96>
mov    (%rbx,%rbp,8),%rdi
cmpb   $0x2d,(%rdi)
jne    11e0 <main+0x70>
add    $0x1,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %r15,%rcx
call   1070 <sscanf@plt>
jmp    11e0 <main+0x70>
lea    0x20(%rsp),%rdi
mov    $0x320,%esi
mov    0x10(%rsp),%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     12f7 <main+0x187>
lea    0xddf(%rip),%r12
lea    0x20(%rsp),%rbp
jmp    126a <main+0xfa>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xdcb(%rip),%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    $0x320,%esi
mov    0x10(%rsp),%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     12f7 <main+0x187>
cmpb   $0x2a,0x20(%rsp)
jne    1240 <main+0xd0>
cmpl   $0x2,0x1c(%rsp)
jl     124f <main+0xdf>
mov    $0x1,%r15d
jmp    1291 <main+0x121>
mov    %r13,%rdi
call   1030 <fclose@plt>
add    $0x1,%r15
cmp    %r14,%r15
je     124f <main+0xdf>
mov    (%rbx,%r15,8),%rdi
cmpb   $0x2d,(%rdi)
je     1288 <main+0x118>
mov    %r12,%rsi
call   1090 <fopen@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1060 <assert@plt>
mov    %rbp,%rdi
mov    $0x320,%esi
mov    %r13,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1280 <main+0x110>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    $0x320,%esi
mov    %r13,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1280 <main+0x110>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %rbp,%rdi
call   1080 <csv_to_ades@plt>
jmp    12d0 <main+0x160>
mov    0x10(%rsp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x348,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"gaia.hdr\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [6 x i8] c"%d,%d\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [800 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %6
store i32 1, i32* %9
store i32 1000000, i32* %10
%13 = load i32*, i32** %6
%14 = call i32 @assert(i32* %13)
store i32 1, i32* %8
br label %15
15: ; preds = %38, %2
%16 = load i32, i32* %8
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %41
19: ; preds = %15
%20 = load i8**, i8*** %5
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 45
br i1 %28, label %29, label %37
29: ; preds = %19
%30 = load i8**, i8*** %5
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
%34 = load i8*, i8** %33
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = call i32 @sscanf(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %9, i32* %10)
br label %37
37: ; preds = %29, %19
br label %38
38: ; preds = %37
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %15
41: ; preds = %15
br label %42
42: ; preds = %103, %41
%43 = getelementptr inbounds [800 x i8], [800 x i8]* %7, i64 0, i64 0
%44 = load i32*, i32** %6
%45 = call i64 @fgets(i8* %43, i32 800, i32* %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %104
47: ; preds = %42
%48 = getelementptr inbounds [800 x i8], [800 x i8]* %7, i64 0, i64 0
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %50, 42
br i1 %51, label %52, label %55
52: ; preds = %47
%53 = getelementptr inbounds [800 x i8], [800 x i8]* %7, i64 0, i64 0
%54 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %53)
br label %103
55: ; preds = %47
store i32 1, i32* %8
br label %56
56: ; preds = %99, %55
%57 = load i32, i32* %8
%58 = load i32, i32* %4
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %102
60: ; preds = %56
%61 = load i8**, i8*** %5
%62 = load i32, i32* %8
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
%66 = getelementptr inbounds i8, i8* %65, i64 0
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp ne i32 %68, 45
br i1 %69, label %70, label %98
70: ; preds = %60
%71 = load i8**, i8*** %5
%72 = load i32, i32* %8
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %71, i64 %73
%75 = load i8*, i8** %74
%76 = call i32* @fopen(i8* %75, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %76, i32** %11
%77 = load i32*, i32** %11
%78 = call i32 @assert(i32* %77)
%79 = getelementptr inbounds [800 x i8], [800 x i8]* %7, i64 0, i64 0
%80 = load i32*, i32** %11
%81 = call i64 @fgets(i8* %79, i32 800, i32* %80)
%82 = icmp ne i64 %81, 0
br i1 %82, label %83, label %95
83: ; preds = %70
br label %84
84: ; preds = %89, %83
%85 = getelementptr inbounds [800 x i8], [800 x i8]* %7, i64 0, i64 0
%86 = load i32*, i32** %11
%87 = call i64 @fgets(i8* %85, i32 800, i32* %86)
%88 = icmp ne i64 %87, 0
br i1 %88, label %89, label %94
89: ; preds = %84
%90 = getelementptr inbounds [800 x i8], [800 x i8]* %7, i64 0, i64 0
%91 = load i32, i32* %9
%92 = load i32, i32* %10
%93 = call i32 @csv_to_ades(i8* %90, i32 %91, i32 %92)
br label %84
94: ; preds = %84
br label %95
95: ; preds = %94, %70
%96 = load i32*, i32** %11
%97 = call i32 @fclose(i32* %96)
br label %98
98: ; preds = %95, %60
br label %99
99: ; preds = %98
%100 = load i32, i32* %8
%101 = add nsw i32 %100, 1
store i32 %101, i32* %8
br label %56
102: ; preds = %56
br label %103
103: ; preds = %102, %52
br label %42
104: ; preds = %42
%105 = load i32*, i32** %6
%106 = call i32 @fclose(i32* %105)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"gaia.hdr\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [6 x i8] c"%d,%d\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [800 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [800 x i8], [800 x i8]* %3, i64 0, i64 0
%8 = bitcast i32* %4 to i8*
store i32 1, i32* %4
%9 = bitcast i32* %5 to i8*
store i32 1000000, i32* %5
%10 = tail call i32 @assert(i32* %6)
%11 = icmp sgt i32 %0, 1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = zext i32 %0 to i64
br label %19
14: ; preds = %28, %2
%15 = call i64 @fgets(i8* %7, i32 800, i32* %6)
%16 = icmp eq i64 %15, 0
br i1 %16, label %65, label %17
17: ; preds = %14
%18 = zext i32 %0 to i64
br label %31
19: ; preds = %12, %28
%20 = phi i64 [ 1, %12 ], [ %29, %28 ]
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 45
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = getelementptr inbounds i8, i8* %22, i64 1
%27 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %4, i32* %5)
br label %28
28: ; preds = %19, %25
%29 = add nuw nsw i64 %20, 1
%30 = icmp eq i64 %29, %13
br i1 %30, label %14, label %19
31: ; preds = %17, %62
%32 = load i8, i8* %7
%33 = icmp eq i8 %32, 42
br i1 %33, label %34, label %35
34: ; preds = %31
br i1 %11, label %37, label %62
35: ; preds = %31
%36 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %7)
br label %62
37: ; preds = %34, %59
%38 = phi i64 [ %60, %59 ], [ 1, %34 ]
%39 = getelementptr inbounds i8*, i8** %1, i64 %38
%40 = load i8*, i8** %39
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 45
br i1 %42, label %59, label %43
43: ; preds = %37
%44 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%45 = call i32 @assert(i32* %44)
%46 = call i64 @fgets(i8* %7, i32 800, i32* %44)
%47 = icmp eq i64 %46, 0
br i1 %47, label %57, label %48
48: ; preds = %43
%49 = call i64 @fgets(i8* %7, i32 800, i32* %44)
%50 = icmp eq i64 %49, 0
br i1 %50, label %57, label %51
51: ; preds = %48, %51
%52 = load i32, i32* %4
%53 = load i32, i32* %5
%54 = call i32 @csv_to_ades(i8* %7, i32 %52, i32 %53)
%55 = call i64 @fgets(i8* %7, i32 800, i32* %44)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %51
57: ; preds = %51, %48, %43
%58 = call i32 @fclose(i32* %44)
br label %59
59: ; preds = %37, %57
%60 = add nuw nsw i64 %38, 1
%61 = icmp eq i64 %60, %18
br i1 %61, label %62, label %37
62: ; preds = %59, %34, %35
%63 = call i64 @fgets(i8* %7, i32 800, i32* %6)
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %31
65: ; preds = %62, %14
%66 = call i32 @fclose(i32* %6)
ret i32 0
}