; LLVM IR from introlab/odas :: src/utils (transcendental)

; 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.transcendental_obj = type { float, float, float, ptr, i32 }

@__const.transcendental_construct_zero.table = external hidden unnamed_addr constant [21 x float], align 16

; Function Attrs: nounwind uwtable
define dso_local ptr @transcendental_construct_zero(float noundef %0, float noundef %1, i32 noundef %2) #0 {
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca [21 x float], align 16
  store float %0, ptr %4, align 4, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 84, ptr %13) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %13, ptr align 16 @__const.transcendental_construct_zero.table, i64 84, i1 false)
  %14 = call noalias ptr @malloc(i64 noundef 32) #8
  store ptr %14, ptr %7, align 8, !tbaa !11
  %15 = load float, ptr %4, align 4, !tbaa !5
  %16 = load ptr, ptr %7, align 8, !tbaa !11
  %17 = getelementptr inbounds %struct.transcendental_obj, ptr %16, i32 0, i32 1
  store float %15, ptr %17, align 4, !tbaa !13
  %18 = load float, ptr %5, align 4, !tbaa !5
  %19 = load ptr, ptr %7, align 8, !tbaa !11
  %20 = getelementptr inbounds %struct.transcendental_obj, ptr %19, i32 0, i32 0
  store float %18, ptr %20, align 8, !tbaa !15
  %21 = load float, ptr %5, align 4, !tbaa !5
  %22 = load float, ptr %4, align 4, !tbaa !5
  %23 = fsub float %21, %22
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = sub i32 %24, 1
  %26 = uitofp i32 %25 to float
  %27 = fdiv float %23, %26
  %28 = load ptr, ptr %7, align 8, !tbaa !11
  %29 = getelementptr inbounds %struct.transcendental_obj, ptr %28, i32 0, i32 2
  store float %27, ptr %29, align 8, !tbaa !16
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = zext i32 %30 to i64
  %32 = mul i64 4, %31
  %33 = call noalias ptr @malloc(i64 noundef %32) #8
  %34 = load ptr, ptr %7, align 8, !tbaa !11
  %35 = getelementptr inbounds %struct.transcendental_obj, ptr %34, i32 0, i32 3
  store ptr %33, ptr %35, align 8, !tbaa !17
  %36 = load ptr, ptr %7, align 8, !tbaa !11
  %37 = getelementptr inbounds %struct.transcendental_obj, ptr %36, i32 0, i32 3
  %38 = load ptr, ptr %37, align 8, !tbaa !17
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = zext i32 %39 to i64
  %41 = mul i64 4, %40
  call void @llvm.memset.p0.i64(ptr align 4 %38, i8 0, i64 %41, i1 false)
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = load ptr, ptr %7, align 8, !tbaa !11
  %44 = getelementptr inbounds %struct.transcendental_obj, ptr %43, i32 0, i32 4
  store i32 %42, ptr %44, align 8, !tbaa !18
  store float 0.000000e+00, ptr %9, align 4, !tbaa !5
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %94, %3
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = icmp ult i32 %46, %47
  br i1 %48, label %49, label %97

49:                                               ; preds = %45
  %50 = load float, ptr %9, align 4, !tbaa !5
  %51 = fcmp ole float %50, 9.500000e+00
  br i1 %51, label %52, label %80

52:                                               ; preds = %49
  %53 = load float, ptr %9, align 4, !tbaa !5
  %54 = fmul float 2.000000e+00, %53
  %55 = call float @llvm.floor.f32(float %54)
  store float %55, ptr %11, align 4, !tbaa !5
  %56 = load float, ptr %9, align 4, !tbaa !5
  %57 = load float, ptr %11, align 4, !tbaa !5
  %58 = fneg float %57
  %59 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %56, float %58)
  store float %59, ptr %12, align 4, !tbaa !5
  %60 = load float, ptr %12, align 4, !tbaa !5
  %61 = fsub float 1.000000e+00, %60
  %62 = load float, ptr %11, align 4, !tbaa !5
  %63 = fptoui float %62 to i32
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds [21 x float], ptr %13, i64 0, i64 %64
  %66 = load float, ptr %65, align 4, !tbaa !5
  %67 = load float, ptr %12, align 4, !tbaa !5
  %68 = load float, ptr %11, align 4, !tbaa !5
  %69 = fptoui float %68 to i32
  %70 = add i32 %69, 1
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds [21 x float], ptr %13, i64 0, i64 %71
  %73 = load float, ptr %72, align 4, !tbaa !5
  %74 = fmul float %67, %73
  %75 = call float @llvm.fmuladd.f32(float %61, float %66, float %74)
  %76 = load float, ptr %9, align 4, !tbaa !5
  %77 = fadd float %76, 0x3F1A36E2E0000000
  %78 = call float @sqrtf(float noundef %77) #7
  %79 = fdiv float %75, %78
  store float %79, ptr %10, align 4, !tbaa !5
  br label %81

80:                                               ; preds = %49
  store float 1.000000e+00, ptr %10, align 4, !tbaa !5
  br label %81

