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

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, int, ...);
scalar_t__ sscanf(char *, char *, float *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *in_file;
  char input_str[256];
  float input_flt[200] = {0};
  unsigned int float_count;
  int i;
  if (argc != 2) {
    fprintf(stderr, "Need an input file\n");
    return 0;
  }
  if ((in_file = fopen(argv[1], "r")) == NULL) {
    fprintf(stderr, "Error opening filter tap file\n");
  }
  float_count = 0;
  while (fgets(input_str, sizeof(input_str), in_file)) {
    if (input_str[0] == '#' || input_str[0] == '\n') {
      continue;
    }
    if (sscanf(input_str, "%f", &input_flt[float_count]) == EOF) {
      fprintf(stderr, "Error scanning float filter tap\n");
      break;
    }
    float_count++;
  }
  printf("Read in %d floats\n", float_count);
  fclose(in_file);
  for (i = 0; i < 200; i++) {
    printf("Float[%d] = %e\n", i, input_flt[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x440(%rbp),%rdi
xor    %esi,%esi
mov    $0x320,%edx
call   1050 <memset@plt>
cmpl   $0x2,-0x8(%rbp)
je     11c7 <main+0x57>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    132b <main+0x1bb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11fe <main+0x8e>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
lea    0xe1d(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x0,-0x444(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12b1 <main+0x141>
movsbl -0x120(%rbp),%eax
cmp    $0x23,%eax
je     1247 <main+0xd7>
movsbl -0x120(%rbp),%eax
cmp    $0xa,%eax
jne    124c <main+0xdc>
jmp    1208 <main+0x98>
lea    -0x120(%rbp),%rdi
mov    -0x444(%rbp),%eax
lea    -0x440(%rbp),%rdx
shl    $0x2,%rax
add    %rax,%rdx
lea    0xdc7(%rip),%rsi
call   1080 <sscanf@plt>
mov    0x2d6e(%rip),%rcx
cmp    (%rcx),%rax
jne    129d <main+0x12d>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
lea    0xda5(%rip),%rsi
call   1070 <fprintf@plt>
jmp    12b1 <main+0x141>
mov    -0x444(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x444(%rbp)
jmp    1208 <main+0x98>
mov    -0x444(%rbp),%esi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x448(%rbp)
cmpl   $0xc8,-0x448(%rbp)
jge    1324 <main+0x1b4>
mov    -0x448(%rbp),%esi
movslq -0x448(%rbp),%rax
movss  -0x440(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
lea    0xd63(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x448(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x448(%rbp)
jmp    12d8 <main+0x168>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x420,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x100(%rsp),%rdi
mov    $0x320,%edx
xor    %esi,%esi
call   1050 <memset@plt>
cmp    $0x2,%ebp
jne    1246 <main+0xd6>
mov    0x8(%rbx),%rdi
lea    0xe68(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11ce <main+0x5e>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1070 <fprintf@plt>
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     1272 <main+0x102>
mov    %rsp,%rbp
lea    0xe41(%rip),%r15
mov    0x2ded(%rip),%r12
jmp    1215 <main+0xa5>
nopl   (%rax)
mov    %rbp,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1272 <main+0x102>
movzbl (%rsp),%eax
cmp    $0x23,%al
je     1200 <main+0x90>
cmp    $0xa,%al
je     1200 <main+0x90>
mov    %r14d,%eax
lea    (%rsp,%rax,4),%rdx
add    $0x100,%rdx
mov    %rbp,%rdi
mov    %r15,%rsi
call   1080 <sscanf@plt>
cmp    (%r12),%rax
je     125d <main+0xed>
add    $0x1,%r14d
jmp    1200 <main+0x90>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
lea    0xdaa(%rip),%rsi
call   1070 <fprintf@plt>
jmp    12c6 <main+0x156>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
lea    0xdcb(%rip),%rsi
call   1070 <fprintf@plt>
lea    0xde0(%rip),%rdi
xor    %ebp,%ebp
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xdd8(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movss  0x100(%rsp,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    $0xc8,%rbp
jne    12a0 <main+0x130>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Need an input file\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"Error opening filter tap file\0A\00"
@.str.3 = [3 x i8] c"%f\00"
@EOF = global i64 0
@.str.4 = [33 x i8] c"Error scanning float filter tap\0A\00"
@.str.5 = [19 x i8] c"Read in %d floats\0A\00"
@.str.6 = [16 x i8] c"Float[%d] = %e\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [256 x i8]
%8 = alloca [200 x float]
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [200 x float]* %8 to i8*
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %77
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %6
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %26
23: ; preds = %17
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %23, %17
store i32 0, i32* %9
br label %27
27: ; preds = %54, %42, %26
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%29 = load i32*, i32** %6
%30 = call i64 @fgets(i8* %28, i32 256, i32* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %57
32: ; preds = %27
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 35
br i1 %36, label %42, label %37
37: ; preds = %32
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 10
br i1 %41, label %42, label %43
42: ; preds = %37, %32
br label %27
43: ; preds = %37
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%45 = load i32, i32* %9
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds [200 x float], [200 x float]* %8, i64 0, i64 %46
%48 = call i64 @sscanf(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %47)
%49 = load i64, i64* @EOF
%50 = icmp eq i64 %48, %49
br i1 %50, label %51, label %54
51: ; preds = %43
%52 = load i32, i32* @stderr
%53 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %57
54: ; preds = %43
%55 = load i32, i32* %9
%56 = add i32 %55, 1
store i32 %56, i32* %9
br label %27
57: ; preds = %51, %27
%58 = load i32, i32* %9
%59 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %58)
%60 = load i32*, i32** %6
%61 = call i32 @fclose(i32* %60)
store i32 0, i32* %10
br label %62
62: ; preds = %73, %57
%63 = load i32, i32* %10
%64 = icmp slt i32 %63, 200
br i1 %64, label %65, label %76
65: ; preds = %62
%66 = load i32, i32* %10
%67 = load i32, i32* %10
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [200 x float], [200 x float]* %8, i64 0, i64 %68
%70 = load float, float* %69
%71 = fpext float %70 to double
%72 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %66, double %71)
br label %73
73: ; preds = %65
%74 = load i32, i32* %10
%75 = add nsw i32 %74, 1
store i32 %75, i32* %10
br label %62
76: ; preds = %62
store i32 0, i32* %3
br label %77
77: ; preds = %76, %14
%78 = load i32, i32* %3
ret i32 %78
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Need an input file\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"Error opening filter tap file\0A\00"
@.str.3 = [3 x i8] c"%f\00"
@EOF = global i64 0
@.str.4 = [33 x i8] c"Error scanning float filter tap\0A\00"
@.str.5 = [19 x i8] c"Read in %d floats\0A\00"
@.str.6 = [16 x i8] c"Float[%d] = %e\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [200 x float]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = bitcast [200 x float]* %4 to i8*
%7 = icmp eq i32 %0, 2
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %55
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %16, %11
%20 = call i64 @fgets(i8* %5, i32 256, i32* %14)
%21 = icmp eq i64 %20, 0
br i1 %21, label %42, label %22
22: ; preds = %19, %38
%23 = phi i32 [ %39, %38 ], [ 0, %19 ]
br label %24
24: ; preds = %22, %26
%25 = load i8, i8* %5
switch i8 %25, label %29 [
i8 35, label %26
i8 10, label %26
]
26: ; preds = %24, %24
%27 = call i64 @fgets(i8* %5, i32 256, i32* %14)
%28 = icmp eq i64 %27, 0
br i1 %28, label %42, label %24
29: ; preds = %24
%30 = zext i32 %23 to i64
%31 = getelementptr inbounds [200 x float], [200 x float]* %4, i64 0, i64 %30
%32 = call i64 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %31)
%33 = load i64, i64* @EOF
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %38
35: ; preds = %29
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %42
38: ; preds = %29
%39 = add i32 %23, 1
%40 = call i64 @fgets(i8* %5, i32 256, i32* %14)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %22
42: ; preds = %38, %26, %19, %35
%43 = phi i32 [ %23, %35 ], [ 0, %19 ], [ %23, %26 ], [ %39, %38 ]
%44 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %43)
%45 = call i32 @fclose(i32* %14)
br label %46
46: ; preds = %42, %46
%47 = phi i64 [ 0, %42 ], [ %53, %46 ]
%48 = getelementptr inbounds [200 x float], [200 x float]* %4, i64 0, i64 %47
%49 = load float, float* %48
%50 = fpext float %49 to double
%51 = trunc i64 %47 to i32
%52 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %51, double %50)
%53 = add nuw nsw i64 %47, 1
%54 = icmp eq i64 %53, 200
br i1 %54, label %55, label %46
55: ; preds = %46, %8
ret i32 0
}