; 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_calloc = external global ptr, align 8
@__const.RcsMesh_createBox.vertexIndex = external hidden unnamed_addr constant [36 x i32], align 16
@__const.RcsMesh_createBox.verts = external hidden unnamed_addr constant [24 x double], align 16

; 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: 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) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @RcsMesh_createBox(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca [36 x i32], align 16
  %5 = alloca [24 x double], align 16
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %7 = load ptr, ptr @Rcs_calloc, align 8, !tbaa !5
  %8 = call ptr %7(i64 noundef 1, i64 noundef 32)
  store ptr %8, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.RcsMeshData, ptr %9, i32 0, i32 2
  store i32 12, ptr %10, align 8, !tbaa !9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.RcsMeshData, ptr %11, i32 0, i32 0
  store i32 8, ptr %12, align 8, !tbaa !12
  %13 = load ptr, ptr @Rcs_calloc, align 8, !tbaa !5
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.RcsMeshData, ptr %14, i32 0, i32 2
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = mul i32 %16, 3
  %18 = zext i32 %17 to i64
  %19 = call ptr %13(i64 noundef %18, i64 noundef 4)
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.RcsMeshData, ptr %20, i32 0, i32 3
  store ptr %19, ptr %21, align 8, !tbaa !13
  %22 = load ptr, ptr @Rcs_calloc, align 8, !tbaa !5
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.RcsMeshData, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !12
  %26 = mul i32 %25, 3
  %27 = zext i32 %26 to i64
  %28 = call ptr %22(i64 noundef %27, i64 noundef 8)
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.RcsMeshData, ptr %29, i32 0, i32 1
  store ptr %28, ptr %30, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 144, ptr %4) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %4, ptr align 16 @__const.RcsMesh_createBox.vertexIndex, i64 144, i1 false)
  call void @llvm.lifetime.start.p0(i64 192, ptr %5) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %5, ptr align 16 @__const.RcsMesh_createBox.verts, i64 192, i1 false)
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.RcsMeshData, ptr %31, i32 0, i32 3
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %34 = getelementptr inbounds [36 x i32], ptr %4, i64 0, i64 0
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.RcsMeshData, ptr %35, i32 0, i32 2
  %37 = load i32, ptr %36, align 8, !tbaa !9
  %38 = mul i32 3, %37
  %39 = zext i32 %38 to i64
  %40 = mul i64 %39, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %33, ptr align 16 %34, i64 %40, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !15
  br label %41

41:                                               ; preds = %94, %1
  %42 = load i32, ptr %6, align 4, !tbaa !15
  %43 = icmp ult i32 %42, 24
  br i1 %43, label %45, label %44

44:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %97

45:                                               ; preds = %41
  %46 = load i32, ptr %6, align 4, !tbaa !15
  %47 = add i32 %46, 0
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds [24 x double], ptr %5, i64 0, i64 %48
  %50 = load double, ptr %49, align 8, !tbaa !16
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds double, ptr %51, i64 0
  %53 = load double, ptr %52, align 8, !tbaa !16
  %54 = fmul double %50, %53
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.RcsMeshData, ptr %55, i32 0, i32 1
  %57 = load ptr, ptr %56, align 8, !tbaa !14
  %58 = load i32, ptr %6, align 4, !tbaa !15
  %59 = add i32 %58, 0
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds double, ptr %57, i64 %60
  store double %54, ptr %61, align 8, !tbaa !16
  %62 = load i32, ptr %6, align 4, !tbaa !15
  %63 = add i32 %62, 1
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds [24 x double], ptr %5, i64 0, i64 %64
  %66 = load double, ptr %65, align 8, !tbaa !16
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds double, ptr %67, i64 1
  %69 = load double, ptr %68, align 8, !tbaa !16
  %70 = fmul double %66, %69
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.RcsMeshData, ptr %71, i32 0, i32 1
  %73 = load ptr, ptr %72, align 8, !tbaa !14
  %74 = load i32, ptr %6, align 4, !tbaa !15
  %75 = add i32 %74, 1
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds double, ptr %73, i64 %76
  store double %70, ptr %77, align 8, !tbaa !16
  %78 = load i32, ptr %6, align 4, !tbaa !15
  %79 = add i32 %78, 2
  %80 = zext i32 %79 to i64
  %81 = getelementptr inbounds [24 x double], ptr %5, i64 0, i64 %80
  %82 = load double, ptr %81, align 8, !tbaa !16
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds double, ptr %83, i64 2
  %85 = load double, ptr %84, align 8, !tbaa !16
  %86 = fmul double %82, %85
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.RcsMeshData, ptr %87, i32 0, i32 1
  %89 = load ptr, ptr %88, align 8, !tbaa !14
  %90 = load i32, ptr %6, align 4, !tbaa !15
  %91 = add i32 %90, 2
  %92 = zext i32 %91 to i64
  %93 = getelementptr inbounds double, ptr %89, i64 %92
  store double %86, ptr %93, align 8, !tbaa !16
  br label %94

