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

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

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [43 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.RcsGraph_jointLimitBorderGradient = external hidden unnamed_addr constant [34 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [37 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare void @MatNd_reshapeAndSetZero(ptr noundef, i32 noundef, i32 noundef) #1

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

declare void @print_trace() #1

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

declare ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @RcsGraph_jointLimitBorderGradient(ptr noundef %0, ptr noundef %1, double noundef %2, i32 noundef %3) #4 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  %21 = alloca double, align 8
  %22 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store double %2, ptr %7, align 8, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  br label %23

23:                                               ; preds = %4
  %24 = load double, ptr %7, align 8, !tbaa !9
  %25 = fcmp oge double %24, 0.000000e+00
  br i1 %25, label %26, label %29

26:                                               ; preds = %23
  %27 = load double, ptr %7, align 8, !tbaa !9
  %28 = fcmp ole double %27, 1.000000e+00
  br i1 %28, label %32, label %29

29:                                               ; preds = %26, %23
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.RcsGraph_jointLimitBorderGradient, i32 noundef 1337, ptr noundef @.str.10) #5
  call void @print_trace()
  call void @abort() #6
  unreachable

32:                                               ; preds = %26
  br label %33

33:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %34 = load i32, ptr %8, align 4, !tbaa !11
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %40

36:                                               ; preds = %33
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._RcsGraph, ptr %37, i32 0, i32 2
  %39 = load i32, ptr %38, align 8, !tbaa !13
  br label %44

40:                                               ; preds = %33
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._RcsGraph, ptr %41, i32 0, i32 3
  %43 = load i32, ptr %42, align 4, !tbaa !15
  br label %44

44:                                               ; preds = %40, %36
  %45 = phi i32 [ %39, %36 ], [ %43, %40 ]
  store i32 %45, ptr %9, align 4, !tbaa !11
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load i32, ptr %9, align 4, !tbaa !11
  call void @MatNd_reshapeAndSetZero(ptr noundef %46, i32 noundef 1, i32 noundef %47)
  %48 = load double, ptr %7, align 8, !tbaa !9
  %49 = fcmp oeq double %48, 1.000000e+00
  br i1 %49, label %50, label %51

50:                                               ; preds = %44
  store i32 1, ptr %10, align 4
  br label %220

51:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._RcsGraph, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !16
  store ptr %54, ptr %11, align 8, !tbaa !5
  br label %55

55:                                               ; preds = %216, %51
  %56 = load ptr, ptr %11, align 8, !tbaa !5
  %57 = icmp ne ptr %56, null
  br i1 %57, label %59, label %58

58:                                               ; preds = %55
  store i32 4, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %219

59:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._RcsBody, ptr %60, i32 0, i32 18
  %62 = load ptr, ptr %61, align 8, !tbaa !17
  store ptr %62, ptr %12, align 8, !tbaa !5
  br label %63

63:                                               ; preds = %211, %59
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  %65 = icmp ne ptr %64, null
  br i1 %65, label %67, label %66

66:                                               ; preds = %63
  store i32 7, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %215

67:                                               ; preds = %63
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._RcsJoint, ptr %68, i32 0, i32 8
  %70 = load i8, ptr %69, align 8, !tbaa !20, !range !23, !noundef !24
  %71 = trunc i8 %70 to i1
  %72 = zext i1 %71 to i32
  %73 = icmp eq i32 %72, 1
  br i1 %73, label %74, label %78

74:                                               ; preds = %67
  %75 = load i32, ptr %8, align 4, !tbaa !11
  %76 = icmp eq i32 %75, 1
  br i1 %76, label %77, label %78

77:                                               ; preds = %74
  br label %211

78:                                               ; preds = %74, %67
  %79 = load ptr, ptr %12, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct._RcsJoint, ptr %79, i32 0, i32 24
  %81 = load ptr, ptr %80, align 8, !tbaa !25
  %82 = icmp ne ptr %81, null
  br i1 %82, label %83, label %84

83:                                               ; preds = %78
  br label %211

84:                                               ; preds = %78
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %85 = load i32, ptr %8, align 4, !tbaa !11
  %86 = icmp eq i32 %85, 1
  br i1 %86, label %87, label %91

87:                                               ; preds = %84
  %88 = load ptr, ptr %12, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct._RcsJoint, ptr %88, i32 0, i32 12
  %90 = load i32, ptr %89, align 8, !tbaa !26
  br label %95

91:                                               ; preds = %84
  %92 = load ptr, ptr %12, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct._RcsJoint, ptr %92, i32 0, i32 11
  %94 = load i32, ptr %93, align 4, !tbaa !27
  br label %95

95:                                               ; preds = %91, %87
  %96 = phi i32 [ %90, %87 ], [ %94, %91 ]
  store i32 %96, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct._RcsGraph, ptr %97, i32 0, i32 4
  %99 = load ptr, ptr %98, align 8, !tbaa !28
  %100 = getelementptr inbounds %struct._MatNd, ptr %99, i32 0, i32 0
  %101 = load ptr, ptr %100, align 8, !tbaa !29
  %102 = load ptr, ptr %12, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct._RcsJoint, ptr %102, i32 0, i32 11
  %104 = load i32, ptr %103, align 4, !tbaa !27
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct._RcsGraph, ptr %105, i32 0, i32 4
  %107 = load ptr, ptr %106, align 8, !tbaa !28
  %108 = getelementptr inbounds %struct._MatNd, ptr %107, i32 0, i32 2
  %109 = load i32, ptr %108, align 4, !tbaa !31
  %110 = mul i32 %104, %109
  %111 = add i32 %110, 0
  %112 = zext i32 %111 to i64
  %113 = getelementptr inbounds double, ptr %101, i64 %112
  %114 = load double, ptr %113, align 8, !tbaa !9
  store double %114, ptr %14, align 8, !tbaa !9
  %115 = load double, ptr %14, align 8, !tbaa !9
  %116 = load ptr, ptr %12, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct._RcsJoint, ptr %116, i32 0, i32 1
  %118 = load double, ptr %117, align 8, !tbaa !32
  %119 = fcmp ogt double %115, %118
  br i1 %119, label %120, label %165

120:                                              ; preds = %95
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %121 = load ptr, ptr %12, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct._RcsJoint, ptr %121, i32 0, i32 4
  %123 = load double, ptr %122, align 8, !tbaa !33
  %124 = load ptr, ptr %12, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct._RcsJoint, ptr %124, i32 0, i32 1
  %126 = load double, ptr %125, align 8, !tbaa !32
  %127 = fsub double %123, %126
  store double %127, ptr %15, align 8, !tbaa !9
  %128 = load double, ptr %15, align 8, !tbaa !9
  %129 = fcmp ogt double %128, 0.000000e+00
  br i1 %129, label %130, label %164

130:                                              ; preds = %120
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %131 = load double, ptr %7, align 8, !tbaa !9
  %132 = load double, ptr %15, align 8, !tbaa !9
  %133 = fmul double %131, %132
  store double %133, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %134 = load double, ptr %15, align 8, !tbaa !9
  %135 = load double, ptr %16, align 8, !tbaa !9
  %136 = fsub double %134, %135
  store double %136, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %137 = load ptr, ptr %12, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct._RcsJoint, ptr %137, i32 0, i32 1
  %139 = load double, ptr %138, align 8, !tbaa !32
  %140 = load double, ptr %16, align 8, !tbaa !9
  %141 = fadd double %139, %140
  store double %141, ptr %18, align 8, !tbaa !9
  %142 = load double, ptr %14, align 8, !tbaa !9
  %143 = load double, ptr %18, align 8, !tbaa !9
  %144 = fcmp ogt double %142, %143
  br i1 %144, label %145, label %163

145:                                              ; preds = %130
  %146 = load ptr, ptr %12, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct._RcsJoint, ptr %146, i32 0, i32 5
  %148 = load double, ptr %147, align 8, !tbaa !34
  %149 = load double, ptr %14, align 8, !tbaa !9
  %150 = load double, ptr %18, align 8, !tbaa !9
  %151 = fsub double %149, %150
  %152 = fmul double %148, %151
  %153 = load double, ptr %17, align 8, !tbaa !9
  %154 = load double, ptr %17, align 8, !tbaa !9
  %155 = fmul double %153, %154
  %156 = fdiv double %152, %155
  %157 = load ptr, ptr %6, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct._MatNd, ptr %157, i32 0, i32 0
  %159 = load ptr, ptr %158, align 8, !tbaa !29
  %160 = load i32, ptr %13, align 4, !tbaa !11
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds double, ptr %159, i64 %161
  store double %156, ptr %162, align 8, !tbaa !9
  br label %163

163:                                              ; preds = %145, %130
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  br label %164

164:                                              ; preds = %163, %120
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  br label %210

165:                                              ; preds = %95
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %166 = load ptr, ptr %12, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct._RcsJoint, ptr %166, i32 0, i32 1
  %168 = load double, ptr %167, align 8, !tbaa !32
  %169 = load ptr, ptr %12, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct._RcsJoint, ptr %169, i32 0, i32 3
  %171 = load double, ptr %170, align 8, !tbaa !35
  %172 = fsub double %168, %171
  store double %172, ptr %19, align 8, !tbaa !9
  %173 = load double, ptr %19, align 8, !tbaa !9
  %174 = fcmp ogt double %173, 0.000000e+00
  br i1 %174, label %175, label %209

175:                                              ; preds = %165
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %176 = load double, ptr %7, align 8, !tbaa !9
  %177 = load double, ptr %19, align 8, !tbaa !9
  %178 = fmul double %176, %177
  store double %178, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  %179 = load double, ptr %19, align 8, !tbaa !9
  %180 = load double, ptr %20, align 8, !tbaa !9
  %181 = fsub double %179, %180
  store double %181, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  %182 = load ptr, ptr %12, align 8, !tbaa !5
  %183 = getelementptr inbounds %struct._RcsJoint, ptr %182, i32 0, i32 1
  %184 = load double, ptr %183, align 8, !tbaa !32
  %185 = load double, ptr %20, align 8, !tbaa !9
  %186 = fsub double %184, %185
  store double %186, ptr %22, align 8, !tbaa !9
  %187 = load double, ptr %14, align 8, !tbaa !9
  %188 = load double, ptr %22, align 8, !tbaa !9
  %189 = fcmp olt double %187, %188
  br i1 %189, label %190, label %208

190:                                              ; preds = %175
  %191 = load ptr, ptr %12, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct._RcsJoint, ptr %191, i32 0, i32 5
  %193 = load double, ptr %192, align 8, !tbaa !34
  %194 = load double, ptr %14, align 8, !tbaa !9
  %195 = load double, ptr %22, align 8, !tbaa !9
  %196 = fsub double %194, %195
  %197 = fmul double %193, %196
  %198 = load double, ptr %21, align 8, !tbaa !9
  %199 = load double, ptr %21, align 8, !tbaa !9
  %200 = fmul double %198, %199
  %201 = fdiv double %197, %200
  %202 = load ptr, ptr %6, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct._MatNd, ptr %202, i32 0, i32 0
  %204 = load ptr, ptr %203, align 8, !tbaa !29
  %205 = load i32, ptr %13, align 4, !tbaa !11
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds double, ptr %204, i64 %206
  store double %201, ptr %207, align 8, !tbaa !9
  br label %208

208:                                              ; preds = %190, %175
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  br label %209

209:                                              ; preds = %208, %165
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  br label %210

210:                                              ; preds = %209, %164
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %211

211:                                              ; preds = %210, %83, %77
  %212 = load ptr, ptr %12, align 8, !tbaa !5
  %213 = getelementptr inbounds %struct._RcsJoint, ptr %212, i32 0, i32 23
  %214 = load ptr, ptr %213, align 8, !tbaa !36
  store ptr %214, ptr %12, align 8, !tbaa !5
  br label %63, !llvm.loop !37

215:                                              ; preds = %66
  br label %216

216:                                              ; preds = %215
  %217 = load ptr, ptr %11, align 8, !tbaa !5
  %218 = call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef %217)
  store ptr %218, ptr %11, align 8, !tbaa !5
  br label %55, !llvm.loop !39

219:                                              ; preds = %58
  store i32 0, ptr %10, align 4
  br label %220

220:                                              ; preds = %219, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  %221 = load i32, ptr %10, align 4
  switch i32 %221, label %223 [
    i32 0, label %222
    i32 1, label %222
  ]

222:                                              ; preds = %220, %220
  ret void

223:                                              ; preds = %220
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 1848}
!14 = !{!"_RcsGraph", !6, i64 0, !7, i64 8, !12, i64 1848, !12, i64 1852, !6, i64 1856, !6, i64 1864, !6, i64 1872, !6, i64 1880, !6, i64 1888}
!15 = !{!14, !12, i64 1852}
!16 = !{!14, !6, i64 0}
!17 = !{!18, !6, i64 168}
!18 = !{!"_RcsBody", !10, i64 0, !19, i64 8, !12, i64 12, !7, i64 16, !7, i64 40, !10, 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}
!19 = !{!"_Bool", !7, i64 0}
!20 = !{!21, !19, i64 64}
!21 = !{!"_RcsJoint", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !19, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !12, i64 80, !6, i64 88, !22, i64 96, !10, i64 192, !10, i64 200, !10, i64 208, !10, i64 216, !12, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264}
!22 = !{!"", !7, i64 0, !7, i64 24}
!23 = !{i8 0, i8 2}
!24 = !{}
!25 = !{!21, !6, i64 264}
!26 = !{!21, !12, i64 80}
!27 = !{!21, !12, i64 76}
!28 = !{!14, !6, i64 1856}
!29 = !{!30, !6, i64 0}
!30 = !{!"_MatNd", !6, i64 0, !12, i64 8, !12, i64 12, !12, i64 16, !19, i64 20}
!31 = !{!30, !12, i64 12}
!32 = !{!21, !10, i64 8}
!33 = !{!21, !10, i64 32}
!34 = !{!21, !10, i64 40}
!35 = !{!21, !10, i64 24}
!36 = !{!21, !6, i64 256}
!37 = distinct !{!37, !38}
!38 = !{!"llvm.loop.mustprogress"}
!39 = distinct !{!39, !38}


