#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 */
typedef int uint32_t;
typedef int /*<<< orphan*/ int64_t;

/* Variables and functions */
int /*<<< orphan*/ ceil_l_s(float const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ floor_l_s(float const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ round_l_s(float const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ trunc_l_s(float const *, int /*<<< orphan*/ *);
void cvt_l_s(const uint32_t *fcr31, const float *source, int64_t *dest) {
  switch (*fcr31 & 3) {
  case 0:
    round_l_s(source, dest);
    return;
  case 1:
    trunc_l_s(source, dest);
    return;
  case 2:
    ceil_l_s(source, dest);
    return;
  case 3:
    floor_l_s(source, dest);
    return;
  }
}


x86 assembly (clang, -O0):
<cvt_l_s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    $0x3,%eax
mov    %rax,-0x20(%rbp)
sub    $0x3,%eax
ja     11c1 <cvt_l_s+0x81>
mov    -0x20(%rbp),%rax
lea    0xe8b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <round_l_s@plt>
jmp    11c1 <cvt_l_s+0x81>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <trunc_l_s@plt>
jmp    11c1 <cvt_l_s+0x81>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <ceil_l_s@plt>
jmp    11c1 <cvt_l_s+0x81>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <floor_l_s@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cvt_l_s>:
mov    (%rdi),%eax
and    $0x3,%eax
lea    0xeb4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
jmp    1060 <round_l_s@plt>
mov    %rsi,%rdi
mov    %rdx,%rsi
jmp    1040 <ceil_l_s@plt>
mov    %rsi,%rdi
mov    %rdx,%rsi
jmp    1030 <floor_l_s@plt>
mov    %rsi,%rdi
mov    %rdx,%rsi
jmp    1050 <trunc_l_s@plt>

LLVM IR (-O0):
define void @cvt_l_s(i32* %0, float* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca float*
%6 = alloca i32*
store i32* %0, i32** %4
store float* %1, float** %5
store i32* %2, i32** %6
%7 = load i32*, i32** %4
%8 = load i32, i32* %7
%9 = and i32 %8, 3
switch i32 %9, label %26 [
i32 0, label %10
i32 1, label %14
i32 2, label %18
i32 3, label %22
]
10: ; preds = %3
%11 = load float*, float** %5
%12 = load i32*, i32** %6
%13 = call i32 @round_l_s(float* %11, i32* %12)
br label %26
14: ; preds = %3
%15 = load float*, float** %5
%16 = load i32*, i32** %6
%17 = call i32 @trunc_l_s(float* %15, i32* %16)
br label %26
18: ; preds = %3
%19 = load float*, float** %5
%20 = load i32*, i32** %6
%21 = call i32 @ceil_l_s(float* %19, i32* %20)
br label %26
22: ; preds = %3
%23 = load float*, float** %5
%24 = load i32*, i32** %6
%25 = call i32 @floor_l_s(float* %23, i32* %24)
br label %26
26: ; preds = %10, %14, %18, %22, %3
ret void
}

LLVM IR (-O2):
define void @cvt_l_s(i32* nocapture %0, float* %1, i32* %2) {
%4 = load i32, i32* %0
%5 = and i32 %4, 3
switch i32 %5, label %14 [
i32 0, label %6
i32 1, label %8
i32 2, label %10
i32 3, label %12
]
6: ; preds = %3
%7 = tail call i32 @round_l_s(float* %1, i32* %2)
br label %15
8: ; preds = %3
%9 = tail call i32 @trunc_l_s(float* %1, i32* %2)
br label %15
10: ; preds = %3
%11 = tail call i32 @ceil_l_s(float* %1, i32* %2)
br label %15
12: ; preds = %3
%13 = tail call i32 @floor_l_s(float* %1, i32* %2)
br label %15
14: ; preds = %3
unreachable
15: ; preds = %6, %8, %10, %12
ret void
}