#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 */
float floorf(float);
float *vec2_snap(float *result, float *a, float *b) {
  result[0] = floorf(a[0] / b[0]) * b[0];
  result[1] = floorf(a[1] / b[1]) * b[1];
  return result;
}


x86 assembly (clang, -O0):
<vec2_snap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x18(%rbp),%rax
divss  (%rax),%xmm0
call   1030 <floorf@plt>
mov    -0x18(%rbp),%rax
mulss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x18(%rbp),%rax
divss  0x4(%rax),%xmm0
call   1030 <floorf@plt>
mov    -0x18(%rbp),%rax
mulss  0x4(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec2_snap>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movss  (%rsi),%xmm0
movss  (%rdx),%xmm1
movss  %xmm1,0xc(%rsp)
divss  %xmm1,%xmm0
call   1030 <floorf@plt>
mulss  0xc(%rsp),%xmm0
movss  %xmm0,(%rbx)
movss  0x4(%r15),%xmm0
movss  0x4(%r14),%xmm1
movss  %xmm1,0xc(%rsp)
divss  %xmm1,%xmm0
call   1030 <floorf@plt>
mulss  0xc(%rsp),%xmm0
movss  %xmm0,0x4(%rbx)
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float* @vec2_snap(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%7 = load float*, float** %5
%8 = getelementptr inbounds float, float* %7, i64 0
%9 = load float, float* %8
%10 = load float*, float** %6
%11 = getelementptr inbounds float, float* %10, i64 0
%12 = load float, float* %11
%13 = fdiv float %9, %12
%14 = call float @llvm.floor.f32(float %13)
%15 = load float*, float** %6
%16 = getelementptr inbounds float, float* %15, i64 0
%17 = load float, float* %16
%18 = fmul float %14, %17
%19 = load float*, float** %4
%20 = getelementptr inbounds float, float* %19, i64 0
store float %18, float* %20
%21 = load float*, float** %5
%22 = getelementptr inbounds float, float* %21, i64 1
%23 = load float, float* %22
%24 = load float*, float** %6
%25 = getelementptr inbounds float, float* %24, i64 1
%26 = load float, float* %25
%27 = fdiv float %23, %26
%28 = call float @llvm.floor.f32(float %27)
%29 = load float*, float** %6
%30 = getelementptr inbounds float, float* %29, i64 1
%31 = load float, float* %30
%32 = fmul float %28, %31
%33 = load float*, float** %4
%34 = getelementptr inbounds float, float* %33, i64 1
store float %32, float* %34
%35 = load float*, float** %4
ret float* %35
}

LLVM IR (-O2):
define float* @vec2_snap(float* returned writeonly %0, float* nocapture %1, float* nocapture %2) {
%4 = load float, float* %1
%5 = load float, float* %2
%6 = fdiv float %4, %5
%7 = tail call float @llvm.floor.f32(float %6)
%8 = fmul float %5, %7
store float %8, float* %0
%9 = getelementptr inbounds float, float* %1, i64 1
%10 = load float, float* %9
%11 = getelementptr inbounds float, float* %2, i64 1
%12 = load float, float* %11
%13 = fdiv float %10, %12
%14 = tail call float @llvm.floor.f32(float %13)
%15 = fmul float %12, %14
%16 = getelementptr inbounds float, float* %0, i64 1
store float %15, float* %16
ret float* %0
}