; 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 [43 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.RcsGraph_jointLimitBorderGradient = external hidden unnamed_addr constant [34 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [37 x i8], align 1

declare void @MatNd_reshapeAndSetZero(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

declare void @print_trace() local_unnamed_addr #0

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

declare ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @RcsGraph_jointLimitBorderGradient(ptr nocapture noundef readonly %0, ptr noundef %1, double noundef %2, i32 noundef %3) local_unnamed_addr #3 {
  %5 = fcmp oge double %2, 0.000000e+00
  %6 = fcmp ole double %2, 1.000000e+00
  %or.cond = and i1 %5, %6
  br i1 %or.cond, label %10, label %7

7:                                                ; preds = %4
  %8 = load ptr, ptr @stderr, align 8, !tbaa !5
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %8, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.RcsGraph_jointLimitBorderGradient, i32 noundef 1337, ptr noundef nonnull @.str.10) #4
  tail call void @print_trace() #5
  tail call void @abort() #6
  unreachable

10:                                               ; preds = %4
  %11 = icmp eq i32 %3, 0
  %.in.v = select i1 %11, i64 1848, i64 1852
  %.in = getelementptr inbounds i8, ptr %0, i64 %.in.v
  %12 = load i32, ptr %.in, align 4, !tbaa !9
  tail call void @MatNd_reshapeAndSetZero(ptr noundef %1, i32 noundef 1, i32 noundef %12) #5
  %13 = fcmp oeq double %2, 1.000000e+00
  br i1 %13, label %.loopexit, label %14

14:                                               ; preds = %10
  %15 = load ptr, ptr %0, align 8, !tbaa !11
  %.not77 = icmp eq ptr %15, null
  br i1 %.not77, label %.loopexit, label %.lr.ph80

.lr.ph80:                                         ; preds = %14
  %16 = icmp eq i32 %3, 1
  %17 = getelementptr inbounds i8, ptr %0, i64 1856
  br label %18

18:                                               ; preds = %.lr.ph80, %._crit_edge
  %.078 = phi ptr [ %15, %.lr.ph80 ], [ %20, %._crit_edge ]
  %19 = getelementptr inbounds i8, ptr %.078, i64 168
  %.06374 = load ptr, ptr %19, align 8, !tbaa !5
  %.not7175 = icmp eq ptr %.06374, null
  br i1 %.not7175, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %80, %18
  %20 = tail call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef nonnull %.078) #5
  %.not = icmp eq ptr %20, null
  br i1 %.not, label %.loopexit, label %18, !llvm.loop !13

.lr.ph:                                           ; preds = %18, %80
  %.06376 = phi ptr [ %.063, %80 ], [ %.06374, %18 ]
  %21 = getelementptr inbounds i8, ptr %.06376, i64 64
  %22 = load i8, ptr %21, align 8, !tbaa !15, !range !20, !noundef !21
  %23 = trunc nuw i8 %22 to i1
  %or.cond3 = and i1 %16, %23
  br i1 %or.cond3, label %80, label %24

24:                                               ; preds = %.lr.ph
  %25 = getelementptr inbounds i8, ptr %.06376, i64 264
  %26 = load ptr, ptr %25, align 8, !tbaa !22
  %.not72 = icmp eq ptr %26, null
  br i1 %.not72, label %27, label %80

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %.06376, i64 80
  %29 = getelementptr inbounds i8, ptr %.06376, i64 76
  %.in73 = select i1 %16, ptr %28, ptr %29
  %30 = load i32, ptr %.in73, align 4, !tbaa !9
  %31 = load ptr, ptr %17, align 8, !tbaa !23
  %32 = load ptr, ptr %31, align 8, !tbaa !24
  %33 = load i32, ptr %29, align 4, !tbaa !26
  %34 = getelementptr inbounds i8, ptr %31, i64 12
  %35 = load i32, ptr %34, align 4, !tbaa !27
  %36 = mul i32 %35, %33
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds double, ptr %32, i64 %37
  %39 = load double, ptr %38, align 8, !tbaa !28
  %40 = getelementptr inbounds i8, ptr %.06376, i64 8
  %41 = load double, ptr %40, align 8, !tbaa !29
  %42 = fcmp ogt double %39, %41
  br i1 %42, label %43, label %60

43:                                               ; preds = %27
  %44 = getelementptr inbounds i8, ptr %.06376, i64 32
  %45 = load double, ptr %44, align 8, !tbaa !30
  %46 = fsub double %45, %41
  %47 = fcmp ogt double %46, 0.000000e+00
  br i1 %47, label %48, label %80

48:                                               ; preds = %43
  %49 = fmul double %46, %2
  %50 = fadd double %41, %49
  %51 = fcmp ogt double %39, %50
  br i1 %51, label %52, label %80

52:                                               ; preds = %48
  %53 = fsub double %46, %49
  %54 = getelementptr inbounds i8, ptr %.06376, i64 40
  %55 = load double, ptr %54, align 8, !tbaa !31
  %56 = fsub double %39, %50
  %57 = fmul double %56, %55
  %58 = fmul double %53, %53
  %59 = fdiv double %57, %58
  br label %.sink.split

60:                                               ; preds = %27
  %61 = getelementptr inbounds i8, ptr %.06376, i64 24
  %62 = load double, ptr %61, align 8, !tbaa !32
  %63 = fsub double %41, %62
  %64 = fcmp ogt double %63, 0.000000e+00
  br i1 %64, label %65, label %80

65:                                               ; preds = %60
  %66 = fmul double %63, %2
  %67 = fsub double %41, %66
  %68 = fcmp olt double %39, %67
  br i1 %68, label %69, label %80

69:                                               ; preds = %65
  %70 = fsub double %63, %66
  %71 = getelementptr inbounds i8, ptr %.06376, i64 40
  %72 = load double, ptr %71, align 8, !tbaa !31
  %73 = fsub double %39, %67
  %74 = fmul double %73, %72
  %75 = fmul double %70, %70
  %76 = fdiv double %74, %75
  br label %.sink.split

.sink.split:                                      ; preds = %69, %52
  %.sink = phi double [ %59, %52 ], [ %76, %69 ]
  %77 = load ptr, ptr %1, align 8, !tbaa !24
  %78 = sext i32 %30 to i64
  %79 = getelementptr inbounds double, ptr %77, i64 %78
  store double %.sink, ptr %79, align 8, !tbaa !28
  br label %80

80:                                               ; preds = %.sink.split, %48, %43, %65, %60, %24, %.lr.ph
  %81 = getelementptr inbounds i8, ptr %.06376, i64 256
  %.063 = load ptr, ptr %81, align 8, !tbaa !5
  %.not71 = icmp eq ptr %.063, null
  br i1 %.not71, label %._crit_edge, label %.lr.ph, !llvm.loop !33

.loopexit:                                        ; preds = %._crit_edge, %14, %10
  ret void
}

attributes #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 = { 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 #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, !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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !18, i64 64}
!16 = !{!"_RcsJoint", !6, 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, !6, i64 88, !19, i64 96, !17, i64 192, !17, i64 200, !17, i64 208, !17, i64 216, !10, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264}
!17 = !{!"double", !7, i64 0}
!18 = !{!"_Bool", !7, i64 0}
!19 = !{!"", !7, i64 0, !7, i64 24}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!16, !6, i64 264}
!23 = !{!12, !6, i64 1856}
!24 = !{!25, !6, i64 0}
!25 = !{!"_MatNd", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !18, i64 20}
!26 = !{!16, !10, i64 76}
!27 = !{!25, !10, i64 12}
!28 = !{!17, !17, i64 0}
!29 = !{!16, !17, i64 8}
!30 = !{!16, !17, i64 32}
!31 = !{!16, !17, i64 40}
!32 = !{!16, !17, i64 24}
!33 = distinct !{!33, !14}


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