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

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

@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1

declare noundef i32 @_ZN4TPCE7CRandom11RndIntRangeEii(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef, i32 noundef) #0

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4TPCE13CAddressTable17GenerateAD_LINE_2Ev(ptr noundef nonnull align 8 dereferenceable(416) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %"class.TPCE::CAddressTable", ptr %3, i32 0, i32 9
  %5 = load i8, ptr %4, align 1, !tbaa !9, !range !18, !noundef !19
  %6 = trunc i8 %5 to i1
  br i1 %6, label %7, label %10

7:                                                ; preds = %1
  %8 = getelementptr inbounds %"class.TPCE::TableTemplate", ptr %3, i32 0, i32 4
  %9 = call noundef zeroext i1 @_ZN4TPCE7CRandom10RndPercentEi(ptr noundef nonnull align 8 dereferenceable(8) %8, i32 noundef 60)
  br i1 %9, label %10, label %14

10:                                               ; preds = %7, %1
  %11 = getelementptr inbounds %"class.TPCE::TableTemplate", ptr %3, i32 0, i32 1
  %12 = getelementptr inbounds %"struct.TPCE::ADDRESS_ROW", ptr %11, i32 0, i32 2
  %13 = getelementptr inbounds [81 x i8], ptr %12, i64 0, i64 0
  store i8 0, ptr %13, align 1, !tbaa !20
  br label %32

14:                                               ; preds = %7
  %15 = getelementptr inbounds %"class.TPCE::TableTemplate", ptr %3, i32 0, i32 4
  %16 = call noundef zeroext i1 @_ZN4TPCE7CRandom10RndPercentEi(ptr noundef nonnull align 8 dereferenceable(8) %15, i32 noundef 75)
  br i1 %16, label %17, label %24

17:                                               ; preds = %14
  %18 = getelementptr inbounds %"class.TPCE::TableTemplate", ptr %3, i32 0, i32 1
  %19 = getelementptr inbounds %"struct.TPCE::ADDRESS_ROW", ptr %18, i32 0, i32 2
  %20 = getelementptr inbounds [81 x i8], ptr %19, i64 0, i64 0
  %21 = getelementptr inbounds %"class.TPCE::TableTemplate", ptr %3, i32 0, i32 4
  %22 = call noundef i32 @_ZN4TPCE7CRandom11RndIntRangeEii(ptr noundef nonnull align 8 dereferenceable(8) %21, i32 noundef 1, i32 noundef 1000)
  %23 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %20, i64 noundef 81, ptr noundef @.str.1, i32 noundef %22) #4
  br label %31

24:                                               ; preds = %14
  %25 = getelementptr inbounds %"class.TPCE::TableTemplate", ptr %3, i32 0, i32 1
  %26 = getelementptr inbounds %"struct.TPCE::ADDRESS_ROW", ptr %25, i32 0, i32 2
  %27 = getelementptr inbounds [81 x i8], ptr %26, i64 0, i64 0
  %28 = getelementptr inbounds %"class.TPCE::TableTemplate", ptr %3, i32 0, i32 4
  %29 = call noundef i32 @_ZN4TPCE7CRandom11RndIntRangeEii(ptr noundef nonnull align 8 dereferenceable(8) %28, i32 noundef 1, i32 noundef 500)
  %30 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %27, i64 noundef 81, ptr noundef @.str.2, i32 noundef %29) #4
  br label %31

31:                                               ; preds = %24, %17
  br label %32

32:                                               ; preds = %31, %10
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4TPCE7CRandom10RndPercentEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #3 align 2

attributes #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 = { 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 #2 = { 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 #3 = { inlinehint 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 #4 = { 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, !14, i64 361}
!10 = !{!"_ZTSN4TPCE13CAddressTableE", !11, i64 0, !16, i64 296, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !13, i64 344, !13, i64 352, !14, i64 360, !14, i64 361, !13, i64 368, !17, i64 376, !13, i64 384, !14, i64 392, !17, i64 396, !13, i64 400, !6, i64 408}
!11 = !{!"_ZTSN4TPCE13TableTemplateINS_11ADDRESS_ROWEEE", !12, i64 8, !13, i64 272, !14, i64 280, !15, i64 288}
!12 = !{!"_ZTSN4TPCE11ADDRESS_ROWE", !13, i64 0, !7, i64 8, !7, i64 89, !7, i64 170, !7, i64 183}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTSN4TPCE7CRandomE", !13, i64 0}
!16 = !{!"_ZTSN4TPCE9CDateTimeE", !17, i64 0, !17, i64 4, !6, i64 8}
!17 = !{!"int", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!7, !7, i64 0}


; 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.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1

declare noundef i32 @_ZN4TPCE7CRandom11RndIntRangeEii(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4TPCE13CAddressTable17GenerateAD_LINE_2Ev(ptr noundef nonnull align 8 dereferenceable(416) %0) local_unnamed_addr #2 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 361
  %3 = load i8, ptr %2, align 1, !tbaa !5, !range !17, !noundef !18
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %5, label %8

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 288
  %7 = tail call noundef zeroext i1 @_ZN4TPCE7CRandom10RndPercentEi(ptr noundef nonnull align 8 dereferenceable(8) %6, i32 noundef 60)
  br i1 %7, label %8, label %10

8:                                                ; preds = %5, %1
  %9 = getelementptr inbounds i8, ptr %0, i64 97
  store i8 0, ptr %9, align 1, !tbaa !19
  br label %19

10:                                               ; preds = %5
  %11 = tail call noundef zeroext i1 @_ZN4TPCE7CRandom10RndPercentEi(ptr noundef nonnull align 8 dereferenceable(8) %6, i32 noundef 75)
  %12 = getelementptr inbounds i8, ptr %0, i64 97
  br i1 %11, label %13, label %16

13:                                               ; preds = %10
  %14 = tail call noundef i32 @_ZN4TPCE7CRandom11RndIntRangeEii(ptr noundef nonnull align 8 dereferenceable(8) %6, i32 noundef 1, i32 noundef 1000)
  %15 = tail call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %12, i64 noundef 81, ptr noundef nonnull @.str.1, i32 noundef %14) #4
  br label %19

16:                                               ; preds = %10
  %17 = tail call noundef i32 @_ZN4TPCE7CRandom11RndIntRangeEii(ptr noundef nonnull align 8 dereferenceable(8) %6, i32 noundef 1, i32 noundef 500)
  %18 = tail call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %12, i64 noundef 81, ptr noundef nonnull @.str.2, i32 noundef %17) #4
  br label %19

19:                                               ; preds = %13, %16, %8
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4TPCE7CRandom10RndPercentEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #3 align 2

attributes #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 = { nofree 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 #2 = { 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 #3 = { inlinehint 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 #4 = { 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, !12, i64 361}
!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 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!10, !10, i64 0}


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