; LLVM IR from Slingshot-Physics/slingshot-community :: common/geometry/src (geometry_type_converters)

; 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.geometry::types::polygon50_t" = type { i32, [50 x %class.Vector3] }
%class.Vector3 = type { [3 x float] }
%struct.polygon50 = type { i32, [50 x %struct.vector3] }
%struct.vector3 = type { [3 x float] }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8geometry10converters6to_podERK7Vector3P7vector3(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8geometry10converters6to_podERKNS_5types11polygon50_tEP9polygon50(ptr noundef nonnull align 4 dereferenceable(604) %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %"struct.geometry::types::polygon50_t", ptr %6, i32 0, i32 0
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.polygon50, ptr %9, i32 0, i32 0
  store i32 %8, ptr %10, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !14
  br label %11

11:                                               ; preds = %29, %2
  %12 = load i32, ptr %5, align 4, !tbaa !14
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.polygon50, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 4, !tbaa !12
  %16 = icmp ult i32 %12, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %32

18:                                               ; preds = %11
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.geometry::types::polygon50_t", ptr %19, i32 0, i32 1
  %21 = load i32, ptr %5, align 4, !tbaa !14
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds [50 x %class.Vector3], ptr %20, i64 0, i64 %22
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.polygon50, ptr %24, i32 0, i32 1
  %26 = load i32, ptr %5, align 4, !tbaa !14
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds [50 x %struct.vector3], ptr %25, i64 0, i64 %27
  call void @_ZN8geometry10converters6to_podERK7Vector3P7vector3(ptr noundef nonnull align 4 dereferenceable(12) %23, ptr noundef %28)
  br label %29

29:                                               ; preds = %18
  %30 = load i32, ptr %5, align 4, !tbaa !14
  %31 = add i32 %30, 1
  store i32 %31, ptr %5, align 4, !tbaa !14
  br label %11, !llvm.loop !15

32:                                               ; preds = %17
  ret void
}

attributes #0 = { mustprogress 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTSN8geometry5types11polygon50_tE", !11, i64 0, !7, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"_ZTS9polygon50", !11, i64 0, !7, i64 4}
!14 = !{!11, !11, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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"

%class.Vector3 = type { [3 x float] }
%struct.vector3 = type { [3 x float] }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8geometry10converters6to_podERK7Vector3P7vector3(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8geometry10converters6to_podERKNS_5types11polygon50_tEP9polygon50(ptr noundef nonnull align 4 dereferenceable(604) %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = load i32, ptr %0, align 4, !tbaa !5
  store i32 %3, ptr %1, align 4, !tbaa !10
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  br label %6

._crit_edge:                                      ; preds = %6, %2
  ret void

6:                                                ; preds = %.lr.ph, %6
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %6 ]
  %7 = getelementptr inbounds [50 x %class.Vector3], ptr %4, i64 0, i64 %indvars.iv
  %8 = getelementptr inbounds [50 x %struct.vector3], ptr %5, i64 0, i64 %indvars.iv
  tail call void @_ZN8geometry10converters6to_podERK7Vector3P7vector3(ptr noundef nonnull align 4 dereferenceable(12) %7, ptr noundef nonnull %8)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %9 = load i32, ptr %1, align 4, !tbaa !10
  %10 = zext i32 %9 to i64
  %11 = icmp ult i64 %indvars.iv.next, %10
  br i1 %11, label %6, label %._crit_edge, !llvm.loop !12
}

attributes #0 = { mustprogress 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" }

!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, !7, i64 0}
!6 = !{!"_ZTSN8geometry5types11polygon50_tE", !7, i64 0, !8, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !7, i64 0}
!11 = !{!"_ZTS9polygon50", !7, i64 0, !8, i64 4}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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