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

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

; 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 @MatNd_create(i32 noundef, i32 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_destroy(ptr noundef) #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_reverseSelf(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store ptr null, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct._MatNd, ptr %6, i32 0, i32 2
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = mul i32 1, %8
  %10 = icmp ugt i32 %9, 1296
  br i1 %10, label %11, label %16

11:                                               ; preds = %1
  %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 !9
  %15 = call ptr @MatNd_create(i32 noundef 1, i32 noundef %14)
  store ptr %15, ptr %3, align 8, !tbaa !5
  br label %57

16:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._MatNd, ptr %17, i32 0, i32 2
  %19 = load i32, ptr %18, align 4, !tbaa !9
  %20 = mul i32 1, %19
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %16
  br label %28

23:                                               ; preds = %16
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._MatNd, ptr %24, i32 0, i32 2
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = mul i32 1, %26
  br label %28

28:                                               ; preds = %23, %22
  %29 = phi i32 [ 1, %22 ], [ %27, %23 ]
  store i32 %29, ptr %4, align 4, !tbaa !13
  %30 = load i32, ptr %4, align 4, !tbaa !13
  %31 = zext i32 %30 to i64
  %32 = mul i64 %31, 8
  %33 = add i64 24, %32
  %34 = alloca i8, i64 %33, align 16
  store ptr %34, ptr %3, align 8, !tbaa !5
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._MatNd, ptr %35, i64 1
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._MatNd, ptr %37, i32 0, i32 0
  store ptr %36, ptr %38, align 8, !tbaa !14
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._MatNd, ptr %39, i32 0, i32 1
  store i32 1, ptr %40, align 8, !tbaa !15
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._MatNd, ptr %41, i32 0, i32 2
  %43 = load i32, ptr %42, align 4, !tbaa !9
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._MatNd, ptr %44, i32 0, i32 2
  store i32 %43, ptr %45, align 4, !tbaa !9
  %46 = load i32, ptr %4, align 4, !tbaa !13
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct._MatNd, ptr %47, i32 0, i32 3
  store i32 %46, ptr %48, align 8, !tbaa !16
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._MatNd, ptr %49, i32 0, i32 4
  store i8 1, ptr %50, align 4, !tbaa !17
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._MatNd, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !14
  %54 = load i32, ptr %4, align 4, !tbaa !13
  %55 = zext i32 %54 to i64
  %56 = mul i64 %55, 8
  call void @llvm.memset.p0.i64(ptr align 8 %53, i8 0, i64 %56, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %57

57:                                               ; preds = %28, %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !13
  br label %58

58:                                               ; preds = %96, %57
  %59 = load i32, ptr %5, align 4, !tbaa !13
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._MatNd, ptr %60, i32 0, i32 1
  %62 = load i32, ptr %61, align 8, !tbaa !15
  %63 = udiv i32 %62, 2
  %64 = icmp ult i32 %59, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %99

66:                                               ; preds = %58
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = load i32, ptr %5, align 4, !tbaa !13
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  call void @MatNd_getRow(ptr noundef %67, i32 noundef %68, ptr noundef %69)
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = load i32, ptr %5, align 4, !tbaa !13
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._MatNd, ptr %73, i32 0, i32 1
  %75 = load i32, ptr %74, align 8, !tbaa !15
  %76 = load i32, ptr %5, align 4, !tbaa !13
  %77 = sub i32 %75, %76
  %78 = sub i32 %77, 1
  %79 = call ptr @MatNd_getRowPtr(ptr noundef %72, i32 noundef %78)
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct._MatNd, ptr %80, i32 0, i32 2
  %82 = load i32, ptr %81, align 4, !tbaa !9
  call void @MatNd_setRow(ptr noundef %70, i32 noundef %71, ptr noundef %79, i32 noundef %82)
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._MatNd, ptr %84, i32 0, i32 1
  %86 = load i32, ptr %85, align 8, !tbaa !15
  %87 = load i32, ptr %5, align 4, !tbaa !13
  %88 = sub i32 %86, %87
  %89 = sub i32 %88, 1
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct._MatNd, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !14
  %93 = load ptr, ptr %2, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct._MatNd, ptr %93, i32 0, i32 2
  %95 = load i32, ptr %94, align 4, !tbaa !9
  call void @MatNd_setRow(ptr noundef %83, i32 noundef %89, ptr noundef %92, i32 noundef %95)
  br label %96

96:                                               ; preds = %66
  %97 = load i32, ptr %5, align 4, !tbaa !13
  %98 = add i32 %97, 1
  store i32 %98, ptr %5, align 4, !tbaa !13
  br label %58, !llvm.loop !18

99:                                               ; preds = %65
  %100 = load ptr, ptr %3, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %100)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

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


; 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
declare dso_local ptr @MatNd_create(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_destroy(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_setRow(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_getRow(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_reverseSelf(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 12
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = icmp ugt i32 %3, 1296
  br i1 %4, label %5, label %7

5:                                                ; preds = %1
  %6 = tail call ptr @MatNd_create(i32 noundef 1, i32 noundef %3)
  br label %17

7:                                                ; preds = %1
  %spec.select = tail call i32 @llvm.umax.i32(i32 %3, i32 1)
  %8 = shl nuw nsw i32 %spec.select, 3
  %9 = zext nneg i32 %8 to i64
  %10 = add nuw nsw i64 %9, 24
  %11 = alloca i8, i64 %10, align 16
  %12 = getelementptr inbounds i8, ptr %11, i64 24
  store ptr %12, ptr %11, align 16, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %11, i64 8
  store i32 1, ptr %13, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %11, i64 12
  store i32 %3, ptr %14, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %11, i64 16
  store i32 %spec.select, ptr %15, align 16, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %11, i64 20
  store i8 1, ptr %16, align 4, !tbaa !15
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %12, i8 0, i64 %9, i1 false)
  br label %17

17:                                               ; preds = %7, %5
  %.032 = phi ptr [ %6, %5 ], [ %11, %7 ]
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load i32, ptr %18, align 8, !tbaa !13
  %.not = icmp ult i32 %19, 2
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %17
  call void @MatNd_destroy(ptr noundef %.032)
  ret void

.lr.ph:                                           ; preds = %17, %.lr.ph
  %.034 = phi i32 [ %29, %.lr.ph ], [ 0, %17 ]
  call void @MatNd_getRow(ptr noundef %.032, i32 noundef %.034, ptr noundef nonnull %0)
  %20 = load i32, ptr %18, align 8, !tbaa !13
  %21 = xor i32 %.034, -1
  %22 = add i32 %20, %21
  %23 = call ptr @MatNd_getRowPtr(ptr noundef nonnull %0, i32 noundef %22)
  %24 = load i32, ptr %2, align 4, !tbaa !5
  call void @MatNd_setRow(ptr noundef nonnull %0, i32 noundef %.034, ptr noundef %23, i32 noundef %24)
  %25 = load i32, ptr %18, align 8, !tbaa !13
  %26 = add i32 %25, %21
  %27 = load ptr, ptr %.032, align 8, !tbaa !12
  %28 = load i32, ptr %2, align 4, !tbaa !5
  call void @MatNd_setRow(ptr noundef nonnull %0, i32 noundef %26, ptr noundef %27, i32 noundef %28)
  %29 = add nuw nsw i32 %.034, 1
  %30 = load i32, ptr %18, align 8, !tbaa !13
  %31 = lshr i32 %30, 1
  %32 = icmp ult i32 %29, %31
  br i1 %32, label %.lr.ph, label %._crit_edge, !llvm.loop !16
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 12}
!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, !7, i64 0}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !11, i64 20}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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