; LLVM IR from goldest-star/seawave-animation :: src/scenes/3D_graphics/01_modeling (modeling)

; 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"

%"struct.vcl::buffer_stack" = type { float, float, float }
%struct.gui_scene_structure = type { i8, i8, i8, float, float, i32, float }

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

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

; 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) #1

declare void @_ZN3vcl12buffer_stackIfLm3EEC1Efff(ptr noundef nonnull align 4 dereferenceable(12), float noundef, float noundef, float noundef) unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_Z25evaluate_perlin_terrain_zffRK19gui_scene_structure(float noundef, float noundef, ptr noundef nonnull align 4 dereferenceable(20)) #3

declare noundef float @_ZN3vcl6perlinEffiff(float noundef, float noundef, i32 noundef, float noundef, float noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, float } @_Z22evaluate_perlin_islandffRK19gui_scene_structure(float noundef %0, float noundef %1, ptr noundef nonnull align 4 dereferenceable(20) %2) #3 {
  %4 = alloca %"struct.vcl::buffer_stack", align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca { <2 x float>, float }, align 8
  store float %0, ptr %5, align 4, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %16 = load ptr, ptr %7, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.gui_scene_structure, ptr %16, i32 0, i32 4
  %18 = load float, ptr %17, align 4, !tbaa !11
  store float %18, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %19 = load ptr, ptr %7, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.gui_scene_structure, ptr %19, i32 0, i32 5
  %21 = load i32, ptr %20, align 4, !tbaa !15
  store i32 %21, ptr %9, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %22 = load ptr, ptr %7, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct.gui_scene_structure, ptr %22, i32 0, i32 6
  %24 = load float, ptr %23, align 4, !tbaa !17
  store float %24, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %25 = load float, ptr %8, align 4, !tbaa !5
  %26 = load float, ptr %5, align 4, !tbaa !5
  %27 = fmul float %25, %26
  %28 = load float, ptr %8, align 4, !tbaa !5
  %29 = load float, ptr %6, align 4, !tbaa !5
  %30 = fmul float %28, %29
  %31 = load i32, ptr %9, align 4, !tbaa !16
  %32 = load float, ptr %10, align 4, !tbaa !5
  %33 = call noundef float @_ZN3vcl6perlinEffiff(float noundef %27, float noundef %30, i32 noundef %31, float noundef %32, float noundef 2.000000e+00)
  store float %33, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %34 = load float, ptr %5, align 4, !tbaa !5
  %35 = fsub float %34, 5.000000e-01
  %36 = fmul float 2.000000e+01, %35
  store float %36, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %37 = load float, ptr %6, align 4, !tbaa !5
  %38 = fsub float %37, 5.000000e-01
  %39 = fmul float 2.000000e+01, %38
  store float %39, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %40 = load float, ptr %5, align 4, !tbaa !5
  %41 = load float, ptr %6, align 4, !tbaa !5
  %42 = load ptr, ptr %7, align 8, !tbaa !9
  %43 = call noundef float @_Z25evaluate_perlin_terrain_zffRK19gui_scene_structure(float noundef %40, float noundef %41, ptr noundef nonnull align 4 dereferenceable(20) %42)
  %44 = load float, ptr %11, align 4, !tbaa !5
  %45 = fmul float %43, %44
  %46 = fpext float %45 to double
  %47 = call double @llvm.fmuladd.f64(double %46, double 1.500000e+00, double -5.000000e-01)
  %48 = fptrunc double %47 to float
  store float %48, ptr %14, align 4, !tbaa !5
  %49 = load float, ptr %12, align 4, !tbaa !5
  %50 = load float, ptr %13, align 4, !tbaa !5
  %51 = load float, ptr %14, align 4, !tbaa !5
  call void @_ZN3vcl12buffer_stackIfLm3EEC1Efff(ptr noundef nonnull align 4 dereferenceable(12) %4, float noundef %49, float noundef %50, float noundef %51)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 4 %4, i64 12, i1 false)
  %52 = load { <2 x float>, float }, ptr %15, align 8
  ret { <2 x float>, float } %52
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 nosync nounwind speculatable willreturn memory(none) }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTS19gui_scene_structure", !13, i64 0, !13, i64 1, !13, i64 2, !6, i64 4, !6, i64 8, !14, i64 12, !6, i64 16}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !14, i64 12}
!16 = !{!14, !14, i64 0}
!17 = !{!12, !6, i64 16}


; 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"

%"struct.vcl::buffer_stack" = type { float, float, float }

declare void @_ZN3vcl12buffer_stackIfLm3EEC1Efff(ptr noundef nonnull align 4 dereferenceable(12), float noundef, float noundef, float noundef) unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_Z25evaluate_perlin_terrain_zffRK19gui_scene_structure(float noundef, float noundef, ptr noundef nonnull align 4 dereferenceable(20)) local_unnamed_addr #1

declare noundef float @_ZN3vcl6perlinEffiff(float noundef, float noundef, i32 noundef, float noundef, float noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, float } @_Z22evaluate_perlin_islandffRK19gui_scene_structure(float noundef %0, float noundef %1, ptr noundef nonnull align 4 dereferenceable(20) %2) local_unnamed_addr #1 {
  %4 = alloca %"struct.vcl::buffer_stack", align 8
  %5 = getelementptr inbounds i8, ptr %2, i64 8
  %6 = load float, ptr %5, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %2, i64 12
  %8 = load i32, ptr %7, align 4, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %2, i64 16
  %10 = load float, ptr %9, align 4, !tbaa !13
  %11 = fmul float %6, %0
  %12 = fmul float %6, %1
  %13 = tail call noundef float @_ZN3vcl6perlinEffiff(float noundef %11, float noundef %12, i32 noundef %8, float noundef %10, float noundef 2.000000e+00)
  %14 = fadd float %0, -5.000000e-01
  %15 = fmul float %14, 2.000000e+01
  %16 = fadd float %1, -5.000000e-01
  %17 = fmul float %16, 2.000000e+01
  %18 = tail call noundef float @_Z25evaluate_perlin_terrain_zffRK19gui_scene_structure(float noundef %0, float noundef %1, ptr noundef nonnull align 4 dereferenceable(20) %2)
  %19 = fmul float %13, %18
  %20 = fpext float %19 to double
  %21 = tail call double @llvm.fmuladd.f64(double %20, double 1.500000e+00, double -5.000000e-01)
  %22 = fptrunc double %21 to float
  call void @_ZN3vcl12buffer_stackIfLm3EEC1Efff(ptr noundef nonnull align 4 dereferenceable(12) %4, float noundef %15, float noundef %17, float noundef %22)
  %.sroa.0.0.copyload = load <2 x float>, ptr %4, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  %.sroa.2.0.copyload = load float, ptr %.sroa.2.0..sroa_idx, align 8
  %.fca.0.insert = insertvalue { <2 x float>, float } poison, <2 x float> %.sroa.0.0.copyload, 0
  %.fca.1.insert = insertvalue { <2 x float>, float } %.fca.0.insert, float %.sroa.2.0.copyload, 1
  ret { <2 x float>, float } %.fca.1.insert
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

attributes #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 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !10, i64 8}
!6 = !{!"_ZTS19gui_scene_structure", !7, i64 0, !7, i64 1, !7, i64 2, !10, i64 4, !10, i64 8, !11, i64 12, !10, i64 16}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !11, i64 12}
!13 = !{!6, !10, i64 16}


; Effective O3 passes: GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,TailCallElimPass