#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*/ FILE;

/* Variables and functions */
double M_PI;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, double);
int /*<<< orphan*/ printf(char *);
int scanf(char *, ...);
void IdealFilter() {
  int i, j;
  int N;
  int NumOfPts;
  int scan_temp;
  double W[1024];
  double M[1024];
  double w[1024];
  double m[1024];
  FILE *fp;
  fp = fopen("IdealMagRes.txt", "w");
  printf("Enter the filter frequency response in terms of peicewise continuous "
         "points\n");
  do {
    printf("Enter number of points < 1024:");
    scan_temp = scanf("%d", &N);
  } while ((N >= 1024) && (N < 0));
  printf("Enter magnitude at F=0\n");
  W[0] = 0;
  scan_temp = scanf("%lf", &M[0]);
  for (i = 1; i < N - 1; i++) {
    printf("Enter digital frequency F 0 < F/pi < 1 \n");
    scan_temp = scanf("%lf", &W[i]);
    W[i] = W[i] * M_PI;
    printf("Enter magnitude\n");
    scan_temp = scanf("%lf", &M[i]);
  }
  printf("Enter magnitude at Pi\n");
  scan_temp = scanf("%lf", &M[i]);
  printf("Writing ideal frequency response into file IdealMagRes.txt\n");
  printf("Enter number of points of response:");
  scan_temp = scanf("%d", &NumOfPts);
  for (i = 0, j = 1; i < NumOfPts; i++) {
    w[i] = i * (M_PI / NumOfPts);
    while (w[i] > W[j]) {
      j++;
    }
    m[i] = M[j - 1] +
           ((M[j - 1] - M[j]) * ((w[i] - W[j - 1]) / (W[j - 1] - W[j])));
    fprintf(fp, "%lf\t%lf\n", w[i], m[i]);
  }
  for (i = 0; i < NumOfPts; i++) {
    fprintf(fp, "%lf\t%lf\n", (2 * M_PI) - w[NumOfPts - i - 1],
            m[NumOfPts - i - 1]);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<IdealFilter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8030,%rsp
lea    0xe9e(%rip),%rdi
lea    0xea7(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8028(%rbp)
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
call   1040 <printf@plt>
lea    0xeea(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x400,-0xc(%rbp)
mov    %al,-0x8029(%rbp)
jl     11c4 <IdealFilter+0x74>
cmpl   $0x0,-0xc(%rbp)
setl   %al
mov    %al,-0x8029(%rbp)
mov    -0x8029(%rbp),%al
test   $0x1,%al
jne    1181 <IdealFilter+0x31>
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x2020(%rbp)
ff
lea    -0x4020(%rbp),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12aa <IdealFilter+0x15a>
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
movslq -0x4(%rbp),%rax
lea    -0x2020(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0x14(%rbp)
movslq -0x4(%rbp),%rax
movsd  -0x2020(%rbp,%rax,8),%xmm0
ff ff
mov    0x2d8c(%rip),%rax
mulsd  (%rax),%xmm0
movslq -0x4(%rbp),%rax
movsd  %xmm0,-0x2020(%rbp,%rax,8)
ff ff
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
movslq -0x4(%rbp),%rax
lea    -0x4020(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1208 <IdealFilter+0xb8>
lea    0xe26(%rip),%rdi
call   1040 <printf@plt>
movslq -0x4(%rbp),%rax
lea    -0x4020(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0x14(%rbp)
lea    0xe0e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
lea    0xd86(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1437 <IdealFilter+0x2e7>
cvtsi2sdl -0x4(%rbp),%xmm0
mov    0x2cbc(%rip),%rax
movsd  (%rax),%xmm1
cvtsi2sdl -0x10(%rbp),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movslq -0x4(%rbp),%rax
movsd  %xmm0,-0x6020(%rbp,%rax,8)
ff ff
movslq -0x4(%rbp),%rax
movsd  -0x6020(%rbp,%rax,8),%xmm0
ff ff
movslq -0x8(%rbp),%rax
ucomisd -0x2020(%rbp,%rax,8),%xmm0
ff ff
jbe    1378 <IdealFilter+0x228>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    134a <IdealFilter+0x1fa>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x4020(%rbp,%rax,8),%xmm1
ff ff
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x4020(%rbp,%rax,8),%xmm0
ff ff
movslq -0x8(%rbp),%rax
subsd  -0x4020(%rbp,%rax,8),%xmm0
ff ff
movslq -0x4(%rbp),%rax
movsd  -0x6020(%rbp,%rax,8),%xmm2
ff ff
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
subsd  -0x2020(%rbp,%rax,8),%xmm2
ff ff
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x2020(%rbp,%rax,8),%xmm3
ff ff
movslq -0x8(%rbp),%rax
subsd  -0x2020(%rbp,%rax,8),%xmm3
ff ff
divsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0x4(%rbp),%rax
movsd  %xmm0,-0x8020(%rbp,%rax,8)
ff ff
mov    -0x8028(%rbp),%rdi
movslq -0x4(%rbp),%rax
cvttsd2si -0x6020(%rbp,%rax,8),%edx
ff ff
movslq -0x4(%rbp),%rax
movsd  -0x8020(%rbp,%rax,8),%xmm0
ff ff
lea    0xd2a(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1314 <IdealFilter+0x1c4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    14c1 <IdealFilter+0x371>
mov    -0x8028(%rbp),%rdi
mov    0x2b90(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%eax
sub    -0x4(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x6020(%rbp,%rax,8),%xmm1
ff ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
mov    -0x10(%rbp),%eax
sub    -0x4(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x8020(%rbp,%rax,8),%xmm0
ff ff
lea    0xca0(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    143e <IdealFilter+0x2ee>
mov    -0x8028(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x8030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IdealFilter>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8018,%rsp
lea    0xf81(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe68(%rip),%rdi
call   1050 <printf@plt>
lea    0xe7b(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
movq   $0x0,0x2010(%rsp)
lea    0xe53(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    $0x1,%r12d
cmpl   $0x3,0xc(%rsp)
jl     126b <IdealFilter+0x10b>
lea    0x18(%rsp),%r14
lea    0x2018(%rsp),%rbx
mov    $0x1,%r12d
lea    0xe1c(%rip),%r13
lea    0xf22(%rip),%rbp
nop
lea    0xef2(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movsd  (%rbx),%xmm0
mov    0x2db4(%rip),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rbx)
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
add    $0x1,%r12
movslq 0xc(%rsp),%rax
add    $0xffffffffffffffff,%rax
add    $0x8,%r14
add    $0x8,%rbx
cmp    %rax,%r12
jl     1210 <IdealFilter+0xb0>
lea    0xe46(%rip),%rdi
call   1030 <puts@plt>
lea    (%rsp,%r12,8),%rsi
add    $0x10,%rsi
lea    0xd9e(%rip),%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xe3a(%rip),%rdi
call   1030 <puts@plt>
lea    0xd88(%rip),%rdi
call   1050 <printf@plt>
lea    0xd75(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x8(%rsp),%eax
test   %eax,%eax
jle    13fd <IdealFilter+0x29d>
mov    $0x1,%ebx
xor    %ebp,%ebp
mov    0x2d16(%rip),%r12
movabs $0x100000000,%r13
lea    0xd69(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
movsd  (%r12),%xmm0
divsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x6010(%rsp,%rbp,8)
mov    %rbx,%rax
shl    $0x20,%rax
movabs $0xfffffffe00000000,%rcx
ff ff ff
add    %rcx,%rax
movslq %ebx,%rbx
add    $0xffffffffffffffff,%rbx
add    %r13,%rax
movsd  0x2018(%rsp,%rbx,8),%xmm1
add    $0x1,%rbx
ucomisd %xmm1,%xmm0
ja     1330 <IdealFilter+0x1d0>
sar    $0x1d,%rax
movsd  0x10(%rsp,%rax,1),%xmm2
movapd %xmm2,%xmm3
subsd  0x10(%rsp,%rbx,8),%xmm3
movsd  0x2010(%rsp,%rax,1),%xmm4
cvttsd2si %xmm0,%edx
subsd  %xmm4,%xmm0
subsd  %xmm1,%xmm4
divsd  %xmm4,%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x4010(%rsp,%rbp,8)
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <fprintf@plt>
add    $0x1,%rbp
movslq 0x8(%rsp),%rax
cmp    %rax,%rbp
jl     12f0 <IdealFilter+0x190>
test   %eax,%eax
jle    13fd <IdealFilter+0x29d>
xor    %ebp,%ebp
mov    $0xffffffff,%ebx
lea    0xc99(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%r12),%xmm0
add    %ebx,%eax
cltq
addsd  %xmm0,%xmm0
subsd  0x6010(%rsp,%rax,8),%xmm0
cvttsd2si %xmm0,%edx
movsd  0x4010(%rsp,%rax,8),%xmm0
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <fprintf@plt>
add    $0x1,%ebp
mov    0x8(%rsp),%eax
add    $0xffffffff,%ebx
cmp    %ebp,%eax
jg     13c0 <IdealFilter+0x260>
mov    %r15,%rdi
call   1040 <fclose@plt>
add    $0x8018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"IdealMagRes.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [77 x i8] c"Enter the filter frequency response in terms of peicewise continuous points\0A\00"
@.str.3 = [31 x i8] c"Enter number of points < 1024:\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [24 x i8] c"Enter magnitude at F=0\0A\00"
@.str.6 = [4 x i8] c"%lf\00"
@.str.7 = [41 x i8] c"Enter digital frequency F 0 < F/pi < 1 \0A\00"
@M_PI = global double 0.000000e+00
@.str.8 = [17 x i8] c"Enter magnitude\0A\00"
@.str.9 = [23 x i8] c"Enter magnitude at Pi\0A\00"
@.str.10 = [60 x i8] c"Writing ideal frequency response into file IdealMagRes.txt\0A\00"
@.str.11 = [36 x i8] c"Enter number of points of response:\00"
@.str.12 = [9 x i8] c"%lf\09%lf\0A\00"
define void @IdealFilter() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1024 x double]
%7 = alloca [1024 x double]
%8 = alloca [1024 x double]
%9 = alloca [1024 x double]
%10 = alloca i32*
%11 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %10
%12 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %22, %0
%14 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
store i32 %15, i32* %5
br label %16
16: ; preds = %13
%17 = load i32, i32* %3
%18 = icmp sge i32 %17, 1024
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 0
br label %22
22: ; preds = %19, %16
%23 = phi i1 [ false, %16 ], [ %21, %19 ]
br i1 %23, label %13, label %24
24: ; preds = %22
%25 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%26 = getelementptr inbounds [1024 x double], [1024 x double]* %6, i64 0, i64 0
store double 0.000000e+00, double* %26
%27 = getelementptr inbounds [1024 x double], [1024 x double]* %7, i64 0, i64 0
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %27)
store i32 %28, i32* %5
store i32 1, i32* %1
br label %29
29: ; preds = %54, %24
%30 = load i32, i32* %1
%31 = load i32, i32* %3
%32 = sub nsw i32 %31, 1
%33 = icmp slt i32 %30, %32
br i1 %33, label %34, label %57
34: ; preds = %29
%35 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0))
%36 = load i32, i32* %1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [1024 x double], [1024 x double]* %6, i64 0, i64 %37
%39 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %38)
store i32 %39, i32* %5
%40 = load i32, i32* %1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [1024 x double], [1024 x double]* %6, i64 0, i64 %41
%43 = load double, double* %42
%44 = load double, double* @M_PI
%45 = fmul double %43, %44
%46 = load i32, i32* %1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [1024 x double], [1024 x double]* %6, i64 0, i64 %47
store double %45, double* %48
%49 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%50 = load i32, i32* %1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [1024 x double], [1024 x double]* %7, i64 0, i64 %51
%53 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %52)
store i32 %53, i32* %5
br label %54
54: ; preds = %34
%55 = load i32, i32* %1
%56 = add nsw i32 %55, 1
store i32 %56, i32* %1
br label %29
57: ; preds = %29
%58 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0))
%59 = load i32, i32* %1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [1024 x double], [1024 x double]* %7, i64 0, i64 %60
%62 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %61)
store i32 %62, i32* %5
%63 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.10, i64 0, i64 0))
%64 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.11, i64 0, i64 0))
%65 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
store i32 %65, i32* %5
store i32 0, i32* %1
store i32 1, i32* %2
br label %66
66: ; preds = %146, %57
%67 = load i32, i32* %1
%68 = load i32, i32* %4
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %149
70: ; preds = %66
%71 = load i32, i32* %1
%72 = sitofp i32 %71 to double
%73 = load double, double* @M_PI
%74 = load i32, i32* %4
%75 = sitofp i32 %74 to double
%76 = fdiv double %73, %75
%77 = fmul double %72, %76
%78 = load i32, i32* %1
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [1024 x double], [1024 x double]* %8, i64 0, i64 %79
store double %77, double* %80
br label %81
81: ; preds = %91, %70
%82 = load i32, i32* %1
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [1024 x double], [1024 x double]* %8, i64 0, i64 %83
%85 = load double, double* %84
%86 = load i32, i32* %2
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [1024 x double], [1024 x double]* %6, i64 0, i64 %87
%89 = load double, double* %88
%90 = fcmp ogt double %85, %89
br i1 %90, label %91, label %94
91: ; preds = %81
%92 = load i32, i32* %2
%93 = add nsw i32 %92, 1
store i32 %93, i32* %2
br label %81
94: ; preds = %81
%95 = load i32, i32* %2
%96 = sub nsw i32 %95, 1
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds [1024 x double], [1024 x double]* %7, i64 0, i64 %97
%99 = load double, double* %98
%100 = load i32, i32* %2
%101 = sub nsw i32 %100, 1
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [1024 x double], [1024 x double]* %7, i64 0, i64 %102
%104 = load double, double* %103
%105 = load i32, i32* %2
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [1024 x double], [1024 x double]* %7, i64 0, i64 %106
%108 = load double, double* %107
%109 = fsub double %104, %108
%110 = load i32, i32* %1
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [1024 x double], [1024 x double]* %8, i64 0, i64 %111
%113 = load double, double* %112
%114 = load i32, i32* %2
%115 = sub nsw i32 %114, 1
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [1024 x double], [1024 x double]* %6, i64 0, i64 %116
%118 = load double, double* %117
%119 = fsub double %113, %118
%120 = load i32, i32* %2
%121 = sub nsw i32 %120, 1
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [1024 x double], [1024 x double]* %6, i64 0, i64 %122
%124 = load double, double* %123
%125 = load i32, i32* %2
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds [1024 x double], [1024 x double]* %6, i64 0, i64 %126
%128 = load double, double* %127
%129 = fsub double %124, %128
%130 = fdiv double %119, %129
%131 = call double @llvm.fmuladd.f64(double %109, double %130, double %99)
%132 = load i32, i32* %1
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds [1024 x double], [1024 x double]* %9, i64 0, i64 %133
store double %131, double* %134
%135 = load i32*, i32** %10
%136 = load i32, i32* %1
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds [1024 x double], [1024 x double]* %8, i64 0, i64 %137
%139 = load double, double* %138
%140 = fptosi double %139 to i32
%141 = load i32, i32* %1
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds [1024 x double], [1024 x double]* %9, i64 0, i64 %142
%144 = load double, double* %143
%145 = call i32 @fprintf(i32* %135, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %140, double %144)
br label %146
146: ; preds = %94
%147 = load i32, i32* %1
%148 = add nsw i32 %147, 1
store i32 %148, i32* %1
br label %66
149: ; preds = %66
store i32 0, i32* %1
br label %150
150: ; preds = %175, %149
%151 = load i32, i32* %1
%152 = load i32, i32* %4
%153 = icmp slt i32 %151, %152
br i1 %153, label %154, label %178
154: ; preds = %150
%155 = load i32*, i32** %10
%156 = load double, double* @M_PI
%157 = load i32, i32* %4
%158 = load i32, i32* %1
%159 = sub nsw i32 %157, %158
%160 = sub nsw i32 %159, 1
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds [1024 x double], [1024 x double]* %8, i64 0, i64 %161
%163 = load double, double* %162
%164 = fneg double %163
%165 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %156, double %164)
%166 = fptosi double %165 to i32
%167 = load i32, i32* %4
%168 = load i32, i32* %1
%169 = sub nsw i32 %167, %168
%170 = sub nsw i32 %169, 1
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds [1024 x double], [1024 x double]* %9, i64 0, i64 %171
%173 = load double, double* %172
%174 = call i32 @fprintf(i32* %155, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %166, double %173)
br label %175
175: ; preds = %154
%176 = load i32, i32* %1
%177 = add nsw i32 %176, 1
store i32 %177, i32* %1
br label %150
178: ; preds = %150
%179 = load i32*, i32** %10
%180 = call i32 @fclose(i32* %179)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"IdealMagRes.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [31 x i8] c"Enter number of points < 1024:\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.6 = [4 x i8] c"%lf\00"
@M_PI = global double 0.000000e+00
@.str.11 = [36 x i8] c"Enter number of points of response:\00"
@.str.12 = [9 x i8] c"%lf\09%lf\0A\00"
@str = [76 x i8] c"Enter the filter frequency response in terms of peicewise continuous points\00"
@str.13 = [23 x i8] c"Enter magnitude at F=0\00"
@str.14 = [22 x i8] c"Enter magnitude at Pi\00"
@str.15 = [59 x i8] c"Writing ideal frequency response into file IdealMagRes.txt\00"
@str.16 = [40 x i8] c"Enter digital frequency F 0 < F/pi < 1 \00"
@str.17 = [16 x i8] c"Enter magnitude\00"
define void @IdealFilter() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1024 x double]
%4 = alloca [1024 x double]
%5 = alloca [1024 x double]
%6 = alloca [1024 x double]
%7 = bitcast i32* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = bitcast [1024 x double]* %3 to i8*
%10 = bitcast [1024 x double]* %4 to i8*
%11 = bitcast [1024 x double]* %5 to i8*
%12 = bitcast [1024 x double]* %6 to i8*
%13 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.13, i64 0, i64 0))
%18 = getelementptr inbounds [1024 x double], [1024 x double]* %3, i64 0, i64 0
store double 0.000000e+00, double* %18
%19 = getelementptr inbounds [1024 x double], [1024 x double]* %4, i64 0, i64 0
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %19)
%21 = load i32, i32* %1
%22 = icmp sgt i32 %21, 2
br i1 %22, label %23, label %41
23: ; preds = %0, %23
%24 = phi i64 [ %34, %23 ], [ 1, %0 ]
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.16, i64 0, i64 0))
%26 = getelementptr inbounds [1024 x double], [1024 x double]* %3, i64 0, i64 %24
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %26)
%28 = load double, double* %26
%29 = load double, double* @M_PI
%30 = fmul double %28, %29
store double %30, double* %26
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.17, i64 0, i64 0))
%32 = getelementptr inbounds [1024 x double], [1024 x double]* %4, i64 0, i64 %24
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %32)
%34 = add nuw nsw i64 %24, 1
%35 = load i32, i32* %1
%36 = add nsw i32 %35, -1
%37 = sext i32 %36 to i64
%38 = icmp slt i64 %34, %37
br i1 %38, label %23, label %39
39: ; preds = %23
%40 = and i64 %34, 4294967295
br label %41
41: ; preds = %39, %0
%42 = phi i64 [ 1, %0 ], [ %40, %39 ]
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.14, i64 0, i64 0))
%44 = getelementptr inbounds [1024 x double], [1024 x double]* %4, i64 0, i64 %42
%45 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %44)
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.15, i64 0, i64 0))
%47 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.11, i64 0, i64 0))
%48 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%49 = load i32, i32* %2
%50 = icmp sgt i32 %49, 0
br i1 %50, label %53, label %112
51: ; preds = %72
%52 = icmp sgt i32 %91, 0
br i1 %52, label %94, label %112
53: ; preds = %41, %72
%54 = phi i64 [ %90, %72 ], [ 0, %41 ]
%55 = phi i32 [ %91, %72 ], [ %49, %41 ]
%56 = phi i64 [ %67, %72 ], [ 1, %41 ]
%57 = trunc i64 %54 to i32
%58 = sitofp i32 %57 to double
%59 = load double, double* @M_PI
%60 = sitofp i32 %55 to double
%61 = fdiv double %59, %60
%62 = fmul double %61, %58
%63 = getelementptr inbounds [1024 x double], [1024 x double]* %5, i64 0, i64 %54
store double %62, double* %63
%64 = shl i64 %56, 32
%65 = ashr exact i64 %64, 32
br label %66
66: ; preds = %66, %53
%67 = phi i64 [ %71, %66 ], [ %65, %53 ]
%68 = getelementptr inbounds [1024 x double], [1024 x double]* %3, i64 0, i64 %67
%69 = load double, double* %68
%70 = fcmp ogt double %62, %69
%71 = add i64 %67, 1
br i1 %70, label %66, label %72
72: ; preds = %66
%73 = shl i64 %67, 32
%74 = add i64 %73, -4294967296
%75 = ashr exact i64 %74, 32
%76 = getelementptr inbounds [1024 x double], [1024 x double]* %4, i64 0, i64 %75
%77 = load double, double* %76
%78 = getelementptr inbounds [1024 x double], [1024 x double]* %4, i64 0, i64 %67
%79 = load double, double* %78
%80 = fsub double %77, %79
%81 = getelementptr inbounds [1024 x double], [1024 x double]* %3, i64 0, i64 %75
%82 = load double, double* %81
%83 = fsub double %62, %82
%84 = fsub double %82, %69
%85 = fdiv double %83, %84
%86 = call double @llvm.fmuladd.f64(double %80, double %85, double %77)
%87 = getelementptr inbounds [1024 x double], [1024 x double]* %6, i64 0, i64 %54
store double %86, double* %87
%88 = fptosi double %62 to i32
%89 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %88, double %86)
%90 = add nuw nsw i64 %54, 1
%91 = load i32, i32* %2
%92 = sext i32 %91 to i64
%93 = icmp slt i64 %90, %92
br i1 %93, label %53, label %51
94: ; preds = %51, %94
%95 = phi i32 [ %110, %94 ], [ %91, %51 ]
%96 = phi i32 [ %109, %94 ], [ 0, %51 ]
%97 = load double, double* @M_PI
%98 = xor i32 %96, -1
%99 = add i32 %95, %98
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds [1024 x double], [1024 x double]* %5, i64 0, i64 %100
%102 = load double, double* %101
%103 = fneg double %102
%104 = call double @llvm.fmuladd.f64(double %97, double 2.000000e+00, double %103)
%105 = fptosi double %104 to i32
%106 = getelementptr inbounds [1024 x double], [1024 x double]* %6, i64 0, i64 %100
%107 = load double, double* %106
%108 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %105, double %107)
%109 = add nuw nsw i32 %96, 1
%110 = load i32, i32* %2
%111 = icmp sgt i32 %110, %109
br i1 %111, label %94, label %112
112: ; preds = %94, %41, %51
%113 = call i32 @fclose(i32* %13)
ret void
}