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

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

@RCS_GLOBAL_RLOG_CB = external global ptr, align 8
@.str = external hidden unnamed_addr constant [67 x i8], align 1
@RcsLogLevel = external global i32, align 4
@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@__func__.RcsMesh_computeAABB = external hidden unnamed_addr constant [20 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [35 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

; 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
define dso_local void @RcsMesh_computeAABB(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %33

13:                                               ; preds = %3
  br label %14

14:                                               ; preds = %13
  %15 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %19

17:                                               ; preds = %14
  %18 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  call void (i32, ptr, ptr, i32, ptr, ...) %18(i32 noundef 4, ptr noundef @.str, ptr noundef @__func__.RcsMesh_computeAABB, i32 noundef 1089, ptr noundef @.str.49)
  br label %19

19:                                               ; preds = %17, %14
  %20 = load i32, ptr @RcsLogLevel, align 4, !tbaa !9
  %21 = icmp sle i32 4, %20
  br i1 %21, label %22, label %29

22:                                               ; preds = %19
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.2, ptr noundef @.str, ptr noundef @__func__.RcsMesh_computeAABB, i32 noundef 1089) #4
  %25 = load ptr, ptr @stderr, align 8, !tbaa !5
  %26 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef @.str.49) #4
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str.3) #4
  br label %29

29:                                               ; preds = %22, %19
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  call void @Vec3d_setZero(ptr noundef %31)
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  call void @Vec3d_setZero(ptr noundef %32)
  br label %106

33:                                               ; preds = %3
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  call void @Vec3d_set(ptr noundef %34, double noundef 0x7FEFFFFFFFFFFFFF, double noundef 0x7FEFFFFFFFFFFFFF, double noundef 0x7FEFFFFFFFFFFFFF)
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  call void @Vec3d_set(ptr noundef %35, double noundef 0xFFEFFFFFFFFFFFFF, double noundef 0xFFEFFFFFFFFFFFFF, double noundef 0xFFEFFFFFFFFFFFFF)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %103, %33
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.RcsMeshData, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !11
  %41 = icmp ult i32 %37, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %36
  store i32 4, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %106

43:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.RcsMeshData, ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !13
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds double, ptr %46, i64 %48
  store ptr %49, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %99, %43
  %51 = load i32, ptr %10, align 4, !tbaa !9
  %52 = icmp slt i32 %51, 3
  br i1 %52, label %54, label %53

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

54:                                               ; preds = %50
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = load i32, ptr %10, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds double, ptr %55, i64 %57
  %59 = load double, ptr %58, align 8, !tbaa !14
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = load i32, ptr %10, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds double, ptr %60, i64 %62
  %64 = load double, ptr %63, align 8, !tbaa !14
  %65 = fcmp olt double %59, %64
  br i1 %65, label %66, label %76

66:                                               ; preds = %54
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = load i32, ptr %10, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds double, ptr %67, i64 %69
  %71 = load double, ptr %70, align 8, !tbaa !14
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = load i32, ptr %10, align 4, !tbaa !9
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds double, ptr %72, i64 %74
  store double %71, ptr %75, align 8, !tbaa !14
  br label %76

76:                                               ; preds = %66, %54
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = load i32, ptr %10, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds double, ptr %77, i64 %79
  %81 = load double, ptr %80, align 8, !tbaa !14
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = load i32, ptr %10, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds double, ptr %82, i64 %84
  %86 = load double, ptr %85, align 8, !tbaa !14
  %87 = fcmp ogt double %81, %86
  br i1 %87, label %88, label %98

88:                                               ; preds = %76
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  %90 = load i32, ptr %10, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds double, ptr %89, i64 %91
  %93 = load double, ptr %92, align 8, !tbaa !14
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = load i32, ptr %10, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds double, ptr %94, i64 %96
  store double %93, ptr %97, align 8, !tbaa !14
  br label %98

98:                                               ; preds = %88, %76
  br label %99

99:                                               ; preds = %98
  %100 = load i32, ptr %10, align 4, !tbaa !9
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %10, align 4, !tbaa !9
  br label %50, !llvm.loop !16

102:                                              ; preds = %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %103

103:                                              ; preds = %102
  %104 = load i32, ptr %7, align 4, !tbaa !9
  %105 = add i32 %104, 3
  store i32 %105, ptr %7, align 4, !tbaa !9
  br label %36, !llvm.loop !18

106:                                              ; preds = %42, %30
  ret void
}

declare void @Vec3d_setZero(ptr noundef) #3

declare void @Vec3d_set(ptr noundef, double noundef, double noundef, double noundef) #3

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 = { 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 #3 = { "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 }

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


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

@RCS_GLOBAL_RLOG_CB = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [67 x i8], align 1
@RcsLogLevel = external local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@__func__.RcsMesh_computeAABB = external hidden unnamed_addr constant [20 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [35 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @RcsMesh_computeAABB(ptr noundef readonly %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = icmp eq ptr %0, null
  br i1 %4, label %5, label %19

5:                                                ; preds = %3
  %6 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %8, label %7

7:                                                ; preds = %5
  tail call void (i32, ptr, ptr, i32, ptr, ...) %6(i32 noundef 4, ptr noundef nonnull @.str, ptr noundef nonnull @__func__.RcsMesh_computeAABB, i32 noundef 1089, ptr noundef nonnull @.str.49) #3
  br label %8

8:                                                ; preds = %7, %5
  %9 = load i32, ptr @RcsLogLevel, align 4, !tbaa !9
  %10 = icmp sgt i32 %9, 3
  br i1 %10, label %11, label %18

11:                                               ; preds = %8
  %12 = load ptr, ptr @stderr, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str, ptr noundef nonnull @__func__.RcsMesh_computeAABB, i32 noundef 1089) #4
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.49) #4
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.3) #4
  br label %18

18:                                               ; preds = %8, %11
  tail call void @Vec3d_setZero(ptr noundef %1) #3
  tail call void @Vec3d_setZero(ptr noundef %2) #3
  br label %.loopexit

19:                                               ; preds = %3
  tail call void @Vec3d_set(ptr noundef %1, double noundef 0x7FEFFFFFFFFFFFFF, double noundef 0x7FEFFFFFFFFFFFFF, double noundef 0x7FEFFFFFFFFFFFFF) #3
  tail call void @Vec3d_set(ptr noundef %2, double noundef 0xFFEFFFFFFFFFFFFF, double noundef 0xFFEFFFFFFFFFFFFF, double noundef 0xFFEFFFFFFFFFFFFF) #3
  %20 = load i32, ptr %0, align 8, !tbaa !11
  %.not34 = icmp eq i32 %20, 0
  br i1 %.not34, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %19
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = getelementptr inbounds i8, ptr %1, i64 8
  %24 = getelementptr inbounds i8, ptr %2, i64 8
  %25 = getelementptr inbounds i8, ptr %1, i64 16
  %26 = getelementptr inbounds i8, ptr %2, i64 16
  br label %27

27:                                               ; preds = %.lr.ph, %61
  %.02733 = phi i32 [ 0, %.lr.ph ], [ %62, %61 ]
  %28 = zext i32 %.02733 to i64
  %29 = getelementptr inbounds double, ptr %22, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !14
  %31 = load double, ptr %1, align 8, !tbaa !14
  %32 = fcmp olt double %30, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %27
  store double %30, ptr %1, align 8, !tbaa !14
  %.pre = load double, ptr %29, align 8, !tbaa !14
  br label %34

34:                                               ; preds = %33, %27
  %35 = phi double [ %.pre, %33 ], [ %30, %27 ]
  %36 = load double, ptr %2, align 8, !tbaa !14
  %37 = fcmp ogt double %35, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %34
  store double %35, ptr %2, align 8, !tbaa !14
  br label %39

39:                                               ; preds = %34, %38
  %40 = getelementptr inbounds i8, ptr %29, i64 8
  %41 = load double, ptr %40, align 8, !tbaa !14
  %42 = load double, ptr %23, align 8, !tbaa !14
  %43 = fcmp olt double %41, %42
  br i1 %43, label %44, label %45

44:                                               ; preds = %39
  store double %41, ptr %23, align 8, !tbaa !14
  %.pre36 = load double, ptr %40, align 8, !tbaa !14
  br label %45

45:                                               ; preds = %44, %39
  %46 = phi double [ %.pre36, %44 ], [ %41, %39 ]
  %47 = load double, ptr %24, align 8, !tbaa !14
  %48 = fcmp ogt double %46, %47
  br i1 %48, label %49, label %50

49:                                               ; preds = %45
  store double %46, ptr %24, align 8, !tbaa !14
  br label %50

50:                                               ; preds = %49, %45
  %51 = getelementptr inbounds i8, ptr %29, i64 16
  %52 = load double, ptr %51, align 8, !tbaa !14
  %53 = load double, ptr %25, align 8, !tbaa !14
  %54 = fcmp olt double %52, %53
  br i1 %54, label %55, label %56

55:                                               ; preds = %50
  store double %52, ptr %25, align 8, !tbaa !14
  %.pre37 = load double, ptr %51, align 8, !tbaa !14
  br label %56

56:                                               ; preds = %55, %50
  %57 = phi double [ %.pre37, %55 ], [ %52, %50 ]
  %58 = load double, ptr %26, align 8, !tbaa !14
  %59 = fcmp ogt double %57, %58
  br i1 %59, label %60, label %61

60:                                               ; preds = %56
  store double %57, ptr %26, align 8, !tbaa !14
  br label %61

61:                                               ; preds = %60, %56
  %62 = add i32 %.02733, 3
  %63 = icmp ult i32 %62, %20
  br i1 %63, label %27, label %.loopexit, !llvm.loop !16

.loopexit:                                        ; preds = %61, %19, %18
  ret void
}

declare void @Vec3d_setZero(ptr noundef) local_unnamed_addr #2

declare void @Vec3d_set(ptr noundef, double noundef, double noundef, double noundef) local_unnamed_addr #2

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 = { 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 = { "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 }
attributes #4 = { cold 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, !10, i64 0}
!12 = !{!"", !10, i64 0, !6, i64 8, !10, i64 16, !6, i64 24}
!13 = !{!12, !6, i64 8}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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