; 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
@__func__.MatNd_columnDerivative = external hidden unnamed_addr constant [23 x i8], align 1
@.str.223 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.224 = external hidden unnamed_addr constant [68 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: nounwind uwtable
declare dso_local void @MatNd_reshape(ptr noundef, i32 noundef, i32 noundef) #4

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

; 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) #5

; Function Attrs: nounwind uwtable
declare dso_local double @MatNd_get(ptr noundef, i32 noundef, i32 noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_set(ptr noundef, i32 noundef, i32 noundef, double noundef) #4

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

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

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

16:                                               ; preds = %11
  %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_columnDerivative, i32 noundef 3679, ptr noundef @.str.223) #6
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = load ptr, ptr %4, 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 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str.224, i32 noundef %22) #6
  %24 = load ptr, ptr @stderr, align 8, !tbaa !5
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str.4) #6
  call void @print_trace()
  call void @exit(i32 noundef 1) #7
  unreachable

26:                                               ; preds = %11
  br label %27

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._MatNd, ptr %30, i32 0, i32 1
  %32 = load i32, ptr %31, align 8, !tbaa !9
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._MatNd, ptr %33, i32 0, i32 2
  %35 = load i32, ptr %34, align 4, !tbaa !13
  call void @MatNd_reshape(ptr noundef %29, i32 noundef %32, i32 noundef %35)
  store i32 0, ptr %5, align 4, !tbaa !14
  br label %36

36:                                               ; preds = %70, %28
  %37 = load i32, ptr %5, align 4, !tbaa !14
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._MatNd, ptr %38, i32 0, i32 1
  %40 = load i32, ptr %39, align 8, !tbaa !9
  %41 = sub i32 %40, 1
  %42 = icmp ult i32 %37, %41
  br i1 %42, label %43, label %73

43:                                               ; preds = %36
  store i32 0, ptr %6, align 4, !tbaa !14
  br label %44

44:                                               ; preds = %66, %43
  %45 = load i32, ptr %6, align 4, !tbaa !14
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._MatNd, ptr %46, i32 0, i32 2
  %48 = load i32, ptr %47, align 4, !tbaa !13
  %49 = icmp ult i32 %45, %48
  br i1 %49, label %50, label %69

50:                                               ; preds = %44
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load i32, ptr %5, align 4, !tbaa !14
  %53 = load i32, ptr %6, align 4, !tbaa !14
  %54 = call double @MatNd_get(ptr noundef %51, i32 noundef %52, i32 noundef %53)
  store double %54, ptr %7, align 8, !tbaa !15
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = load i32, ptr %5, align 4, !tbaa !14
  %57 = add i32 %56, 1
  %58 = load i32, ptr %6, align 4, !tbaa !14
  %59 = call double @MatNd_get(ptr noundef %55, i32 noundef %57, i32 noundef %58)
  store double %59, ptr %8, align 8, !tbaa !15
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = load i32, ptr %5, align 4, !tbaa !14
  %62 = load i32, ptr %6, align 4, !tbaa !14
  %63 = load double, ptr %8, align 8, !tbaa !15
  %64 = load double, ptr %7, align 8, !tbaa !15
  %65 = fsub double %63, %64
  call void @MatNd_set(ptr noundef %60, i32 noundef %61, i32 noundef %62, double noundef %65)
  br label %66

66:                                               ; preds = %50
  %67 = load i32, ptr %6, align 4, !tbaa !14
  %68 = add i32 %67, 1
  store i32 %68, ptr %6, align 4, !tbaa !14
  br label %44, !llvm.loop !17

69:                                               ; preds = %44
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %5, align 4, !tbaa !14
  %72 = add i32 %71, 1
  store i32 %72, ptr %5, align 4, !tbaa !14
  br label %36, !llvm.loop !19

73:                                               ; preds = %36
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct._MatNd, ptr %75, i32 0, i32 1
  %77 = load i32, ptr %76, align 8, !tbaa !9
  %78 = sub i32 %77, 1
  %79 = call ptr @MatNd_getRowPtr(ptr noundef %74, i32 noundef %78)
  store ptr %79, ptr %9, align 8, !tbaa !5
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct._MatNd, ptr %81, i32 0, i32 1
  %83 = load i32, ptr %82, align 8, !tbaa !9
  %84 = sub i32 %83, 2
  %85 = call ptr @MatNd_getRowPtr(ptr noundef %80, i32 noundef %84)
  store ptr %85, ptr %10, align 8, !tbaa !5
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  %87 = load ptr, ptr %10, align 8, !tbaa !5
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct._MatNd, ptr %88, i32 0, i32 2
  %90 = load i32, ptr %89, align 4, !tbaa !13
  %91 = zext i32 %90 to i64
  %92 = mul i64 %91, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %86, ptr align 8 %87, i64 %92, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
attributes #7 = { 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 = !{!16, !16, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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
@__func__.MatNd_columnDerivative = external hidden unnamed_addr constant [23 x i8], align 1
@.str.223 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.224 = external hidden unnamed_addr constant [68 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
declare dso_local void @MatNd_reshape(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

; 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) #4

; Function Attrs: nounwind uwtable
declare dso_local double @MatNd_get(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_set(ptr noundef, i32 noundef, i32 noundef, double noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_columnDerivative(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %5, label %13

5:                                                ; preds = %2
  %6 = load ptr, ptr @stderr, align 8, !tbaa !12
  %7 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.MatNd_columnDerivative, i32 noundef 3679, ptr noundef nonnull @.str.223) #5
  %8 = load ptr, ptr @stderr, align 8, !tbaa !12
  %9 = load i32, ptr %3, align 8, !tbaa !5
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %8, ptr noundef nonnull @.str.224, i32 noundef %9) #5
  %11 = load ptr, ptr @stderr, align 8, !tbaa !12
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.4) #5
  tail call void @print_trace() #6
  tail call void @exit(i32 noundef 1) #7
  unreachable

13:                                               ; preds = %2
  %14 = getelementptr inbounds i8, ptr %1, i64 12
  %15 = load i32, ptr %14, align 4, !tbaa !13
  tail call void @MatNd_reshape(ptr noundef %0, i32 noundef %4, i32 noundef %15)
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = load i32, ptr %16, align 8, !tbaa !5
  %18 = add i32 %17, -1
  %.not35 = icmp eq i32 %18, 0
  br i1 %.not35, label %._crit_edge34, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %13
  %19 = getelementptr inbounds i8, ptr %0, i64 12
  %20 = load i32, ptr %19, align 4, !tbaa !13
  %.not36 = icmp eq i32 %20, 0
  br i1 %.not36, label %._crit_edge34, label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %21 = phi i32 [ %29, %._crit_edge ], [ %17, %.preheader.lr.ph ]
  %22 = phi i32 [ %30, %._crit_edge ], [ 1, %.preheader.lr.ph ]
  %.033 = phi i32 [ %.pre40, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.not37 = icmp eq i32 %22, 0
  %.pre40 = add nuw i32 %.033, 1
  br i1 %.not37, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.02832 = phi i32 [ %26, %.lr.ph ], [ 0, %.preheader ]
  %23 = tail call double @MatNd_get(ptr noundef %1, i32 noundef %.033, i32 noundef %.02832)
  %24 = tail call double @MatNd_get(ptr noundef %1, i32 noundef %.pre40, i32 noundef %.02832)
  %25 = fsub double %24, %23
  tail call void @MatNd_set(ptr noundef nonnull %0, i32 noundef %.033, i32 noundef %.02832, double noundef %25)
  %26 = add nuw i32 %.02832, 1
  %27 = load i32, ptr %19, align 4, !tbaa !13
  %28 = icmp ult i32 %26, %27
  br i1 %28, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !14

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i32, ptr %16, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %.preheader, %._crit_edge.loopexit
  %29 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %21, %.preheader ]
  %30 = phi i32 [ %27, %._crit_edge.loopexit ], [ 0, %.preheader ]
  %31 = add i32 %29, -1
  %32 = icmp ult i32 %.pre40, %31
  br i1 %32, label %.preheader, label %._crit_edge34, !llvm.loop !16

._crit_edge34:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %13
  %.lcssa = phi i32 [ 0, %13 ], [ %18, %.preheader.lr.ph ], [ %31, %._crit_edge ]
  %33 = tail call ptr @MatNd_getRowPtr(ptr noundef nonnull %0, i32 noundef %.lcssa)
  %34 = load i32, ptr %16, align 8, !tbaa !5
  %35 = add i32 %34, -2
  %36 = tail call ptr @MatNd_getRowPtr(ptr noundef nonnull %0, i32 noundef %35)
  %37 = getelementptr inbounds i8, ptr %0, i64 12
  %38 = load i32, ptr %37, align 4, !tbaa !13
  %39 = zext i32 %38 to i64
  %40 = shl nuw nsw i64 %39, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %33, ptr align 8 %36, i64 %40, i1 false)
  ret void
}

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { cold nounwind }
attributes #6 = { nounwind }
attributes #7 = { 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 = !{!7, !7, i64 0}
!13 = !{!6, !10, i64 12}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15, !17}
!17 = !{!"llvm.loop.unswitch.partial.disable"}


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