94:                                               ; preds = %45
  %95 = load i32, ptr %6, align 4, !tbaa !15
  %96 = add i32 %95, 3
  store i32 %96, ptr %6, align 4, !tbaa !15
  br label %41, !llvm.loop !18

97:                                               ; preds = %44
  %98 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 192, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 144, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret ptr %98
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 16}
!10 = !{!"", !11, i64 0, !6, i64 8, !11, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!10, !6, i64 24}
!14 = !{!10, !6, i64 8}
!15 = !{!11, !11, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!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"

@Rcs_calloc = external local_unnamed_addr global ptr, align 8
@__const.RcsMesh_createBox.vertexIndex = external hidden unnamed_addr constant [36 x i32], align 16
@__const.RcsMesh_createBox.verts = external hidden unnamed_addr constant [24 x double], align 16

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

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @RcsMesh_createBox(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = load ptr, ptr @Rcs_calloc, align 8, !tbaa !5
  %3 = tail call ptr %2(i64 noundef 1, i64 noundef 32) #2
  %4 = getelementptr inbounds i8, ptr %3, i64 16
  store i32 12, ptr %4, align 8, !tbaa !9
  store i32 8, ptr %3, align 8, !tbaa !12
  %5 = load ptr, ptr @Rcs_calloc, align 8, !tbaa !5
  %6 = tail call ptr %5(i64 noundef 36, i64 noundef 4) #2
  %7 = getelementptr inbounds i8, ptr %3, i64 24
  store ptr %6, ptr %7, align 8, !tbaa !13
  %8 = load ptr, ptr @Rcs_calloc, align 8, !tbaa !5
  %9 = load i32, ptr %3, align 8, !tbaa !12
  %10 = mul i32 %9, 3
  %11 = zext i32 %10 to i64
  %12 = tail call ptr %8(i64 noundef %11, i64 noundef 8) #2
  %13 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %12, ptr %13, align 8, !tbaa !14
  %14 = load ptr, ptr %7, align 8, !tbaa !13
  %15 = load i32, ptr %4, align 8, !tbaa !9
  %16 = mul i32 %15, 3
  %17 = zext i32 %16 to i64
  %18 = shl nuw nsw i64 %17, 2
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr nonnull align 16 @__const.RcsMesh_createBox.vertexIndex, i64 %18, i1 false)
  %19 = load ptr, ptr %13, align 8, !tbaa !14
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  %21 = getelementptr inbounds i8, ptr %0, i64 16
  %22 = load double, ptr @__const.RcsMesh_createBox.verts, align 16, !tbaa !15
  %23 = load double, ptr %0, align 8, !tbaa !15
  %24 = fmul double %22, %23
  store double %24, ptr %19, align 8, !tbaa !15
  %25 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 8), align 8, !tbaa !15
  %26 = load double, ptr %20, align 8, !tbaa !15
  %27 = fmul double %25, %26
  %28 = getelementptr inbounds i8, ptr %19, i64 8
  store double %27, ptr %28, align 8, !tbaa !15
  %29 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 16), align 16, !tbaa !15
  %30 = load double, ptr %21, align 8, !tbaa !15
  %31 = fmul double %29, %30
  %32 = getelementptr inbounds i8, ptr %19, i64 16
  store double %31, ptr %32, align 8, !tbaa !15
  %33 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 24), align 8, !tbaa !15
  %34 = load double, ptr %0, align 8, !tbaa !15
  %35 = fmul double %33, %34
  %36 = getelementptr inbounds i8, ptr %19, i64 24
  store double %35, ptr %36, align 8, !tbaa !15
  %37 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 32), align 16, !tbaa !15
  %38 = load double, ptr %20, align 8, !tbaa !15
  %39 = fmul double %37, %38
  %40 = getelementptr inbounds i8, ptr %19, i64 32
  store double %39, ptr %40, align 8, !tbaa !15
  %41 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 40), align 8, !tbaa !15
  %42 = load double, ptr %21, align 8, !tbaa !15
  %43 = fmul double %41, %42
  %44 = getelementptr inbounds i8, ptr %19, i64 40
  store double %43, ptr %44, align 8, !tbaa !15
  %45 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 48), align 16, !tbaa !15
  %46 = load double, ptr %0, align 8, !tbaa !15
  %47 = fmul double %45, %46
  %48 = getelementptr inbounds i8, ptr %19, i64 48
  store double %47, ptr %48, align 8, !tbaa !15
  %49 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 56), align 8, !tbaa !15
  %50 = load double, ptr %20, align 8, !tbaa !15
  %51 = fmul double %49, %50
  %52 = getelementptr inbounds i8, ptr %19, i64 56
  store double %51, ptr %52, align 8, !tbaa !15
  %53 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 64), align 16, !tbaa !15
  %54 = load double, ptr %21, align 8, !tbaa !15
  %55 = fmul double %53, %54
  %56 = getelementptr inbounds i8, ptr %19, i64 64
  store double %55, ptr %56, align 8, !tbaa !15
  %57 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 72), align 8, !tbaa !15
  %58 = load double, ptr %0, align 8, !tbaa !15
  %59 = fmul double %57, %58
  %60 = getelementptr inbounds i8, ptr %19, i64 72
  store double %59, ptr %60, align 8, !tbaa !15
  %61 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 80), align 16, !tbaa !15
  %62 = load double, ptr %20, align 8, !tbaa !15
  %63 = fmul double %61, %62
  %64 = getelementptr inbounds i8, ptr %19, i64 80
  store double %63, ptr %64, align 8, !tbaa !15
  %65 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 88), align 8, !tbaa !15
  %66 = load double, ptr %21, align 8, !tbaa !15
  %67 = fmul double %65, %66
  %68 = getelementptr inbounds i8, ptr %19, i64 88
  store double %67, ptr %68, align 8, !tbaa !15
  %69 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 96), align 16, !tbaa !15
  %70 = load double, ptr %0, align 8, !tbaa !15
  %71 = fmul double %69, %70
  %72 = getelementptr inbounds i8, ptr %19, i64 96
  store double %71, ptr %72, align 8, !tbaa !15
  %73 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 104), align 8, !tbaa !15
  %74 = load double, ptr %20, align 8, !tbaa !15
  %75 = fmul double %73, %74
  %76 = getelementptr inbounds i8, ptr %19, i64 104
  store double %75, ptr %76, align 8, !tbaa !15
  %77 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 112), align 16, !tbaa !15
  %78 = load double, ptr %21, align 8, !tbaa !15
  %79 = fmul double %77, %78
  %80 = getelementptr inbounds i8, ptr %19, i64 112
  store double %79, ptr %80, align 8, !tbaa !15
  %81 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 120), align 8, !tbaa !15
  %82 = load double, ptr %0, align 8, !tbaa !15
  %83 = fmul double %81, %82
  %84 = getelementptr inbounds i8, ptr %19, i64 120
  store double %83, ptr %84, align 8, !tbaa !15
  %85 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 128), align 16, !tbaa !15
  %86 = load double, ptr %20, align 8, !tbaa !15
  %87 = fmul double %85, %86
  %88 = getelementptr inbounds i8, ptr %19, i64 128
  store double %87, ptr %88, align 8, !tbaa !15
  %89 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 136), align 8, !tbaa !15
  %90 = load double, ptr %21, align 8, !tbaa !15
  %91 = fmul double %89, %90
  %92 = getelementptr inbounds i8, ptr %19, i64 136
  store double %91, ptr %92, align 8, !tbaa !15
  %93 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 144), align 16, !tbaa !15
  %94 = load double, ptr %0, align 8, !tbaa !15
  %95 = fmul double %93, %94
  %96 = getelementptr inbounds i8, ptr %19, i64 144
  store double %95, ptr %96, align 8, !tbaa !15
  %97 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 152), align 8, !tbaa !15
  %98 = load double, ptr %20, align 8, !tbaa !15
  %99 = fmul double %97, %98
  %100 = getelementptr inbounds i8, ptr %19, i64 152
  store double %99, ptr %100, align 8, !tbaa !15
  %101 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 160), align 16, !tbaa !15
  %102 = load double, ptr %21, align 8, !tbaa !15
  %103 = fmul double %101, %102
  %104 = getelementptr inbounds i8, ptr %19, i64 160
  store double %103, ptr %104, align 8, !tbaa !15
  %105 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 168), align 8, !tbaa !15
  %106 = load double, ptr %0, align 8, !tbaa !15
  %107 = fmul double %105, %106
  %108 = getelementptr inbounds i8, ptr %19, i64 168
  store double %107, ptr %108, align 8, !tbaa !15
  %109 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 176), align 16, !tbaa !15
  %110 = load double, ptr %20, align 8, !tbaa !15
  %111 = fmul double %109, %110
  %112 = getelementptr inbounds i8, ptr %19, i64 176
  store double %111, ptr %112, align 8, !tbaa !15
  %113 = load double, ptr getelementptr inbounds (i8, ptr @__const.RcsMesh_createBox.verts, i64 184), align 8, !tbaa !15
  %114 = load double, ptr %21, align 8, !tbaa !15
  %115 = fmul double %113, %114
  %116 = getelementptr inbounds i8, ptr %19, i64 184
  store double %115, ptr %116, align 8, !tbaa !15
  ret ptr %3
}

attributes #0 = { mustprogress nocallback nofree 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 = { 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 16}
!10 = !{!"", !11, i64 0, !6, i64 8, !11, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!10, !6, i64 24}
!14 = !{!10, !6, i64 8}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass