; 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
@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_clone = external hidden unnamed_addr constant [14 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [33 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 ptr @RcsMesh_clone(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = icmp eq ptr %5, null
  br i1 %6, label %7, label %25

7:                                                ; preds = %1
  br label %8

8:                                                ; preds = %7
  %9 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %13

11:                                               ; preds = %8
  %12 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  call void (i32, ptr, ptr, i32, ptr, ...) %12(i32 noundef 4, ptr noundef @.str, ptr noundef @__func__.RcsMesh_clone, i32 noundef 1003, ptr noundef @.str.48)
  br label %13

13:                                               ; preds = %11, %8
  %14 = load i32, ptr @RcsLogLevel, align 4, !tbaa !9
  %15 = icmp sle i32 4, %14
  br i1 %15, label %16, label %23

16:                                               ; preds = %13
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef @.str.2, ptr noundef @.str, ptr noundef @__func__.RcsMesh_clone, i32 noundef 1003) #4
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str.48) #4
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef @.str.3) #4
  br label %23

23:                                               ; preds = %16, %13
  br label %24

24:                                               ; preds = %23
  store ptr null, ptr %2, align 8
  br label %81

25:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %26 = load ptr, ptr @Rcs_calloc, align 8, !tbaa !5
  %27 = call ptr %26(i64 noundef 1, i64 noundef 32)
  store ptr %27, ptr %4, align 8, !tbaa !5
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.RcsMeshData, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !11
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.RcsMeshData, ptr %31, i32 0, i32 0
  store i32 %30, ptr %32, align 8, !tbaa !11
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.RcsMeshData, ptr %33, i32 0, i32 2
  %35 = load i32, ptr %34, align 8, !tbaa !13
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.RcsMeshData, ptr %36, i32 0, i32 2
  store i32 %35, ptr %37, align 8, !tbaa !13
  %38 = load ptr, ptr @Rcs_calloc, align 8, !tbaa !5
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.RcsMeshData, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 8, !tbaa !11
  %42 = mul i32 3, %41
  %43 = zext i32 %42 to i64
  %44 = call ptr %38(i64 noundef %43, i64 noundef 8)
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.RcsMeshData, ptr %45, i32 0, i32 1
  store ptr %44, ptr %46, align 8, !tbaa !14
  %47 = load ptr, ptr @Rcs_calloc, align 8, !tbaa !5
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.RcsMeshData, ptr %48, i32 0, i32 2
  %50 = load i32, ptr %49, align 8, !tbaa !13
  %51 = mul i32 3, %50
  %52 = zext i32 %51 to i64
  %53 = call ptr %47(i64 noundef %52, i64 noundef 4)
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.RcsMeshData, ptr %54, i32 0, i32 3
  store ptr %53, ptr %55, align 8, !tbaa !15
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.RcsMeshData, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !14
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.RcsMeshData, ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !14
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.RcsMeshData, ptr %62, i32 0, i32 0
  %64 = load i32, ptr %63, align 8, !tbaa !11
  %65 = mul i32 3, %64
  %66 = zext i32 %65 to i64
  %67 = mul i64 %66, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %58, ptr align 8 %61, i64 %67, i1 false)
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.RcsMeshData, ptr %68, i32 0, i32 3
  %70 = load ptr, ptr %69, align 8, !tbaa !15
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.RcsMeshData, ptr %71, i32 0, i32 3
  %73 = load ptr, ptr %72, align 8, !tbaa !15
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.RcsMeshData, ptr %74, i32 0, i32 2
  %76 = load i32, ptr %75, align 8, !tbaa !13
  %77 = mul i32 3, %76
  %78 = zext i32 %77 to i64
  %79 = mul i64 %78, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %70, ptr align 4 %73, i64 %79, i1 false)
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %80, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %81

81:                                               ; preds = %25, %24
  %82 = load ptr, ptr %2, align 8
  ret ptr %82
}

; 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) #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 16}
!14 = !{!12, !6, i64 8}
!15 = !{!12, !6, i64 24}


; 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
@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_clone = external hidden unnamed_addr constant [14 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [33 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 noundef ptr @RcsMesh_clone(ptr noundef readonly %0) local_unnamed_addr #1 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %3, label %16

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

5:                                                ; preds = %3
  tail call void (i32, ptr, ptr, i32, ptr, ...) %4(i32 noundef 4, ptr noundef nonnull @.str, ptr noundef nonnull @__func__.RcsMesh_clone, i32 noundef 1003, ptr noundef nonnull @.str.48) #3
  br label %6

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

9:                                                ; preds = %6
  %10 = load ptr, ptr @stderr, align 8, !tbaa !5
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str, ptr noundef nonnull @__func__.RcsMesh_clone, i32 noundef 1003) #4
  %12 = load ptr, ptr @stderr, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.48) #4
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.3) #4
  br label %48

16:                                               ; preds = %1
  %17 = load ptr, ptr @Rcs_calloc, align 8, !tbaa !5
  %18 = tail call ptr %17(i64 noundef 1, i64 noundef 32) #3
  %19 = load i32, ptr %0, align 8, !tbaa !11
  store i32 %19, ptr %18, align 8, !tbaa !11
  %20 = getelementptr inbounds i8, ptr %0, i64 16
  %21 = load i32, ptr %20, align 8, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %18, i64 16
  store i32 %21, ptr %22, align 8, !tbaa !13
  %23 = load ptr, ptr @Rcs_calloc, align 8, !tbaa !5
  %24 = mul i32 %19, 3
  %25 = zext i32 %24 to i64
  %26 = tail call ptr %23(i64 noundef %25, i64 noundef 8) #3
  %27 = getelementptr inbounds i8, ptr %18, i64 8
  store ptr %26, ptr %27, align 8, !tbaa !14
  %28 = load ptr, ptr @Rcs_calloc, align 8, !tbaa !5
  %29 = load i32, ptr %22, align 8, !tbaa !13
  %30 = mul i32 %29, 3
  %31 = zext i32 %30 to i64
  %32 = tail call ptr %28(i64 noundef %31, i64 noundef 4) #3
  %33 = getelementptr inbounds i8, ptr %18, i64 24
  store ptr %32, ptr %33, align 8, !tbaa !15
  %34 = load ptr, ptr %27, align 8, !tbaa !14
  %35 = getelementptr inbounds i8, ptr %0, i64 8
  %36 = load ptr, ptr %35, align 8, !tbaa !14
  %37 = load i32, ptr %18, align 8, !tbaa !11
  %38 = mul i32 %37, 3
  %39 = zext i32 %38 to i64
  %40 = shl nuw nsw i64 %39, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %34, ptr align 8 %36, i64 %40, i1 false)
  %41 = load ptr, ptr %33, align 8, !tbaa !15
  %42 = getelementptr inbounds i8, ptr %0, i64 24
  %43 = load ptr, ptr %42, align 8, !tbaa !15
  %44 = load i32, ptr %22, align 8, !tbaa !13
  %45 = mul i32 %44, 3
  %46 = zext i32 %45 to i64
  %47 = shl nuw nsw i64 %46, 2
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %41, ptr align 4 %43, i64 %47, i1 false)
  br label %48

48:                                               ; preds = %9, %6, %16
  %.0 = phi ptr [ %18, %16 ], [ null, %6 ], [ null, %9 ]
  ret ptr %.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) #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 16}
!14 = !{!12, !6, i64 8}
!15 = !{!12, !6, i64 24}


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