#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 floor(double const);
int ti_floor(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] = (floor(in1[i]));
  }
  return 0;
}


x86 assembly (clang, -O0):
<ti_floor>:
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_floor+0x6d>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <floor@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_floor+0x34>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ti_floor>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %edi,%edi
jle    12d0 <ti_floor+0x1c0>
mov    (%rsi),%r14
mov    (%rcx),%r12
mov    %edi,%r15d
cmp    $0x1,%edi
je     114e <ti_floor+0x3e>
lea    (%r14,%r15,8),%rax
cmp    %rax,%r12
jae    11f8 <ti_floor+0xe8>
lea    (%r12,%r15,8),%rax
cmp    %rax,%r14
jae    11f8 <ti_floor+0xe8>
xor    %ebx,%ebx
mov    %r15d,%ebp
sub    %ebx,%ebp
mov    %rbx,%r13
not    %r13
add    %r15,%r13
and    $0x3,%rbp
je     118b <ti_floor+0x7b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%r14,%rbx,8),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
add    $0xffffffffffffffff,%rbp
jne    1170 <ti_floor+0x60>
cmp    $0x3,%r13
jb     12d0 <ti_floor+0x1c0>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%r14,%rbx,8),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,(%r12,%rbx,8)
movsd  0x8(%r14,%rbx,8),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,0x8(%r12,%rbx,8)
movsd  0x10(%r14,%rbx,8),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,0x10(%r12,%rbx,8)
movsd  0x18(%r14,%rbx,8),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,0x18(%r12,%rbx,8)
add    $0x4,%rbx
cmp    %rbx,%r15
jne    11a0 <ti_floor+0x90>
jmp    12d0 <ti_floor+0x1c0>
mov    %r15d,%ebx
and    $0xfffffffe,%ebx
lea    -0x2(%rbx),%rax
mov    %rax,%rbp
shr    %rbp
add    $0x1,%rbp
test   %rax,%rax
mov    %rbp,0x20(%rsp)
je     12e1 <ti_floor+0x1d1>
and    $0xfffffffffffffffe,%rbp
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movups (%r14,%r13,8),%xmm0
movaps %xmm0,(%rsp)
call   1030 <floor@plt>
movaps %xmm0,0x10(%rsp)
movaps (%rsp),%xmm0
movhlps %xmm0,%xmm0
call   1030 <floor@plt>
movaps 0x10(%rsp),%xmm1
movlhps %xmm0,%xmm1
movups %xmm1,(%r12,%r13,8)
movups 0x10(%r14,%r13,8),%xmm0
movaps %xmm0,(%rsp)
call   1030 <floor@plt>
movaps %xmm0,0x10(%rsp)
movaps (%rsp),%xmm0
movhlps %xmm0,%xmm0
call   1030 <floor@plt>
movaps 0x10(%rsp),%xmm1
movlhps %xmm0,%xmm1
movups %xmm1,0x10(%r12,%r13,8)
add    $0x4,%r13
add    $0xfffffffffffffffe,%rbp
jne    1230 <ti_floor+0x120>
testb  $0x1,0x20(%rsp)
je     12c7 <ti_floor+0x1b7>
movups (%r14,%r13,8),%xmm0
movaps %xmm0,(%rsp)
call   1030 <floor@plt>
movaps %xmm0,0x10(%rsp)
movaps (%rsp),%xmm0
movhlps %xmm0,%xmm0
call   1030 <floor@plt>
movaps 0x10(%rsp),%xmm1
movlhps %xmm0,%xmm1
movups %xmm1,(%r12,%r13,8)
cmp    %r15,%rbx
jne    1150 <ti_floor+0x40>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r13d,%r13d
testb  $0x1,0x20(%rsp)
jne    129b <ti_floor+0x18b>
jmp    12c7 <ti_floor+0x1b7>

