; LLVM IR from devlinzhou/deterministic_physics :: UnrealDemo/Source/UnrealDemo/gphysics/src/math/glacier_float.ll (ZN6GFloat4InitEv)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%class.GFloat = type { i32 }
%class.GFixedType32 = type { i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6GFloat4InitEv() #0 align 2 {
  %1 = alloca i32, align 4
  %2 = alloca float, align 4
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca %class.GFloat, align 4
  %6 = alloca %class.GFloat, align 4
  %7 = alloca %class.GFixedType32, align 4
  %8 = alloca %class.GFloat, align 4
  %9 = alloca %class.GFixedType32, align 4
  %10 = alloca %class.GFloat, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %39, %0
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = icmp slt i32 %12, 256
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  br label %42

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = sitofp i32 %16 to float
  %18 = fmul float %17, 0x400921FB60000000
  %19 = fmul float %18, 2.000000e+00
  %20 = fdiv float %19, 2.560000e+02
  store float %20, ptr %2, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %21 = load float, ptr %2, align 4, !tbaa !9
  %22 = call float @sinf(float noundef %21) #5
  store float %22, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %23 = load float, ptr %2, align 4, !tbaa !9
  %24 = call float @cosf(float noundef %23) #5
  store float %24, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %25 = load float, ptr %3, align 4, !tbaa !9
  %26 = call i32 @_ZN6GFloat9FromFloatEf(float noundef %25)
  %27 = getelementptr inbounds %class.GFloat, ptr %5, i32 0, i32 0
  store i32 %26, ptr %27, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %28 = load float, ptr %4, align 4, !tbaa !9
  %29 = call i32 @_ZN6GFloat9FromFloatEf(float noundef %28)
  %30 = getelementptr inbounds %class.GFloat, ptr %6, i32 0, i32 0
  store i32 %29, ptr %30, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %5, i64 4, i1 false), !tbaa.struct !11
  %31 = getelementptr inbounds %class.GFloat, ptr %8, i32 0, i32 0
  %32 = load i32, ptr %31, align 4
  %33 = call i32 @_ZN12GFixedType32ILi30EE10FromGFloatE6GFloat(i32 %32)
  %34 = getelementptr inbounds %class.GFixedType32, ptr %7, i32 0, i32 0
  store i32 %33, ptr %34, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %6, i64 4, i1 false), !tbaa.struct !11
  %35 = getelementptr inbounds %class.GFloat, ptr %10, i32 0, i32 0
  %36 = load i32, ptr %35, align 4
  %37 = call i32 @_ZN12GFixedType32ILi30EE10FromGFloatE6GFloat(i32 %36)
  %38 = getelementptr inbounds %class.GFixedType32, ptr %9, i32 0, i32 0
  store i32 %37, ptr %38, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %39

39:                                               ; preds = %15
  %40 = load i32, ptr %1, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %1, align 4, !tbaa !5
  br label %11, !llvm.loop !12

42:                                               ; preds = %14
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind
declare float @sinf(float noundef) #2

; Function Attrs: nounwind
declare float @cosf(float noundef) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZN6GFloat9FromFloatEf(float noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZN12GFixedType32ILi30EE10FromGFloatE6GFloat(i32) #3 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{i64 0, i64 4, !5}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6GFloat4InitEv() local_unnamed_addr #0 align 2 {
  br label %2

1:                                                ; preds = %2
  ret void

2:                                                ; preds = %0, %2
  %.011 = phi i32 [ 0, %0 ], [ %13, %2 ]
  %3 = uitofp nneg i32 %.011 to float
  %4 = fmul float %3, 0x400921FB60000000
  %5 = fmul float %4, 2.000000e+00
  %6 = fmul float %5, 3.906250e-03
  %7 = tail call float @sinf(float noundef %6) #3
  %8 = tail call float @cosf(float noundef %6) #3
  %9 = tail call i32 @_ZN6GFloat9FromFloatEf(float noundef %7)
  %10 = tail call i32 @_ZN6GFloat9FromFloatEf(float noundef %8)
  %11 = tail call i32 @_ZN12GFixedType32ILi30EE10FromGFloatE6GFloat(i32 %9)
  %12 = tail call i32 @_ZN12GFixedType32ILi30EE10FromGFloatE6GFloat(i32 %10)
  %13 = add nuw nsw i32 %.011, 1
  %exitcond.not = icmp eq i32 %13, 256
  br i1 %exitcond.not, label %1, label %2, !llvm.loop !5
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sinf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @cosf(float noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZN6GFloat9FromFloatEf(float noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZN12GFixedType32ILi30EE10FromGFloatE6GFloat(i32) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass