#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 /*<<< orphan*/ abort();
scalar_t__ isnan(double);
void drift(double *r, double *v, double dt) {
  int d;
  for (d = 0; d < 3; d++) {
    r[d] += v[d] * dt;
    if (isnan(r[d]))
      abort();
  }
}


x86 assembly (clang, -O0):
<drift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11a8 <drift+0x88>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x18(%rbp),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     1195 <drift+0x75>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    119a <drift+0x7a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113c <drift+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drift>:
push   %r14
push   %rbx
push   %rax
movapd %xmm0,%xmm1
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rsi),%xmm0
movsd  %xmm1,(%rsp)
mulsd  %xmm1,%xmm0
addsd  (%rdi),%xmm0
movsd  %xmm0,(%rdi)
call   1040 <isnan@plt>
test   %rax,%rax
jne    1193 <drift+0x73>
movsd  0x8(%r14),%xmm0
mulsd  (%rsp),%xmm0
addsd  0x8(%rbx),%xmm0
movsd  %xmm0,0x8(%rbx)
call   1040 <isnan@plt>
test   %rax,%rax
jne    1193 <drift+0x73>
movsd  (%rsp),%xmm0
mulsd  0x10(%r14),%xmm0
addsd  0x10(%rbx),%xmm0
movsd  %xmm0,0x10(%rbx)
call   1040 <isnan@plt>
test   %rax,%rax
jne    1193 <drift+0x73>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
call   1030 <abort@plt>

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

LLVM IR (-O2):
define void @drift(double* nocapture %0, double* nocapture %1, double %2) {
%4 = load double, double* %1
%5 = load double, double* %0
%6 = tail call double @llvm.fmuladd.f64(double %4, double %2, double %5)
store double %6, double* %0
%7 = tail call i64 @isnan(double %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %26
9: ; preds = %3
%10 = getelementptr inbounds double, double* %1, i64 1
%11 = load double, double* %10
%12 = getelementptr inbounds double, double* %0, i64 1
%13 = load double, double* %12
%14 = tail call double @llvm.fmuladd.f64(double %11, double %2, double %13)
store double %14, double* %12
%15 = tail call i64 @isnan(double %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %9
%18 = getelementptr inbounds double, double* %1, i64 2
%19 = load double, double* %18
%20 = getelementptr inbounds double, double* %0, i64 2
%21 = load double, double* %20
%22 = tail call double @llvm.fmuladd.f64(double %19, double %2, double %21)
store double %22, double* %20
%23 = tail call i64 @isnan(double %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %17
ret void
26: ; preds = %17, %9, %3
%27 = tail call i32 (...) @abort()
unreachable
}