#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
void assign_chunk_coordinate(float *coord, float *vec_ranges_lo,
                             float *vec_binwidths, int *chunk_coord) {
  int bin;
  int i;
  for (i = 0; i < 3; i++) {
    bin = (int)((coord[i] - vec_ranges_lo[i]) / vec_binwidths[i]);
    chunk_coord[i] = bin;
    if (bin < 0) {
      printf("LESS THAN 0!!!!\n");
      printf("%d %f %f %f\n", i, coord[i], vec_ranges_lo[i], vec_binwidths[i]);
      exit(-1);
    }
  }
}


x86 assembly (clang, -O0):
<assign_chunk_coordinate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    11fe <assign_chunk_coordinate+0xde>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
subss  (%rax,%rcx,4),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
divss  (%rax,%rcx,4),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
cmpl   $0x0,-0x24(%rbp)
jge    11eb <assign_chunk_coordinate+0xcb>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe37(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
jmp    11f0 <assign_chunk_coordinate+0xd0>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    113f <assign_chunk_coordinate+0x1f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assign_chunk_coordinate>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movss  (%rdi),%xmm0
subss  (%rsi),%xmm0
divss  (%rdx),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,(%rcx)
test   %eax,%eax
js     1198 <assign_chunk_coordinate+0x68>
movss  0x4(%rbx),%xmm0
subss  0x4(%r15),%xmm0
divss  0x4(%r14),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,0x4(%rcx)
test   %eax,%eax
js     119d <assign_chunk_coordinate+0x6d>
movss  0x8(%rbx),%xmm0
subss  0x8(%r15),%xmm0
divss  0x8(%r14),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,0x8(%rcx)
test   %eax,%eax
js     11a5 <assign_chunk_coordinate+0x75>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r12d,%r12d
jmp    11ab <assign_chunk_coordinate+0x7b>
mov    $0x1,%r12d
jmp    11ab <assign_chunk_coordinate+0x7b>
mov    $0x2,%r12d
mov    %r12d,%ebp
lea    0xe58(%rip),%rdi
call   1030 <puts@plt>
movss  (%rbx,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
movss  (%r15,%rbp,4),%xmm1
cvtss2sd %xmm1,%xmm1
movss  (%r14,%rbp,4),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe22(%rip),%rdi
mov    %r12d,%esi
mov    $0x3,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"LESS THAN 0!!!!\0A\00"
@.str.1 = [13 x i8] c"%d %f %f %f\0A\00"
define void @assign_chunk_coordinate(float* %0, float* %1, float* %2, i32* %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %7
store i32* %3, i32** %8
store i32 0, i32* %10
br label %11
11: ; preds = %64, %4
%12 = load i32, i32* %10
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %67
14: ; preds = %11
%15 = load float*, float** %5
%16 = load i32, i32* %10
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds float, float* %15, i64 %17
%19 = load float, float* %18
%20 = load float*, float** %6
%21 = load i32, i32* %10
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds float, float* %20, i64 %22
%24 = load float, float* %23
%25 = fsub float %19, %24
%26 = load float*, float** %7
%27 = load i32, i32* %10
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds float, float* %26, i64 %28
%30 = load float, float* %29
%31 = fdiv float %25, %30
%32 = fptosi float %31 to i32
store i32 %32, i32* %9
%33 = load i32, i32* %9
%34 = load i32*, i32** %8
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
store i32 %33, i32* %37
%38 = load i32, i32* %9
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %63
40: ; preds = %14
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%42 = load i32, i32* %10
%43 = load float*, float** %5
%44 = load i32, i32* %10
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds float, float* %43, i64 %45
%47 = load float, float* %46
%48 = fpext float %47 to double
%49 = load float*, float** %6
%50 = load i32, i32* %10
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds float, float* %49, i64 %51
%53 = load float, float* %52
%54 = fpext float %53 to double
%55 = load float*, float** %7
%56 = load i32, i32* %10
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds float, float* %55, i64 %57
%59 = load float, float* %58
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %42, double %48, double %54, double %60)
%62 = call i32 @exit(i32 -1)
unreachable
63: ; preds = %14
br label %64
64: ; preds = %63
%65 = load i32, i32* %10
%66 = add nsw i32 %65, 1
store i32 %66, i32* %10
br label %11
67: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"%d %f %f %f\0A\00"
@str = [16 x i8] c"LESS THAN 0!!!!\00"
define void @assign_chunk_coordinate(float* nocapture %0, float* nocapture %1, float* nocapture %2, i32* nocapture writeonly %3) {
%5 = load float, float* %0
%6 = load float, float* %1
%7 = fsub float %5, %6
%8 = load float, float* %2
%9 = fdiv float %7, %8
%10 = fptosi float %9 to i32
store i32 %10, i32* %3
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %39, %27, %4
%13 = phi i32 [ 0, %4 ], [ 1, %27 ], [ 2, %39 ]
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds float, float* %0, i64 %14
%16 = getelementptr inbounds float, float* %1, i64 %14
%17 = getelementptr inbounds float, float* %2, i64 %14
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%19 = load float, float* %15
%20 = fpext float %19 to double
%21 = load float, float* %16
%22 = fpext float %21 to double
%23 = load float, float* %17
%24 = fpext float %23 to double
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %13, double %20, double %22, double %24)
%26 = tail call i32 @exit(i32 -1)
unreachable
27: ; preds = %4
%28 = getelementptr inbounds float, float* %0, i64 1
%29 = load float, float* %28
%30 = getelementptr inbounds float, float* %1, i64 1
%31 = load float, float* %30
%32 = fsub float %29, %31
%33 = getelementptr inbounds float, float* %2, i64 1
%34 = load float, float* %33
%35 = fdiv float %32, %34
%36 = fptosi float %35 to i32
%37 = getelementptr inbounds i32, i32* %3, i64 1
store i32 %36, i32* %37
%38 = icmp slt i32 %36, 0
br i1 %38, label %12, label %39
39: ; preds = %27
%40 = getelementptr inbounds float, float* %0, i64 2
%41 = load float, float* %40
%42 = getelementptr inbounds float, float* %1, i64 2
%43 = load float, float* %42
%44 = fsub float %41, %43
%45 = getelementptr inbounds float, float* %2, i64 2
%46 = load float, float* %45
%47 = fdiv float %44, %46
%48 = fptosi float %47 to i32
%49 = getelementptr inbounds i32, i32* %3, i64 2
store i32 %48, i32* %49
%50 = icmp slt i32 %48, 0
br i1 %50, label %12, label %51
51: ; preds = %39
ret void
}