; LLVM IR from NavInfoNC/nc-geo :: src/static_polygon.ll (ZN13StaticPolygon12initWithGridEiii)

; 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.StaticPolygon = type { ptr, i32, %struct.Rect, i8, i64 }
%struct.Rect = type { i32, i32, i32, i32 }
%struct.Point = type { i32, i32 }

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__PRETTY_FUNCTION__._ZN13StaticPolygon12initWithGridEiii = external hidden unnamed_addr constant [48 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN13StaticPolygon12initWithGridEiii(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #2 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  %9 = load ptr, ptr %5, align 8
  %10 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %4
  br label %16

14:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 73, ptr noundef @__PRETTY_FUNCTION__._ZN13StaticPolygon12initWithGridEiii) #3
  unreachable

15:                                               ; No predecessors!
  br label %16

16:                                               ; preds = %15, %13
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = mul nsw i32 %17, %18
  %20 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 2
  %21 = getelementptr inbounds %struct.Rect, ptr %20, i32 0, i32 0
  store i32 %19, ptr %21, align 4, !tbaa !16
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = mul nsw i32 %22, %23
  %25 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 2
  %26 = getelementptr inbounds %struct.Rect, ptr %25, i32 0, i32 1
  store i32 %24, ptr %26, align 4, !tbaa !17
  %27 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 2
  %28 = getelementptr inbounds %struct.Rect, ptr %27, i32 0, i32 0
  %29 = load i32, ptr %28, align 4, !tbaa !16
  %30 = load i32, ptr %8, align 4, !tbaa !9
  %31 = add nsw i32 %29, %30
  %32 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 2
  %33 = getelementptr inbounds %struct.Rect, ptr %32, i32 0, i32 2
  store i32 %31, ptr %33, align 4, !tbaa !18
  %34 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 2
  %35 = getelementptr inbounds %struct.Rect, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !17
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = add nsw i32 %36, %37
  %39 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 2
  %40 = getelementptr inbounds %struct.Rect, ptr %39, i32 0, i32 3
  store i32 %38, ptr %40, align 4, !tbaa !19
  %41 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 1
  store i32 4, ptr %41, align 8, !tbaa !20
  %42 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 1
  %43 = load i32, ptr %42, align 8, !tbaa !20
  %44 = sext i32 %43 to i64
  %45 = mul i64 %44, 8
  %46 = call noalias ptr @malloc(i64 noundef %45) #4
  %47 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 0
  store ptr %46, ptr %47, align 8, !tbaa !11
  %48 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 2
  %49 = getelementptr inbounds %struct.Rect, ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 4, !tbaa !16
  %51 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !11
  %53 = getelementptr inbounds %struct.Point, ptr %52, i64 0
  %54 = getelementptr inbounds %struct.Point, ptr %53, i32 0, i32 0
  store i32 %50, ptr %54, align 4, !tbaa !21
  %55 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 2
  %56 = getelementptr inbounds %struct.Rect, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 4, !tbaa !17
  %58 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 0
  %59 = load ptr, ptr %58, align 8, !tbaa !11
  %60 = getelementptr inbounds %struct.Point, ptr %59, i64 0
  %61 = getelementptr inbounds %struct.Point, ptr %60, i32 0, i32 1
  store i32 %57, ptr %61, align 4, !tbaa !23
  %62 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 2
  %63 = getelementptr inbounds %struct.Rect, ptr %62, i32 0, i32 0
  %64 = load i32, ptr %63, align 4, !tbaa !16
  %65 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !11
  %67 = getelementptr inbounds %struct.Point, ptr %66, i64 1
  %68 = getelementptr inbounds %struct.Point, ptr %67, i32 0, i32 0
  store i32 %64, ptr %68, align 4, !tbaa !21
  %69 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 2
  %70 = getelementptr inbounds %struct.Rect, ptr %69, i32 0, i32 3
  %71 = load i32, ptr %70, align 4, !tbaa !19
  %72 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !11
  %74 = getelementptr inbounds %struct.Point, ptr %73, i64 1
  %75 = getelementptr inbounds %struct.Point, ptr %74, i32 0, i32 1
  store i32 %71, ptr %75, align 4, !tbaa !23
  %76 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 2
  %77 = getelementptr inbounds %struct.Rect, ptr %76, i32 0, i32 2
  %78 = load i32, ptr %77, align 4, !tbaa !18
  %79 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !11
  %81 = getelementptr inbounds %struct.Point, ptr %80, i64 2
  %82 = getelementptr inbounds %struct.Point, ptr %81, i32 0, i32 0
  store i32 %78, ptr %82, align 4, !tbaa !21
  %83 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 2
  %84 = getelementptr inbounds %struct.Rect, ptr %83, i32 0, i32 3
  %85 = load i32, ptr %84, align 4, !tbaa !19
  %86 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !11
  %88 = getelementptr inbounds %struct.Point, ptr %87, i64 2
  %89 = getelementptr inbounds %struct.Point, ptr %88, i32 0, i32 1
  store i32 %85, ptr %89, align 4, !tbaa !23
  %90 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 2
  %91 = getelementptr inbounds %struct.Rect, ptr %90, i32 0, i32 2
  %92 = load i32, ptr %91, align 4, !tbaa !18
  %93 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !11
  %95 = getelementptr inbounds %struct.Point, ptr %94, i64 3
  %96 = getelementptr inbounds %struct.Point, ptr %95, i32 0, i32 0
  store i32 %92, ptr %96, align 4, !tbaa !21
  %97 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 2
  %98 = getelementptr inbounds %struct.Rect, ptr %97, i32 0, i32 1
  %99 = load i32, ptr %98, align 4, !tbaa !17
  %100 = getelementptr inbounds %class.StaticPolygon, ptr %9, i32 0, i32 0
  %101 = load ptr, ptr %100, align 8, !tbaa !11
  %102 = getelementptr inbounds %struct.Point, ptr %101, i64 3
  %103 = getelementptr inbounds %struct.Point, ptr %102, i32 0, i32 1
  store i32 %99, ptr %103, align 4, !tbaa !23
  ret void
}

