; LLVM IR from achilles288/robot-monitor-graphics :: src/base/mesh.ll (ZN3rmg4MeshC2ERKS0_)

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

%"class.rmg::Mesh" = type <{ ptr, ptr, ptr, ptr, i32, [4 x i8], ptr, i32, [4 x i8] }>

@_ZTVN3rmg4MeshE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #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: mustprogress nounwind uwtable
define dso_local void @_ZN3rmg4MeshC2ERKS0_(ptr noundef nonnull align 8 dereferenceable(52) %0, ptr noundef nonnull align 8 dereferenceable(52) %1) unnamed_addr #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN3rmg4MeshE, i32 0, i32 0, i32 2), ptr %5, align 8, !tbaa !9
  %6 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 1
  store ptr null, ptr %6, align 8, !tbaa !11
  %7 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 2
  store ptr null, ptr %7, align 8, !tbaa !14
  %8 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 3
  store ptr null, ptr %8, align 8, !tbaa !15
  %9 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 4
  store i32 0, ptr %9, align 8, !tbaa !16
  %10 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 6
  store ptr null, ptr %10, align 8, !tbaa !17
  %11 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 7
  store i32 0, ptr %11, align 8, !tbaa !18
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %"class.rmg::Mesh", ptr %12, i32 0, i32 4
  %14 = load i32, ptr %13, align 8, !tbaa !16
  %15 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 4
  store i32 %14, ptr %15, align 8, !tbaa !16
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %"class.rmg::Mesh", ptr %16, i32 0, i32 7
  %18 = load i32, ptr %17, align 8, !tbaa !18
  %19 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 7
  store i32 %18, ptr %19, align 8, !tbaa !18
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %"class.rmg::Mesh", ptr %20, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %40

24:                                               ; preds = %2
  %25 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 4
  %26 = load i32, ptr %25, align 8, !tbaa !16
  %27 = zext i32 %26 to i64
  %28 = mul i64 12, %27
  %29 = call noalias ptr @malloc(i64 noundef %28) #3
  %30 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 1
  store ptr %29, ptr %30, align 8, !tbaa !11
  %31 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %"class.rmg::Mesh", ptr %33, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !11
  %36 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 4
  %37 = load i32, ptr %36, align 8, !tbaa !16
  %38 = zext i32 %37 to i64
  %39 = mul i64 12, %38
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %32, ptr align 4 %35, i64 %39, i1 false)
  br label %40

40:                                               ; preds = %24, %2
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %"class.rmg::Mesh", ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !14
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %61

45:                                               ; preds = %40
  %46 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 4
  %47 = load i32, ptr %46, align 8, !tbaa !16
  %48 = zext i32 %47 to i64
  %49 = mul i64 12, %48
  %50 = call noalias ptr @malloc(i64 noundef %49) #3
  %51 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 2
  store ptr %50, ptr %51, align 8, !tbaa !14
  %52 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 2
  %53 = load ptr, ptr %52, align 8, !tbaa !14
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %"class.rmg::Mesh", ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !14
  %57 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 4
  %58 = load i32, ptr %57, align 8, !tbaa !16
  %59 = zext i32 %58 to i64
  %60 = mul i64 12, %59
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %53, ptr align 4 %56, i64 %60, i1 false)
  br label %61

61:                                               ; preds = %45, %40
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %"class.rmg::Mesh", ptr %62, i32 0, i32 3
  %64 = load ptr, ptr %63, align 8, !tbaa !15
  %65 = icmp ne ptr %64, null
  br i1 %65, label %66, label %82

66:                                               ; preds = %61
  %67 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 4
  %68 = load i32, ptr %67, align 8, !tbaa !16
  %69 = zext i32 %68 to i64
  %70 = mul i64 8, %69
  %71 = call noalias ptr @malloc(i64 noundef %70) #3
  %72 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 3
  store ptr %71, ptr %72, align 8, !tbaa !15
  %73 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 3
  %74 = load ptr, ptr %73, align 8, !tbaa !15
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %"class.rmg::Mesh", ptr %75, i32 0, i32 3
  %77 = load ptr, ptr %76, align 8, !tbaa !15
  %78 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 4
  %79 = load i32, ptr %78, align 8, !tbaa !16
  %80 = zext i32 %79 to i64
  %81 = mul i64 8, %80
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %74, ptr align 4 %77, i64 %81, i1 false)
  br label %82

82:                                               ; preds = %66, %61
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %"class.rmg::Mesh", ptr %83, i32 0, i32 6
  %85 = load ptr, ptr %84, align 8, !tbaa !17
  %86 = icmp ne ptr %85, null
  br i1 %86, label %87, label %103

