; LLVM IR from tyoma/agge :: src/agge/figures.ll (ZN4agge4line6vertexEPfS1_)

; 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.agge::line" = type { [2 x %"struct.agge::point"], i32 }
%"struct.agge::point" = type { float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN4agge4line6vertexEPfS1_(ptr noundef nonnull align 4 dereferenceable(20) %0, ptr noundef %1, ptr noundef %2) #0 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %11 = getelementptr inbounds %"class.agge::line", ptr %10, i32 0, i32 1
  %12 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %12, ptr %8, align 4, !tbaa !12
  %13 = getelementptr inbounds %"class.agge::line", ptr %10, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !9
  switch i32 %14, label %15 [
    i32 2, label %37
    i32 3, label %39
  ]

15:                                               ; preds = %3
  %16 = getelementptr inbounds %"class.agge::line", ptr %10, i32 0, i32 0
  %17 = load i32, ptr %8, align 4, !tbaa !12
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [2 x %"struct.agge::point"], ptr %16, i64 0, i64 %18
  %20 = getelementptr inbounds %"struct.agge::point", ptr %19, i32 0, i32 0
  %21 = load float, ptr %20, align 4, !tbaa !13
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  store float %21, ptr %22, align 4, !tbaa !16
  %23 = getelementptr inbounds %"class.agge::line", ptr %10, i32 0, i32 0
  %24 = load i32, ptr %8, align 4, !tbaa !12
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [2 x %"struct.agge::point"], ptr %23, i64 0, i64 %25
  %27 = getelementptr inbounds %"struct.agge::point", ptr %26, i32 0, i32 1
  %28 = load float, ptr %27, align 4, !tbaa !17
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  store float %28, ptr %29, align 4, !tbaa !16
  %30 = load i32, ptr %8, align 4, !tbaa !12
  %31 = add nsw i32 %30, 1
  %32 = getelementptr inbounds %"class.agge::line", ptr %10, i32 0, i32 1
  store i32 %31, ptr %32, align 4, !tbaa !9
  %33 = load i32, ptr %8, align 4, !tbaa !12
  %34 = icmp eq i32 %33, 0
  %35 = zext i1 %34 to i64
  %36 = select i1 %34, i32 1, i32 2
  store i32 %36, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %40

37:                                               ; preds = %3
  %38 = getelementptr inbounds %"class.agge::line", ptr %10, i32 0, i32 1
  store i32 3, ptr %38, align 4, !tbaa !9
  store i32 16, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %40

39:                                               ; preds = %3
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %40

40:                                               ; preds = %39, %37, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %41 = load i32, ptr %4, align 4
  ret i32 %41
}

; 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

attributes #0 = { 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 #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 16}
!10 = !{!"_ZTSN4agge4lineE", !7, i64 0, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"_ZTSN4agge5pointIfEE", !15, i64 0, !15, i64 4}
!15 = !{!"float", !7, i64 0}
!16 = !{!15, !15, i64 0}
!17 = !{!14, !15, i64 4}


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

%"struct.agge::point" = type { float, float }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef range(i32 0, 17) i32 @_ZN4agge4line6vertexEPfS1_(ptr nocapture noundef nonnull align 4 dereferenceable(20) %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load i32, ptr %4, align 4, !tbaa !5
  switch i32 %5, label %6 [
    i32 2, label %15
    i32 3, label %16
  ]

6:                                                ; preds = %3
  %7 = sext i32 %5 to i64
  %8 = getelementptr inbounds [2 x %"struct.agge::point"], ptr %0, i64 0, i64 %7
  %9 = load float, ptr %8, align 4, !tbaa !10
  store float %9, ptr %1, align 4, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %8, i64 4
  %11 = load float, ptr %10, align 4, !tbaa !14
  store float %11, ptr %2, align 4, !tbaa !13
  %12 = add nsw i32 %5, 1
  store i32 %12, ptr %4, align 4, !tbaa !5
  %13 = icmp eq i32 %5, 0
  %14 = select i1 %13, i32 1, i32 2
  br label %16

15:                                               ; preds = %3
  store i32 3, ptr %4, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %3, %15, %6
  %.0 = phi i32 [ %14, %6 ], [ 16, %15 ], [ 0, %3 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !9, i64 16}
!6 = !{!"_ZTSN4agge4lineE", !7, i64 0, !9, i64 16}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!11, !12, i64 0}
!11 = !{!"_ZTSN4agge5pointIfEE", !12, i64 0, !12, i64 4}
!12 = !{!"float", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!11, !12, i64 4}


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