; LLVM IR from introlab/odas :: src/init (space)

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

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

declare ptr @points_construct_zero(i32 noundef) #1

declare void @points_destroy(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @space_triangles_level_next(ptr noundef) #2

declare void @triangles_destroy(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @space_triangles_points(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @space_points_triangles(ptr noundef) #2

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

16:                                               ; preds = %25, %2
  %17 = load i32, ptr %11, align 4, !tbaa !9
  %18 = load i32, ptr %4, align 4, !tbaa !9
  %19 = icmp ule i32 %17, %18
  br i1 %19, label %20, label %28

20:                                               ; preds = %16
  %21 = load i32, ptr %9, align 4, !tbaa !9
  %22 = mul i32 %21, 2
  store i32 %22, ptr %9, align 4, !tbaa !9
  %23 = load i32, ptr %10, align 4, !tbaa !9
  %24 = mul i32 %23, 4
  store i32 %24, ptr %10, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %20
  %26 = load i32, ptr %11, align 4, !tbaa !9
  %27 = add i32 %26, 1
  store i32 %27, ptr %11, align 4, !tbaa !9
  br label %16, !llvm.loop !11

28:                                               ; preds = %16
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = load i32, ptr %10, align 4, !tbaa !9
  %31 = add i32 %29, %30
  %32 = mul i32 4, %31
  %33 = add i32 %32, 1
  store i32 %33, ptr %8, align 4, !tbaa !9
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.points_obj, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !13
  store i32 %36, ptr %6, align 4, !tbaa !9
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = mul i32 %37, %38
  store i32 %39, ptr %7, align 4, !tbaa !9
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = call ptr @points_construct_zero(i32 noundef %40)
  store ptr %41, ptr %5, align 8, !tbaa !5
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %83, %28
  %43 = load i32, ptr %12, align 4, !tbaa !9
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = icmp ult i32 %43, %44
  br i1 %45, label %46, label %86

46:                                               ; preds = %42
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = load i32, ptr %12, align 4, !tbaa !9
  %49 = call ptr @space_triangles_points(ptr noundef %47, i32 noundef %48)
  store ptr %49, ptr %13, align 8, !tbaa !5
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %59, %46
  %51 = load i32, ptr %11, align 4, !tbaa !9
  %52 = load i32, ptr %4, align 4, !tbaa !9
  %53 = icmp ult i32 %51, %52
  br i1 %53, label %54, label %62

54:                                               ; preds = %50
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = call ptr @space_triangles_level_next(ptr noundef %55)
  store ptr %56, ptr %14, align 8, !tbaa !5
  %57 = load ptr, ptr %13, align 8, !tbaa !5
  call void @triangles_destroy(ptr noundef %57)
  %58 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %58, ptr %13, align 8, !tbaa !5
  br label %59

59:                                               ; preds = %54
  %60 = load i32, ptr %11, align 4, !tbaa !9
  %61 = add i32 %60, 1
  store i32 %61, ptr %11, align 4, !tbaa !9
  br label %50, !llvm.loop !15

62:                                               ; preds = %50
  %63 = load ptr, ptr %13, align 8, !tbaa !5
  %64 = call ptr @space_points_triangles(ptr noundef %63)
  store ptr %64, ptr %15, align 8, !tbaa !5
  %65 = load ptr, ptr %13, align 8, !tbaa !5
  call void @triangles_destroy(ptr noundef %65)
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.points_obj, ptr %66, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8, !tbaa !16
  %69 = load i32, ptr %12, align 4, !tbaa !9
  %70 = load i32, ptr %8, align 4, !tbaa !9
  %71 = mul i32 %69, %70
  %72 = mul i32 %71, 3
  %73 = zext i32 %72 to i64
  %74 = getelementptr inbounds float, ptr %68, i64 %73
  %75 = load ptr, ptr %15, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.points_obj, ptr %75, i32 0, i32 1
  %77 = load ptr, ptr %76, align 8, !tbaa !16
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = mul i32 %78, 3
  %80 = zext i32 %79 to i64
  %81 = mul i64 %80, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %74, ptr align 4 %77, i64 %81, i1 false)
  %82 = load ptr, ptr %15, align 8, !tbaa !5
  call void @points_destroy(ptr noundef %82)
  br label %83

83:                                               ; preds = %62
  %84 = load i32, ptr %12, align 4, !tbaa !9
  %85 = add i32 %84, 1
  store i32 %85, ptr %12, align 4, !tbaa !9
  br label %42, !llvm.loop !17

86:                                               ; preds = %42
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret ptr %87
}

; 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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 0}
!14 = !{!"points_obj", !10, i64 0, !6, i64 8}
!15 = distinct !{!15, !12}
!16 = !{!14, !6, i64 8}
!17 = distinct !{!17, !12}


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

declare ptr @points_construct_zero(i32 noundef) local_unnamed_addr #0

declare void @points_destroy(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @space_triangles_level_next(ptr noundef) local_unnamed_addr #1

declare void @triangles_destroy(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @space_triangles_points(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @space_points_triangles(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @space_points_fine(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %.not35 = icmp eq i32 %1, 0
  br i1 %.not35, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %3 = add i32 %1, 1
  %umax = tail call i32 @llvm.umax.i32(i32 %3, i32 2)
  %4 = add i32 %umax, -1
  %5 = add i32 %umax, -2
  %xtraiter = and i32 %4, 7
  %6 = icmp ult i32 %5, 7
  br i1 %6, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i32 %4, -8
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.038 = phi i32 [ 1, %.lr.ph.preheader.new ], [ %7, %.lr.ph ]
  %.03037 = phi i32 [ 1, %.lr.ph.preheader.new ], [ %8, %.lr.ph ]
  %niter = phi i32 [ 0, %.lr.ph.preheader.new ], [ %niter.next.7, %.lr.ph ]
  %7 = shl i32 %.038, 8
  %8 = shl i32 %.03037, 16
  %niter.next.7 = add i32 %niter, 8
  %niter.ncmp.7 = icmp eq i32 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !5

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa71.ph = phi i32 [ poison, %.lr.ph.preheader ], [ %7, %.lr.ph ]
  %.lcssa70.ph = phi i32 [ poison, %.lr.ph.preheader ], [ %8, %.lr.ph ]
  %.038.unr = phi i32 [ 1, %.lr.ph.preheader ], [ %7, %.lr.ph ]
  %.03037.unr = phi i32 [ 1, %.lr.ph.preheader ], [ %8, %.lr.ph ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge.loopexit, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %.038.epil = phi i32 [ %9, %.lr.ph.epil ], [ %.038.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.03037.epil = phi i32 [ %10, %.lr.ph.epil ], [ %.03037.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i32 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %9 = shl i32 %.038.epil, 1
  %10 = shl i32 %.03037.epil, 2
  %epil.iter.next = add i32 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i32 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge.loopexit, label %.lr.ph.epil, !llvm.loop !7

._crit_edge.loopexit:                             ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa
  %.lcssa71 = phi i32 [ %.lcssa71.ph, %._crit_edge.loopexit.unr-lcssa ], [ %9, %.lr.ph.epil ]
  %.lcssa70 = phi i32 [ %.lcssa70.ph, %._crit_edge.loopexit.unr-lcssa ], [ %10, %.lr.ph.epil ]
  %11 = add i32 %.lcssa71, %.lcssa70
  %12 = shl i32 %11, 2
  %13 = or disjoint i32 %12, 1
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %2
  %14 = phi i32 [ 9, %2 ], [ %13, %._crit_edge.loopexit ]
  %15 = load i32, ptr %0, align 8, !tbaa !9
  %16 = mul i32 %15, %14
  %17 = tail call ptr @points_construct_zero(i32 noundef %16) #4
  %.not50 = icmp eq i32 %15, 0
  br i1 %.not50, label %._crit_edge49, label %.lr.ph48

.lr.ph48:                                         ; preds = %._crit_edge
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  %19 = mul i32 %14, 3
  %20 = zext i32 %19 to i64
  %21 = shl nuw nsw i64 %20, 2
  %wide.trip.count61 = zext i32 %15 to i64
  br i1 %.not35, label %.lr.ph48.split, label %.lr.ph43.us

.lr.ph43.us:                                      ; preds = %.lr.ph48, %._crit_edge44.us
  %indvars.iv = phi i64 [ %indvars.iv.next, %._crit_edge44.us ], [ 0, %.lr.ph48 ]
  %22 = trunc nuw i64 %indvars.iv to i32
  %23 = tail call ptr @space_triangles_points(ptr noundef nonnull %0, i32 noundef %22)
  br label %24

24:                                               ; preds = %.lr.ph43.us, %24
  %.03141.us = phi ptr [ %23, %.lr.ph43.us ], [ %25, %24 ]
  %.140.us = phi i32 [ 0, %.lr.ph43.us ], [ %26, %24 ]
  %25 = tail call ptr @space_triangles_level_next(ptr noundef %.03141.us)
  tail call void @triangles_destroy(ptr noundef %.03141.us) #4
  %26 = add nuw i32 %.140.us, 1
  %exitcond55.not = icmp eq i32 %26, %1
  br i1 %exitcond55.not, label %._crit_edge44.us, label %24, !llvm.loop !15

._crit_edge44.us:                                 ; preds = %24
  %27 = tail call ptr @space_points_triangles(ptr noundef %25)
  tail call void @triangles_destroy(ptr noundef %25) #4
  %28 = load ptr, ptr %18, align 8, !tbaa !16
  %29 = mul i32 %19, %22
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds float, ptr %28, i64 %30
  %32 = getelementptr inbounds i8, ptr %27, i64 8
  %33 = load ptr, ptr %32, align 8, !tbaa !16
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(1) %31, ptr noundef nonnull align 4 dereferenceable(1) %33, i64 %21, i1 false)
  tail call void @points_destroy(ptr noundef %27) #4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond57.not = icmp eq i64 %indvars.iv.next, %wide.trip.count61
  br i1 %exitcond57.not, label %._crit_edge49, label %.lr.ph43.us, !llvm.loop !17

.lr.ph48.split:                                   ; preds = %.lr.ph48, %.lr.ph48.split
  %indvars.iv58 = phi i64 [ %indvars.iv.next59, %.lr.ph48.split ], [ 0, %.lr.ph48 ]
  %34 = trunc nuw i64 %indvars.iv58 to i32
  %35 = tail call ptr @space_triangles_points(ptr noundef nonnull %0, i32 noundef %34)
  %36 = tail call ptr @space_points_triangles(ptr noundef %35)
  tail call void @triangles_destroy(ptr noundef %35) #4
  %37 = load ptr, ptr %18, align 8, !tbaa !16
  %38 = mul i32 %19, %34
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds float, ptr %37, i64 %39
  %41 = getelementptr inbounds i8, ptr %36, i64 8
  %42 = load ptr, ptr %41, align 8, !tbaa !16
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(1) %40, ptr noundef nonnull align 4 dereferenceable(1) %42, i64 %21, i1 false)
  tail call void @points_destroy(ptr noundef %36) #4
  %indvars.iv.next59 = add nuw nsw i64 %indvars.iv58, 1
  %exitcond62.not = icmp eq i64 %indvars.iv.next59, %wide.trip.count61
  br i1 %exitcond62.not, label %._crit_edge49, label %.lr.ph48.split, !llvm.loop !17

._crit_edge49:                                    ; preds = %._crit_edge44.us, %.lr.ph48.split, %._crit_edge
  ret ptr %17
}

; 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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #3

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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !8}
!8 = !{!"llvm.loop.unroll.disable"}
!9 = !{!10, !11, i64 0}
!10 = !{!"points_obj", !11, i64 0, !14, i64 8}
!11 = !{!"int", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C/C++ TBAA"}
!14 = !{!"any pointer", !12, i64 0}
!15 = distinct !{!15, !6}
!16 = !{!10, !14, i64 8}
!17 = distinct !{!17, !6}


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