81:                                               ; preds = %80, %52
  %82 = load float, ptr %10, align 4, !tbaa !5
  %83 = load ptr, ptr %7, align 8, !tbaa !11
  %84 = getelementptr inbounds %struct.transcendental_obj, ptr %83, i32 0, i32 3
  %85 = load ptr, ptr %84, align 8, !tbaa !17
  %86 = load i32, ptr %8, align 4, !tbaa !9
  %87 = zext i32 %86 to i64
  %88 = getelementptr inbounds float, ptr %85, i64 %87
  store float %82, ptr %88, align 4, !tbaa !5
  %89 = load ptr, ptr %7, align 8, !tbaa !11
  %90 = getelementptr inbounds %struct.transcendental_obj, ptr %89, i32 0, i32 2
  %91 = load float, ptr %90, align 8, !tbaa !16
  %92 = load float, ptr %9, align 4, !tbaa !5
  %93 = fadd float %92, %91
  store float %93, ptr %9, align 4, !tbaa !5
  br label %94

94:                                               ; preds = %81
  %95 = load i32, ptr %8, align 4, !tbaa !9
  %96 = add i32 %95, 1
  store i32 %96, ptr %8, align 4, !tbaa !9
  br label %45, !llvm.loop !19

97:                                               ; preds = %45
  %98 = load ptr, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 84, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  ret ptr %98
}

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.floor.f32(float) #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #5

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #6

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

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind allocsize(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: write) }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !6, i64 4}
!14 = !{!"transcendental_obj", !6, i64 0, !6, i64 4, !6, i64 8, !12, i64 16, !10, i64 24}
!15 = !{!14, !6, i64 0}
!16 = !{!14, !6, i64 8}
!17 = !{!14, !12, i64 16}
!18 = !{!14, !10, i64 24}
!19 = distinct !{!19, !20}
!20 = !{!"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"

@__const.transcendental_construct_zero.table = external hidden unnamed_addr constant [21 x float], align 16

; Function Attrs: nofree nounwind memory(write, inaccessiblemem: readwrite) uwtable
define dso_local noalias noundef ptr @transcendental_construct_zero(float noundef %0, float noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #5
  %5 = getelementptr inbounds i8, ptr %4, i64 4
  store float %0, ptr %5, align 4, !tbaa !5
  store float %1, ptr %4, align 8, !tbaa !12
  %6 = fsub float %1, %0
  %7 = add i32 %2, -1
  %8 = uitofp i32 %7 to float
  %9 = fdiv float %6, %8
  %10 = getelementptr inbounds i8, ptr %4, i64 8
  store float %9, ptr %10, align 8, !tbaa !13
  %11 = zext i32 %2 to i64
  %12 = shl nuw nsw i64 %11, 2
  %calloc = tail call ptr @calloc(i64 1, i64 %12)
  %13 = getelementptr inbounds i8, ptr %4, i64 16
  store ptr %calloc, ptr %13, align 8, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %4, i64 24
  store i32 %2, ptr %14, align 8, !tbaa !15
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %35
  %indvars.iv = phi i64 [ %indvars.iv.next, %35 ], [ 0, %3 ]
  %.03133 = phi float [ %37, %35 ], [ 0.000000e+00, %3 ]
  %15 = fcmp ugt float %.03133, 9.500000e+00
  br i1 %15, label %35, label %16

16:                                               ; preds = %.lr.ph
  %17 = fmul float %.03133, 2.000000e+00
  %18 = tail call float @llvm.floor.f32(float %17)
  %19 = fneg float %18
  %20 = tail call float @llvm.fmuladd.f32(float %.03133, float 2.000000e+00, float %19)
  %21 = fsub float 1.000000e+00, %20
  %22 = fptoui float %18 to i32
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds [21 x float], ptr @__const.transcendental_construct_zero.table, i64 0, i64 %23
  %25 = load float, ptr %24, align 4, !tbaa !16
  %26 = add i32 %22, 1
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds [21 x float], ptr @__const.transcendental_construct_zero.table, i64 0, i64 %27
  %29 = load float, ptr %28, align 4, !tbaa !16
  %30 = fmul float %20, %29
  %31 = tail call float @llvm.fmuladd.f32(float %21, float %25, float %30)
  %32 = fadd float %.03133, 0x3F1A36E2E0000000
  %33 = tail call float @sqrtf(float noundef %32) #6
  %34 = fdiv float %31, %33
  br label %35

35:                                               ; preds = %.lr.ph, %16
  %.032 = phi float [ %34, %16 ], [ 1.000000e+00, %.lr.ph ]
  %36 = getelementptr inbounds float, ptr %calloc, i64 %indvars.iv
  store float %.032, ptr %36, align 4, !tbaa !16
  %37 = fadd float %9, %.03133
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %11
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !17

._crit_edge:                                      ; preds = %35, %3
  ret ptr %4
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.floor.f32(float) #2

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

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

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #4

attributes #0 = { nofree nounwind memory(write, inaccessiblemem: readwrite) 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 allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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) }
attributes #3 = { 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 #4 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #5 = { nounwind allocsize(0) }
attributes #6 = { 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, !7, i64 4}
!6 = !{!"transcendental_obj", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !11, i64 24}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !11, i64 24}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass