#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_round(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] + 0.5));
  }
  return 0;
}


x86 assembly (clang, -O0):
<ti_round>:
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    1185 <ti_round+0x75>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  0xea0(%rip),%xmm0
addsd  (%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_round+0x34>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ti_round>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %edi,%edi
jle    1327 <ti_round+0x217>
mov    (%rsi),%r14
mov    (%rcx),%r12
mov    %edi,%r15d
cmp    $0x1,%edi
je     114e <ti_round+0x3e>
lea    (%r14,%r15,8),%rax
cmp    %rax,%r12
jae    121c <ti_round+0x10c>
lea    (%r12,%r15,8),%rax
cmp    %rax,%r14
jae    121c <ti_round+0x10c>
xor    %ebx,%ebx
mov    %r15d,%ebp
sub    %ebx,%ebp
mov    %rbx,%r13
not    %r13
add    %r15,%r13
and    $0x3,%rbp
je     1193 <ti_round+0x83>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%r14,%rbx,8),%xmm0
addsd  0xe92(%rip),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
add    $0xffffffffffffffff,%rbp
jne    1170 <ti_round+0x60>
cmp    $0x3,%r13
jb     1327 <ti_round+0x217>
nopl   (%rax)
movsd  (%r14,%rbx,8),%xmm0
movsd  0xe62(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <floor@plt>
movsd  %xmm0,(%r12,%rbx,8)
movsd  0x8(%r14,%rbx,8),%xmm0
addsd  0xe44(%rip),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,0x8(%r12,%rbx,8)
movsd  0x10(%r14,%rbx,8),%xmm0
addsd  0xe29(%rip),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,0x10(%r12,%rbx,8)
movsd  0x18(%r14,%rbx,8),%xmm0
addsd  0xe0e(%rip),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,0x18(%r12,%rbx,8)
add    $0x4,%rbx
cmp    %rbx,%r15
jne    11a0 <ti_round+0x90>
jmp    1327 <ti_round+0x217>
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     1338 <ti_round+0x228>
and    $0xfffffffffffffffe,%rbp
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nop
movupd (%r14,%r13,8),%xmm1
movapd 0xda2(%rip),%xmm0
addpd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
movapd %xmm1,%xmm0
call   1030 <floor@plt>
movapd %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)
movupd 0x10(%r14,%r13,8),%xmm0
addpd  0xd62(%rip),%xmm0
movapd %xmm0,(%rsp)
call   1030 <floor@plt>
movapd %xmm0,0x10(%rsp)
movapd (%rsp),%xmm0
unpckhpd %xmm0,%xmm0
call   1030 <floor@plt>
movapd 0x10(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0x10(%r12,%r13,8)
add    $0x4,%r13
add    $0xfffffffffffffffe,%rbp
jne    1250 <ti_round+0x140>
testb  $0x1,0x20(%rsp)
je     131e <ti_round+0x20e>
movupd (%r14,%r13,8),%xmm0
addpd  0xd10(%rip),%xmm0
movapd %xmm0,(%rsp)
call   1030 <floor@plt>
movapd %xmm0,0x10(%rsp)
movapd (%rsp),%xmm0
unpckhpd %xmm0,%xmm0
call   1030 <floor@plt>
movapd 0x10(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,(%r12,%r13,8)
cmp    %r15,%rbx
jne    1150 <ti_round+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    12e2 <ti_round+0x1d2>
jmp    131e <ti_round+0x20e>

LLVM IR (-O0):
define i32 @ti_round(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 = %35, %4
%20 = load i32, i32* %11
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %38
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 = fadd double %28, 5.000000e-01
%30 = call double @llvm.floor.f64(double %29)
%31 = load double*, double** %10
%32 = load i32, i32* %11
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
store double %30, double* %34
br label %35
35: ; preds = %23
%36 = load i32, i32* %11
%37 = add nsw i32 %36, 1
store i32 %37, i32* %11
br label %19
38: ; preds = %19
ret i32 0
}

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