#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 */
int sin(int);
void f1(double *in, double *out, unsigned size) {
  for (unsigned i = 0; i < size; ++i) {
    out[i] = sin(2 * in[i]) + 1;
  }
}


x86 assembly (clang, -O0):
<f1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1174 <f1+0x64>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsd  0xebb(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <f1+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f1>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
je     11ba <f1+0xaa>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r12d
cmp    $0x1,%edx
jne    1133 <f1+0x23>
xor    %ebx,%ebx
jmp    1191 <f1+0x81>
mov    %r12d,%r13d
and    $0xfffffffe,%r13d
xor    %ebx,%ebx
nopl   0x0(%rax)
movsd  (%r15,%rbx,8),%xmm0
addsd  %xmm0,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r14,%rbx,8)
movsd  0x8(%r15,%rbx,8),%xmm0
addsd  %xmm0,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%r14,%rbx,8)
add    $0x2,%rbx
cmp    %rbx,%r13
jne    1140 <f1+0x30>
test   $0x1,%r12b
je     11ba <f1+0xaa>
movsd  (%r15,%rbx,8),%xmm0
addsd  %xmm0,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r14,%rbx,8)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @f1(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %27, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %30
12: ; preds = %8
%13 = load double*, double** %4
%14 = load i32, i32* %7
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = fmul double 2.000000e+00, %17
%19 = fptosi double %18 to i32
%20 = call i32 @sin(i32 %19)
%21 = add nsw i32 %20, 1
%22 = sitofp i32 %21 to double
%23 = load double*, double** %5
%24 = load i32, i32* %7
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
store double %22, double* %26
br label %27
27: ; preds = %12
%28 = load i32, i32* %7
%29 = add i32 %28, 1
store i32 %29, i32* %7
br label %8
30: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @f1(double* nocapture %0, double* nocapture writeonly %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %23, label %5
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = and i64 %6, 1
%8 = icmp eq i32 %2, 1
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = and i64 %6, 4294967294
br label %24
11: ; preds = %24, %5
%12 = phi i64 [ 0, %5 ], [ %44, %24 ]
%13 = icmp eq i64 %7, 0
br i1 %13, label %23, label %14
14: ; preds = %11
%15 = getelementptr inbounds double, double* %0, i64 %12
%16 = load double, double* %15
%17 = fmul double %16, 2.000000e+00
%18 = fptosi double %17 to i32
%19 = tail call i32 @sin(i32 %18)
%20 = add nsw i32 %19, 1
%21 = sitofp i32 %20 to double
%22 = getelementptr inbounds double, double* %1, i64 %12
store double %21, double* %22
br label %23
23: ; preds = %14, %11, %3
ret void
24: ; preds = %24, %9
%25 = phi i64 [ 0, %9 ], [ %44, %24 ]
%26 = phi i64 [ 0, %9 ], [ %45, %24 ]
%27 = getelementptr inbounds double, double* %0, i64 %25
%28 = load double, double* %27
%29 = fmul double %28, 2.000000e+00
%30 = fptosi double %29 to i32
%31 = tail call i32 @sin(i32 %30)
%32 = add nsw i32 %31, 1
%33 = sitofp i32 %32 to double
%34 = getelementptr inbounds double, double* %1, i64 %25
store double %33, double* %34
%35 = or i64 %25, 1
%36 = getelementptr inbounds double, double* %0, i64 %35
%37 = load double, double* %36
%38 = fmul double %37, 2.000000e+00
%39 = fptosi double %38 to i32
%40 = tail call i32 @sin(i32 %39)
%41 = add nsw i32 %40, 1
%42 = sitofp i32 %41 to double
%43 = getelementptr inbounds double, double* %1, i64 %35
store double %42, double* %43
%44 = add nuw nsw i64 %25, 2
%45 = add i64 %26, 2
%46 = icmp eq i64 %45, %10
br i1 %46, label %11, label %24
}