; LLVM IR from HRI-EU/Rcs :: src/RcsCore (Rcs_MatNd)

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

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [39 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.76 = external hidden unnamed_addr constant [31 x i8], align 1
@__func__.MatNd_mirrorUppeHTriangle = external hidden unnamed_addr constant [26 x i8], align 1
@.str.186 = external hidden unnamed_addr constant [13 x i8], align 1

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

declare void @print_trace() #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_mirrorUppeHTriangle(ptr noundef %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %1
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct._MatNd, ptr %9, i32 0, i32 1
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._MatNd, ptr %12, i32 0, i32 2
  %14 = load i32, ptr %13, align 4, !tbaa !13
  %15 = icmp eq i32 %11, %14
  br i1 %15, label %29, label %16

16:                                               ; preds = %8
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.MatNd_mirrorUppeHTriangle, i32 noundef 3073, ptr noundef @.str.186) #5
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._MatNd, ptr %20, i32 0, i32 1
  %22 = load i32, ptr %21, align 8, !tbaa !9
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct._MatNd, ptr %23, i32 0, i32 2
  %25 = load i32, ptr %24, align 4, !tbaa !13
  %26 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str.76, i32 noundef %22, i32 noundef %25) #5
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str.4) #5
  call void @print_trace()
  call void @exit(i32 noundef 1) #6
  unreachable

29:                                               ; preds = %8
  br label %30

30:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._MatNd, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 8, !tbaa !9
  store i32 %33, ptr %3, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !14
  br label %34

34:                                               ; preds = %73, %30
  %35 = load i32, ptr %4, align 4, !tbaa !14
  %36 = load i32, ptr %3, align 4, !tbaa !14
  %37 = icmp ult i32 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  store i32 4, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %76

39:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %40 = load i32, ptr %4, align 4, !tbaa !14
  %41 = load i32, ptr %3, align 4, !tbaa !14
  %42 = mul i32 %40, %41
  store i32 %42, ptr %6, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %43 = load i32, ptr %4, align 4, !tbaa !14
  store i32 %43, ptr %7, align 4, !tbaa !14
  br label %44

44:                                               ; preds = %69, %39
  %45 = load i32, ptr %7, align 4, !tbaa !14
  %46 = load i32, ptr %3, align 4, !tbaa !14
  %47 = icmp ult i32 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  store i32 7, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %72

49:                                               ; preds = %44
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._MatNd, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !15
  %53 = load i32, ptr %6, align 4, !tbaa !14
  %54 = load i32, ptr %7, align 4, !tbaa !14
  %55 = add i32 %53, %54
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds double, ptr %52, i64 %56
  %58 = load double, ptr %57, align 8, !tbaa !16
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._MatNd, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = load i32, ptr %7, align 4, !tbaa !14
  %63 = load i32, ptr %3, align 4, !tbaa !14
  %64 = mul i32 %62, %63
  %65 = load i32, ptr %4, align 4, !tbaa !14
  %66 = add i32 %64, %65
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds double, ptr %61, i64 %67
  store double %58, ptr %68, align 8, !tbaa !16
  br label %69

69:                                               ; preds = %49
  %70 = load i32, ptr %7, align 4, !tbaa !14
  %71 = add i32 %70, 1
  store i32 %71, ptr %7, align 4, !tbaa !14
  br label %44, !llvm.loop !18

72:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %4, align 4, !tbaa !14
  %75 = add i32 %74, 1
  store i32 %75, ptr %4, align 4, !tbaa !14
  br label %34, !llvm.loop !20

76:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret void
}

attributes #0 = { 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 #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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nounwind }
attributes #6 = { 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, !11, i64 8}
!10 = !{!"_MatNd", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !12, i64 20}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!10, !11, i64 12}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !6, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.76 = external hidden unnamed_addr constant [31 x i8], align 1
@__func__.MatNd_mirrorUppeHTriangle = external hidden unnamed_addr constant [26 x i8], align 1
@.str.186 = external hidden unnamed_addr constant [13 x i8], align 1

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

declare void @print_trace() local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_mirrorUppeHTriangle(ptr nocapture noundef readonly %0) local_unnamed_addr #3 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 12
  %5 = load i32, ptr %4, align 4, !tbaa !12
  %6 = icmp eq i32 %3, %5
  br i1 %6, label %.preheader, label %9

.preheader:                                       ; preds = %1
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %7 = load ptr, ptr %0, align 8, !tbaa !13
  %wide.trip.count28 = zext i32 %3 to i64
  %ident.check = icmp ne i32 %3, 1
  %8 = add nsw i64 %wide.trip.count28, -1
  br label %18

9:                                                ; preds = %1
  %10 = load ptr, ptr @stderr, align 8, !tbaa !14
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.MatNd_mirrorUppeHTriangle, i32 noundef 3073, ptr noundef nonnull @.str.186) #4
  %12 = load ptr, ptr @stderr, align 8, !tbaa !14
  %13 = load i32, ptr %2, align 8, !tbaa !5
  %14 = load i32, ptr %4, align 4, !tbaa !12
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.76, i32 noundef %13, i32 noundef %14) #4
  %16 = load ptr, ptr @stderr, align 8, !tbaa !14
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.4) #4
  tail call void @print_trace() #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

._crit_edge:                                      ; preds = %.loopexit, %.preheader
  ret void

18:                                               ; preds = %.lr.ph, %.loopexit
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %.loopexit ]
  %19 = sub nsw i64 %wide.trip.count28, %indvars.iv
  %indvars27 = trunc i64 %indvars.iv to i32
  %20 = mul i32 %3, %indvars27
  %min.iters.check = icmp ult i64 %19, 10
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.scevcheck

scalar.ph.preheader:                              ; preds = %middle.block, %vector.scevcheck, %18
  %indvars.iv24.ph = phi i64 [ %indvars.iv, %vector.scevcheck ], [ %indvars.iv, %18 ], [ %ind.end, %middle.block ]
  %21 = sub i64 %wide.trip.count28, %indvars.iv24.ph
  %xtraiter = and i64 %21, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader
  %22 = trunc nuw i64 %indvars.iv24.ph to i32
  %23 = add i32 %20, %22
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds double, ptr %7, i64 %24
  %26 = load double, ptr %25, align 8, !tbaa !15
  %27 = mul i32 %3, %22
  %28 = add i32 %27, %indvars27
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds double, ptr %7, i64 %29
  store double %26, ptr %30, align 8, !tbaa !15
  %indvars.iv.next25.prol = add nuw nsw i64 %indvars.iv24.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %indvars.iv24.unr = phi i64 [ %indvars.iv24.ph, %scalar.ph.preheader ], [ %indvars.iv.next25.prol, %scalar.ph.prol ]
  %31 = icmp eq i64 %indvars.iv24.ph, %8
  br i1 %31, label %.loopexit, label %scalar.ph

vector.scevcheck:                                 ; preds = %18
  %indvars.iv.tr = trunc i64 %indvars.iv to i32
  %32 = shl i32 %indvars.iv.tr, 1
  %33 = xor i64 %indvars.iv, -1
  %34 = add nsw i64 %33, %wide.trip.count28
  %35 = trunc i64 %34 to i32
  %36 = xor i32 %32, -1
  %37 = icmp ult i32 %36, %35
  %38 = icmp ugt i64 %34, 4294967295
  %39 = or i1 %37, %38
  %40 = or i1 %ident.check, %39
  br i1 %40, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.scevcheck
  %n.vec = and i64 %19, -4
  %ind.end = add i64 %indvars.iv, %n.vec
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = add i64 %indvars.iv, %index
  %41 = trunc i64 %offset.idx to i32
  %42 = add i32 %20, %41
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds double, ptr %7, i64 %43
  %45 = getelementptr inbounds i8, ptr %44, i64 16
  %wide.load = load <2 x double>, ptr %44, align 8, !tbaa !15
  %wide.load30 = load <2 x double>, ptr %45, align 8, !tbaa !15
  %46 = add i64 %offset.idx, %indvars.iv
  %47 = and i64 %46, 4294967295
  %48 = getelementptr inbounds double, ptr %7, i64 %47
  %49 = getelementptr inbounds i8, ptr %48, i64 16
  store <2 x double> %wide.load, ptr %48, align 8, !tbaa !15
  store <2 x double> %wide.load30, ptr %49, align 8, !tbaa !15
  %index.next = add nuw i64 %index, 4
  %50 = icmp eq i64 %index.next, %n.vec
  br i1 %50, label %middle.block, label %vector.body, !llvm.loop !17

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

.loopexit:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond29.not = icmp eq i64 %indvars.iv.next, %wide.trip.count28
  br i1 %exitcond29.not, label %._crit_edge, label %18, !llvm.loop !21

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %indvars.iv24 = phi i64 [ %indvars.iv.next25.1, %scalar.ph ], [ %indvars.iv24.unr, %scalar.ph.prol.loopexit ]
  %51 = trunc nuw i64 %indvars.iv24 to i32
  %52 = add i32 %20, %51
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds double, ptr %7, i64 %53
  %55 = load double, ptr %54, align 8, !tbaa !15
  %56 = mul i32 %3, %51
  %57 = add i32 %56, %indvars27
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds double, ptr %7, i64 %58
  store double %55, ptr %59, align 8, !tbaa !15
  %60 = trunc i64 %indvars.iv24 to i32
  %61 = add i32 %60, 1
  %62 = add i32 %20, %61
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds double, ptr %7, i64 %63
  %65 = load double, ptr %64, align 8, !tbaa !15
  %66 = mul i32 %3, %61
  %67 = add i32 %66, %indvars27
  %68 = zext i32 %67 to i64
  %69 = getelementptr inbounds double, ptr %7, i64 %68
  store double %65, ptr %69, align 8, !tbaa !15
  %indvars.iv.next25.1 = add nuw nsw i64 %indvars.iv24, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next25.1, %wide.trip.count28
  br i1 %exitcond.not.1, label %.loopexit, label %scalar.ph, !llvm.loop !22
}

attributes #0 = { 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 #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 = { 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 = { 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 #4 = { cold nounwind }
attributes #5 = { nounwind }
attributes #6 = { 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, !10, i64 8}
!6 = !{!"_MatNd", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !11, i64 20}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!6, !10, i64 12}
!13 = !{!6, !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !8, i64 0}
!17 = distinct !{!17, !18, !19, !20}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!"llvm.loop.isvectorized", i32 1}
!20 = !{!"llvm.loop.unroll.runtime.disable"}
!21 = distinct !{!21, !18}
!22 = distinct !{!22, !18, !19}


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