#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 sin(double);
void lifter(double *x, double *y, const int m, const int leng) {
  int k;
  double theta;
  for (k = 0; k < m; k++) {
    theta = 3.14159265358979323846 * (double)k / (double)leng;
    y[k] = (1.0 + (double)leng / 2.0 * sin(theta)) * x[k];
  }
}


x86 assembly (clang, -O0):
<lifter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b8 <lifter+0xa8>
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xeca(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  0xea3(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe74(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112d <lifter+0x1d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lifter>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edx,%edx
jle    118d <lifter+0x7d>
mov    %rsi,%r14
mov    %rdi,%r15
cvtsi2sd %ecx,%xmm0
movsd  0xecf(%rip),%xmm1
movsd  %xmm0,0x10(%rsp)
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %edx,%r12d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xea9(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0xe98(%rip),%xmm0
mulsd  (%r15,%rbx,8),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <lifter+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @lifter(double* %0, double* %1, i32 %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %11
11: ; preds = %38, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %7
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %41
15: ; preds = %11
%16 = load i32, i32* %9
%17 = sitofp i32 %16 to double
%18 = fmul double 0x400921FB54442D18, %17
%19 = load i32, i32* %8
%20 = sitofp i32 %19 to double
%21 = fdiv double %18, %20
store double %21, double* %10
%22 = load i32, i32* %8
%23 = sitofp i32 %22 to double
%24 = fdiv double %23, 2.000000e+00
%25 = load double, double* %10
%26 = call double @sin(double %25)
%27 = call double @llvm.fmuladd.f64(double %24, double %26, double 1.000000e+00)
%28 = load double*, double** %5
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
%32 = load double, double* %31
%33 = fmul double %27, %32
%34 = load double*, double** %6
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
store double %33, double* %37
br label %38
38: ; preds = %15
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %11
41: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @lifter(double* nocapture %0, double* nocapture writeonly %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %24
6: ; preds = %4
%7 = sitofp i32 %3 to double
%8 = fmul double %7, 5.000000e-01
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %6, %10
%11 = phi i64 [ 0, %6 ], [ %22, %10 ]
%12 = trunc i64 %11 to i32
%13 = sitofp i32 %12 to double
%14 = fmul double %13, 0x400921FB54442D18
%15 = fdiv double %14, %7
%16 = tail call double @sin(double %15)
%17 = tail call double @llvm.fmuladd.f64(double %8, double %16, double 1.000000e+00)
%18 = getelementptr inbounds double, double* %0, i64 %11
%19 = load double, double* %18
%20 = fmul double %17, %19
%21 = getelementptr inbounds double, double* %1, i64 %11
store double %20, double* %21
%22 = add nuw nsw i64 %11, 1
%23 = icmp eq i64 %22, %9
br i1 %23, label %24, label %10
24: ; preds = %10, %4
ret void
}