; LLVM IR from sfu-dis/mosaicdb :: benchmarks/egen (AddressTable)

; 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.TPCE::CAddressTable" = type { %"class.TPCE::TableTemplate", %"class.TPCE::CDateTime", ptr, ptr, ptr, ptr, i64, i64, i8, i8, i64, i32, i64, i8, i32, i64, ptr }
%"class.TPCE::TableTemplate" = type { ptr, %"struct.TPCE::ADDRESS_ROW", i64, i8, %"class.TPCE::CRandom" }
%"struct.TPCE::ADDRESS_ROW" = type { i64, [81 x i8], [81 x i8], [13 x i8], [81 x i8] }
%"class.TPCE::CRandom" = type { i64 }
%"class.TPCE::CDateTime" = type { i32, i32, ptr }
%"struct.TPCE::TZipCodeInputRow" = type <{ %"struct.TPCE::TBaseInputRow", i32, [13 x i8], [81 x i8], [81 x i8], [5 x i8] }>
%"struct.TPCE::TBaseInputRow" = type { ptr }

; 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 uwtable
declare dso_local noundef i32 @_ZN4TPCE13CAddressTable31GetTownDivisionZipCodeThresholdEx(ptr noundef nonnull align 8 dereferenceable(416), i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4TPCE13CAddressTable14GetCountryCodeEPKc(ptr noundef nonnull align 8 dereferenceable(416), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4TPCE13CAddressTable36GetDivisionAndCountryCodesForAddressExRjS1_(ptr noundef nonnull align 8 dereferenceable(416) %0, i64 noundef %1, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i8, align 1
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store ptr null, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %14 = load i64, ptr %6, align 8, !tbaa !9
  %15 = getelementptr inbounds %"class.TPCE::CAddressTable", ptr %13, i32 0, i32 15
  %16 = load i64, ptr %15, align 8, !tbaa !11
  %17 = sub nsw i64 %14, %16
  store i64 %17, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #3
  %18 = load i64, ptr %10, align 8, !tbaa !9
  %19 = icmp sge i64 %18, 0
  br i1 %19, label %20, label %26

20:                                               ; preds = %4
  %21 = load i64, ptr %10, align 8, !tbaa !9
  %22 = getelementptr inbounds %"class.TPCE::CAddressTable", ptr %13, i32 0, i32 14
  %23 = load i32, ptr %22, align 4, !tbaa !19
  %24 = sext i32 %23 to i64
  %25 = icmp sle i64 %21, %24
  br label %26

26:                                               ; preds = %20, %4
  %27 = phi i1 [ false, %4 ], [ %25, %20 ]
  %28 = zext i1 %27 to i8
  store i8 %28, ptr %11, align 1, !tbaa !20
  %29 = getelementptr inbounds %"class.TPCE::CAddressTable", ptr %13, i32 0, i32 13
  %30 = load i8, ptr %29, align 8, !tbaa !21, !range !22, !noundef !23
  %31 = trunc i8 %30 to i1
  br i1 %31, label %32, label %41

32:                                               ; preds = %26
  %33 = load i8, ptr %11, align 1, !tbaa !20, !range !22, !noundef !23
  %34 = trunc i8 %33 to i1
  br i1 %34, label %35, label %41

35:                                               ; preds = %32
  %36 = getelementptr inbounds %"class.TPCE::CAddressTable", ptr %13, i32 0, i32 16
  %37 = load ptr, ptr %36, align 8, !tbaa !24
  %38 = load i64, ptr %10, align 8, !tbaa !9
  %39 = getelementptr inbounds ptr, ptr %37, i64 %38
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  store ptr %40, ptr %9, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %35, %32, %26
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = icmp eq ptr %42, null
  br i1 %43, label %44, label %64

44:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %45 = load i64, ptr %6, align 8, !tbaa !9
  %46 = call noundef i32 @_ZN4TPCE13CAddressTable31GetTownDivisionZipCodeThresholdEx(ptr noundef nonnull align 8 dereferenceable(416) %13, i64 noundef %45)
  store i32 %46, ptr %12, align 4, !tbaa !25
  %47 = getelementptr inbounds %"class.TPCE::CAddressTable", ptr %13, i32 0, i32 5
  %48 = load ptr, ptr %47, align 8, !tbaa !26
  %49 = load i32, ptr %12, align 4, !tbaa !25
  %50 = call noundef ptr @_ZN4TPCE10CInputFileINS_16TZipCodeInputRowENS_14TZipCodeLimitsEE9GetRecordEi(ptr noundef nonnull align 8 dereferenceable(40) %48, i32 noundef %49)
  store ptr %50, ptr %9, align 8, !tbaa !5
  %51 = getelementptr inbounds %"class.TPCE::CAddressTable", ptr %13, i32 0, i32 13
  %52 = load i8, ptr %51, align 8, !tbaa !21, !range !22, !noundef !23
  %53 = trunc i8 %52 to i1
  br i1 %53, label %54, label %63

54:                                               ; preds = %44
  %55 = load i8, ptr %11, align 1, !tbaa !20, !range !22, !noundef !23
  %56 = trunc i8 %55 to i1
  br i1 %56, label %57, label %63

57:                                               ; preds = %54
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = getelementptr inbounds %"class.TPCE::CAddressTable", ptr %13, i32 0, i32 16
  %60 = load ptr, ptr %59, align 8, !tbaa !24
  %61 = load i64, ptr %10, align 8, !tbaa !9
  %62 = getelementptr inbounds ptr, ptr %60, i64 %61
  store ptr %58, ptr %62, align 8, !tbaa !5
  br label %63

63:                                               ; preds = %57, %54, %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %64

64:                                               ; preds = %63, %41
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = getelementptr inbounds %"struct.TPCE::TZipCodeInputRow", ptr %65, i32 0, i32 1
  %67 = load i32, ptr %66, align 8, !tbaa !27
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %67, ptr %68, align 4, !tbaa !25
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = getelementptr inbounds %"struct.TPCE::TZipCodeInputRow", ptr %69, i32 0, i32 2
  %71 = getelementptr inbounds [13 x i8], ptr %70, i64 0, i64 0
  %72 = call noundef i32 @_ZN4TPCE13CAddressTable14GetCountryCodeEPKc(ptr noundef nonnull align 8 dereferenceable(416) %13, ptr noundef %71)
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 %72, ptr %73, align 4, !tbaa !25
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4TPCE10CInputFileINS_16TZipCodeInputRowENS_14TZipCodeLimitsEE9GetRecordEi(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !10, i64 400}
!12 = !{!"_ZTSN4TPCE13CAddressTableE", !13, i64 0, !17, i64 296, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !10, i64 344, !10, i64 352, !15, i64 360, !15, i64 361, !10, i64 368, !18, i64 376, !10, i64 384, !15, i64 392, !18, i64 396, !10, i64 400, !6, i64 408}
!13 = !{!"_ZTSN4TPCE13TableTemplateINS_11ADDRESS_ROWEEE", !14, i64 8, !10, i64 272, !15, i64 280, !16, i64 288}
!14 = !{!"_ZTSN4TPCE11ADDRESS_ROWE", !10, i64 0, !7, i64 8, !7, i64 89, !7, i64 170, !7, i64 183}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"_ZTSN4TPCE7CRandomE", !10, i64 0}
!17 = !{!"_ZTSN4TPCE9CDateTimeE", !18, i64 0, !18, i64 4, !6, i64 8}
!18 = !{!"int", !7, i64 0}
!19 = !{!12, !18, i64 396}
!20 = !{!15, !15, i64 0}
!21 = !{!12, !15, i64 392}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!12, !6, i64 408}
!25 = !{!18, !18, i64 0}
!26 = !{!12, !6, i64 336}
!27 = !{!28, !18, i64 8}
!28 = !{!"_ZTSN4TPCE16TZipCodeInputRowE", !29, i64 0, !18, i64 8, !7, i64 12, !7, i64 25, !7, i64 106}
!29 = !{!"_ZTSN4TPCE13TBaseInputRowE"}


; 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 uwtable
declare dso_local noundef i32 @_ZN4TPCE13CAddressTable31GetTownDivisionZipCodeThresholdEx(ptr noundef nonnull align 8 dereferenceable(416), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4TPCE13CAddressTable14GetCountryCodeEPKc(ptr noundef nonnull align 8 dereferenceable(416), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4TPCE13CAddressTable36GetDivisionAndCountryCodesForAddressExRjS1_(ptr noundef nonnull align 8 dereferenceable(416) %0, i64 noundef %1, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %2, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %3) local_unnamed_addr #0 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 400
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = sub nsw i64 %1, %6
  %8 = icmp slt i64 %7, 0
  %9 = getelementptr inbounds i8, ptr %0, i64 396
  %10 = load i32, ptr %9, align 4
  %11 = sext i32 %10 to i64
  %12 = icmp sgt i64 %7, %11
  %.not23 = select i1 %8, i1 true, i1 %12
  %13 = getelementptr inbounds i8, ptr %0, i64 392
  %14 = load i8, ptr %13, align 8, !tbaa !17, !range !18, !noundef !19
  %15 = trunc nuw i8 %14 to i1
  %.not = xor i1 %15, true
  %brmerge = select i1 %.not, i1 true, i1 %.not23
  br i1 %brmerge, label %.thread, label %16

16:                                               ; preds = %4
  %17 = getelementptr inbounds i8, ptr %0, i64 408
  %18 = load ptr, ptr %17, align 8, !tbaa !20
  %19 = getelementptr inbounds ptr, ptr %18, i64 %7
  %20 = load ptr, ptr %19, align 8, !tbaa !21
  %21 = icmp eq ptr %20, null
  br i1 %21, label %.thread, label %32

.thread:                                          ; preds = %4, %16
  %22 = tail call noundef i32 @_ZN4TPCE13CAddressTable31GetTownDivisionZipCodeThresholdEx(ptr noundef nonnull align 8 dereferenceable(416) %0, i64 noundef %1)
  %23 = getelementptr inbounds i8, ptr %0, i64 336
  %24 = load ptr, ptr %23, align 8, !tbaa !22
  %25 = tail call noundef ptr @_ZN4TPCE10CInputFileINS_16TZipCodeInputRowENS_14TZipCodeLimitsEE9GetRecordEi(ptr noundef nonnull align 8 dereferenceable(40) %24, i32 noundef %22)
  %26 = load i8, ptr %13, align 8, !tbaa !17, !range !18, !noundef !19
  %27 = trunc nuw i8 %26 to i1
  %.not17 = xor i1 %27, true
  %brmerge19 = select i1 %.not17, i1 true, i1 %.not23
  br i1 %brmerge19, label %32, label %28

28:                                               ; preds = %.thread
  %29 = getelementptr inbounds i8, ptr %0, i64 408
  %30 = load ptr, ptr %29, align 8, !tbaa !20
  %31 = getelementptr inbounds ptr, ptr %30, i64 %7
  store ptr %25, ptr %31, align 8, !tbaa !21
  br label %32

32:                                               ; preds = %28, %.thread, %16
  %.1 = phi ptr [ %20, %16 ], [ %25, %.thread ], [ %25, %28 ]
  %33 = getelementptr inbounds i8, ptr %.1, i64 8
  %34 = load i32, ptr %33, align 8, !tbaa !23
  store i32 %34, ptr %2, align 4, !tbaa !26
  %35 = getelementptr inbounds i8, ptr %.1, i64 12
  %36 = tail call noundef i32 @_ZN4TPCE13CAddressTable14GetCountryCodeEPKc(ptr noundef nonnull align 8 dereferenceable(416) %0, ptr noundef nonnull %35)
  store i32 %36, ptr %3, align 4, !tbaa !26
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4TPCE10CInputFileINS_16TZipCodeInputRowENS_14TZipCodeLimitsEE9GetRecordEi(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) local_unnamed_addr #0 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, !9, i64 400}
!6 = !{!"_ZTSN4TPCE13CAddressTableE", !7, i64 0, !14, i64 296, !16, i64 312, !16, i64 320, !16, i64 328, !16, i64 336, !9, i64 344, !9, i64 352, !12, i64 360, !12, i64 361, !9, i64 368, !15, i64 376, !9, i64 384, !12, i64 392, !15, i64 396, !9, i64 400, !16, i64 408}
!7 = !{!"_ZTSN4TPCE13TableTemplateINS_11ADDRESS_ROWEEE", !8, i64 8, !9, i64 272, !12, i64 280, !13, i64 288}
!8 = !{!"_ZTSN4TPCE11ADDRESS_ROWE", !9, i64 0, !10, i64 8, !10, i64 89, !10, i64 170, !10, i64 183}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"bool", !10, i64 0}
!13 = !{!"_ZTSN4TPCE7CRandomE", !9, i64 0}
!14 = !{!"_ZTSN4TPCE9CDateTimeE", !15, i64 0, !15, i64 4, !16, i64 8}
!15 = !{!"int", !10, i64 0}
!16 = !{!"any pointer", !10, i64 0}
!17 = !{!6, !12, i64 392}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!6, !16, i64 408}
!21 = !{!16, !16, i64 0}
!22 = !{!6, !16, i64 336}
!23 = !{!24, !15, i64 8}
!24 = !{!"_ZTSN4TPCE16TZipCodeInputRowE", !25, i64 0, !15, i64 8, !10, i64 12, !10, i64 25, !10, i64 106}
!25 = !{!"_ZTSN4TPCE13TBaseInputRowE"}
!26 = !{!15, !15, i64 0}


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