87:                                               ; preds = %82
  %88 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 7
  %89 = load i32, ptr %88, align 8, !tbaa !18
  %90 = zext i32 %89 to i64
  %91 = mul i64 4, %90
  %92 = call noalias ptr @malloc(i64 noundef %91) #3
  %93 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 6
  store ptr %92, ptr %93, align 8, !tbaa !17
  %94 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 6
  %95 = load ptr, ptr %94, align 8, !tbaa !17
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds %"class.rmg::Mesh", ptr %96, i32 0, i32 6
  %98 = load ptr, ptr %97, align 8, !tbaa !17
  %99 = getelementptr inbounds %"class.rmg::Mesh", ptr %5, i32 0, i32 7
  %100 = load i32, ptr %99, align 8, !tbaa !18
  %101 = zext i32 %100 to i64
  %102 = mul i64 4, %101
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %95, ptr align 4 %98, i64 %102, i1 false)
  br label %103

103:                                              ; preds = %87, %82
  ret void
}

attributes #0 = { nounwind allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 allocsize(0) }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTSN3rmg4MeshE", !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !6, i64 40, !13, i64 48}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 24}
!16 = !{!12, !13, i64 32}
!17 = !{!12, !6, i64 40}
!18 = !{!12, !13, i64 48}


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

@_ZTVN3rmg4MeshE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nofree nounwind willreturn uwtable
define dso_local void @_ZN3rmg4MeshC2ERKS0_(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(52) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(52) %1) unnamed_addr #2 align 2 {
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN3rmg4MeshE, i64 16), ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr null, ptr %7, align 8, !tbaa !8
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 0, ptr %8, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %1, i64 32
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(28) %3, i8 0, i64 28, i1 false)
  %10 = load i32, ptr %9, align 8, !tbaa !14
  store i32 %10, ptr %6, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %1, i64 48
  %12 = load i32, ptr %11, align 8, !tbaa !13
  store i32 %12, ptr %8, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %1, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %.not = icmp eq ptr %14, null
  br i1 %.not, label %20, label %15

15:                                               ; preds = %2
  %16 = zext i32 %10 to i64
  %17 = mul nuw nsw i64 %16, 12
  %18 = tail call noalias ptr @malloc(i64 noundef %17) #4
  store ptr %18, ptr %3, align 8, !tbaa !15
  %19 = load ptr, ptr %13, align 8, !tbaa !15
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 4 %19, i64 %17, i1 false)
  br label %20

20:                                               ; preds = %15, %2
  %21 = getelementptr inbounds i8, ptr %1, i64 16
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  %.not11 = icmp eq ptr %22, null
  br i1 %.not11, label %28, label %23

23:                                               ; preds = %20
  %24 = zext i32 %10 to i64
  %25 = mul nuw nsw i64 %24, 12
  %26 = tail call noalias ptr @malloc(i64 noundef %25) #4
  store ptr %26, ptr %4, align 8, !tbaa !16
  %27 = load ptr, ptr %21, align 8, !tbaa !16
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %26, ptr align 4 %27, i64 %25, i1 false)
  br label %28

28:                                               ; preds = %23, %20
  %29 = getelementptr inbounds i8, ptr %1, i64 24
  %30 = load ptr, ptr %29, align 8, !tbaa !17
  %.not12 = icmp eq ptr %30, null
  br i1 %.not12, label %36, label %31

31:                                               ; preds = %28
  %32 = zext i32 %10 to i64
  %33 = shl nuw nsw i64 %32, 3
  %34 = tail call noalias ptr @malloc(i64 noundef %33) #4
  store ptr %34, ptr %5, align 8, !tbaa !17
  %35 = load ptr, ptr %29, align 8, !tbaa !17
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %34, ptr align 4 %35, i64 %33, i1 false)
  br label %36

36:                                               ; preds = %31, %28
  %37 = getelementptr inbounds i8, ptr %1, i64 40
  %38 = load ptr, ptr %37, align 8, !tbaa !8
  %.not13 = icmp eq ptr %38, null
  br i1 %.not13, label %44, label %39

39:                                               ; preds = %36
  %40 = zext i32 %12 to i64
  %41 = shl nuw nsw i64 %40, 2
  %42 = tail call noalias ptr @malloc(i64 noundef %41) #4
  store ptr %42, ptr %7, align 8, !tbaa !8
  %43 = load ptr, ptr %37, align 8, !tbaa !8
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %42, ptr align 4 %43, i64 %41, i1 false)
  br label %44

44:                                               ; preds = %39, %36
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind allocsize(0) }

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 40}
!9 = !{!"_ZTSN3rmg4MeshE", !10, i64 8, !10, i64 16, !10, i64 24, !12, i64 32, !10, i64 40, !12, i64 48}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"int", !11, i64 0}
!13 = !{!9, !12, i64 48}
!14 = !{!9, !12, i64 32}
!15 = !{!9, !10, i64 8}
!16 = !{!9, !10, i64 16}
!17 = !{!9, !10, i64 24}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass