; LLVM IR from introlab/odas :: src/system (track2steer)

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

; Function Attrs: nounwind uwtable
define dso_local ptr @track2steer_construct_zero(i32 noundef %0, i32 noundef %1, i32 noundef %2, float noundef %3, i32 noundef %4, ptr noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !5
  store float %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %15 = call noalias ptr @malloc(i64 noundef 48) #5
  store ptr %15, ptr %13, align 8, !tbaa !11
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = load ptr, ptr %13, align 8, !tbaa !11
  %18 = getelementptr inbounds %struct.track2steer_obj, ptr %17, i32 0, i32 0
  store i32 %16, ptr %18, align 8, !tbaa !13
  %19 = load i32, ptr %8, align 4, !tbaa !5
  %20 = load ptr, ptr %13, align 8, !tbaa !11
  %21 = getelementptr inbounds %struct.track2steer_obj, ptr %20, i32 0, i32 1
  store i32 %19, ptr %21, align 4, !tbaa !15
  %22 = load i32, ptr %9, align 4, !tbaa !5
  %23 = load ptr, ptr %13, align 8, !tbaa !11
  %24 = getelementptr inbounds %struct.track2steer_obj, ptr %23, i32 0, i32 2
  store i32 %22, ptr %24, align 8, !tbaa !16
  %25 = load float, ptr %10, align 4, !tbaa !9
  %26 = load ptr, ptr %13, align 8, !tbaa !11
  %27 = getelementptr inbounds %struct.track2steer_obj, ptr %26, i32 0, i32 3
  store float %25, ptr %27, align 4, !tbaa !17
  %28 = load i32, ptr %11, align 4, !tbaa !5
  %29 = load ptr, ptr %13, align 8, !tbaa !11
  %30 = getelementptr inbounds %struct.track2steer_obj, ptr %29, i32 0, i32 4
  store i32 %28, ptr %30, align 8, !tbaa !18
  %31 = load i32, ptr %8, align 4, !tbaa !5
  %32 = zext i32 %31 to i64
  %33 = mul i64 4, %32
  %34 = mul i64 %33, 3
  %35 = call noalias ptr @malloc(i64 noundef %34) #5
  %36 = load ptr, ptr %13, align 8, !tbaa !11
  %37 = getelementptr inbounds %struct.track2steer_obj, ptr %36, i32 0, i32 5
  store ptr %35, ptr %37, align 8, !tbaa !19
  %38 = load ptr, ptr %13, align 8, !tbaa !11
  %39 = getelementptr inbounds %struct.track2steer_obj, ptr %38, i32 0, i32 5
  %40 = load ptr, ptr %39, align 8, !tbaa !19
  %41 = load ptr, ptr %12, align 8, !tbaa !11
  %42 = load i32, ptr %8, align 4, !tbaa !5
  %43 = zext i32 %42 to i64
  %44 = mul i64 4, %43
  %45 = mul i64 %44, 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %40, ptr align 4 %41, i64 %45, i1 false)
  %46 = load i32, ptr %9, align 4, !tbaa !5
  %47 = zext i32 %46 to i64
  %48 = mul i64 4, %47
  %49 = call noalias ptr @malloc(i64 noundef %48) #5
  %50 = load ptr, ptr %13, align 8, !tbaa !11
  %51 = getelementptr inbounds %struct.track2steer_obj, ptr %50, i32 0, i32 6
  store ptr %49, ptr %51, align 8, !tbaa !20
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %74, %6
  %53 = load i32, ptr %14, align 4, !tbaa !5
  %54 = load i32, ptr %9, align 4, !tbaa !5
  %55 = icmp ult i32 %53, %54
  br i1 %55, label %56, label %77

56:                                               ; preds = %52
  %57 = load i32, ptr %14, align 4, !tbaa !5
  %58 = uitofp i32 %57 to float
  %59 = fpext float %58 to double
  %60 = fmul double 0xC01921FB54442D18, %59
  %61 = load i32, ptr %9, align 4, !tbaa !5
  %62 = sub i32 %61, 1
  %63 = mul i32 %62, 2
  %64 = uitofp i32 %63 to float
  %65 = fpext float %64 to double
  %66 = fdiv double %60, %65
  %67 = fptrunc double %66 to float
  %68 = load ptr, ptr %13, align 8, !tbaa !11
  %69 = getelementptr inbounds %struct.track2steer_obj, ptr %68, i32 0, i32 6
  %70 = load ptr, ptr %69, align 8, !tbaa !20
  %71 = load i32, ptr %14, align 4, !tbaa !5
  %72 = zext i32 %71 to i64
  %73 = getelementptr inbounds float, ptr %70, i64 %72
  store float %67, ptr %73, align 4, !tbaa !9
  br label %74

74:                                               ; preds = %56
  %75 = load i32, ptr %14, align 4, !tbaa !5
  %76 = add i32 %75, 1
  store i32 %76, ptr %14, align 4, !tbaa !5
  br label %52, !llvm.loop !21

