; LLVM IR from ryanlayer/giggle :: test/unit (test_giggle)

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

@.str.56 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [28 x i8], align 1
@__const.test_giggle_bulk_insert.A_names = external hidden unnamed_addr constant [22 x ptr], align 16
@__const.test_giggle_bulk_insert.A_num_intervals = external hidden unnamed_addr constant [22 x i32], align 16
@__const.test_giggle_bulk_insert.A_mean_interval_sizes = external hidden unnamed_addr constant [22 x double], align 16

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

declare void @UnityAssertEqualNumber(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i32 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: nounwind
declare void @free(ptr noundef) #2

; 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) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #4

declare i32 @rmrf(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @test_giggle_bulk_insert() #5 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca [22 x ptr], align 16
  %9 = alloca [22 x i32], align 16
  %10 = alloca [22 x double], align 16
  %11 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #6
  store ptr @.str.56, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  store ptr @.str.57, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %12 = load ptr, ptr %1, align 8, !tbaa !5
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = call i64 @giggle_bulk_insert(ptr noundef %12, ptr noundef %13, i32 noundef 1)
  store i64 %14, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store ptr null, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store ptr null, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = call i32 @giggle_get_indexed_files(ptr noundef %15, ptr noundef %4, ptr noundef %5, ptr noundef %6)
  store i32 %16, ptr %7, align 4, !tbaa !11
  %17 = load i32, ptr %7, align 4, !tbaa !11
  %18 = zext i32 %17 to i64
  call void @UnityAssertEqualNumber(i64 noundef 22, i64 noundef %18, ptr noundef null, i64 noundef 1851, i32 noundef 148)
  call void @llvm.lifetime.start.p0(i64 176, ptr %8) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %8, ptr align 16 @__const.test_giggle_bulk_insert.A_names, i64 176, i1 false)
  call void @llvm.lifetime.start.p0(i64 88, ptr %9) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %9, ptr align 16 @__const.test_giggle_bulk_insert.A_num_intervals, i64 88, i1 false)
  call void @llvm.lifetime.start.p0(i64 176, ptr %10) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %10, ptr align 16 @__const.test_giggle_bulk_insert.A_mean_interval_sizes, i64 176, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %19

19:                                               ; preds = %62, %0
  %20 = load i32, ptr %11, align 4, !tbaa !11
  %21 = load i32, ptr %7, align 4, !tbaa !11
  %22 = icmp ult i32 %20, %21
  br i1 %22, label %23, label %65

23:                                               ; preds = %19
  %24 = load i32, ptr %11, align 4, !tbaa !11
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds [22 x ptr], ptr %8, i64 0, i64 %25
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = load i32, ptr %11, align 4, !tbaa !11
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds ptr, ptr %28, i64 %30
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = call i32 @strcmp(ptr noundef %27, ptr noundef %32) #7
  %34 = sext i32 %33 to i64
  call void @UnityAssertEqualNumber(i64 noundef 0, i64 noundef %34, ptr noundef null, i64 noundef 1922, i32 noundef 148)
  %35 = load i32, ptr %11, align 4, !tbaa !11
  %36 = zext i32 %35 to i64
  %37 = getelementptr inbounds [22 x i32], ptr %9, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !11
  %39 = zext i32 %38 to i64
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = load i32, ptr %11, align 4, !tbaa !11
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds i32, ptr %40, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !11
  %45 = zext i32 %44 to i64
  call void @UnityAssertEqualNumber(i64 noundef %39, i64 noundef %45, ptr noundef null, i64 noundef 1923, i32 noundef 148)
  %46 = load i32, ptr %11, align 4, !tbaa !11
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds [22 x double], ptr %10, i64 0, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !13
  %50 = fptosi double %49 to i64
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load i32, ptr %11, align 4, !tbaa !11
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds double, ptr %51, i64 %53
  %55 = load double, ptr %54, align 8, !tbaa !13
  %56 = fptosi double %55 to i64
  call void @UnityAssertEqualNumber(i64 noundef %50, i64 noundef %56, ptr noundef null, i64 noundef 1924, i32 noundef 148)
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = load i32, ptr %11, align 4, !tbaa !11
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds ptr, ptr %57, i64 %59
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  call void @free(ptr noundef %61) #6
  br label %62

62:                                               ; preds = %23
  %63 = load i32, ptr %11, align 4, !tbaa !11
  %64 = add i32 %63, 1
  store i32 %64, ptr %11, align 4, !tbaa !11
  br label %19, !llvm.loop !15

65:                                               ; preds = %19
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %66) #6
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  call void @free(ptr noundef %67) #6
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %68) #6
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = call i32 @rmrf(ptr noundef %69)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 176, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 88, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 176, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #6
  ret void
}

declare i64 @giggle_bulk_insert(ptr noundef, ptr noundef, i32 noundef) #1

declare i32 @giggle_get_indexed_files(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; 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.56 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [28 x i8], align 1
@__const.test_giggle_bulk_insert.A_names = external hidden unnamed_addr constant [22 x ptr], align 16
@__const.test_giggle_bulk_insert.A_num_intervals = external hidden unnamed_addr constant [22 x i32], align 16
@__const.test_giggle_bulk_insert.A_mean_interval_sizes = external hidden unnamed_addr constant [22 x double], align 16

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

declare void @UnityAssertEqualNumber(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i32 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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

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

declare i32 @rmrf(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @test_giggle_bulk_insert() local_unnamed_addr #4 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = tail call i64 @giggle_bulk_insert(ptr noundef nonnull @.str.56, ptr noundef nonnull @.str.57, i32 noundef 1) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  store ptr null, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  store ptr null, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  store ptr null, ptr %3, align 8, !tbaa !5
  %5 = call i32 @giggle_get_indexed_files(ptr noundef nonnull @.str.57, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3) #5
  %6 = zext i32 %5 to i64
  call void @UnityAssertEqualNumber(i64 noundef 22, i64 noundef %6, ptr noundef null, i64 noundef 1851, i32 noundef 148) #5
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %7 = getelementptr inbounds [22 x ptr], ptr @__const.test_giggle_bulk_insert.A_names, i64 0, i64 %indvars.iv
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = load ptr, ptr %1, align 8, !tbaa !5
  %10 = getelementptr inbounds ptr, ptr %9, i64 %indvars.iv
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) %11) #6
  %13 = sext i32 %12 to i64
  call void @UnityAssertEqualNumber(i64 noundef 0, i64 noundef %13, ptr noundef null, i64 noundef 1922, i32 noundef 148) #5
  %14 = getelementptr inbounds [22 x i32], ptr @__const.test_giggle_bulk_insert.A_num_intervals, i64 0, i64 %indvars.iv
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = zext i32 %15 to i64
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds i32, ptr %17, i64 %indvars.iv
  %19 = load i32, ptr %18, align 4, !tbaa !9
  %20 = zext i32 %19 to i64
  call void @UnityAssertEqualNumber(i64 noundef %16, i64 noundef %20, ptr noundef null, i64 noundef 1923, i32 noundef 148) #5
  %21 = getelementptr inbounds [22 x double], ptr @__const.test_giggle_bulk_insert.A_mean_interval_sizes, i64 0, i64 %indvars.iv
  %22 = load double, ptr %21, align 8, !tbaa !11
  %23 = fptosi double %22 to i64
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds double, ptr %24, i64 %indvars.iv
  %26 = load double, ptr %25, align 8, !tbaa !11
  %27 = fptosi double %26 to i64
  call void @UnityAssertEqualNumber(i64 noundef %23, i64 noundef %27, ptr noundef null, i64 noundef 1924, i32 noundef 148) #5
  %28 = load ptr, ptr %1, align 8, !tbaa !5
  %29 = getelementptr inbounds ptr, ptr %28, i64 %indvars.iv
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  call void @free(ptr noundef %30) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %6
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %0
  %31 = load ptr, ptr %1, align 8, !tbaa !5
  call void @free(ptr noundef %31) #5
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %32) #5
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %33) #5
  %34 = call i32 @rmrf(ptr noundef nonnull @.str.57) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  ret void
}

declare i64 @giggle_bulk_insert(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @giggle_get_indexed_files(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 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 #5 = { nounwind }
attributes #6 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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