; LLVM IR from CLASS-SZ/class_sz :: class-sz/tools (growTable)

; 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.growTable = type { ptr, i64, i64, i32, [2048 x i8] }

@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [6 x i8], align 1
@__func__.gt_retrieve = external hidden unnamed_addr constant [12 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [22 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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @gt_retrieve(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca [2048 x i8], align 16
  %12 = alloca [2048 x i8], align 16
  %13 = alloca i32, align 4
  %14 = alloca [2048 x i8], align 16
  %15 = alloca [2048 x i8], align 16
  %16 = alloca [2048 x i8], align 16
  %17 = alloca [2048 x i8], align 16
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !9
  store i64 %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %18 = load i64, ptr %7, align 8, !tbaa !9
  %19 = icmp slt i64 %18, 0
  br i1 %19, label %20, label %29

20:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 2048, ptr %11) #4
  %21 = getelementptr inbounds [2048 x i8], ptr %11, i64 0, i64 0
  %22 = load i64, ptr %7, align 8, !tbaa !9
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef %21, ptr noundef @.str.12, i64 noundef %22)
  call void @llvm.lifetime.start.p0(i64 2048, ptr %12) #4
  %23 = getelementptr inbounds [2048 x i8], ptr %12, i64 0, i64 0
  %24 = getelementptr inbounds [2048 x i8], ptr %11, i64 0, i64 0
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef %23, ptr noundef @.str.4, ptr noundef @.str.13, ptr noundef %24)
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.growTable, ptr %25, i32 0, i32 4
  %27 = getelementptr inbounds [2048 x i8], ptr %26, i64 0, i64 0
  %28 = getelementptr inbounds [2048 x i8], ptr %12, i64 0, i64 0
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef %27, ptr noundef @.str.2, ptr noundef @__func__.gt_retrieve, i32 noundef 89, ptr noundef %28)
  call void @llvm.lifetime.end.p0(i64 2048, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 2048, ptr %11) #4
  store i32 1, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %75

29:                                               ; preds = %4
  %30 = load i64, ptr %7, align 8, !tbaa !9
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.growTable, ptr %31, i32 0, i32 2
  %33 = load i64, ptr %32, align 8, !tbaa !11
  %34 = icmp sgt i64 %30, %33
  br i1 %34, label %43, label %35

35:                                               ; preds = %29
  %36 = load i64, ptr %7, align 8, !tbaa !9
  %37 = load i64, ptr %8, align 8, !tbaa !9
  %38 = add nsw i64 %36, %37
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.growTable, ptr %39, i32 0, i32 2
  %41 = load i64, ptr %40, align 8, !tbaa !11
  %42 = icmp sgt i64 %38, %41
  br i1 %42, label %43, label %51

43:                                               ; preds = %35, %29
  call void @llvm.lifetime.start.p0(i64 2048, ptr %14) #4
  %44 = getelementptr inbounds [2048 x i8], ptr %14, i64 0, i64 0
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef %44, ptr noundef @.str.14)
  call void @llvm.lifetime.start.p0(i64 2048, ptr %15) #4
  %45 = getelementptr inbounds [2048 x i8], ptr %15, i64 0, i64 0
  %46 = getelementptr inbounds [2048 x i8], ptr %14, i64 0, i64 0
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef %45, ptr noundef @.str.4, ptr noundef @.str.15, ptr noundef %46)
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.growTable, ptr %47, i32 0, i32 4
  %49 = getelementptr inbounds [2048 x i8], ptr %48, i64 0, i64 0
  %50 = getelementptr inbounds [2048 x i8], ptr %15, i64 0, i64 0
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef %49, ptr noundef @.str.2, ptr noundef @__func__.gt_retrieve, i32 noundef 93, ptr noundef %50)
  call void @llvm.lifetime.end.p0(i64 2048, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 2048, ptr %14) #4
  store i32 1, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %75

51:                                               ; preds = %35
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.growTable, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !14
  %56 = load i64, ptr %7, align 8, !tbaa !9
  %57 = getelementptr inbounds i8, ptr %55, i64 %56
  %58 = load i64, ptr %8, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %52, ptr align 1 %57, i64 %58, i1 false)
  store ptr %52, ptr %10, align 8, !tbaa !5
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.growTable, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !14
  %63 = load i64, ptr %7, align 8, !tbaa !9
  %64 = getelementptr inbounds i8, ptr %62, i64 %63
  %65 = icmp ne ptr %59, %64
  br i1 %65, label %66, label %74

66:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 2048, ptr %16) #4
  %67 = getelementptr inbounds [2048 x i8], ptr %16, i64 0, i64 0
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef %67, ptr noundef @.str.16)
  call void @llvm.lifetime.start.p0(i64 2048, ptr %17) #4
  %68 = getelementptr inbounds [2048 x i8], ptr %17, i64 0, i64 0
  %69 = getelementptr inbounds [2048 x i8], ptr %16, i64 0, i64 0
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef %68, ptr noundef @.str.4, ptr noundef @.str.17, ptr noundef %69)
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.growTable, ptr %70, i32 0, i32 4
  %72 = getelementptr inbounds [2048 x i8], ptr %71, i64 0, i64 0
  %73 = getelementptr inbounds [2048 x i8], ptr %17, i64 0, i64 0
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef %72, ptr noundef @.str.2, ptr noundef @__func__.gt_retrieve, i32 noundef 98, ptr noundef %73)
  call void @llvm.lifetime.end.p0(i64 2048, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 2048, ptr %16) #4
  store i32 1, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %75

74:                                               ; preds = %51
  store i32 0, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %75

75:                                               ; preds = %74, %66, %43, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %76 = load i32, ptr %5, align 4
  ret i32 %76
}

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"", !6, i64 0, !10, i64 8, !10, i64 16, !13, i64 24, !7, i64 28}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, 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.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [6 x i8], align 1
@__func__.gt_retrieve = external hidden unnamed_addr constant [12 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [22 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

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @gt_retrieve(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef writeonly %3) local_unnamed_addr #3 {
  %5 = alloca [2048 x i8], align 16
  %6 = alloca [2048 x i8], align 16
  %7 = alloca [2048 x i8], align 16
  %8 = alloca [2048 x i8], align 16
  %9 = alloca [2048 x i8], align 16
  %10 = alloca [2048 x i8], align 16
  %11 = icmp slt i64 %1, 0
  br i1 %11, label %12, label %14

12:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %5) #4
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef nonnull %5, ptr noundef nonnull @.str.12, i64 noundef %1) #4
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %6) #4
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef nonnull %6, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.13, ptr noundef nonnull %5) #4
  %13 = getelementptr inbounds i8, ptr %0, i64 28
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef nonnull %13, ptr noundef nonnull @.str.2, ptr noundef nonnull @__func__.gt_retrieve, i32 noundef 89, ptr noundef nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %5) #4
  br label %29

14:                                               ; preds = %4
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = icmp slt i64 %16, %1
  %18 = add nsw i64 %2, %1
  %19 = icmp sgt i64 %18, %16
  %or.cond = select i1 %17, i1 true, i1 %19
  br i1 %or.cond, label %20, label %22

20:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %7) #4
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef nonnull %7, ptr noundef nonnull @.str.14) #4
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %8) #4
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef nonnull %8, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.15, ptr noundef nonnull %7) #4
  %21 = getelementptr inbounds i8, ptr %0, i64 28
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef nonnull %21, ptr noundef nonnull @.str.2, ptr noundef nonnull @__func__.gt_retrieve, i32 noundef 93, ptr noundef nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %7) #4
  br label %29

22:                                               ; preds = %14
  %23 = load ptr, ptr %0, align 8, !tbaa !12
  %24 = getelementptr inbounds i8, ptr %23, i64 %1
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %3, ptr align 1 %24, i64 %2, i1 false)
  %25 = load ptr, ptr %0, align 8, !tbaa !12
  %26 = getelementptr inbounds i8, ptr %25, i64 %1
  %.not = icmp eq ptr %26, %3
  br i1 %.not, label %29, label %27

27:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %9) #4
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef nonnull %9, ptr noundef nonnull @.str.16) #4
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %10) #4
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef nonnull %10, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.17, ptr noundef nonnull %9) #4
  %28 = getelementptr inbounds i8, ptr %0, i64 28
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef nonnull %28, ptr noundef nonnull @.str.2, ptr noundef nonnull @__func__.gt_retrieve, i32 noundef 98, ptr noundef nonnull %10) #4
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %10) #4
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %9) #4
  br label %29

29:                                               ; preds = %22, %27, %20, %12
  %.0 = phi i32 [ 1, %12 ], [ 1, %20 ], [ 1, %27 ], [ 0, %22 ]
  ret i32 %.0
}

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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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, !10, i64 16}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !8, i64 28}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 0}


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