; LLVM IR from cruppstahl/upscaledb :: 3rdparty/simdcomp/src (unit)

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

; Function Attrs: nounwind uwtable
define dso_local i32 @testshortpack() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @srand(i32 noundef 0) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %90, %0
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 32
  br i1 %12, label %13, label %93

13:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 128, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %14 = call noalias ptr @malloc(i64 noundef 512) #6
  store ptr %14, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %15 = call noalias ptr @malloc(i64 noundef 512) #6
  store ptr %15, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %16 = call noalias ptr @malloc(i64 noundef 5120) #6
  store ptr %16, ptr %8, align 8, !tbaa !11
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %17

17:                                               ; preds = %29, %13
  %18 = load i64, ptr %3, align 8, !tbaa !9
  %19 = icmp ult i64 %18, 128
  br i1 %19, label %20, label %32

20:                                               ; preds = %17
  %21 = call i32 @rand() #5
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = shl i32 1, %22
  %24 = sub nsw i32 %23, 1
  %25 = and i32 %21, %24
  %26 = load ptr, ptr %6, align 8, !tbaa !11
  %27 = load i64, ptr %3, align 8, !tbaa !9
  %28 = getelementptr inbounds i32, ptr %26, i64 %27
  store i32 %25, ptr %28, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %20
  %30 = load i64, ptr %3, align 8, !tbaa !9
  %31 = add i64 %30, 1
  store i64 %31, ptr %3, align 8, !tbaa !9
  br label %17, !llvm.loop !13

32:                                               ; preds = %17
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %33

33:                                               ; preds = %80, %32
  %34 = load i64, ptr %4, align 8, !tbaa !9
  %35 = icmp ule i64 %34, 128
  br i1 %35, label %36, label %83

36:                                               ; preds = %33
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %37

37:                                               ; preds = %44, %36
  %38 = load i64, ptr %3, align 8, !tbaa !9
  %39 = icmp ult i64 %38, 128
  br i1 %39, label %40, label %47

40:                                               ; preds = %37
  %41 = load ptr, ptr %7, align 8, !tbaa !11
  %42 = load i64, ptr %3, align 8, !tbaa !9
  %43 = getelementptr inbounds i32, ptr %41, i64 %42
  store i32 0, ptr %43, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %40
  %45 = load i64, ptr %3, align 8, !tbaa !9
  %46 = add i64 %45, 1
  store i64 %46, ptr %3, align 8, !tbaa !9
  br label %37, !llvm.loop !15

47:                                               ; preds = %37
  %48 = load ptr, ptr %6, align 8, !tbaa !11
  %49 = load i64, ptr %4, align 8, !tbaa !9
  %50 = trunc i64 %49 to i32
  %51 = load ptr, ptr %8, align 8, !tbaa !11
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = call ptr @simdpack_length(ptr noundef %48, i32 noundef %50, ptr noundef %51, i32 noundef %52)
  %54 = load ptr, ptr %8, align 8, !tbaa !11
  %55 = load i64, ptr %4, align 8, !tbaa !9
  %56 = trunc i64 %55 to i32
  %57 = load ptr, ptr %7, align 8, !tbaa !11
  %58 = load i32, ptr %2, align 4, !tbaa !5
  %59 = call ptr @simdunpack_length(ptr noundef %54, i32 noundef %56, ptr noundef %57, i32 noundef %58)
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %60

60:                                               ; preds = %76, %47
  %61 = load i64, ptr %3, align 8, !tbaa !9
  %62 = load i64, ptr %4, align 8, !tbaa !9
  %63 = icmp ult i64 %61, %62
  br i1 %63, label %64, label %79

64:                                               ; preds = %60
  %65 = load ptr, ptr %6, align 8, !tbaa !11
  %66 = load i64, ptr %3, align 8, !tbaa !9
  %67 = getelementptr inbounds i32, ptr %65, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = load ptr, ptr %7, align 8, !tbaa !11
  %70 = load i64, ptr %3, align 8, !tbaa !9
  %71 = getelementptr inbounds i32, ptr %69, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = icmp ne i32 %68, %72
  br i1 %73, label %74, label %75

74:                                               ; preds = %64
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %9, align 4
  br label %87

75:                                               ; preds = %64
  br label %76

76:                                               ; preds = %75
  %77 = load i64, ptr %3, align 8, !tbaa !9
  %78 = add i64 %77, 1
  store i64 %78, ptr %3, align 8, !tbaa !9
  br label %60, !llvm.loop !16

79:                                               ; preds = %60
  br label %80

80:                                               ; preds = %79
  %81 = load i64, ptr %4, align 8, !tbaa !9
  %82 = add i64 %81, 1
  store i64 %82, ptr %4, align 8, !tbaa !9
  br label %33, !llvm.loop !17

83:                                               ; preds = %33
  %84 = load ptr, ptr %6, align 8, !tbaa !11
  call void @free(ptr noundef %84) #5
  %85 = load ptr, ptr %7, align 8, !tbaa !11
  call void @free(ptr noundef %85) #5
  %86 = load ptr, ptr %8, align 8, !tbaa !11
  call void @free(ptr noundef %86) #5
  store i32 0, ptr %9, align 4
  br label %87

87:                                               ; preds = %83, %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  %88 = load i32, ptr %9, align 4
  switch i32 %88, label %94 [
    i32 0, label %89
  ]

89:                                               ; preds = %87
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %2, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !18

93:                                               ; preds = %10
  store i32 0, ptr %1, align 4
  store i32 1, ptr %9, align 4
  br label %94

94:                                               ; preds = %93, %87
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %95 = load i32, ptr %1, align 4
  ret i32 %95
}

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

; Function Attrs: nounwind
declare void @srand(i32 noundef) #2

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nounwind
declare i32 @rand() #2

declare ptr @simdpack_length(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #4

declare ptr @simdunpack_length(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #4

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

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

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

!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 = !{!"int", !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 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


; 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: nounwind uwtable
define dso_local noundef i32 @testshortpack() local_unnamed_addr #0 {
  tail call void @srand(i32 noundef 0) #6
  br label %1

1:                                                ; preds = %0, %.thread
  %.03343 = phi i32 [ 0, %0 ], [ %21, %.thread ]
  %2 = tail call noalias dereferenceable_or_null(512) ptr @malloc(i64 noundef 512) #7
  %3 = tail call noalias dereferenceable_or_null(512) ptr @malloc(i64 noundef 512) #7
  %4 = tail call noalias dereferenceable_or_null(5120) ptr @malloc(i64 noundef 5120) #7
  %notmask = shl nsw i32 -1, %.03343
  %5 = xor i32 %notmask, -1
  br label %6

6:                                                ; preds = %1, %6
  %.03439 = phi i64 [ 0, %1 ], [ %10, %6 ]
  %7 = tail call i32 @rand() #6
  %8 = and i32 %7, %5
  %9 = getelementptr inbounds i32, ptr %2, i64 %.03439
  store i32 %8, ptr %9, align 4, !tbaa !5
  %10 = add nuw nsw i64 %.03439, 1
  %exitcond.not = icmp eq i64 %10, 128
  br i1 %exitcond.not, label %.preheader, label %6, !llvm.loop !9

.preheader:                                       ; preds = %6, %._crit_edge
  %.03742 = phi i64 [ %20, %._crit_edge ], [ 0, %6 ]
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(512) %3, i8 0, i64 512, i1 false), !tbaa !5
  %11 = trunc nuw nsw i64 %.03742 to i32
  %12 = tail call ptr @simdpack_length(ptr noundef %2, i32 noundef %11, ptr noundef %4, i32 noundef %.03343) #6
  %13 = tail call ptr @simdunpack_length(ptr noundef %4, i32 noundef %11, ptr noundef %3, i32 noundef %.03343) #6
  %.not44 = icmp eq i64 %.03742, 0
  br i1 %.not44, label %._crit_edge, label %.lr.ph

14:                                               ; preds = %.lr.ph
  %15 = add nuw nsw i64 %.23641, 1
  %exitcond46.not = icmp eq i64 %15, %.03742
  br i1 %exitcond46.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

.lr.ph:                                           ; preds = %.preheader, %14
  %.23641 = phi i64 [ %15, %14 ], [ 0, %.preheader ]
  %16 = getelementptr inbounds i32, ptr %2, i64 %.23641
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = getelementptr inbounds i32, ptr %3, i64 %.23641
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %.not = icmp eq i32 %17, %19
  br i1 %.not, label %14, label %.loopexit

._crit_edge:                                      ; preds = %14, %.preheader
  %20 = add nuw nsw i64 %.03742, 1
  %exitcond47 = icmp eq i64 %20, 129
  br i1 %exitcond47, label %.thread, label %.preheader, !llvm.loop !12

.thread:                                          ; preds = %._crit_edge
  tail call void @free(ptr noundef %2) #6
  tail call void @free(ptr noundef nonnull %3) #6
  tail call void @free(ptr noundef %4) #6
  %21 = add nuw nsw i32 %.03343, 1
  %exitcond48.not = icmp eq i32 %21, 32
  br i1 %exitcond48.not, label %.loopexit, label %1, !llvm.loop !13

.loopexit:                                        ; preds = %.thread, %.lr.ph
  %.2 = phi i32 [ -1, %.lr.ph ], [ 0, %.thread ]
  ret i32 %.2
}

; Function Attrs: nounwind
declare void @srand(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #1

declare ptr @simdpack_length(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare ptr @simdunpack_length(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

attributes #0 = { 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 #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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 = { "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 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass