; LLVM IR from sunkafei/xcpc-algorithm-templates :: 算法/数据结构/四分树.ll (Z5buildiiii)

; 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.area = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@A = external dso_local global [2000 x [2000 x i32]], align 16
@cur = external dso_local global i32, align 4
@t = external dso_local global [4840000 x %struct.area], align 16

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8maintaini(i32 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 noundef i32 @_Z5buildiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %12 = load i32, ptr @cur, align 4, !tbaa !5
  %13 = add nsw i32 %12, 1
  store i32 %13, ptr @cur, align 4, !tbaa !5
  store i32 %13, ptr %9, align 4, !tbaa !5
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = load i32, ptr %9, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %16
  %18 = getelementptr inbounds %struct.area, ptr %17, i32 0, i32 0
  store i32 %14, ptr %18, align 4, !tbaa !9
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = load i32, ptr %9, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %21
  %23 = getelementptr inbounds %struct.area, ptr %22, i32 0, i32 1
  store i32 %19, ptr %23, align 4, !tbaa !11
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = load i32, ptr %9, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %26
  %28 = getelementptr inbounds %struct.area, ptr %27, i32 0, i32 2
  store i32 %24, ptr %28, align 4, !tbaa !12
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = load i32, ptr %9, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %31
  %33 = getelementptr inbounds %struct.area, ptr %32, i32 0, i32 3
  store i32 %29, ptr %33, align 4, !tbaa !13
  %34 = load i32, ptr %9, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %35
  %37 = getelementptr inbounds %struct.area, ptr %36, i32 0, i32 7
  store i32 0, ptr %37, align 4, !tbaa !14
  %38 = load i32, ptr %9, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %39
  %41 = getelementptr inbounds %struct.area, ptr %40, i32 0, i32 6
  store i32 0, ptr %41, align 4, !tbaa !15
  %42 = load i32, ptr %9, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %43
  %45 = getelementptr inbounds %struct.area, ptr %44, i32 0, i32 5
  store i32 0, ptr %45, align 4, !tbaa !16
  %46 = load i32, ptr %9, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %47
  %49 = getelementptr inbounds %struct.area, ptr %48, i32 0, i32 4
  store i32 0, ptr %49, align 4, !tbaa !17
  %50 = load i32, ptr %9, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %51
  %53 = getelementptr inbounds %struct.area, ptr %52, i32 0, i32 12
  store i32 0, ptr %53, align 4, !tbaa !18
  %54 = load i32, ptr %9, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %55
  %57 = getelementptr inbounds %struct.area, ptr %56, i32 0, i32 11
  store i32 -1, ptr %57, align 4, !tbaa !19
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = icmp eq i32 %58, %59
  br i1 %60, label %61, label %77

61:                                               ; preds = %4
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = load i32, ptr %8, align 4, !tbaa !5
  %64 = icmp eq i32 %62, %63
  br i1 %64, label %65, label %77

65:                                               ; preds = %61
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [2000 x [2000 x i32]], ptr @A, i64 0, i64 %67
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [2000 x i32], ptr %68, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = load i32, ptr %9, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %74
  %76 = getelementptr inbounds %struct.area, ptr %75, i32 0, i32 12
  store i32 %72, ptr %76, align 4, !tbaa !18
  br label %145

77:                                               ; preds = %61, %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %78 = load i32, ptr %5, align 4, !tbaa !5
  %79 = load i32, ptr %6, align 4, !tbaa !5
  %80 = add nsw i32 %78, %79
  %81 = ashr i32 %80, 1
  store i32 %81, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %82 = load i32, ptr %7, align 4, !tbaa !5
  %83 = load i32, ptr %8, align 4, !tbaa !5
  %84 = add nsw i32 %82, %83
  %85 = ashr i32 %84, 1
  store i32 %85, ptr %11, align 4, !tbaa !5
  %86 = load i32, ptr %5, align 4, !tbaa !5
  %87 = load i32, ptr %10, align 4, !tbaa !5
  %88 = load i32, ptr %7, align 4, !tbaa !5
  %89 = load i32, ptr %11, align 4, !tbaa !5
  %90 = call noundef i32 @_Z5buildiiii(i32 noundef %86, i32 noundef %87, i32 noundef %88, i32 noundef %89)
  %91 = load i32, ptr %9, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %92
  %94 = getelementptr inbounds %struct.area, ptr %93, i32 0, i32 4
  store i32 %90, ptr %94, align 4, !tbaa !17
  %95 = load i32, ptr %11, align 4, !tbaa !5
  %96 = load i32, ptr %8, align 4, !tbaa !5
  %97 = icmp slt i32 %95, %96
  br i1 %97, label %98, label %109

98:                                               ; preds = %77
  %99 = load i32, ptr %5, align 4, !tbaa !5
  %100 = load i32, ptr %10, align 4, !tbaa !5
  %101 = load i32, ptr %11, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  %103 = load i32, ptr %8, align 4, !tbaa !5
  %104 = call noundef i32 @_Z5buildiiii(i32 noundef %99, i32 noundef %100, i32 noundef %102, i32 noundef %103)
  %105 = load i32, ptr %9, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %106
  %108 = getelementptr inbounds %struct.area, ptr %107, i32 0, i32 5
  store i32 %104, ptr %108, align 4, !tbaa !16
  br label %109

109:                                              ; preds = %98, %77
  %110 = load i32, ptr %10, align 4, !tbaa !5
  %111 = load i32, ptr %6, align 4, !tbaa !5
  %112 = icmp slt i32 %110, %111
  br i1 %112, label %113, label %124

113:                                              ; preds = %109
  %114 = load i32, ptr %10, align 4, !tbaa !5
  %115 = add nsw i32 %114, 1
  %116 = load i32, ptr %6, align 4, !tbaa !5
  %117 = load i32, ptr %7, align 4, !tbaa !5
  %118 = load i32, ptr %11, align 4, !tbaa !5
  %119 = call noundef i32 @_Z5buildiiii(i32 noundef %115, i32 noundef %116, i32 noundef %117, i32 noundef %118)
  %120 = load i32, ptr %9, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %121
  %123 = getelementptr inbounds %struct.area, ptr %122, i32 0, i32 6
  store i32 %119, ptr %123, align 4, !tbaa !15
  br label %124

124:                                              ; preds = %113, %109
  %125 = load i32, ptr %10, align 4, !tbaa !5
  %126 = load i32, ptr %6, align 4, !tbaa !5
  %127 = icmp slt i32 %125, %126
  br i1 %127, label %128, label %144

128:                                              ; preds = %124
  %129 = load i32, ptr %11, align 4, !tbaa !5
  %130 = load i32, ptr %8, align 4, !tbaa !5
  %131 = icmp slt i32 %129, %130
  br i1 %131, label %132, label %144

132:                                              ; preds = %128
  %133 = load i32, ptr %10, align 4, !tbaa !5
  %134 = add nsw i32 %133, 1
  %135 = load i32, ptr %6, align 4, !tbaa !5
  %136 = load i32, ptr %11, align 4, !tbaa !5
  %137 = add nsw i32 %136, 1
  %138 = load i32, ptr %8, align 4, !tbaa !5
  %139 = call noundef i32 @_Z5buildiiii(i32 noundef %134, i32 noundef %135, i32 noundef %137, i32 noundef %138)
  %140 = load i32, ptr %9, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %141
  %143 = getelementptr inbounds %struct.area, ptr %142, i32 0, i32 7
  store i32 %139, ptr %143, align 4, !tbaa !14
  br label %144

144:                                              ; preds = %132, %128, %124
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  br label %145

145:                                              ; preds = %144, %65
  %146 = load i32, ptr %9, align 4, !tbaa !5
  call void @_Z8maintaini(i32 noundef %146)
  %147 = load i32, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  ret i32 %147
}

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS4area", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 12}
!14 = !{!10, !6, i64 28}
!15 = !{!10, !6, i64 24}
!16 = !{!10, !6, i64 20}
!17 = !{!10, !6, i64 16}
!18 = !{!10, !6, i64 48}
!19 = !{!10, !6, i64 44}


; 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.area = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@A = external dso_local local_unnamed_addr global [2000 x [2000 x i32]], align 16
@cur = external dso_local local_unnamed_addr global i32, align 4
@t = external dso_local local_unnamed_addr global [4840000 x %struct.area], align 16

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8maintaini(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 -2147483647, -2147483648) i32 @_Z5buildiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = load i32, ptr @cur, align 4, !tbaa !5
  %6 = add nsw i32 %5, 1
  store i32 %6, ptr @cur, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [4840000 x %struct.area], ptr @t, i64 0, i64 %7
  store i32 %0, ptr %8, align 4, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %8, i64 4
  store i32 %1, ptr %9, align 4, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %8, i64 8
  store i32 %2, ptr %10, align 4, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %8, i64 12
  store i32 %3, ptr %11, align 4, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %8, i64 28
  %13 = getelementptr inbounds i8, ptr %8, i64 24
  %14 = getelementptr inbounds i8, ptr %8, i64 20
  %15 = getelementptr inbounds i8, ptr %8, i64 16
  %16 = getelementptr inbounds i8, ptr %8, i64 48
  store i32 0, ptr %16, align 4, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %8, i64 44
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %15, i8 0, i64 16, i1 false)
  store i32 -1, ptr %17, align 4, !tbaa !15
  %18 = icmp eq i32 %0, %1
  %19 = icmp eq i32 %2, %3
  %or.cond = and i1 %18, %19
  br i1 %or.cond, label %20, label %25

20:                                               ; preds = %4
  %21 = sext i32 %0 to i64
  %22 = sext i32 %2 to i64
  %23 = getelementptr inbounds [2000 x [2000 x i32]], ptr @A, i64 0, i64 %21, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  store i32 %24, ptr %16, align 4, !tbaa !14
  br label %.critedge

25:                                               ; preds = %4
  %26 = add nsw i32 %1, %0
  %27 = ashr i32 %26, 1
  %28 = add nsw i32 %3, %2
  %29 = ashr i32 %28, 1
  %30 = tail call noundef i32 @_Z5buildiiii(i32 noundef %0, i32 noundef %27, i32 noundef %2, i32 noundef %29)
  store i32 %30, ptr %15, align 4, !tbaa !16
  %.not = icmp slt i32 %29, %3
  br i1 %.not, label %31, label %34

31:                                               ; preds = %25
  %32 = add nsw i32 %29, 1
  %33 = tail call noundef i32 @_Z5buildiiii(i32 noundef %0, i32 noundef %27, i32 noundef %32, i32 noundef %3)
  store i32 %33, ptr %14, align 4, !tbaa !17
  br label %34

34:                                               ; preds = %31, %25
  %35 = icmp slt i32 %27, %1
  br i1 %35, label %36, label %.critedge

36:                                               ; preds = %34
  %37 = add nsw i32 %27, 1
  %38 = tail call noundef i32 @_Z5buildiiii(i32 noundef %37, i32 noundef %1, i32 noundef %2, i32 noundef %29)
  store i32 %38, ptr %13, align 4, !tbaa !18
  br i1 %.not, label %39, label %.critedge

39:                                               ; preds = %36
  %40 = add nsw i32 %29, 1
  %41 = tail call noundef i32 @_Z5buildiiii(i32 noundef %37, i32 noundef %1, i32 noundef %40, i32 noundef %3)
  store i32 %41, ptr %12, align 4, !tbaa !19
  br label %.critedge

.critedge:                                        ; preds = %39, %36, %34, %20
  tail call void @_Z8maintaini(i32 noundef %6)
  ret i32 %6
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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 nounwind willreturn memory(argmem: write) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS4area", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 12}
!14 = !{!10, !6, i64 48}
!15 = !{!10, !6, i64 44}
!16 = !{!10, !6, i64 16}
!17 = !{!10, !6, i64 20}
!18 = !{!10, !6, i64 24}
!19 = !{!10, !6, i64 28}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass