; LLVM IR from facebook/redex :: tools/redexdump/DumpTables.ll (Z12dump_stringsP10ddump_datab)

; 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.ddump_data = type { i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.dex_header = type { [8 x i8], i32, [20 x i8], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@_ZL18string_data_header = external hidden constant [18 x i8], align 16
@.str.5 = external hidden unnamed_addr constant [26 x i8], align 1

; 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

declare void @_Z6redumpPKcz(ptr noundef, ...) #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL21dump_string_data_itemPPKh(ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12dump_stringsP10ddump_datab(ptr noundef %0, i1 noundef zeroext %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %15 = zext i1 %1 to i8
  store i8 %15, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ddump_data, ptr %16, i32 0, i32 4
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = getelementptr inbounds %struct.dex_header, ptr %18, i32 0, i32 10
  %20 = load i32, ptr %19, align 1, !tbaa !14
  store i32 %20, ptr %5, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ddump_data, ptr %21, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !18
  %24 = load i32, ptr %5, align 4, !tbaa !17
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %23, i64 %25
  store ptr %26, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ddump_data, ptr %27, i32 0, i32 4
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  %30 = getelementptr inbounds %struct.dex_header, ptr %29, i32 0, i32 9
  %31 = load i32, ptr %30, align 1, !tbaa !19
  store i32 %31, ptr %7, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !17
  br label %32

32:                                               ; preds = %52, %2
  %33 = load i32, ptr %10, align 4, !tbaa !17
  %34 = load i32, ptr %7, align 4, !tbaa !17
  %35 = icmp ult i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %55

37:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ddump_data, ptr %38, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !18
  %41 = load i32, ptr %9, align 4, !tbaa !17
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds i8, ptr %40, i64 %42
  store ptr %43, ptr %11, align 8, !tbaa !5
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = call i64 @strlen(ptr noundef %44) #5
  %46 = load i32, ptr %8, align 4, !tbaa !17
  %47 = sext i32 %46 to i64
  %48 = add i64 %47, %45
  %49 = trunc i64 %48 to i32
  store i32 %49, ptr %8, align 4, !tbaa !17
  %50 = load i32, ptr %9, align 4, !tbaa !17
  %51 = add i32 %50, 4
  store i32 %51, ptr %9, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %52

52:                                               ; preds = %37
  %53 = load i32, ptr %10, align 4, !tbaa !17
  %54 = add i32 %53, 1
  store i32 %54, ptr %10, align 4, !tbaa !17
  br label %32, !llvm.loop !20

55:                                               ; preds = %36
  %56 = load i8, ptr %4, align 1, !tbaa !9, !range !22, !noundef !23
  %57 = trunc i8 %56 to i1
  br i1 %57, label %58, label %61

58:                                               ; preds = %55
  %59 = load i32, ptr %7, align 4, !tbaa !17
  %60 = load i32, ptr %8, align 4, !tbaa !17
  call void (ptr, ...) @_Z6redumpPKcz(ptr noundef @.str.5, i32 noundef %59, i32 noundef %60)
  call void (ptr, ...) @_Z6redumpPKcz(ptr noundef @.str.3, ptr noundef @_ZL18string_data_header)
  br label %61

61:                                               ; preds = %58, %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !17
  br label %62

62:                                               ; preds = %78, %61
  %63 = load i32, ptr %12, align 4, !tbaa !17
  %64 = load i32, ptr %7, align 4, !tbaa !17
  %65 = icmp ult i32 %63, %64
  br i1 %65, label %67, label %66

66:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %81

67:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = load i32, ptr %68, align 4, !tbaa !17
  store i32 %69, ptr %13, align 4, !tbaa !17
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds i8, ptr %70, i64 4
  store ptr %71, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.ddump_data, ptr %72, i32 0, i32 2
  %74 = load ptr, ptr %73, align 8, !tbaa !18
  %75 = load i32, ptr %13, align 4, !tbaa !17
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds i8, ptr %74, i64 %76
  store ptr %77, ptr %14, align 8, !tbaa !5
  call void @_ZL21dump_string_data_itemPPKh(ptr noundef %14)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %78

78:                                               ; preds = %67
  %79 = load i32, ptr %12, align 4, !tbaa !17
  %80 = add i32 %79, 1
  store i32 %80, ptr %12, align 4, !tbaa !17
  br label %62, !llvm.loop !24

81:                                               ; preds = %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret void
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { nounwind willreturn memory(read) "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 }
attributes #5 = { nounwind willreturn memory(read) }

!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 = !{!"bool", !7, i64 0}
!11 = !{!12, !6, i64 32}
!12 = !{!"_ZTS10ddump_data", !13, i64 0, !13, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !16, i64 60}
!15 = !{!"_ZTS10dex_header", !7, i64 0, !16, i64 8, !7, i64 12, !16, i64 32, !16, i64 36, !16, i64 40, !16, i64 44, !16, i64 48, !16, i64 52, !16, i64 56, !16, i64 60, !16, i64 64, !16, i64 68, !16, i64 72, !16, i64 76, !16, i64 80, !16, i64 84, !16, i64 88, !16, i64 92, !16, i64 96, !16, i64 100, !16, i64 104, !16, i64 108}
!16 = !{!"int", !7, i64 0}
!17 = !{!16, !16, i64 0}
!18 = !{!12, !6, i64 16}
!19 = !{!15, !16, i64 56}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = distinct !{!24, !21}


; 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.3 = external hidden unnamed_addr constant [4 x i8], align 1
@_ZL18string_data_header = external hidden constant [18 x i8], align 16
@.str.5 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare void @_Z6redumpPKcz(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL21dump_string_data_itemPPKh(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12dump_stringsP10ddump_datab(ptr nocapture noundef readonly %0, i1 noundef zeroext %1) local_unnamed_addr #2 {
  %3 = alloca ptr, align 8
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 60
  %7 = load i32, ptr %6, align 1, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !14
  %10 = zext i32 %7 to i64
  %11 = getelementptr inbounds i8, ptr %9, i64 %10
  %12 = getelementptr inbounds i8, ptr %5, i64 56
  %13 = load i32, ptr %12, align 1, !tbaa !15
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  %.022.lcssa = phi i32 [ 0, %2 ], [ %18, %.lr.ph ]
  br i1 %1, label %21, label %22

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.02228 = phi i32 [ %18, %.lr.ph ], [ 0, %2 ]
  %.02327 = phi i32 [ %20, %.lr.ph ], [ 0, %2 ]
  %.02426 = phi i32 [ %19, %.lr.ph ], [ 0, %2 ]
  %14 = zext i32 %.02426 to i64
  %15 = getelementptr inbounds i8, ptr %9, i64 %14
  %16 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %15) #4
  %17 = trunc i64 %16 to i32
  %18 = add i32 %.02228, %17
  %19 = add i32 %.02426, 4
  %20 = add nuw i32 %.02327, 1
  %exitcond.not = icmp eq i32 %20, %13
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !16

21:                                               ; preds = %._crit_edge
  tail call void (ptr, ...) @_Z6redumpPKcz(ptr noundef nonnull @.str.5, i32 noundef %13, i32 noundef %.022.lcssa)
  tail call void (ptr, ...) @_Z6redumpPKcz(ptr noundef nonnull @.str.3, ptr noundef nonnull @_ZL18string_data_header)
  br label %22

22:                                               ; preds = %21, %._crit_edge
  br i1 %.not, label %._crit_edge33, label %.lr.ph32

._crit_edge33:                                    ; preds = %.lr.ph32, %22
  ret void

.lr.ph32:                                         ; preds = %22, %.lr.ph32
  %.030 = phi ptr [ %24, %.lr.ph32 ], [ %11, %22 ]
  %.02129 = phi i32 [ %28, %.lr.ph32 ], [ 0, %22 ]
  %23 = load i32, ptr %.030, align 4, !tbaa !18
  %24 = getelementptr inbounds i8, ptr %.030, i64 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %25 = load ptr, ptr %8, align 8, !tbaa !14
  %26 = zext i32 %23 to i64
  %27 = getelementptr inbounds i8, ptr %25, i64 %26
  store ptr %27, ptr %3, align 8, !tbaa !19
  call void @_ZL21dump_string_data_itemPPKh(ptr noundef nonnull %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  %28 = add nuw i32 %.02129, 1
  %exitcond35.not = icmp eq i32 %28, %13
  br i1 %exitcond35.not, label %._crit_edge33, label %.lr.ph32, !llvm.loop !20
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }
attributes #5 = { 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, !10, i64 32}
!6 = !{!"_ZTS10ddump_data", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !13, i64 60}
!12 = !{!"_ZTS10dex_header", !8, i64 0, !13, i64 8, !8, i64 12, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !13, i64 56, !13, i64 60, !13, i64 64, !13, i64 68, !13, i64 72, !13, i64 76, !13, i64 80, !13, i64 84, !13, i64 88, !13, i64 92, !13, i64 96, !13, i64 100, !13, i64 104, !13, i64 108}
!13 = !{!"int", !8, i64 0}
!14 = !{!6, !10, i64 16}
!15 = !{!12, !13, i64 56}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!13, !13, i64 0}
!19 = !{!10, !10, i64 0}
!20 = distinct !{!20, !17}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass