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

; 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._RcsGraph = type { ptr, [10 x %struct._RcsBody], i32, i32, ptr, ptr, ptr, ptr, ptr }
%struct._RcsBody = type { double, i8, i32, [3 x double], [3 x double], double, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._RcsJoint = type { ptr, double, double, double, double, double, double, double, i8, i32, i32, i32, i32, ptr, %struct.HTr, double, double, double, double, i32, ptr, ptr, ptr, ptr, ptr }
%struct.HTr = type { [3 x double], [3 x [3 x double]] }

@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [76 x i8], align 1
@__func__.Rcs_setIKState = external hidden unnamed_addr constant [15 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [14 x i8], align 1

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

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

declare void @print_trace() #2

; Function Attrs: noreturn nounwind
declare void @abort() #3

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

12:                                               ; preds = %51, %2
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %54

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._RcsBody, ptr %17, i32 0, i32 18
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  store ptr %19, ptr %8, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %46, %16
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %50

24:                                               ; preds = %20
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._RcsJoint, ptr %25, i32 0, i32 12
  %27 = load i32, ptr %26, align 8, !tbaa !17
  %28 = icmp ne i32 %27, -1
  br i1 %28, label %29, label %45

29:                                               ; preds = %24
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._RcsGraph, ptr %30, i32 0, i32 4
  %32 = load ptr, ptr %31, align 8, !tbaa !20
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._RcsJoint, ptr %33, i32 0, i32 11
  %35 = load i32, ptr %34, align 4, !tbaa !21
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._RcsJoint, ptr %37, i32 0, i32 12
  %39 = load i32, ptr %38, align 8, !tbaa !17
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds double, ptr %36, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !22
  call void @MatNd_set(ptr noundef %32, i32 noundef %35, i32 noundef 0, double noundef %42)
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %5, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %29, %24
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct._RcsJoint, ptr %47, i32 0, i32 23
  %49 = load ptr, ptr %48, align 8, !tbaa !23
  store ptr %49, ptr %8, align 8, !tbaa !5
  br label %20, !llvm.loop !24

50:                                               ; preds = %23
  br label %51

51:                                               ; preds = %50
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef %52)
  store ptr %53, ptr %6, align 8, !tbaa !5
  br label %12, !llvm.loop !26

54:                                               ; preds = %15
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %5, align 4, !tbaa !9
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._RcsGraph, ptr %57, i32 0, i32 3
  %59 = load i32, ptr %58, align 4, !tbaa !27
  %60 = icmp eq i32 %56, %59
  br i1 %60, label %64, label %61

61:                                               ; preds = %55
  %62 = load ptr, ptr @stderr, align 8, !tbaa !5
  %63 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %62, ptr noundef @.str.1, ptr noundef @.str.2, ptr noundef @__func__.Rcs_setIKState, i32 noundef 1211, ptr noundef @.str.10) #5
  call void @print_trace()
  call void @abort() #6
  unreachable

64:                                               ; preds = %55
  br label %65

65:                                               ; preds = %64
  br label %66

66:                                               ; preds = %65
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = call zeroext i1 @RcsGraph_setState(ptr noundef %67, ptr noundef null, ptr noundef null)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret void
}

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

declare ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef) #2

declare void @MatNd_set(ptr noundef, i32 noundef, i32 noundef, double noundef) #2

declare zeroext i1 @RcsGraph_setState(ptr noundef, ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_RcsGraph", !6, i64 0, !7, i64 8, !10, i64 1848, !10, i64 1852, !6, i64 1856, !6, i64 1864, !6, i64 1872, !6, i64 1880, !6, i64 1888}
!13 = !{!14, !6, i64 168}
!14 = !{!"_RcsBody", !15, i64 0, !16, i64 8, !10, i64 12, !7, i64 16, !7, i64 40, !15, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176}
!15 = !{!"double", !7, i64 0}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!18, !10, i64 80}
!18 = !{!"_RcsJoint", !6, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !15, i64 48, !15, i64 56, !16, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !6, i64 88, !19, i64 96, !15, i64 192, !15, i64 200, !15, i64 208, !15, i64 216, !10, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264}
!19 = !{!"", !7, i64 0, !7, i64 24}
!20 = !{!12, !6, i64 1856}
!21 = !{!18, !10, i64 76}
!22 = !{!15, !15, i64 0}
!23 = !{!18, !6, i64 256}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25}
!27 = !{!12, !10, i64 1852}


; 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.1 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [76 x i8], align 1
@__func__.Rcs_setIKState = external hidden unnamed_addr constant [15 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [14 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 @abort() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @Rcs_setIKState(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #3 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %.not23 = icmp eq ptr %3, null
  br i1 %.not23, label %._crit_edge28, label %.lr.ph27

.lr.ph27:                                         ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 1856
  br label %8

._crit_edge28:                                    ; preds = %._crit_edge, %2
  %.015.lcssa = phi i32 [ 0, %2 ], [ %.1.lcssa, %._crit_edge ]
  %5 = getelementptr inbounds i8, ptr %0, i64 1852
  %6 = load i32, ptr %5, align 4, !tbaa !11
  %7 = icmp eq i32 %.015.lcssa, %6
  br i1 %7, label %26, label %23

8:                                                ; preds = %.lr.ph27, %._crit_edge
  %.01425 = phi ptr [ %3, %.lr.ph27 ], [ %10, %._crit_edge ]
  %.01524 = phi i32 [ 0, %.lr.ph27 ], [ %.1.lcssa, %._crit_edge ]
  %9 = getelementptr inbounds i8, ptr %.01425, i64 168
  %.019 = load ptr, ptr %9, align 8, !tbaa !12
  %.not1720 = icmp eq ptr %.019, null
  br i1 %.not1720, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %21, %8
  %.1.lcssa = phi i32 [ %.01524, %8 ], [ %.2, %21 ]
  %10 = tail call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef nonnull %.01425) #4
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %._crit_edge28, label %8, !llvm.loop !13

.lr.ph:                                           ; preds = %8, %21
  %.022 = phi ptr [ %.0, %21 ], [ %.019, %8 ]
  %.121 = phi i32 [ %.2, %21 ], [ %.01524, %8 ]
  %11 = getelementptr inbounds i8, ptr %.022, i64 80
  %12 = load i32, ptr %11, align 8, !tbaa !15
  %.not18 = icmp eq i32 %12, -1
  br i1 %.not18, label %21, label %13

13:                                               ; preds = %.lr.ph
  %14 = load ptr, ptr %4, align 8, !tbaa !20
  %15 = getelementptr inbounds i8, ptr %.022, i64 76
  %16 = load i32, ptr %15, align 4, !tbaa !21
  %17 = sext i32 %12 to i64
  %18 = getelementptr inbounds double, ptr %1, i64 %17
  %19 = load double, ptr %18, align 8, !tbaa !22
  tail call void @MatNd_set(ptr noundef %14, i32 noundef %16, i32 noundef 0, double noundef %19) #4
  %20 = add nsw i32 %.121, 1
  br label %21

21:                                               ; preds = %.lr.ph, %13
  %.2 = phi i32 [ %20, %13 ], [ %.121, %.lr.ph ]
  %22 = getelementptr inbounds i8, ptr %.022, i64 256
  %.0 = load ptr, ptr %22, align 8, !tbaa !12
  %.not17 = icmp eq ptr %.0, null
  br i1 %.not17, label %._crit_edge, label %.lr.ph, !llvm.loop !23

23:                                               ; preds = %._crit_edge28
  %24 = load ptr, ptr @stderr, align 8, !tbaa !12
  %25 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, ptr noundef nonnull @__func__.Rcs_setIKState, i32 noundef 1211, ptr noundef nonnull @.str.10) #5
  tail call void @print_trace() #4
  tail call void @abort() #6
  unreachable

26:                                               ; preds = %._crit_edge28
  %27 = tail call zeroext i1 @RcsGraph_setState(ptr noundef nonnull %0, ptr noundef null, ptr noundef null) #4
  ret void
}

declare ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef) local_unnamed_addr #1

declare void @MatNd_set(ptr noundef, i32 noundef, i32 noundef, double noundef) local_unnamed_addr #1

declare zeroext i1 @RcsGraph_setState(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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 = { nounwind }
attributes #5 = { cold 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, !7, i64 0}
!6 = !{!"_RcsGraph", !7, i64 0, !8, i64 8, !10, i64 1848, !10, i64 1852, !7, i64 1856, !7, i64 1864, !7, i64 1872, !7, i64 1880, !7, i64 1888}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 1852}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !10, i64 80}
!16 = !{!"_RcsJoint", !7, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !17, i64 32, !17, i64 40, !17, i64 48, !17, i64 56, !18, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !7, i64 88, !19, i64 96, !17, i64 192, !17, i64 200, !17, i64 208, !17, i64 216, !10, i64 224, !7, i64 232, !7, i64 240, !7, i64 248, !7, i64 256, !7, i64 264}
!17 = !{!"double", !8, i64 0}
!18 = !{!"_Bool", !8, i64 0}
!19 = !{!"", !8, i64 0, !8, i64 24}
!20 = !{!6, !7, i64 1856}
!21 = !{!16, !10, i64 76}
!22 = !{!17, !17, i64 0}
!23 = distinct !{!23, !14}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass