#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 */
double M_PI;
double atof(char *);
double atoi(char *);
int /*<<< orphan*/ printf(char *, double, ...);
double sin(int);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  if (argc != 7) {
    usage();
    return 1;
  }
  double f1 = atof(argv[1]);
  double amp_f1 = atof(argv[2]);
  double freq = atof(argv[3]);
  double amp = atof(argv[4]);
  double fA = atof(argv[5]);
  double end = atoi(argv[6]);
  double step_width = 1 / fA;
  double pi = M_PI;
  double erg = 0.00;
  double t = 0;
  for (t = 0; t < end; t += step_width) {
    erg = amp * sin(2 * pi * freq * t);
    if (t > 0.2 * end && t < 0.8 * end) {
      erg += amp_f1 * sin(2 * pi * f1 * t);
    }
    printf("%d\n", (int)(erg * 1024));
  }
  printf("f1:%f a:%f fs:%f as:%f fA:%f end:%f ste:%f", f1, amp_f1, freq, amp,
         fA, end, step_width);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x7,-0x8(%rbp)
je     1183 <main+0x33>
mov    $0x0,%al
call   1060 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1363 <main+0x213>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
call   1070 <atoi@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  0xe09(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    0x2de0(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    132b <main+0x1db>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xdc1(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  0xd83(%rip),%xmm1
mulsd  -0x40(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    12f4 <main+0x1a4>
movsd  -0x60(%rbp),%xmm1
movsd  0xd77(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12f4 <main+0x1a4>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xd4e(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
movaps %xmm0,%xmm2
movsd  -0x70(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xd24(%rip),%xmm0
mulsd  -0x58(%rbp),%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
lea    0xd18(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x48(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1229 <main+0xd9>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm4
movsd  -0x40(%rbp),%xmm5
movsd  -0x48(%rbp),%xmm6
lea    0xcd7(%rip),%rdi
mov    $0x7,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
cmp    $0x7,%edi
jne    12dc <main+0x18c>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x10(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x20(%rsp)
mov    0x18(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x20(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x30(%rsp)
mov    0x28(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x18(%rsp)
mov    0x30(%rbx),%rdi
call   1070 <atoi@plt>
movsd  0xe43(%rip),%xmm1
divsd  0x18(%rsp),%xmm1
movsd  %xmm1,0x28(%rsp)
xorpd  %xmm2,%xmm2
movsd  %xmm0,(%rsp)
ucomisd %xmm2,%xmm0
jbe    12ea <main+0x19a>
mov    0x2e05(%rip),%rax
movsd  (%rax),%xmm0
addsd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x58(%rsp)
movsd  0xe05(%rip),%xmm3
movsd  (%rsp),%xmm1
mulsd  %xmm1,%xmm3
movsd  %xmm3,0x50(%rsp)
movsd  0xdf6(%rip),%xmm3
mulsd  %xmm1,%xmm3
movsd  %xmm3,0x48(%rsp)
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x40(%rsp)
lea    0xde5(%rip),%rbx
jmp    1271 <main+0x121>
nopl   (%rax)
mulsd  0xdd0(%rip),%xmm2
cvttpd2dq %xmm2,%xmm0
cvtdq2pd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x38(%rsp),%xmm2
addsd  0x28(%rsp),%xmm2
movsd  (%rsp),%xmm0
ucomisd %xmm2,%xmm0
jbe    12ea <main+0x19a>
movsd  %xmm2,0x38(%rsp)
movsd  0x58(%rsp),%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
movsd  0x38(%rsp),%xmm1
movapd %xmm0,%xmm2
mulsd  0x30(%rsp),%xmm2
ucomisd 0x50(%rsp),%xmm1
jbe    1240 <main+0xf0>
movsd  0x48(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1240 <main+0xf0>
movsd  0x40(%rsp),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
movapd %xmm2,0x60(%rsp)
call   1050 <sin@plt>
movapd 0x60(%rsp),%xmm2
mulsd  0x20(%rsp),%xmm0
addsd  %xmm0,%xmm2
jmp    1240 <main+0xf0>
xor    %eax,%eax
call   1060 <usage@plt>
mov    $0x1,%eax
jmp    1323 <main+0x1d3>
lea    0xd33(%rip),%rdi
movsd  0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movsd  0x30(%rsp),%xmm3
movsd  0x18(%rsp),%xmm4
movsd  (%rsp),%xmm5
movsd  0x28(%rsp),%xmm6
mov    $0x7,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [43 x i8] c"f1:%f a:%f fs:%f as:%f fA:%f end:%f ste:%f\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 7
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 (...) @usage()
store i32 1, i32* %3
br label %103
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call double @atof(i8* %23)
store double %24, double* %6
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call double @atof(i8* %27)
store double %28, double* %7
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
%32 = call double @atof(i8* %31)
store double %32, double* %8
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 4
%35 = load i8*, i8** %34
%36 = call double @atof(i8* %35)
store double %36, double* %9
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 5
%39 = load i8*, i8** %38
%40 = call double @atof(i8* %39)
store double %40, double* %10
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 6
%43 = load i8*, i8** %42
%44 = call double @atoi(i8* %43)
store double %44, double* %11
%45 = load double, double* %10
%46 = fdiv double 1.000000e+00, %45
store double %46, double* %12
%47 = load double, double* @M_PI
store double %47, double* %13
store double 0.000000e+00, double* %14
store double 0.000000e+00, double* %15
store double 0.000000e+00, double* %15
br label %48
48: ; preds = %90, %20
%49 = load double, double* %15
%50 = load double, double* %11
%51 = fcmp olt double %49, %50
br i1 %51, label %52, label %94
52: ; preds = %48
%53 = load double, double* %9
%54 = load double, double* %13
%55 = fmul double 2.000000e+00, %54
%56 = load double, double* %8
%57 = fmul double %55, %56
%58 = load double, double* %15
%59 = fmul double %57, %58
%60 = fptosi double %59 to i32
%61 = call double @sin(i32 %60)
%62 = fmul double %53, %61
store double %62, double* %14
%63 = load double, double* %15
%64 = load double, double* %11
%65 = fmul double 2.000000e-01, %64
%66 = fcmp ogt double %63, %65
br i1 %66, label %67, label %84
67: ; preds = %52
%68 = load double, double* %15
%69 = load double, double* %11
%70 = fmul double 8.000000e-01, %69
%71 = fcmp olt double %68, %70
br i1 %71, label %72, label %84
72: ; preds = %67
%73 = load double, double* %7
%74 = load double, double* %13
%75 = fmul double 2.000000e+00, %74
%76 = load double, double* %6
%77 = fmul double %75, %76
%78 = load double, double* %15
%79 = fmul double %77, %78
%80 = fptosi double %79 to i32
%81 = call double @sin(i32 %80)
%82 = load double, double* %14
%83 = call double @llvm.fmuladd.f64(double %73, double %81, double %82)
store double %83, double* %14
br label %84
84: ; preds = %72, %67, %52
%85 = load double, double* %14
%86 = fmul double %85, 1.024000e+03
%87 = fptosi double %86 to i32
%88 = sitofp i32 %87 to double
%89 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %88)
br label %90
90: ; preds = %84
%91 = load double, double* %12
%92 = load double, double* %15
%93 = fadd double %92, %91
store double %93, double* %15
br label %48
94: ; preds = %48
%95 = load double, double* %6
%96 = load double, double* %7
%97 = load double, double* %8
%98 = load double, double* %9
%99 = load double, double* %10
%100 = load double, double* %11
%101 = load double, double* %12
%102 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), double %95, double %96, double %97, double %98, double %99, double %100, double %101)
store i32 0, i32* %3
br label %103
103: ; preds = %94, %18
%104 = load i32, i32* %3
ret i32 %104
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [43 x i8] c"f1:%f a:%f fs:%f as:%f fA:%f end:%f ste:%f\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 7
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %58
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call double @atof(i8* %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call double @atof(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 3
%14 = load i8*, i8** %13
%15 = tail call double @atof(i8* %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 4
%17 = load i8*, i8** %16
%18 = tail call double @atof(i8* %17)
%19 = getelementptr inbounds i8*, i8** %1, i64 5
%20 = load i8*, i8** %19
%21 = tail call double @atof(i8* %20)
%22 = getelementptr inbounds i8*, i8** %1, i64 6
%23 = load i8*, i8** %22
%24 = tail call double @atoi(i8* %23)
%25 = fdiv double 1.000000e+00, %21
%26 = fcmp ogt double %24, 0.000000e+00
br i1 %26, label %27, label %56
27: ; preds = %6
%28 = load double, double* @M_PI
%29 = fmul double %28, 2.000000e+00
%30 = fmul double %15, %29
%31 = fmul double %24, 2.000000e-01
%32 = fmul double %24, 8.000000e-01
%33 = fmul double %9, %29
br label %34
34: ; preds = %27, %48
%35 = phi double [ 0.000000e+00, %27 ], [ %54, %48 ]
%36 = fmul double %30, %35
%37 = fptosi double %36 to i32
%38 = tail call double @sin(i32 %37)
%39 = fmul double %18, %38
%40 = fcmp ogt double %35, %31
%41 = fcmp olt double %35, %32
%42 = and i1 %40, %41
br i1 %42, label %43, label %48
43: ; preds = %34
%44 = fmul double %33, %35
%45 = fptosi double %44 to i32
%46 = tail call double @sin(i32 %45)
%47 = tail call double @llvm.fmuladd.f64(double %12, double %46, double %39)
br label %48
48: ; preds = %43, %34
%49 = phi double [ %47, %43 ], [ %39, %34 ]
%50 = fmul double %49, 1.024000e+03
%51 = fptosi double %50 to i32
%52 = sitofp i32 %51 to double
%53 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %52)
%54 = fadd double %25, %35
%55 = fcmp olt double %54, %24
br i1 %55, label %34, label %56
56: ; preds = %48, %6
%57 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), double %9, double %12, double %15, double %18, double %21, double %24, double %25)
br label %58
58: ; preds = %56, %4
%59 = phi i32 [ 1, %4 ], [ 0, %56 ]
ret i32 %59
}