; LLVM IR from bark-simulator/bark :: bark/world/opendrive/odrSpiral.ll (ZN4bark5world9opendrive7fresnelEdPdS2_)

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

@_ZN4bark5world9opendriveL2snE = external hidden global [6 x double], align 16
@_ZN4bark5world9opendriveL2sdE = external hidden global [6 x double], align 16
@_ZN4bark5world9opendriveL2cnE = external hidden global [6 x double], align 16
@_ZN4bark5world9opendriveL2cdE = external hidden global [7 x double], align 16
@_ZN4bark5world9opendriveL2fnE = external hidden global [10 x double], align 16
@_ZN4bark5world9opendriveL2fdE = external hidden global [10 x double], align 16
@_ZN4bark5world9opendriveL2gnE = external hidden global [11 x double], align 16
@_ZN4bark5world9opendriveL2gdE = external hidden global [11 x double], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4bark5world9opendrive7fresnelEdPdS2_(double noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca double, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  store double %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %17 = load double, ptr %4, align 8, !tbaa !5
  %18 = call double @llvm.fabs.f64(double %17)
  store double %18, ptr %15, align 8, !tbaa !5
  %19 = load double, ptr %15, align 8, !tbaa !5
  %20 = load double, ptr %15, align 8, !tbaa !5
  %21 = fmul double %19, %20
  store double %21, ptr %16, align 8, !tbaa !5
  %22 = load double, ptr %16, align 8, !tbaa !5
  %23 = fcmp olt double %22, 2.562500e+00
  br i1 %23, label %24, label %44

24:                                               ; preds = %3
  %25 = load double, ptr %16, align 8, !tbaa !5
  %26 = load double, ptr %16, align 8, !tbaa !5
  %27 = fmul double %25, %26
  store double %27, ptr %13, align 8, !tbaa !5
  %28 = load double, ptr %15, align 8, !tbaa !5
  %29 = load double, ptr %16, align 8, !tbaa !5
  %30 = fmul double %28, %29
  %31 = load double, ptr %13, align 8, !tbaa !5
  %32 = call noundef double @_ZN4bark5world9opendriveL6polevlEdPdi(double noundef %31, ptr noundef @_ZN4bark5world9opendriveL2snE, i32 noundef 5)
  %33 = fmul double %30, %32
  %34 = load double, ptr %13, align 8, !tbaa !5
  %35 = call noundef double @_ZN4bark5world9opendriveL5p1evlEdPdi(double noundef %34, ptr noundef @_ZN4bark5world9opendriveL2sdE, i32 noundef 6)
  %36 = fdiv double %33, %35
  store double %36, ptr %10, align 8, !tbaa !5
  %37 = load double, ptr %15, align 8, !tbaa !5
  %38 = load double, ptr %13, align 8, !tbaa !5
  %39 = call noundef double @_ZN4bark5world9opendriveL6polevlEdPdi(double noundef %38, ptr noundef @_ZN4bark5world9opendriveL2cnE, i32 noundef 5)
  %40 = fmul double %37, %39
  %41 = load double, ptr %13, align 8, !tbaa !5
  %42 = call noundef double @_ZN4bark5world9opendriveL6polevlEdPdi(double noundef %41, ptr noundef @_ZN4bark5world9opendriveL2cdE, i32 noundef 6)
  %43 = fdiv double %40, %42
  store double %43, ptr %9, align 8, !tbaa !5
  br label %103

44:                                               ; preds = %3
  %45 = load double, ptr %15, align 8, !tbaa !5
  %46 = fcmp ogt double %45, 3.697400e+04
  br i1 %46, label %47, label %48

47:                                               ; preds = %44
  store double 5.000000e-01, ptr %9, align 8, !tbaa !5
  store double 5.000000e-01, ptr %10, align 8, !tbaa !5
  br label %102

48:                                               ; preds = %44
  %49 = load double, ptr %15, align 8, !tbaa !5
  %50 = load double, ptr %15, align 8, !tbaa !5
  %51 = fmul double %49, %50
  store double %51, ptr %16, align 8, !tbaa !5
  %52 = load double, ptr %16, align 8, !tbaa !5
  %53 = fmul double 0x400921FB54442D18, %52
  store double %53, ptr %13, align 8, !tbaa !5
  %54 = load double, ptr %13, align 8, !tbaa !5
  %55 = load double, ptr %13, align 8, !tbaa !5
  %56 = fmul double %54, %55
  %57 = fdiv double 1.000000e+00, %56
  store double %57, ptr %14, align 8, !tbaa !5
  %58 = load double, ptr %13, align 8, !tbaa !5
  %59 = fdiv double 1.000000e+00, %58
  store double %59, ptr %13, align 8, !tbaa !5
  %60 = load double, ptr %14, align 8, !tbaa !5
  %61 = load double, ptr %14, align 8, !tbaa !5
  %62 = call noundef double @_ZN4bark5world9opendriveL6polevlEdPdi(double noundef %61, ptr noundef @_ZN4bark5world9opendriveL2fnE, i32 noundef 9)
  %63 = fmul double %60, %62
  %64 = load double, ptr %14, align 8, !tbaa !5
  %65 = call noundef double @_ZN4bark5world9opendriveL5p1evlEdPdi(double noundef %64, ptr noundef @_ZN4bark5world9opendriveL2fdE, i32 noundef 10)
  %66 = fdiv double %63, %65
  %67 = fsub double 1.000000e+00, %66
  store double %67, ptr %7, align 8, !tbaa !5
  %68 = load double, ptr %13, align 8, !tbaa !5
  %69 = load double, ptr %14, align 8, !tbaa !5
  %70 = call noundef double @_ZN4bark5world9opendriveL6polevlEdPdi(double noundef %69, ptr noundef @_ZN4bark5world9opendriveL2gnE, i32 noundef 10)
  %71 = fmul double %68, %70
  %72 = load double, ptr %14, align 8, !tbaa !5
  %73 = call noundef double @_ZN4bark5world9opendriveL5p1evlEdPdi(double noundef %72, ptr noundef @_ZN4bark5world9opendriveL2gdE, i32 noundef 11)
  %74 = fdiv double %71, %73
  store double %74, ptr %8, align 8, !tbaa !5
  %75 = load double, ptr %16, align 8, !tbaa !5
  %76 = fmul double 0x3FF921FB54442D18, %75
  store double %76, ptr %13, align 8, !tbaa !5
  %77 = load double, ptr %13, align 8, !tbaa !5
  %78 = call double @cos(double noundef %77) #5
  store double %78, ptr %11, align 8, !tbaa !5
  %79 = load double, ptr %13, align 8, !tbaa !5
  %80 = call double @sin(double noundef %79) #5
  store double %80, ptr %12, align 8, !tbaa !5
  %81 = load double, ptr %15, align 8, !tbaa !5
  %82 = fmul double 0x400921FB54442D18, %81
  store double %82, ptr %13, align 8, !tbaa !5
  %83 = load double, ptr %7, align 8, !tbaa !5
  %84 = load double, ptr %12, align 8, !tbaa !5
  %85 = load double, ptr %8, align 8, !tbaa !5
  %86 = load double, ptr %11, align 8, !tbaa !5
  %87 = fmul double %85, %86
  %88 = fneg double %87
  %89 = call double @llvm.fmuladd.f64(double %83, double %84, double %88)
  %90 = load double, ptr %13, align 8, !tbaa !5
  %91 = fdiv double %89, %90
  %92 = fadd double 5.000000e-01, %91
  store double %92, ptr %9, align 8, !tbaa !5
  %93 = load double, ptr %7, align 8, !tbaa !5
  %94 = load double, ptr %11, align 8, !tbaa !5
  %95 = load double, ptr %8, align 8, !tbaa !5
  %96 = load double, ptr %12, align 8, !tbaa !5
  %97 = fmul double %95, %96
  %98 = call double @llvm.fmuladd.f64(double %93, double %94, double %97)
  %99 = load double, ptr %13, align 8, !tbaa !5
  %100 = fdiv double %98, %99
  %101 = fsub double 5.000000e-01, %100
  store double %101, ptr %10, align 8, !tbaa !5
  br label %102

102:                                              ; preds = %48, %47
  br label %103

103:                                              ; preds = %102, %24
  %104 = load double, ptr %4, align 8, !tbaa !5
  %105 = fcmp olt double %104, 0.000000e+00
  br i1 %105, label %106, label %111

106:                                              ; preds = %103
  %107 = load double, ptr %9, align 8, !tbaa !5
  %108 = fneg double %107
  store double %108, ptr %9, align 8, !tbaa !5
  %109 = load double, ptr %10, align 8, !tbaa !5
  %110 = fneg double %109
  store double %110, ptr %10, align 8, !tbaa !5
  br label %111

111:                                              ; preds = %106, %103
  %112 = load double, ptr %9, align 8, !tbaa !5
  %113 = load ptr, ptr %6, align 8, !tbaa !9
  store double %112, ptr %113, align 8, !tbaa !5
  %114 = load double, ptr %10, align 8, !tbaa !5
  %115 = load ptr, ptr %5, align 8, !tbaa !9
  store double %114, ptr %115, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef double @_ZN4bark5world9opendriveL6polevlEdPdi(double noundef, ptr noundef, i32 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef double @_ZN4bark5world9opendriveL5p1evlEdPdi(double noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare double @cos(double noundef) #4

; Function Attrs: nounwind
declare double @sin(double noundef) #4

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

; 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { mustprogress nounwind 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 = { 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 #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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


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

@_ZN4bark5world9opendriveL2snE = external hidden global [6 x double], align 16
@_ZN4bark5world9opendriveL2sdE = external hidden global [6 x double], align 16
@_ZN4bark5world9opendriveL2cnE = external hidden global [6 x double], align 16
@_ZN4bark5world9opendriveL2cdE = external hidden global [7 x double], align 16
@_ZN4bark5world9opendriveL2fnE = external hidden global [10 x double], align 16
@_ZN4bark5world9opendriveL2fdE = external hidden global [10 x double], align 16
@_ZN4bark5world9opendriveL2gnE = external hidden global [11 x double], align 16
@_ZN4bark5world9opendriveL2gdE = external hidden global [11 x double], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4bark5world9opendrive7fresnelEdPdS2_(double noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = tail call double @llvm.fabs.f64(double %0)
  %5 = fmul double %0, %0
  %6 = fcmp olt double %5, 2.562500e+00
  br i1 %6, label %7, label %22

7:                                                ; preds = %3
  %8 = fmul double %5, %5
  %9 = fmul double %4, %5
  %10 = tail call noundef double @_ZN4bark5world9opendriveL6polevlEdPdi(double noundef %8, ptr noundef nonnull @_ZN4bark5world9opendriveL2snE, i32 noundef 5)
  %11 = tail call noundef double @_ZN4bark5world9opendriveL5p1evlEdPdi(double noundef %8, ptr noundef nonnull @_ZN4bark5world9opendriveL2sdE, i32 noundef 6)
  %12 = tail call noundef double @_ZN4bark5world9opendriveL6polevlEdPdi(double noundef %8, ptr noundef nonnull @_ZN4bark5world9opendriveL2cnE, i32 noundef 5)
  %13 = insertelement <2 x double> poison, double %4, i64 0
  %14 = insertelement <2 x double> %13, double %9, i64 1
  %15 = insertelement <2 x double> poison, double %12, i64 0
  %16 = insertelement <2 x double> %15, double %10, i64 1
  %17 = fmul <2 x double> %14, %16
  %18 = tail call noundef double @_ZN4bark5world9opendriveL6polevlEdPdi(double noundef %8, ptr noundef nonnull @_ZN4bark5world9opendriveL2cdE, i32 noundef 6)
  %19 = insertelement <2 x double> poison, double %18, i64 0
  %20 = insertelement <2 x double> %19, double %11, i64 1
  %21 = fdiv <2 x double> %17, %20
  br label %58

22:                                               ; preds = %3
  %23 = fcmp ogt double %4, 3.697400e+04
  br i1 %23, label %58, label %24

24:                                               ; preds = %22
  %25 = fmul double %5, 0x400921FB54442D18
  %26 = fmul double %25, %25
  %27 = fdiv double 1.000000e+00, %26
  %28 = fdiv double 1.000000e+00, %25
  %29 = tail call noundef double @_ZN4bark5world9opendriveL6polevlEdPdi(double noundef %27, ptr noundef nonnull @_ZN4bark5world9opendriveL2fnE, i32 noundef 9)
  %30 = fmul double %27, %29
  %31 = tail call noundef double @_ZN4bark5world9opendriveL5p1evlEdPdi(double noundef %27, ptr noundef nonnull @_ZN4bark5world9opendriveL2fdE, i32 noundef 10)
  %32 = fdiv double %30, %31
  %33 = fsub double 1.000000e+00, %32
  %34 = tail call noundef double @_ZN4bark5world9opendriveL6polevlEdPdi(double noundef %27, ptr noundef nonnull @_ZN4bark5world9opendriveL2gnE, i32 noundef 10)
  %35 = fmul double %28, %34
  %36 = tail call noundef double @_ZN4bark5world9opendriveL5p1evlEdPdi(double noundef %27, ptr noundef nonnull @_ZN4bark5world9opendriveL2gdE, i32 noundef 11)
  %37 = fdiv double %35, %36
  %38 = fmul double %5, 0x3FF921FB54442D18
  %39 = tail call double @cos(double noundef %38) #4
  %40 = tail call double @sin(double noundef %38) #4
  %41 = fmul double %4, 0x400921FB54442D18
  %42 = fneg double %37
  %43 = insertelement <2 x double> poison, double %39, i64 0
  %44 = insertelement <2 x double> %43, double %37, i64 1
  %45 = insertelement <2 x double> poison, double %42, i64 0
  %46 = insertelement <2 x double> %45, double %40, i64 1
  %47 = fmul <2 x double> %44, %46
  %48 = insertelement <2 x double> poison, double %33, i64 0
  %49 = shufflevector <2 x double> %48, <2 x double> poison, <2 x i32> zeroinitializer
  %50 = shufflevector <2 x double> %46, <2 x double> %43, <2 x i32> <i32 1, i32 2>
  %51 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %49, <2 x double> %50, <2 x double> %47)
  %52 = insertelement <2 x double> poison, double %41, i64 0
  %53 = shufflevector <2 x double> %52, <2 x double> poison, <2 x i32> zeroinitializer
  %54 = fdiv <2 x double> %51, %53
  %55 = fadd <2 x double> %54, <double 5.000000e-01, double poison>
  %56 = fsub <2 x double> <double poison, double 5.000000e-01>, %54
  %57 = shufflevector <2 x double> %55, <2 x double> %56, <2 x i32> <i32 0, i32 3>
  br label %58

58:                                               ; preds = %22, %24, %7
  %59 = phi <2 x double> [ %21, %7 ], [ %57, %24 ], [ <double 5.000000e-01, double 5.000000e-01>, %22 ]
  %60 = fcmp olt double %0, 0.000000e+00
  %61 = extractelement <2 x double> %59, i64 0
  %62 = fneg double %61
  %63 = extractelement <2 x double> %59, i64 1
  %64 = fneg double %63
  %.148 = select i1 %60, double %64, double %63
  %.1 = select i1 %60, double %62, double %61
  store double %.1, ptr %2, align 8, !tbaa !5
  store double %.148, ptr %1, align 8, !tbaa !5
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef double @_ZN4bark5world9opendriveL6polevlEdPdi(double noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef double @_ZN4bark5world9opendriveL5p1evlEdPdi(double noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #3

attributes #0 = { mustprogress nounwind 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass