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

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

; 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: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN4agge9rectangle6vertexEPfS1_(ptr noundef nonnull align 4 dereferenceable(20) %0, ptr noundef %1, ptr noundef %2) #1 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::rectangle", 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 = load i32, ptr %8, align 4, !tbaa !12
  switch i32 %13, label %14 [
    i32 4, label %40
    i32 5, label %42
  ]

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

40:                                               ; preds = %3
  %41 = getelementptr inbounds %"class.agge::rectangle", ptr %10, i32 0, i32 1
  store i32 5, ptr %41, align 4, !tbaa !9
  store i32 48, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %43

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

43:                                               ; preds = %42, %40, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %44 = load i32, ptr %4, align 4
  ret i32 %44
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"_ZTSN4agge9rectangleE", !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, 49) i32 @_ZN4agge9rectangle6vertexEPfS1_(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 4, label %19
    i32 5, label %20
  ]

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

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

20:                                               ; preds = %3, %19, %6
  %.0 = phi i32 [ %18, %6 ], [ 48, %19 ], [ 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 = !{!"_ZTSN4agge9rectangleE", !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