#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 const fabs(float const);
float fmod(float const, float);
float posAfterNoMax(float, float, float);
float posAfter(float s, float start, float speed, float axisMax) {
  register const float p = posAfterNoMax(s, start, speed);
  return p > 0 ? fmod(p, axisMax) : axisMax - (fmod(fabs(p), axisMax));
}


x86 assembly (clang, -O0):
<posAfter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm2
call   1030 <posAfterNoMax@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    118f <posAfter+0x5f>
movss  -0x14(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
call   1040 <fmod@plt>
movss  %xmm0,-0x18(%rbp)
jmp    11be <posAfter+0x8e>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
call   1050 <fabs@plt>
movss  -0x10(%rbp),%xmm1
call   1040 <fmod@plt>
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<posAfter>:
push   %rax
movss  %xmm3,0x4(%rsp)
call   1030 <posAfterNoMax@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1140 <posAfter+0x20>
movss  0x4(%rsp),%xmm1
pop    %rax
jmp    1040 <fmod@plt>
movaps 0xeb9(%rip),%xmm1
andps  %xmm0,%xmm1
movaps %xmm1,%xmm0
movss  0x4(%rsp),%xmm1
call   1040 <fmod@plt>
movss  0x4(%rsp),%xmm1
subss  %xmm0,%xmm1
movaps %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @posAfter(float %0, float %1, float %2, float %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
%10 = load float, float* %5
%11 = load float, float* %6
%12 = load float, float* %7
%13 = call float @posAfterNoMax(float %10, float %11, float %12)
store float %13, float* %9
%14 = load float, float* %9
%15 = fcmp ogt float %14, 0.000000e+00
br i1 %15, label %16, label %20
16: ; preds = %4
%17 = load float, float* %9
%18 = load float, float* %8
%19 = call float @fmod(float %17, float %18)
br label %27
20: ; preds = %4
%21 = load float, float* %8
%22 = load float, float* %9
%23 = call float @fabs(float %22)
%24 = load float, float* %8
%25 = call float @fmod(float %23, float %24)
%26 = fsub float %21, %25
br label %27
27: ; preds = %20, %16
%28 = phi float [ %19, %16 ], [ %26, %20 ]
ret float %28
}

LLVM IR (-O2):
define float @posAfter(float %0, float %1, float %2, float %3) {
%5 = tail call float @posAfterNoMax(float %0, float %1, float %2)
%6 = fcmp ogt float %5, 0.000000e+00
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call float @fmod(float %5, float %3)
br label %13
9: ; preds = %4
%10 = tail call float @llvm.fabs.f32(float %5)
%11 = tail call float @fmod(float %10, float %3)
%12 = fsub float %3, %11
br label %13
13: ; preds = %9, %7
%14 = phi float [ %8, %7 ], [ %12, %9 ]
ret float %14
}