#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 cos(double const);
int ti_cos(int size, double const *const *inputs, double const *options,
           double *const *outputs) {
  const double *in1 = inputs[0];
  (void)options;
  double *output = outputs[0];
  int i;
  for (i = 0; i < size; ++i) {
    output[i] = (cos(in1[i]));
  }
  return 0;
}


x86 assembly (clang, -O0):
<ti_cos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    117d <ti_cos+0x6d>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <cos@plt>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1144 <ti_cos+0x34>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ti_cos>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edi,%edi
jle    11da <ti_cos+0xca>
mov    (%rsi),%r15
mov    (%rcx),%r13
mov    %edi,%r12d
lea    -0x1(%r12),%rax
mov    %r12d,%r14d
and    $0x3,%r14d
cmp    $0x3,%rax
jae    1140 <ti_cos+0x30>
xor    %ebx,%ebx
jmp    11a4 <ti_cos+0x94>
and    $0xfffffffc,%r12d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movsd  (%r15,%rbx,8),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,0x0(%r13,%rbx,8)
movsd  0x8(%r15,%rbx,8),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,0x8(%r13,%rbx,8)
movsd  0x10(%r15,%rbx,8),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,0x10(%r13,%rbx,8)
movsd  0x18(%r15,%rbx,8),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,0x18(%r13,%rbx,8)
add    $0x4,%rbx
cmp    %rbx,%r12
jne    1150 <ti_cos+0x40>
test   %r14,%r14
je     11da <ti_cos+0xca>
lea    0x0(,%rbx,8),%r12
add    %r13,%r12
lea    (%r15,%rbx,8),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsd  (%r15,%rbx,8),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11c0 <ti_cos+0xb0>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @ti_cos(i32 %0, double** %1, double* %2, double** %3) {
%5 = alloca i32
%6 = alloca double**
%7 = alloca double*
%8 = alloca double**
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
store i32 %0, i32* %5
store double** %1, double*** %6
store double* %2, double** %7
store double** %3, double*** %8
%12 = load double**, double*** %6
%13 = getelementptr inbounds double*, double** %12, i64 0
%14 = load double*, double** %13
store double* %14, double** %9
%15 = load double*, double** %7
%16 = load double**, double*** %8
%17 = getelementptr inbounds double*, double** %16, i64 0
%18 = load double*, double** %17
store double* %18, double** %10
store i32 0, i32* %11
br label %19
19: ; preds = %34, %4
%20 = load i32, i32* %11
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %37
23: ; preds = %19
%24 = load double*, double** %9
%25 = load i32, i32* %11
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
%29 = call double @cos(double %28)
%30 = load double*, double** %10
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
store double %29, double* %33
br label %34
34: ; preds = %23
%35 = load i32, i32* %11
%36 = add nsw i32 %35, 1
store i32 %36, i32* %11
br label %19
37: ; preds = %19
ret i32 0
}

LLVM IR (-O2):
define i32 @ti_cos(i32 %0, double** nocapture %1, double* nocapture readnone %2, double** nocapture %3) {
%5 = load double*, double** %1
%6 = load double*, double** %3
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %53
8: ; preds = %4
%9 = zext i32 %0 to i64
%10 = add nsw i64 %9, -1
%11 = and i64 %9, 3
%12 = icmp ult i64 %10, 3
br i1 %12, label %40, label %13
13: ; preds = %8
%14 = and i64 %9, 4294967292
br label %15
15: ; preds = %15, %13
%16 = phi i64 [ 0, %13 ], [ %37, %15 ]
%17 = phi i64 [ 0, %13 ], [ %38, %15 ]
%18 = getelementptr inbounds double, double* %5, i64 %16
%19 = load double, double* %18
%20 = tail call double @cos(double %19)
%21 = getelementptr inbounds double, double* %6, i64 %16
store double %20, double* %21
%22 = or i64 %16, 1
%23 = getelementptr inbounds double, double* %5, i64 %22
%24 = load double, double* %23
%25 = tail call double @cos(double %24)
%26 = getelementptr inbounds double, double* %6, i64 %22
store double %25, double* %26
%27 = or i64 %16, 2
%28 = getelementptr inbounds double, double* %5, i64 %27
%29 = load double, double* %28
%30 = tail call double @cos(double %29)
%31 = getelementptr inbounds double, double* %6, i64 %27
store double %30, double* %31
%32 = or i64 %16, 3
%33 = getelementptr inbounds double, double* %5, i64 %32
%34 = load double, double* %33
%35 = tail call double @cos(double %34)
%36 = getelementptr inbounds double, double* %6, i64 %32
store double %35, double* %36
%37 = add nuw nsw i64 %16, 4
%38 = add i64 %17, 4
%39 = icmp eq i64 %38, %14
br i1 %39, label %40, label %15
40: ; preds = %15, %8
%41 = phi i64 [ 0, %8 ], [ %37, %15 ]
%42 = icmp eq i64 %11, 0
br i1 %42, label %53, label %43
43: ; preds = %40, %43
%44 = phi i64 [ %50, %43 ], [ %41, %40 ]
%45 = phi i64 [ %51, %43 ], [ 0, %40 ]
%46 = getelementptr inbounds double, double* %5, i64 %44
%47 = load double, double* %46
%48 = tail call double @cos(double %47)
%49 = getelementptr inbounds double, double* %6, i64 %44
store double %48, double* %49
%50 = add nuw nsw i64 %44, 1
%51 = add i64 %45, 1
%52 = icmp eq i64 %51, %11
br i1 %52, label %53, label %43
53: ; preds = %40, %43, %4
ret i32 0
}