LLVM IR (-O0):
define i32 @ti_floor(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 @llvm.floor.f64(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_floor(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 %100
8: ; preds = %4
%9 = zext i32 %0 to i64
%10 = icmp eq i32 %0, 1
br i1 %10, label %57, label %11
11: ; preds = %8
%12 = getelementptr double, double* %6, i64 %9
%13 = getelementptr double, double* %5, i64 %9
%14 = icmp ult double* %6, %13
%15 = icmp ult double* %5, %12
%16 = and i1 %14, %15
br i1 %16, label %57, label %17
17: ; preds = %11
%18 = and i64 %9, 4294967294
%19 = add nsw i64 %18, -2
%20 = lshr exact i64 %19, 1
%21 = add nuw i64 %20, 1
%22 = and i64 %21, 1
%23 = icmp eq i64 %19, 0
br i1 %23, label %45, label %24
24: ; preds = %17
%25 = and i64 %21, -2
br label %26
26: ; preds = %26, %24
%27 = phi i64 [ 0, %24 ], [ %42, %26 ]
%28 = phi i64 [ 0, %24 ], [ %43, %26 ]
%29 = getelementptr inbounds double, double* %5, i64 %27
%30 = bitcast double* %29 to <2 x double>*
%31 = load <2 x double>, <2 x double>* %30
%32 = call <2 x double> @llvm.floor.v2f64(<2 x double> %31)
%33 = getelementptr inbounds double, double* %6, i64 %27
%34 = bitcast double* %33 to <2 x double>*
store <2 x double> %32, <2 x double>* %34
%35 = or i64 %27, 2
%36 = getelementptr inbounds double, double* %5, i64 %35
%37 = bitcast double* %36 to <2 x double>*
%38 = load <2 x double>, <2 x double>* %37
%39 = call <2 x double> @llvm.floor.v2f64(<2 x double> %38)
%40 = getelementptr inbounds double, double* %6, i64 %35
%41 = bitcast double* %40 to <2 x double>*
store <2 x double> %39, <2 x double>* %41
%42 = add nuw i64 %27, 4
%43 = add nuw i64 %28, 2
%44 = icmp eq i64 %43, %25
br i1 %44, label %45, label %26
45: ; preds = %26, %17
%46 = phi i64 [ 0, %17 ], [ %42, %26 ]
%47 = icmp eq i64 %22, 0
br i1 %47, label %55, label %48
48: ; preds = %45
%49 = getelementptr inbounds double, double* %5, i64 %46
%50 = bitcast double* %49 to <2 x double>*
%51 = load <2 x double>, <2 x double>* %50
%52 = call <2 x double> @llvm.floor.v2f64(<2 x double> %51)
%53 = getelementptr inbounds double, double* %6, i64 %46
%54 = bitcast double* %53 to <2 x double>*
store <2 x double> %52, <2 x double>* %54
br label %55
55: ; preds = %45, %48
%56 = icmp eq i64 %18, %9
br i1 %56, label %100, label %57
57: ; preds = %11, %8, %55
%58 = phi i64 [ 0, %11 ], [ 0, %8 ], [ %18, %55 ]
%59 = sub nsw i64 %9, %58
%60 = xor i64 %58, -1
%61 = add nsw i64 %60, %9
%62 = and i64 %59, 3
%63 = icmp eq i64 %62, 0
br i1 %63, label %74, label %64
64: ; preds = %57, %64
%65 = phi i64 [ %71, %64 ], [ %58, %57 ]
%66 = phi i64 [ %72, %64 ], [ 0, %57 ]
%67 = getelementptr inbounds double, double* %5, i64 %65
%68 = load double, double* %67
%69 = tail call double @llvm.floor.f64(double %68)
%70 = getelementptr inbounds double, double* %6, i64 %65
store double %69, double* %70
%71 = add nuw nsw i64 %65, 1
%72 = add i64 %66, 1
%73 = icmp eq i64 %72, %62
br i1 %73, label %74, label %64
74: ; preds = %64, %57
%75 = phi i64 [ %58, %57 ], [ %71, %64 ]
%76 = icmp ult i64 %61, 3
br i1 %76, label %100, label %77
77: ; preds = %74, %77
%78 = phi i64 [ %98, %77 ], [ %75, %74 ]
%79 = getelementptr inbounds double, double* %5, i64 %78
%80 = load double, double* %79
%81 = tail call double @llvm.floor.f64(double %80)
%82 = getelementptr inbounds double, double* %6, i64 %78
store double %81, double* %82
%83 = add nuw nsw i64 %78, 1
%84 = getelementptr inbounds double, double* %5, i64 %83
%85 = load double, double* %84
%86 = tail call double @llvm.floor.f64(double %85)
%87 = getelementptr inbounds double, double* %6, i64 %83
store double %86, double* %87
%88 = add nuw nsw i64 %78, 2
%89 = getelementptr inbounds double, double* %5, i64 %88
%90 = load double, double* %89
%91 = tail call double @llvm.floor.f64(double %90)
%92 = getelementptr inbounds double, double* %6, i64 %88
store double %91, double* %92
%93 = add nuw nsw i64 %78, 3
%94 = getelementptr inbounds double, double* %5, i64 %93
%95 = load double, double* %94
%96 = tail call double @llvm.floor.f64(double %95)
%97 = getelementptr inbounds double, double* %6, i64 %93
store double %96, double* %97
%98 = add nuw nsw i64 %78, 4
%99 = icmp eq i64 %98, %9
br i1 %99, label %100, label %77
100: ; preds = %74, %77, %55, %4
ret i32 0
}