attributes #0 = { noreturn 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 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 #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 = { noreturn nounwind }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS13StaticPolygon", !6, i64 0, !10, i64 8, !13, i64 12, !14, i64 28, !15, i64 32}
!13 = !{!"_ZTS4Rect", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"long long", !7, i64 0}
!16 = !{!12, !10, i64 12}
!17 = !{!12, !10, i64 16}
!18 = !{!12, !10, i64 20}
!19 = !{!12, !10, i64 24}
!20 = !{!12, !10, i64 8}
!21 = !{!22, !10, i64 0}
!22 = !{!"_ZTS5Point", !10, i64 0, !10, i64 4}
!23 = !{!22, !10, 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"

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__PRETTY_FUNCTION__._ZN13StaticPolygon12initWithGridEiii = external hidden unnamed_addr constant [48 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN13StaticPolygon12initWithGridEiii(ptr nocapture noundef nonnull align 8 dereferenceable(40) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #2 align 2 {
  %5 = load ptr, ptr %0, align 8, !tbaa !5
  %6 = icmp eq ptr %5, null
  br i1 %6, label %8, label %7

7:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 73, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN13StaticPolygon12initWithGridEiii) #3
  unreachable

8:                                                ; preds = %4
  %9 = mul nsw i32 %3, %1
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %9, ptr %10, align 4, !tbaa !14
  %11 = mul nsw i32 %3, %2
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %11, ptr %12, align 8, !tbaa !15
  %13 = add nsw i32 %9, %3
  %14 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %13, ptr %14, align 4, !tbaa !16
  %15 = add nsw i32 %11, %3
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %15, ptr %16, align 8, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 4, ptr %17, align 8, !tbaa !18
  %18 = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #4
  store ptr %18, ptr %0, align 8, !tbaa !5
  store i32 %9, ptr %18, align 4, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %18, i64 4
  store i32 %11, ptr %19, align 4, !tbaa !21
  %20 = getelementptr inbounds i8, ptr %18, i64 8
  store i32 %9, ptr %20, align 4, !tbaa !19
  %21 = getelementptr inbounds i8, ptr %18, i64 12
  store i32 %15, ptr %21, align 4, !tbaa !21
  %22 = getelementptr inbounds i8, ptr %18, i64 16
  store i32 %13, ptr %22, align 4, !tbaa !19
  %23 = getelementptr inbounds i8, ptr %18, i64 20
  store i32 %15, ptr %23, align 4, !tbaa !21
  %24 = getelementptr inbounds i8, ptr %18, i64 24
  store i32 %13, ptr %24, align 4, !tbaa !19
  %25 = getelementptr inbounds i8, ptr %18, i64 28
  store i32 %11, ptr %25, align 4, !tbaa !21
  ret void
}

attributes #0 = { noreturn 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 = { 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 #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 = { noreturn nounwind }
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, !7, i64 0}
!6 = !{!"_ZTS13StaticPolygon", !7, i64 0, !10, i64 8, !11, i64 12, !12, i64 28, !13, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS4Rect", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!12 = !{!"bool", !8, i64 0}
!13 = !{!"long long", !8, i64 0}
!14 = !{!6, !10, i64 12}
!15 = !{!6, !10, i64 16}
!16 = !{!6, !10, i64 20}
!17 = !{!6, !10, i64 24}
!18 = !{!6, !10, i64 8}
!19 = !{!20, !10, i64 0}
!20 = !{!"_ZTS5Point", !10, i64 0, !10, i64 4}
!21 = !{!20, !10, i64 4}


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