#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 cosf(float);
float sinf(float);
int kinematicsForward(float *x, float *y, float L1, float L2, float S,
                      float E) {
  if (L1 <= 0 || L2 <= 0)
    return 0;
  *x = L1 * cosf(S) + L2 * cosf(S + E);
  *y = L1 * sinf(S) + L2 * sinf(S + E);
  return 1;
}


x86 assembly (clang, -O0):
<kinematicsForward>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movss  %xmm0,-0x1c(%rbp)
movss  %xmm1,-0x20(%rbp)
movss  %xmm2,-0x24(%rbp)
movss  %xmm3,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x1c(%rbp),%xmm0
jae    115e <kinematicsForward+0x3e>
xorps  %xmm0,%xmm0
ucomiss -0x20(%rbp),%xmm0
jb     116a <kinematicsForward+0x4a>
movl   $0x0,-0x4(%rbp)
jmp    1221 <kinematicsForward+0x101>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x24(%rbp),%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x3c(%rbp)
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x24(%rbp),%xmm0
addss  -0x28(%rbp),%xmm0
call   1040 <cosf@plt>
movss  -0x40(%rbp),%xmm1
movss  -0x3c(%rbp),%xmm2
movaps %xmm0,%xmm3
movss  -0x38(%rbp),%xmm0
mulss  %xmm3,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x24(%rbp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x24(%rbp),%xmm0
addss  -0x28(%rbp),%xmm0
call   1030 <sinf@plt>
movss  -0x34(%rbp),%xmm1
movss  -0x30(%rbp),%xmm2
movaps %xmm0,%xmm3
movss  -0x2c(%rbp),%xmm0
mulss  %xmm3,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kinematicsForward>:
movaps %xmm0,%xmm4
xor    %eax,%eax
xorps  %xmm0,%xmm0
ucomiss %xmm4,%xmm0
jae    11e1 <kinematicsForward+0xc1>
ucomiss %xmm1,%xmm0
jae    11e1 <kinematicsForward+0xc1>
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movaps %xmm2,%xmm0
movss  %xmm4,0x10(%rsp)
movss  %xmm1,0xc(%rsp)
movss  %xmm3,0x8(%rsp)
movss  %xmm2,0x4(%rsp)
call   1040 <cosf@plt>
movss  %xmm0,0x14(%rsp)
movss  0x8(%rsp),%xmm0
addss  0x4(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
call   1040 <cosf@plt>
mulss  0xc(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
mulss  0x10(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,(%rbx)
movss  0x4(%rsp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,0x4(%rsp)
movss  0x8(%rsp),%xmm0
call   1030 <sinf@plt>
mulss  0xc(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
mulss  0x10(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,(%r14)
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @kinematicsForward(float* %0, float* %1, float %2, float %3, float %4, float %5) {
%7 = alloca i32
%8 = alloca float*
%9 = alloca float*
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
store float* %0, float** %8
store float* %1, float** %9
store float %2, float* %10
store float %3, float* %11
store float %4, float* %12
store float %5, float* %13
%14 = load float, float* %10
%15 = fcmp ole float %14, 0.000000e+00
br i1 %15, label %19, label %16
16: ; preds = %6
%17 = load float, float* %11
%18 = fcmp ole float %17, 0.000000e+00
br i1 %18, label %19, label %20
19: ; preds = %16, %6
store i32 0, i32* %7
br label %43
20: ; preds = %16
%21 = load float, float* %10
%22 = load float, float* %12
%23 = call float @cosf(float %22)
%24 = load float, float* %11
%25 = load float, float* %12
%26 = load float, float* %13
%27 = fadd float %25, %26
%28 = call float @cosf(float %27)
%29 = fmul float %24, %28
%30 = call float @llvm.fmuladd.f32(float %21, float %23, float %29)
%31 = load float*, float** %8
store float %30, float* %31
%32 = load float, float* %10
%33 = load float, float* %12
%34 = call float @sinf(float %33)
%35 = load float, float* %11
%36 = load float, float* %12
%37 = load float, float* %13
%38 = fadd float %36, %37
%39 = call float @sinf(float %38)
%40 = fmul float %35, %39
%41 = call float @llvm.fmuladd.f32(float %32, float %34, float %40)
%42 = load float*, float** %9
store float %41, float* %42
store i32 1, i32* %7
br label %43
43: ; preds = %20, %19
%44 = load i32, i32* %7
ret i32 %44
}

LLVM IR (-O2):
define i32 @kinematicsForward(float* nocapture writeonly %0, float* nocapture writeonly %1, float %2, float %3, float %4, float %5) {
%7 = fcmp ole float %2, 0.000000e+00
%8 = fcmp ole float %3, 0.000000e+00
%9 = or i1 %7, %8
br i1 %9, label %20, label %10
10: ; preds = %6
%11 = tail call float @cosf(float %4)
%12 = fadd float %4, %5
%13 = tail call float @cosf(float %12)
%14 = fmul float %13, %3
%15 = tail call float @llvm.fmuladd.f32(float %2, float %11, float %14)
store float %15, float* %0
%16 = tail call float @sinf(float %4)
%17 = tail call float @sinf(float %12)
%18 = fmul float %17, %3
%19 = tail call float @llvm.fmuladd.f32(float %2, float %16, float %18)
store float %19, float* %1
br label %20
20: ; preds = %6, %10
%21 = phi i32 [ 1, %10 ], [ 0, %6 ]
ret i32 %21
}