; LLVM IR from P-py/c-numerical-methods :: dichotomy (validateFunction)

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

@stderr = external global ptr, align 8
@.str.11 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [47 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @validateFunction(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %58, %5
  %19 = load i32, ptr %11, align 4, !tbaa !9
  %20 = icmp slt i32 %19, 2
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %61

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %23 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %23, ptr %13, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %54, %22
  %25 = load i32, ptr %13, align 4, !tbaa !9
  %26 = icmp sge i32 %25, 0
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %57

28:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = load i32, ptr %13, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds float, ptr %29, i64 %31
  %33 = load float, ptr %32, align 4, !tbaa !11
  store float %33, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load i32, ptr %13, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i32, ptr %34, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !9
  %39 = sitofp i32 %38 to float
  store float %39, ptr %15, align 4, !tbaa !11
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load i32, ptr %11, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds float, ptr %40, i64 %42
  %44 = load float, ptr %43, align 4, !tbaa !11
  %45 = load float, ptr %15, align 4, !tbaa !11
  %46 = call float @powf(float noundef %44, float noundef %45) #6
  %47 = load float, ptr %14, align 4, !tbaa !11
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = load i32, ptr %11, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds float, ptr %48, i64 %50
  %52 = load float, ptr %51, align 4, !tbaa !11
  %53 = call float @llvm.fmuladd.f32(float %46, float %47, float %52)
  store float %53, ptr %51, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %54

54:                                               ; preds = %28
  %55 = load i32, ptr %13, align 4, !tbaa !9
  %56 = add nsw i32 %55, -1
  store i32 %56, ptr %13, align 4, !tbaa !9
  br label %24, !llvm.loop !13

57:                                               ; preds = %27
  br label %58

58:                                               ; preds = %57
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %11, align 4, !tbaa !9
  br label %18, !llvm.loop !15

61:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = load float, ptr %62, align 4, !tbaa !11
  store float %63, ptr %16, align 4, !tbaa !11
  %64 = load float, ptr %16, align 4, !tbaa !11
  %65 = fpext float %64 to double
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, double noundef %65)
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = getelementptr inbounds float, ptr %67, i64 1
  %69 = load float, ptr %68, align 4, !tbaa !11
  store float %69, ptr %17, align 4, !tbaa !11
  %70 = load float, ptr %17, align 4, !tbaa !11
  %71 = fpext float %70 to double
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, double noundef %71)
  %73 = load float, ptr %16, align 4, !tbaa !11
  %74 = load float, ptr %17, align 4, !tbaa !11
  %75 = fmul float %73, %74
  %76 = fcmp ogt float %75, 0.000000e+00
  br i1 %76, label %77, label %80

77:                                               ; preds = %61
  %78 = load ptr, ptr @stderr, align 8, !tbaa !5
  %79 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %78, ptr noundef @.str.13) #6
  call void @exit(i32 noundef 2) #7
  unreachable

80:                                               ; preds = %61
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  br label %82

82:                                               ; preds = %80
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  ret void
}

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

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #3

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #4