77:                                               ; preds = %52
  %78 = load ptr, ptr %13, align 8, !tbaa !11
  %79 = getelementptr inbounds %struct.track2steer_obj, ptr %78, i32 0, i32 4
  %80 = load i32, ptr %79, align 8, !tbaa !18
  %81 = uitofp i32 %80 to float
  %82 = load ptr, ptr %13, align 8, !tbaa !11
  %83 = getelementptr inbounds %struct.track2steer_obj, ptr %82, i32 0, i32 3
  %84 = load float, ptr %83, align 4, !tbaa !17
  %85 = fdiv float %81, %84
  %86 = load ptr, ptr %13, align 8, !tbaa !11
  %87 = getelementptr inbounds %struct.track2steer_obj, ptr %86, i32 0, i32 7
  store float %85, ptr %87, align 8, !tbaa !23
  %88 = load ptr, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  ret ptr %88
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #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) #3

; 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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind }
attributes #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"track2steer_obj", !6, i64 0, !6, i64 4, !6, i64 8, !10, i64 12, !6, i64 16, !12, i64 24, !12, i64 32, !10, i64 40}
!15 = !{!14, !6, i64 4}
!16 = !{!14, !6, i64 8}
!17 = !{!14, !10, i64 12}
!18 = !{!14, !6, i64 16}
!19 = !{!14, !12, i64 24}
!20 = !{!14, !12, i64 32}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!14, !10, i64 40}


; 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: nofree nounwind uwtable
define dso_local noalias noundef ptr @track2steer_construct_zero(i32 noundef %0, i32 noundef %1, i32 noundef %2, float noundef %3, i32 noundef %4, ptr nocapture noundef readonly %5) local_unnamed_addr #0 {
  %7 = tail call noalias dereferenceable_or_null(48) ptr @malloc(i64 noundef 48) #3
  store i32 %0, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 4
  store i32 %1, ptr %8, align 4, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %7, i64 8
  store i32 %2, ptr %9, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %7, i64 12
  store float %3, ptr %10, align 4, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %7, i64 16
  store i32 %4, ptr %11, align 8, !tbaa !15
  %12 = zext i32 %1 to i64
  %13 = mul nuw nsw i64 %12, 12
  %14 = tail call noalias ptr @malloc(i64 noundef %13) #3
  %15 = getelementptr inbounds i8, ptr %7, i64 24
  store ptr %14, ptr %15, align 8, !tbaa !16
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %5, i64 %13, i1 false)
  %16 = zext i32 %2 to i64
  %17 = shl nuw nsw i64 %16, 2
  %18 = tail call noalias ptr @malloc(i64 noundef %17) #3
  %19 = getelementptr inbounds i8, ptr %7, i64 32
  store ptr %18, ptr %19, align 8, !tbaa !17
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %6
  %20 = shl i32 %2, 1
  %21 = add i32 %20, -2
  %22 = uitofp i32 %21 to float
  %23 = fpext float %22 to double
  %min.iters.check = icmp ult i32 %2, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %16, 4294967292
  %broadcast.splatinsert = insertelement <4 x double> poison, double %23, i64 0
  %broadcast.splat = shufflevector <4 x double> %broadcast.splatinsert, <4 x double> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %24 = uitofp <4 x i32> %vec.ind to <4 x float>
  %25 = fpext <4 x float> %24 to <4 x double>
  %26 = fmul <4 x double> %25, <double 0xC01921FB54442D18, double 0xC01921FB54442D18, double 0xC01921FB54442D18, double 0xC01921FB54442D18>
  %27 = fdiv <4 x double> %26, %broadcast.splat
  %28 = fptrunc <4 x double> %27 to <4 x float>
  %29 = getelementptr inbounds float, ptr %18, i64 %index
  store <4 x float> %28, ptr %29, align 4, !tbaa !18
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %30 = icmp eq i64 %index.next, %n.vec
  br i1 %30, label %middle.block, label %vector.body, !llvm.loop !19

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %16
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %31 = trunc nuw i64 %indvars.iv to i32
  %32 = uitofp i32 %31 to float
  %33 = fpext float %32 to double
  %34 = fmul double %33, 0xC01921FB54442D18
  %35 = fdiv double %34, %23
  %36 = fptrunc double %35 to float
  %37 = getelementptr inbounds float, ptr %18, i64 %indvars.iv
  store float %36, ptr %37, align 4, !tbaa !18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %16
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !23

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %6
  %38 = uitofp i32 %4 to float
  %39 = fdiv float %38, %3
  %40 = getelementptr inbounds i8, ptr %7, i64 40
  store float %39, ptr %40, align 8, !tbaa !24
  ret ptr %7
}

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

attributes #0 = { nofree 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 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 nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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, !7, i64 0}
!6 = !{!"track2steer_obj", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !7, i64 16, !11, i64 24, !11, i64 32, !10, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !10, i64 12}
!15 = !{!6, !7, i64 16}
!16 = !{!6, !11, i64 24}
!17 = !{!6, !11, i64 32}
!18 = !{!10, !10, i64 0}
!19 = distinct !{!19, !20, !21, !22}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!"llvm.loop.isvectorized", i32 1}
!22 = !{!"llvm.loop.unroll.runtime.disable"}
!23 = distinct !{!23, !20, !22, !21}
!24 = !{!6, !10, i64 40}


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