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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @combining_generate(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %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
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 1, ptr %6, align 4, !tbaa !5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %20, %2
  %12 = load i32, ptr %8, align 4, !tbaa !5
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = icmp ult i32 %12, %13
  br i1 %14, label %15, label %23

15:                                               ; preds = %11
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = add i32 2, %16
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = mul i32 %18, %17
  store i32 %19, ptr %6, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %15
  %21 = load i32, ptr %8, align 4, !tbaa !5
  %22 = add i32 %21, 1
  store i32 %22, ptr %8, align 4, !tbaa !5
  br label %11, !llvm.loop !9

23:                                               ; preds = %11
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = call ptr @assignations_construct_zero(i32 noundef %24, i32 noundef %25)
  store ptr %26, ptr %5, align 8, !tbaa !11
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %38, %23
  %28 = load i32, ptr %8, align 4, !tbaa !5
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = icmp ult i32 %28, %29
  br i1 %30, label %31, label %41

31:                                               ; preds = %27
  %32 = load ptr, ptr %5, align 8, !tbaa !11
  %33 = getelementptr inbounds %struct.assignations_obj, ptr %32, i32 0, i32 2
  %34 = load ptr, ptr %33, align 8, !tbaa !13
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = zext i32 %35 to i64
  %37 = getelementptr inbounds i32, ptr %34, i64 %36
  store i32 -2, ptr %37, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %31
  %39 = load i32, ptr %8, align 4, !tbaa !5
  %40 = add i32 %39, 1
  store i32 %40, ptr %8, align 4, !tbaa !5
  br label %27, !llvm.loop !15

41:                                               ; preds = %27
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %104, %41
  %43 = load i32, ptr %7, align 4, !tbaa !5
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = icmp ult i32 %43, %44
  br i1 %45, label %46, label %107

46:                                               ; preds = %42
  store i32 1, ptr %9, align 4, !tbaa !5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %100, %46
  %48 = load i32, ptr %8, align 4, !tbaa !5
  %49 = load ptr, ptr %5, align 8, !tbaa !11
  %50 = getelementptr inbounds %struct.assignations_obj, ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 4, !tbaa !16
  %52 = icmp ult i32 %48, %51
  br i1 %52, label %53, label %103

53:                                               ; preds = %47
  %54 = load ptr, ptr %5, align 8, !tbaa !11
  %55 = getelementptr inbounds %struct.assignations_obj, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !13
  %57 = load i32, ptr %7, align 4, !tbaa !5
  %58 = sub i32 %57, 1
  %59 = load ptr, ptr %5, align 8, !tbaa !11
  %60 = getelementptr inbounds %struct.assignations_obj, ptr %59, i32 0, i32 1
  %61 = load i32, ptr %60, align 4, !tbaa !16
  %62 = mul i32 %58, %61
  %63 = load ptr, ptr %5, align 8, !tbaa !11
  %64 = getelementptr inbounds %struct.assignations_obj, ptr %63, i32 0, i32 1
  %65 = load i32, ptr %64, align 4, !tbaa !16
  %66 = add i32 %62, %65
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = sub i32 %66, %67
  %69 = sub i32 %68, 1
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds i32, ptr %56, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  store i32 %72, ptr %10, align 4, !tbaa !5
  %73 = load i32, ptr %9, align 4, !tbaa !5
  %74 = load i32, ptr %10, align 4, !tbaa !5
  %75 = add nsw i32 %74, %73
  store i32 %75, ptr %10, align 4, !tbaa !5
  %76 = load i32, ptr %10, align 4, !tbaa !5
  %77 = load i32, ptr %4, align 4, !tbaa !5
  %78 = icmp eq i32 %76, %77
  br i1 %78, label %79, label %80

79:                                               ; preds = %53
  store i32 -2, ptr %10, align 4, !tbaa !5
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %81

80:                                               ; preds = %53
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %81

81:                                               ; preds = %80, %79
  %82 = load i32, ptr %10, align 4, !tbaa !5
  %83 = load ptr, ptr %5, align 8, !tbaa !11
  %84 = getelementptr inbounds %struct.assignations_obj, ptr %83, i32 0, i32 2
  %85 = load ptr, ptr %84, align 8, !tbaa !13
  %86 = load i32, ptr %7, align 4, !tbaa !5
  %87 = load ptr, ptr %5, align 8, !tbaa !11
  %88 = getelementptr inbounds %struct.assignations_obj, ptr %87, i32 0, i32 1
  %89 = load i32, ptr %88, align 4, !tbaa !16
  %90 = mul i32 %86, %89
  %91 = load ptr, ptr %5, align 8, !tbaa !11
  %92 = getelementptr inbounds %struct.assignations_obj, ptr %91, i32 0, i32 1
  %93 = load i32, ptr %92, align 4, !tbaa !16
  %94 = add i32 %90, %93
  %95 = load i32, ptr %8, align 4, !tbaa !5
  %96 = sub i32 %94, %95
  %97 = sub i32 %96, 1
  %98 = zext i32 %97 to i64
  %99 = getelementptr inbounds i32, ptr %85, i64 %98
  store i32 %82, ptr %99, align 4, !tbaa !5
  br label %100

100:                                              ; preds = %81
  %101 = load i32, ptr %8, align 4, !tbaa !5
  %102 = add i32 %101, 1
  store i32 %102, ptr %8, align 4, !tbaa !5
  br label %47, !llvm.loop !17

103:                                              ; preds = %47
  br label %104

104:                                              ; preds = %103
  %105 = load i32, ptr %7, align 4, !tbaa !5
  %106 = add i32 %105, 1
  store i32 %106, ptr %7, align 4, !tbaa !5
  br label %42, !llvm.loop !18

107:                                              ; preds = %42
  %108 = load ptr, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret ptr %108
}

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

declare ptr @assignations_construct_zero(i32 noundef, i32 noundef) #2

; 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 = { "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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"assignations_obj", !6, i64 0, !6, i64 4, !12, i64 8}
!15 = distinct !{!15, !10}
!16 = !{!14, !6, i64 4}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}


; 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: nounwind uwtable
define dso_local ptr @combining_generate(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %.not = icmp eq i32 %0, 0
  br i1 %.not, label %.preheader42.thread, label %.lr.ph

.preheader42.thread:                              ; preds = %2
  %3 = tail call ptr @assignations_construct_zero(i32 noundef 1, i32 noundef %0) #3
  br label %._crit_edge53

.lr.ph:                                           ; preds = %2
  %4 = add i32 %1, 2
  %min.iters.check = icmp ult i32 %0, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

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

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %vector.ph ], [ %5, %vector.body ]
  %vec.phi66 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %vector.ph ], [ %6, %vector.body ]
  %5 = mul <4 x i32> %vec.phi, %broadcast.splat
  %6 = mul <4 x i32> %vec.phi66, %broadcast.splat
  %index.next = add nuw i32 %index, 8
  %7 = icmp eq i32 %index.next, %n.vec
  br i1 %7, label %middle.block, label %vector.body, !llvm.loop !5

middle.block:                                     ; preds = %vector.body
  %bin.rdx = mul <4 x i32> %6, %5
  %8 = tail call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i32 %n.vec, %0
  br i1 %cmp.n, label %.lr.ph47, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %.03444.ph = phi i32 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  %.03743.ph = phi i32 [ 1, %.lr.ph ], [ %8, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.03444 = phi i32 [ %10, %scalar.ph ], [ %.03444.ph, %scalar.ph.preheader ]
  %.03743 = phi i32 [ %9, %scalar.ph ], [ %.03743.ph, %scalar.ph.preheader ]
  %9 = mul i32 %.03743, %4
  %10 = add nuw i32 %.03444, 1
  %exitcond.not = icmp eq i32 %10, %0
  br i1 %exitcond.not, label %.lr.ph47, label %scalar.ph, !llvm.loop !9

.lr.ph47:                                         ; preds = %scalar.ph, %middle.block
  %.lcssa65 = phi i32 [ %8, %middle.block ], [ %9, %scalar.ph ]
  %11 = tail call ptr @assignations_construct_zero(i32 noundef %.lcssa65, i32 noundef %0) #3
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !10
  %wide.trip.count = zext i32 %0 to i64
  %min.iters.check69 = icmp ult i32 %0, 8
  br i1 %min.iters.check69, label %scalar.ph68.preheader, label %vector.ph70

scalar.ph68.preheader:                            ; preds = %middle.block67, %.lr.ph47
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph47 ], [ %n.vec72, %middle.block67 ]
  br label %scalar.ph68

vector.ph70:                                      ; preds = %.lr.ph47
  %n.vec72 = and i64 %wide.trip.count, 4294967288
  br label %vector.body74

vector.body74:                                    ; preds = %vector.body74, %vector.ph70
  %index75 = phi i64 [ 0, %vector.ph70 ], [ %index.next76, %vector.body74 ]
  %14 = getelementptr inbounds i32, ptr %13, i64 %index75
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  store <4 x i32> <i32 -2, i32 -2, i32 -2, i32 -2>, ptr %14, align 4, !tbaa !16
  store <4 x i32> <i32 -2, i32 -2, i32 -2, i32 -2>, ptr %15, align 4, !tbaa !16
  %index.next76 = add nuw i64 %index75, 8
  %16 = icmp eq i64 %index.next76, %n.vec72
  br i1 %16, label %middle.block67, label %vector.body74, !llvm.loop !17

middle.block67:                                   ; preds = %vector.body74
  %cmp.n77 = icmp eq i64 %n.vec72, %wide.trip.count
  br i1 %cmp.n77, label %.preheader42, label %scalar.ph68.preheader

.preheader42:                                     ; preds = %scalar.ph68, %middle.block67
  %17 = icmp ugt i32 %.lcssa65, 1
  br i1 %17, label %.preheader.lr.ph, label %._crit_edge53

.preheader.lr.ph:                                 ; preds = %.preheader42
  %18 = getelementptr inbounds i8, ptr %11, i64 4
  %19 = getelementptr inbounds i8, ptr %11, i64 8
  %20 = load i32, ptr %18, align 4, !tbaa !18
  %.not55 = icmp eq i32 %20, 0
  br i1 %.not55, label %._crit_edge53, label %.preheader

scalar.ph68:                                      ; preds = %scalar.ph68.preheader, %scalar.ph68
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph68 ], [ %indvars.iv.ph, %scalar.ph68.preheader ]
  %21 = getelementptr inbounds i32, ptr %13, i64 %indvars.iv
  store i32 -2, ptr %21, align 4, !tbaa !16
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond59.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond59.not, label %.preheader42, label %scalar.ph68, !llvm.loop !19

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge51
  %22 = phi i32 [ %42, %._crit_edge51 ], [ %20, %.preheader.lr.ph ]
  %.03652 = phi i32 [ %.pre-phi, %._crit_edge51 ], [ 1, %.preheader.lr.ph ]
  %.not56 = icmp eq i32 %22, 0
  br i1 %.not56, label %.preheader.._crit_edge51_crit_edge, label %.lr.ph50

.preheader.._crit_edge51_crit_edge:               ; preds = %.preheader
  %.pre = add nuw i32 %.03652, 1
  br label %._crit_edge51

.lr.ph50:                                         ; preds = %.preheader
  %23 = load ptr, ptr %19, align 8, !tbaa !10
  %24 = add nuw i32 %.03652, 1
  br label %25

25:                                               ; preds = %.lr.ph50, %25
  %26 = phi i32 [ %22, %.lr.ph50 ], [ %40, %25 ]
  %.03349 = phi i32 [ 1, %.lr.ph50 ], [ %., %25 ]
  %.248 = phi i32 [ 0, %.lr.ph50 ], [ %39, %25 ]
  %27 = mul i32 %26, %.03652
  %28 = xor i32 %.248, -1
  %29 = add i32 %27, %28
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds i32, ptr %23, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !16
  %33 = add nsw i32 %32, %.03349
  %34 = icmp eq i32 %33, %1
  %. = zext i1 %34 to i32
  %.41 = select i1 %34, i32 -2, i32 %33
  %35 = mul i32 %26, %24
  %36 = add i32 %35, %28
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds i32, ptr %23, i64 %37
  store i32 %.41, ptr %38, align 4, !tbaa !16
  %39 = add nuw i32 %.248, 1
  %40 = load i32, ptr %18, align 4, !tbaa !18
  %41 = icmp ult i32 %39, %40
  br i1 %41, label %25, label %._crit_edge51, !llvm.loop !20

._crit_edge51:                                    ; preds = %25, %.preheader.._crit_edge51_crit_edge
  %.pre-phi = phi i32 [ %.pre, %.preheader.._crit_edge51_crit_edge ], [ %24, %25 ]
  %42 = phi i32 [ 0, %.preheader.._crit_edge51_crit_edge ], [ %40, %25 ]
  %exitcond60.not = icmp eq i32 %.pre-phi, %.lcssa65
  br i1 %exitcond60.not, label %._crit_edge53, label %.preheader, !llvm.loop !21

._crit_edge53:                                    ; preds = %._crit_edge51, %.preheader.lr.ph, %.preheader42.thread, %.preheader42
  %43 = phi ptr [ %3, %.preheader42.thread ], [ %11, %.preheader42 ], [ %11, %.preheader.lr.ph ], [ %11, %._crit_edge51 ]
  ret ptr %43
}

declare ptr @assignations_construct_zero(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.mul.v4i32(<4 x i32>) #2

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 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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, !7, !8}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.isvectorized", i32 1}
!8 = !{!"llvm.loop.unroll.runtime.disable"}
!9 = distinct !{!9, !6, !8, !7}
!10 = !{!11, !15, i64 8}
!11 = !{!"assignations_obj", !12, i64 0, !12, i64 4, !15, i64 8}
!12 = !{!"int", !13, i64 0}
!13 = !{!"omnipotent char", !14, i64 0}
!14 = !{!"Simple C/C++ TBAA"}
!15 = !{!"any pointer", !13, i64 0}
!16 = !{!12, !12, i64 0}
!17 = distinct !{!17, !6, !7, !8}
!18 = !{!11, !12, i64 4}
!19 = distinct !{!19, !6, !8, !7}
!20 = distinct !{!20, !6}
!21 = distinct !{!21, !6, !22}
!22 = !{!"llvm.loop.unswitch.partial.disable"}


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