#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 round(double);
void DataDouble2Int(double *in_data, int *out_data, int n) {
  int i;
  for (i = 0; i < n; i++) {
    out_data[i] = round(in_data[i]);
  }
}


x86 assembly (clang, -O0):
<DataDouble2Int>:
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
jge    1163 <DataDouble2Int+0x53>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <round@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <DataDouble2Int+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DataDouble2Int>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
jle    11d8 <DataDouble2Int+0xc8>
mov    %rsi,%r14
mov    %rdi,%r13
mov    %edx,%r12d
lea    -0x1(%r12),%rax
mov    %r12d,%r15d
and    $0x3,%r15d
cmp    $0x3,%rax
jae    1140 <DataDouble2Int+0x30>
xor    %ebx,%ebx
jmp    119c <DataDouble2Int+0x8c>
and    $0xfffffffc,%r12d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movsd  0x0(%r13,%rbx,8),%xmm0
call   1030 <round@plt>
mov    %eax,(%r14,%rbx,4)
movsd  0x8(%r13,%rbx,8),%xmm0
call   1030 <round@plt>
mov    %eax,0x4(%r14,%rbx,4)
movsd  0x10(%r13,%rbx,8),%xmm0
call   1030 <round@plt>
mov    %eax,0x8(%r14,%rbx,4)
movsd  0x18(%r13,%rbx,8),%xmm0
call   1030 <round@plt>
mov    %eax,0xc(%r14,%rbx,4)
add    $0x4,%rbx
cmp    %rbx,%r12
jne    1150 <DataDouble2Int+0x40>
test   %r15,%r15
je     11d8 <DataDouble2Int+0xc8>
lea    (%r14,%rbx,4),%r14
lea    0x0(,%rbx,8),%r12
add    %r13,%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%r12,%rbx,8),%xmm0
call   1030 <round@plt>
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11c0 <DataDouble2Int+0xb0>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @DataDouble2Int(double* %0, i32* %1, i32 %2) {
%4 = alloca double*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %23, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = load double*, double** %4
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = call i32 @round(double %17)
%19 = load i32*, i32** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
store i32 %18, i32* %22
br label %23
23: ; preds = %12
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %8
26: ; preds = %8
ret void
}

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