#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 lrint(double const);
scalar_t__ test_zscale(double);
void local_neuroseg_stack_position(const double position[3], int c[3],
                                   double offpos[3], double z_scale) {
  c[0] = lrint(position[0]);
  c[1] = lrint(position[1]);
  offpos[0] = position[0] - c[0];
  offpos[1] = position[1] - c[1];
  if (test_zscale(z_scale) != 0) {
    c[2] = lrint(position[2] * z_scale);
    offpos[2] = position[2] * z_scale - c[2];
  } else {
    c[2] = lrint(position[2]);
    offpos[2] = position[2] - c[2];
  }
}


x86 assembly (clang, -O0):
<local_neuroseg_stack_position>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <lrint@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1030 <lrint@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
subsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
cvtsi2sdl 0x4(%rax),%xmm1
subsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
call   1040 <test_zscale@plt>
cmp    $0x0,%rax
je     1214 <local_neuroseg_stack_position+0xf4>
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <lrint@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  -0x20(%rbp),%xmm2
mov    -0x10(%rbp),%rax
cvtsi2sdl 0x8(%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    124a <local_neuroseg_stack_position+0x12a>
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
call   1030 <lrint@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
cvtsi2sdl 0x8(%rax),%xmm1
subsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<local_neuroseg_stack_position>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
call   1030 <lrint@plt>
mov    %eax,(%r15)
movsd  0x8(%rbx),%xmm0
call   1030 <lrint@plt>
mov    %eax,0x4(%r15)
xorps  %xmm0,%xmm0
cvtsi2sdl (%r15),%xmm0
movsd  (%rbx),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
movsd  0x8(%rbx),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%r14)
movsd  0x8(%rsp),%xmm0
call   1040 <test_zscale@plt>
movsd  0x10(%rbx),%xmm0
test   %rax,%rax
je     11b1 <local_neuroseg_stack_position+0x91>
mulsd  0x8(%rsp),%xmm0
call   1030 <lrint@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x10(%rbx),%xmm1
jmp    11c2 <local_neuroseg_stack_position+0xa2>
call   1030 <lrint@plt>
movsd  0x10(%rbx),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
subsd  %xmm0,%xmm1
mov    %eax,0x8(%r15)
movsd  %xmm1,0x10(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @local_neuroseg_stack_position(double* %0, i32* %1, double* %2, double %3) {
%5 = alloca double*
%6 = alloca i32*
%7 = alloca double*
%8 = alloca double
store double* %0, double** %5
store i32* %1, i32** %6
store double* %2, double** %7
store double %3, double* %8
%9 = load double*, double** %5
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = load double, double* %10
%12 = call i32 @lrint(double %11)
%13 = load i32*, i32** %6
%14 = getelementptr inbounds i32, i32* %13, i64 0
store i32 %12, i32* %14
%15 = load double*, double** %5
%16 = getelementptr inbounds double, double* %15, i64 1
%17 = load double, double* %16
%18 = call i32 @lrint(double %17)
%19 = load i32*, i32** %6
%20 = getelementptr inbounds i32, i32* %19, i64 1
store i32 %18, i32* %20
%21 = load double*, double** %5
%22 = getelementptr inbounds double, double* %21, i64 0
%23 = load double, double* %22
%24 = load i32*, i32** %6
%25 = getelementptr inbounds i32, i32* %24, i64 0
%26 = load i32, i32* %25
%27 = sitofp i32 %26 to double
%28 = fsub double %23, %27
%29 = load double*, double** %7
%30 = getelementptr inbounds double, double* %29, i64 0
store double %28, double* %30
%31 = load double*, double** %5
%32 = getelementptr inbounds double, double* %31, i64 1
%33 = load double, double* %32
%34 = load i32*, i32** %6
%35 = getelementptr inbounds i32, i32* %34, i64 1
%36 = load i32, i32* %35
%37 = sitofp i32 %36 to double
%38 = fsub double %33, %37
%39 = load double*, double** %7
%40 = getelementptr inbounds double, double* %39, i64 1
store double %38, double* %40
%41 = load double, double* %8
%42 = call i64 @test_zscale(double %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %65
44: ; preds = %4
%45 = load double*, double** %5
%46 = getelementptr inbounds double, double* %45, i64 2
%47 = load double, double* %46
%48 = load double, double* %8
%49 = fmul double %47, %48
%50 = call i32 @lrint(double %49)
%51 = load i32*, i32** %6
%52 = getelementptr inbounds i32, i32* %51, i64 2
store i32 %50, i32* %52
%53 = load double*, double** %5
%54 = getelementptr inbounds double, double* %53, i64 2
%55 = load double, double* %54
%56 = load double, double* %8
%57 = load i32*, i32** %6
%58 = getelementptr inbounds i32, i32* %57, i64 2
%59 = load i32, i32* %58
%60 = sitofp i32 %59 to double
%61 = fneg double %60
%62 = call double @llvm.fmuladd.f64(double %55, double %56, double %61)
%63 = load double*, double** %7
%64 = getelementptr inbounds double, double* %63, i64 2
store double %62, double* %64
br label %82
65: ; preds = %4
%66 = load double*, double** %5
%67 = getelementptr inbounds double, double* %66, i64 2
%68 = load double, double* %67
%69 = call i32 @lrint(double %68)
%70 = load i32*, i32** %6
%71 = getelementptr inbounds i32, i32* %70, i64 2
store i32 %69, i32* %71
%72 = load double*, double** %5
%73 = getelementptr inbounds double, double* %72, i64 2
%74 = load double, double* %73
%75 = load i32*, i32** %6
%76 = getelementptr inbounds i32, i32* %75, i64 2
%77 = load i32, i32* %76
%78 = sitofp i32 %77 to double
%79 = fsub double %74, %78
%80 = load double*, double** %7
%81 = getelementptr inbounds double, double* %80, i64 2
store double %79, double* %81
br label %82
82: ; preds = %65, %44
ret void
}

LLVM IR (-O2):
define void @local_neuroseg_stack_position(double* nocapture %0, i32* nocapture %1, double* nocapture writeonly %2, double %3) {
%5 = load double, double* %0
%6 = tail call i32 @lrint(double %5)
store i32 %6, i32* %1
%7 = getelementptr inbounds double, double* %0, i64 1
%8 = load double, double* %7
%9 = tail call i32 @lrint(double %8)
%10 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %9, i32* %10
%11 = load double, double* %0
%12 = load i32, i32* %1
%13 = sitofp i32 %12 to double
%14 = fsub double %11, %13
store double %14, double* %2
%15 = load double, double* %7
%16 = sitofp i32 %9 to double
%17 = fsub double %15, %16
%18 = getelementptr inbounds double, double* %2, i64 1
store double %17, double* %18
%19 = tail call i64 @test_zscale(double %3)
%20 = icmp eq i64 %19, 0
%21 = getelementptr inbounds double, double* %0, i64 2
%22 = load double, double* %21
br i1 %20, label %30, label %23
23: ; preds = %4
%24 = fmul double %22, %3
%25 = tail call i32 @lrint(double %24)
%26 = load double, double* %21
%27 = sitofp i32 %25 to double
%28 = fneg double %27
%29 = tail call double @llvm.fmuladd.f64(double %26, double %3, double %28)
br label %35
30: ; preds = %4
%31 = tail call i32 @lrint(double %22)
%32 = load double, double* %21
%33 = sitofp i32 %31 to double
%34 = fsub double %32, %33
br label %35
35: ; preds = %30, %23
%36 = phi i32 [ %31, %30 ], [ %25, %23 ]
%37 = phi double [ %34, %30 ], [ %29, %23 ]
%38 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %36, i32* %38
%39 = getelementptr inbounds double, double* %2, i64 2
store double %37, double* %39
ret void
}