#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 atan(double);
float cos(double);
float sin(double);
int add_signal_vector(float f0, float t0, float amp, unsigned char *symbols,
                      double *isig, double *qsig) {
  int i, j, ii, idelay;
  double phi = 0.0, twopidt, df, dt, dphi;
  twopidt = 8.0 * atan(1.0) / 375.0;
  df = 375.0 / 256.0;
  dt = 1 / 375.0;
  idelay = t0 / dt;
  for (i = 0; i < 162; i++) {
    dphi = twopidt * (f0 + ((double)symbols[i] - 1.5) * df);
    for (j = 0; j < 256; j++) {
      ii = idelay + 256 * i + j;
      isig[ii] = isig[ii] + amp * cos(phi);
      qsig[ii] = qsig[ii] + amp * sin(phi);
      phi = phi + dphi;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<add_signal_vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xeba(%rip),%xmm0
call   1040 <atan@plt>
movaps %xmm0,%xmm1
movsd  0xea2(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe8e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe75(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe60(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  -0x58(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0xa2,-0x2c(%rbp)
jge    12fb <add_signal_vector+0x1cb>
movsd  -0x48(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cvtsi2sd %eax,%xmm1
movsd  0xe34(%rip),%xmm3
subsd  %xmm3,%xmm1
movsd  -0x50(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x100,-0x30(%rbp)
jge    12e8 <add_signal_vector+0x1b8>
mov    -0x38(%rbp),%eax
mov    -0x2c(%rbp),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x7c(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1050 <cos@plt>
movss  -0x7c(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x78(%rbp),%xmm0
mulss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x6c(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <sin@plt>
movss  -0x6c(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
mulss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x40(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1215 <add_signal_vector+0xe5>
jmp    12ed <add_signal_vector+0x1bd>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11c1 <add_signal_vector+0x91>
mov    $0x1,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_signal_vector>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
movss  %xmm2,0x1c(%rsp)
movss  %xmm1,0x8(%rsp)
movss  %xmm0,0x10(%rsp)
movsd  0xea0(%rip),%xmm0
call   1040 <atan@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0xe91(%rip),%xmm0
cvttsd2si %xmm0,%eax
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x20(%rsp)
cltq
lea    (%r15,%rax,8),%r15
lea    (%r14,%rax,8),%r13
xorps  %xmm0,%xmm0
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
movzbl (%r12,%r14,1),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  0xe5c(%rip),%xmm1
mulsd  0xe5c(%rip),%xmm1
addsd  0x20(%rsp),%xmm1
mulsd  0xe56(%rip),%xmm1
movsd  %xmm1,0x28(%rsp)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,0x10(%rsp)
movsd  (%r15,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
mulss  0x1c(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
movsd  0x0(%r13,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulss  0x1c(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x0(%r13,%rbx,8)
movsd  0x10(%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    11e0 <add_signal_vector+0xb0>
add    $0x1,%r14
add    $0x800,%r15
add    $0x800,%r13
cmp    $0xa2,%r14
jne    11a0 <add_signal_vector+0x70>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @add_signal_vector(float %0, float %1, float %2, i8* %3, double* %4, double* %5) {
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca i8*
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
store float %0, float* %7
store float %1, float* %8
store float %2, float* %9
store i8* %3, i8** %10
store double* %4, double** %11
store double* %5, double** %12
store double 0.000000e+00, double* %17
%22 = call double @atan(double 1.000000e+00)
%23 = fmul double 8.000000e+00, %22
%24 = fdiv double %23, 3.750000e+02
store double %24, double* %18
store double 0x3FF7700000000000, double* %19
store double 0x3F65D867C3ECE2A5, double* %20
%25 = load float, float* %8
%26 = fpext float %25 to double
%27 = load double, double* %20
%28 = fdiv double %26, %27
%29 = fptosi double %28 to i32
store i32 %29, i32* %16
store i32 0, i32* %13
br label %30
30: ; preds = %94, %6
%31 = load i32, i32* %13
%32 = icmp slt i32 %31, 162
br i1 %32, label %33, label %97
33: ; preds = %30
%34 = load double, double* %18
%35 = load float, float* %7
%36 = fpext float %35 to double
%37 = load i8*, i8** %10
%38 = load i32, i32* %13
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = uitofp i8 %41 to double
%43 = fsub double %42, 1.500000e+00
%44 = load double, double* %19
%45 = call double @llvm.fmuladd.f64(double %43, double %44, double %36)
%46 = fmul double %34, %45
store double %46, double* %21
store i32 0, i32* %14
br label %47
47: ; preds = %90, %33
%48 = load i32, i32* %14
%49 = icmp slt i32 %48, 256
br i1 %49, label %50, label %93
50: ; preds = %47
%51 = load i32, i32* %16
%52 = load i32, i32* %13
%53 = mul nsw i32 256, %52
%54 = add nsw i32 %51, %53
%55 = load i32, i32* %14
%56 = add nsw i32 %54, %55
store i32 %56, i32* %15
%57 = load double*, double** %11
%58 = load i32, i32* %15
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %57, i64 %59
%61 = load double, double* %60
%62 = load float, float* %9
%63 = load double, double* %17
%64 = call float @cos(double %63)
%65 = fmul float %62, %64
%66 = fpext float %65 to double
%67 = fadd double %61, %66
%68 = load double*, double** %11
%69 = load i32, i32* %15
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
store double %67, double* %71
%72 = load double*, double** %12
%73 = load i32, i32* %15
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %72, i64 %74
%76 = load double, double* %75
%77 = load float, float* %9
%78 = load double, double* %17
%79 = call float @sin(double %78)
%80 = fmul float %77, %79
%81 = fpext float %80 to double
%82 = fadd double %76, %81
%83 = load double*, double** %12
%84 = load i32, i32* %15
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %83, i64 %85
store double %82, double* %86
%87 = load double, double* %17
%88 = load double, double* %21
%89 = fadd double %87, %88
store double %89, double* %17
br label %90
90: ; preds = %50
%91 = load i32, i32* %14
%92 = add nsw i32 %91, 1
store i32 %92, i32* %14
br label %47
93: ; preds = %47
br label %94
94: ; preds = %93
%95 = load i32, i32* %13
%96 = add nsw i32 %95, 1
store i32 %96, i32* %13
br label %30
97: ; preds = %30
ret i32 1
}

LLVM IR (-O2):
define i32 @add_signal_vector(float %0, float %1, float %2, i8* nocapture %3, double* nocapture %4, double* nocapture %5) {
%7 = tail call double @atan(double 1.000000e+00)
%8 = fpext float %1 to double
%9 = fdiv double %8, 0x3F65D867C3ECE2A5
%10 = fptosi double %9 to i32
%11 = fpext float %0 to double
%12 = sext i32 %10 to i64
br label %13
13: ; preds = %6, %43
%14 = phi i64 [ 0, %6 ], [ %44, %43 ]
%15 = phi double [ 0.000000e+00, %6 ], [ %40, %43 ]
%16 = getelementptr inbounds i8, i8* %3, i64 %14
%17 = load i8, i8* %16
%18 = uitofp i8 %17 to double
%19 = fadd double %18, -1.500000e+00
%20 = tail call double @llvm.fmuladd.f64(double %19, double 0x3FF7700000000000, double %11)
%21 = fmul double %20, 0x3F912843CF07A12C
%22 = shl nsw i64 %14, 8
%23 = add nsw i64 %22, %12
br label %24
24: ; preds = %13, %24
%25 = phi i64 [ 0, %13 ], [ %41, %24 ]
%26 = phi double [ %15, %13 ], [ %40, %24 ]
%27 = add nsw i64 %23, %25
%28 = getelementptr inbounds double, double* %4, i64 %27
%29 = load double, double* %28
%30 = tail call float @cos(double %26)
%31 = fmul float %30, %2
%32 = fpext float %31 to double
%33 = fadd double %29, %32
store double %33, double* %28
%34 = getelementptr inbounds double, double* %5, i64 %27
%35 = load double, double* %34
%36 = tail call float @sin(double %26)
%37 = fmul float %36, %2
%38 = fpext float %37 to double
%39 = fadd double %35, %38
store double %39, double* %34
%40 = fadd double %21, %26
%41 = add nuw nsw i64 %25, 1
%42 = icmp eq i64 %41, 256
br i1 %42, label %43, label %24
43: ; preds = %24
%44 = add nuw nsw i64 %14, 1
%45 = icmp eq i64 %44, 162
br i1 %45, label %46, label %13
46: ; preds = %43
ret i32 1
}