; LLVM IR from alibaba/GCanvas :: core/src/gcanvas/GTreemap.ll (ZN8GTreemap3AddERK5GSizeR5GRect)

; 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.GSize = type { i32, i32 }
%class.GTreemap = type { i32, i32, i32, i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN8GTreemap3AddERK5GSizeR5GRect(ptr noundef nonnull align 4 dereferenceable(20) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(16) %2) #0 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  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
  %8 = load ptr, ptr %5, align 8
  %9 = load ptr, ptr %7, align 8, !tbaa !5
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN5GRect7SetSizeERK5GSize(ptr noundef nonnull align 4 dereferenceable(16) %9, ptr noundef nonnull align 4 dereferenceable(8) %10)
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.GSize, ptr %11, i32 0, i32 0
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 2
  %15 = load i32, ptr %14, align 4, !tbaa !12
  %16 = icmp sgt i32 %13, %15
  br i1 %16, label %17, label %63

17:                                               ; preds = %3
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.GSize, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 0
  %22 = load i32, ptr %21, align 4, !tbaa !14
  %23 = icmp ugt i32 %20, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %17
  store i1 false, ptr %4, align 1
  br label %110

25:                                               ; preds = %17
  %26 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 4
  %27 = load i32, ptr %26, align 4, !tbaa !15
  %28 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 3
  %29 = load i32, ptr %28, align 4, !tbaa !16
  %30 = sub nsw i32 %29, %27
  store i32 %30, ptr %28, align 4, !tbaa !16
  %31 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 3
  %32 = load i32, ptr %31, align 4, !tbaa !16
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.GSize, ptr %33, i32 0, i32 1
  %35 = load i32, ptr %34, align 4, !tbaa !17
  %36 = icmp slt i32 %32, %35
  br i1 %36, label %37, label %43

37:                                               ; preds = %25
  %38 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 4
  %39 = load i32, ptr %38, align 4, !tbaa !15
  %40 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 3
  %41 = load i32, ptr %40, align 4, !tbaa !16
  %42 = add nsw i32 %41, %39
  store i32 %42, ptr %40, align 4, !tbaa !16
  store i1 false, ptr %4, align 1
  br label %110

43:                                               ; preds = %25
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 1
  %46 = load i32, ptr %45, align 4, !tbaa !18
  %47 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 3
  %48 = load i32, ptr %47, align 4, !tbaa !16
  %49 = sub i32 %46, %48
  call void @_ZN5GRect11SetPositionEii(ptr noundef nonnull align 4 dereferenceable(16) %44, i32 noundef 0, i32 noundef %49)
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.GSize, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 4, !tbaa !17
  %53 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 4
  store i32 %52, ptr %53, align 4, !tbaa !15
  %54 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 0
  %55 = load i32, ptr %54, align 4, !tbaa !14
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.GSize, ptr %56, i32 0, i32 0
  %58 = load i32, ptr %57, align 4, !tbaa !9
  %59 = sub i32 %55, %58
  %60 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 2
  store i32 %59, ptr %60, align 4, !tbaa !12
  br label %61

61:                                               ; preds = %43
  br label %62

62:                                               ; preds = %61
  br label %109

63:                                               ; preds = %3
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 0
  %66 = load i32, ptr %65, align 4, !tbaa !14
  %67 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 2
  %68 = load i32, ptr %67, align 4, !tbaa !12
  %69 = sub i32 %66, %68
  %70 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 1
  %71 = load i32, ptr %70, align 4, !tbaa !18
  %72 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 3
  %73 = load i32, ptr %72, align 4, !tbaa !16
  %74 = sub i32 %71, %73
  call void @_ZN5GRect11SetPositionEii(ptr noundef nonnull align 4 dereferenceable(16) %64, i32 noundef %69, i32 noundef %74)
  %75 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 4
  %76 = load i32, ptr %75, align 4, !tbaa !15
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.GSize, ptr %77, i32 0, i32 1
  %79 = load i32, ptr %78, align 4, !tbaa !17
  %80 = icmp slt i32 %76, %79
  br i1 %80, label %81, label %101

81:                                               ; preds = %63
  %82 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 3
  %83 = load i32, ptr %82, align 4, !tbaa !16
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.GSize, ptr %84, i32 0, i32 1
  %86 = load i32, ptr %85, align 4, !tbaa !17
  %87 = icmp slt i32 %83, %86
  br i1 %87, label %88, label %89

88:                                               ; preds = %81
  store i1 false, ptr %4, align 1
  br label %110

89:                                               ; preds = %81
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.GSize, ptr %90, i32 0, i32 1
  %92 = load i32, ptr %91, align 4, !tbaa !17
  %93 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 4
  store i32 %92, ptr %93, align 4, !tbaa !15
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.GSize, ptr %94, i32 0, i32 0
  %96 = load i32, ptr %95, align 4, !tbaa !9
  %97 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 2
  %98 = load i32, ptr %97, align 4, !tbaa !12
  %99 = sub nsw i32 %98, %96
  store i32 %99, ptr %97, align 4, !tbaa !12
  br label %100

100:                                              ; preds = %89
  br label %108

101:                                              ; preds = %63
  %102 = load ptr, ptr %6, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.GSize, ptr %102, i32 0, i32 0
  %104 = load i32, ptr %103, align 4, !tbaa !9
  %105 = getelementptr inbounds %class.GTreemap, ptr %8, i32 0, i32 2
  %106 = load i32, ptr %105, align 4, !tbaa !12
  %107 = sub nsw i32 %106, %104
  store i32 %107, ptr %105, align 4, !tbaa !12
  br label %108

108:                                              ; preds = %101, %100
  br label %109

109:                                              ; preds = %108, %62
  store i1 true, ptr %4, align 1
  br label %110

110:                                              ; preds = %109, %88, %37, %24
  %111 = load i1, ptr %4, align 1
  ret i1 %111
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5GRect7SetSizeERK5GSize(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(8)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5GRect11SetPositionEii(ptr noundef nonnull align 4 dereferenceable(16), i32 noundef, i32 noundef) #1 align 2

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 = { 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" }

!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 = !{!"_ZTS5GSize", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 8}
!13 = !{!"_ZTS8GTreemap", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16}
!14 = !{!13, !11, i64 0}
!15 = !{!13, !11, i64 16}
!16 = !{!13, !11, i64 12}
!17 = !{!10, !11, i64 4}
!18 = !{!13, !11, 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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN8GTreemap3AddERK5GSizeR5GRect(ptr nocapture noundef nonnull align 4 dereferenceable(20) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(16) %2) local_unnamed_addr #0 align 2 {
  tail call void @_ZN5GRect7SetSizeERK5GSize(ptr noundef nonnull align 4 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(8) %1)
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i32, ptr %5, align 4, !tbaa !10
  %7 = icmp sgt i32 %4, %6
  %8 = load i32, ptr %0, align 4, !tbaa !12
  br i1 %7, label %9, label %29

9:                                                ; preds = %3
  %10 = icmp ugt i32 %4, %8
  br i1 %10, label %52, label %11

11:                                               ; preds = %9
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load i32, ptr %12, align 4, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %0, i64 12
  %15 = load i32, ptr %14, align 4, !tbaa !14
  %16 = sub nsw i32 %15, %13
  store i32 %16, ptr %14, align 4, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %1, i64 4
  %18 = load i32, ptr %17, align 4, !tbaa !15
  %19 = icmp slt i32 %16, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %11
  store i32 %15, ptr %14, align 4, !tbaa !14
  br label %52

21:                                               ; preds = %11
  %22 = getelementptr inbounds i8, ptr %0, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !16
  %24 = sub i32 %23, %16
  tail call void @_ZN5GRect11SetPositionEii(ptr noundef nonnull align 4 dereferenceable(16) %2, i32 noundef 0, i32 noundef %24)
  %25 = load i32, ptr %17, align 4, !tbaa !15
  store i32 %25, ptr %12, align 4, !tbaa !13
  %26 = load i32, ptr %0, align 4, !tbaa !12
  %27 = load i32, ptr %1, align 4, !tbaa !5
  %28 = sub i32 %26, %27
  store i32 %28, ptr %5, align 4, !tbaa !10
  br label %52

29:                                               ; preds = %3
  %30 = sub i32 %8, %6
  %31 = getelementptr inbounds i8, ptr %0, i64 4
  %32 = load i32, ptr %31, align 4, !tbaa !16
  %33 = getelementptr inbounds i8, ptr %0, i64 12
  %34 = load i32, ptr %33, align 4, !tbaa !14
  %35 = sub i32 %32, %34
  tail call void @_ZN5GRect11SetPositionEii(ptr noundef nonnull align 4 dereferenceable(16) %2, i32 noundef %30, i32 noundef %35)
  %36 = getelementptr inbounds i8, ptr %0, i64 16
  %37 = load i32, ptr %36, align 4, !tbaa !13
  %38 = getelementptr inbounds i8, ptr %1, i64 4
  %39 = load i32, ptr %38, align 4, !tbaa !15
  %40 = icmp slt i32 %37, %39
  br i1 %40, label %41, label %48

41:                                               ; preds = %29
  %42 = load i32, ptr %33, align 4, !tbaa !14
  %43 = icmp slt i32 %42, %39
  br i1 %43, label %52, label %44

44:                                               ; preds = %41
  store i32 %39, ptr %36, align 4, !tbaa !13
  %45 = load i32, ptr %1, align 4, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !10
  %47 = sub nsw i32 %46, %45
  store i32 %47, ptr %5, align 4, !tbaa !10
  br label %52

48:                                               ; preds = %29
  %49 = load i32, ptr %1, align 4, !tbaa !5
  %50 = load i32, ptr %5, align 4, !tbaa !10
  %51 = sub nsw i32 %50, %49
  store i32 %51, ptr %5, align 4, !tbaa !10
  br label %52

52:                                               ; preds = %21, %48, %44, %41, %9, %20
  %.0 = phi i1 [ false, %20 ], [ false, %9 ], [ false, %41 ], [ true, %44 ], [ true, %48 ], [ true, %21 ]
  ret i1 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5GRect7SetSizeERK5GSize(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5GRect11SetPositionEii(ptr noundef nonnull align 4 dereferenceable(16), i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

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

!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 = !{!"_ZTS5GSize", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !7, i64 8}
!11 = !{!"_ZTS8GTreemap", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16}
!12 = !{!11, !7, i64 0}
!13 = !{!11, !7, i64 16}
!14 = !{!11, !7, i64 12}
!15 = !{!6, !7, i64 4}
!16 = !{!11, !7, i64 4}


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