; Function Attrs: nounwind
declare float @powf(float noundef, float noundef) #4

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { noreturn 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { noreturn 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 = !{!"any pointer", !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 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.11 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [47 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @validateFunction(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, i32 noundef %3, ptr nocapture noundef %4) local_unnamed_addr #0 {
  %6 = icmp sgt i32 %3, -1
  br i1 %6, label %.preheader.us.preheader, label %.split24.us

.preheader.us.preheader:                          ; preds = %5
  %7 = zext nneg i32 %3 to i64
  %8 = and i64 %7, 1
  %lcmp.mod.not.not = icmp eq i64 %8, 0
  br i1 %lcmp.mod.not.not, label %.prol.loopexit.unr-lcssa, label %.prol.loopexit

.prol.loopexit.unr-lcssa:                         ; preds = %.preheader.us.preheader
  %9 = getelementptr inbounds float, ptr %2, i64 %7
  %10 = load float, ptr %9, align 4, !tbaa !5
  %11 = getelementptr inbounds i32, ptr %1, i64 %7
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = sitofp i32 %12 to float
  %14 = load float, ptr %0, align 4, !tbaa !5
  %15 = tail call float @powf(float noundef %14, float noundef %13) #5
  %16 = load float, ptr %4, align 4, !tbaa !5
  %17 = tail call float @llvm.fmuladd.f32(float %15, float %10, float %16)
  store float %17, ptr %4, align 4, !tbaa !5
  %indvars.iv.next.prol = add nsw i64 %7, -1
  br label %.prol.loopexit

.prol.loopexit:                                   ; preds = %.prol.loopexit.unr-lcssa, %.preheader.us.preheader
  %indvars.iv.unr = phi i64 [ %7, %.preheader.us.preheader ], [ %indvars.iv.next.prol, %.prol.loopexit.unr-lcssa ]
  %18 = icmp eq i32 %3, 0
  br i1 %18, label %._crit_edge.us, label %.preheader.us.preheader.new

.preheader.us.preheader.new:                      ; preds = %.prol.loopexit, %.preheader.us.preheader.new
  %indvars.iv = phi i64 [ %indvars.iv.next.131, %.preheader.us.preheader.new ], [ %indvars.iv.unr, %.prol.loopexit ]
  %19 = getelementptr inbounds float, ptr %2, i64 %indvars.iv
  %20 = load float, ptr %19, align 4, !tbaa !5
  %21 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv
  %22 = load i32, ptr %21, align 4, !tbaa !9
  %23 = sitofp i32 %22 to float
  %24 = load float, ptr %0, align 4, !tbaa !5
  %25 = tail call float @powf(float noundef %24, float noundef %23) #5
  %26 = load float, ptr %4, align 4, !tbaa !5
  %27 = tail call float @llvm.fmuladd.f32(float %25, float %20, float %26)
  store float %27, ptr %4, align 4, !tbaa !5
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %28 = getelementptr inbounds float, ptr %2, i64 %indvars.iv.next
  %29 = load float, ptr %28, align 4, !tbaa !5
  %30 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv.next
  %31 = load i32, ptr %30, align 4, !tbaa !9
  %32 = sitofp i32 %31 to float
  %33 = load float, ptr %0, align 4, !tbaa !5
  %34 = tail call float @powf(float noundef %33, float noundef %32) #5
  %35 = load float, ptr %4, align 4, !tbaa !5
  %36 = tail call float @llvm.fmuladd.f32(float %34, float %29, float %35)
  store float %36, ptr %4, align 4, !tbaa !5
  %indvars.iv.next.131 = add nsw i64 %indvars.iv, -2
  %.not.1 = icmp eq i64 %indvars.iv.next, 0
  br i1 %.not.1, label %._crit_edge.us, label %.preheader.us.preheader.new, !llvm.loop !11

._crit_edge.us:                                   ; preds = %.preheader.us.preheader.new, %.prol.loopexit
  %37 = getelementptr inbounds i8, ptr %0, i64 4
  %38 = getelementptr inbounds i8, ptr %4, i64 4
  %39 = and i64 %7, 1
  %lcmp.mod35.not.not = icmp eq i64 %39, 0
  br i1 %lcmp.mod35.not.not, label %.prol.loopexit33.unr-lcssa, label %.prol.loopexit33

.prol.loopexit33.unr-lcssa:                       ; preds = %._crit_edge.us
  %40 = getelementptr inbounds float, ptr %2, i64 %7
  %41 = load float, ptr %40, align 4, !tbaa !5
  %42 = getelementptr inbounds i32, ptr %1, i64 %7
  %43 = load i32, ptr %42, align 4, !tbaa !9
  %44 = sitofp i32 %43 to float
  %45 = load float, ptr %37, align 4, !tbaa !5
  %46 = tail call float @powf(float noundef %45, float noundef %44) #5
  %47 = load float, ptr %38, align 4, !tbaa !5
  %48 = tail call float @llvm.fmuladd.f32(float %46, float %41, float %47)
  store float %48, ptr %38, align 4, !tbaa !5
  %indvars.iv.next.1.prol = add nsw i64 %7, -1
  br label %.prol.loopexit33

.prol.loopexit33:                                 ; preds = %.prol.loopexit33.unr-lcssa, %._crit_edge.us
  %indvars.iv.1.unr = phi i64 [ %7, %._crit_edge.us ], [ %indvars.iv.next.1.prol, %.prol.loopexit33.unr-lcssa ]
  %49 = icmp eq i32 %3, 0
  br i1 %49, label %.split24.us, label %._crit_edge.us.new

._crit_edge.us.new:                               ; preds = %.prol.loopexit33, %._crit_edge.us.new
  %indvars.iv.1 = phi i64 [ %indvars.iv.next.1.1, %._crit_edge.us.new ], [ %indvars.iv.1.unr, %.prol.loopexit33 ]
  %50 = getelementptr inbounds float, ptr %2, i64 %indvars.iv.1
  %51 = load float, ptr %50, align 4, !tbaa !5
  %52 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv.1
  %53 = load i32, ptr %52, align 4, !tbaa !9
  %54 = sitofp i32 %53 to float
  %55 = load float, ptr %37, align 4, !tbaa !5
  %56 = tail call float @powf(float noundef %55, float noundef %54) #5
  %57 = load float, ptr %38, align 4, !tbaa !5
  %58 = tail call float @llvm.fmuladd.f32(float %56, float %51, float %57)
  store float %58, ptr %38, align 4, !tbaa !5
  %indvars.iv.next.1 = add nsw i64 %indvars.iv.1, -1
  %59 = getelementptr inbounds float, ptr %2, i64 %indvars.iv.next.1
  %60 = load float, ptr %59, align 4, !tbaa !5
  %61 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv.next.1
  %62 = load i32, ptr %61, align 4, !tbaa !9
  %63 = sitofp i32 %62 to float
  %64 = load float, ptr %37, align 4, !tbaa !5
  %65 = tail call float @powf(float noundef %64, float noundef %63) #5
  %66 = load float, ptr %38, align 4, !tbaa !5
  %67 = tail call float @llvm.fmuladd.f32(float %65, float %60, float %66)
  store float %67, ptr %38, align 4, !tbaa !5
  %indvars.iv.next.1.1 = add nsw i64 %indvars.iv.1, -2
  %68 = icmp sgt i64 %indvars.iv.1, 1
  br i1 %68, label %._crit_edge.us.new, label %.split24.us, !llvm.loop !11

.split24.us:                                      ; preds = %.prol.loopexit33, %._crit_edge.us.new, %5
  %69 = load float, ptr %4, align 4, !tbaa !5
  %70 = fpext float %69 to double
  %71 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, double noundef %70)
  %72 = getelementptr inbounds i8, ptr %4, i64 4
  %73 = load float, ptr %72, align 4, !tbaa !5
  %74 = fpext float %73 to double
  %75 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, double noundef %74)
  %76 = fmul float %69, %73
  %77 = fcmp ogt float %76, 0.000000e+00
  br i1 %77, label %78, label %81

78:                                               ; preds = %.split24.us
  %79 = load ptr, ptr @stderr, align 8, !tbaa !13
  %80 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %79, ptr noundef nonnull @.str.13) #6
  tail call void @exit(i32 noundef 2) #7
  unreachable

81:                                               ; preds = %.split24.us
  %82 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

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

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 = { nofree 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 #2 = { noreturn 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 = { 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }
attributes #6 = { cold nounwind }
attributes #7 = { noreturn 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}


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