; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

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

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

; Function Attrs: nounwind
declare void @free(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: nounwind uwtable
define dso_local i32 @testshortFORpack() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = 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 @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 7, ptr %5, align 4, !tbaa !5
  call void @srand(i32 noundef 0) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %11

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

14:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store i64 128, ptr %6, align 8, !tbaa !9
  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 512) #6
  store ptr %16, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %17 = call noalias ptr @malloc(i64 noundef 5120) #6
  store ptr %17, ptr %9, align 8, !tbaa !11
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %18

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

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

32:                                               ; preds = %21
  %33 = load i64, ptr %3, align 8, !tbaa !9
  %34 = add i64 %33, 1
  store i64 %34, ptr %3, align 8, !tbaa !9
  br label %18, !llvm.loop !13

35:                                               ; preds = %18
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %36

36:                                               ; preds = %85, %35
  %37 = load i64, ptr %4, align 8, !tbaa !9
  %38 = icmp ule i64 %37, 128
  br i1 %38, label %39, label %88

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

40:                                               ; preds = %47, %39
  %41 = load i64, ptr %3, align 8, !tbaa !9
  %42 = icmp ult i64 %41, 128
  br i1 %42, label %43, label %50

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

47:                                               ; preds = %43
  %48 = load i64, ptr %3, align 8, !tbaa !9
  %49 = add i64 %48, 1
  store i64 %49, ptr %3, align 8, !tbaa !9
  br label %40, !llvm.loop !15

50:                                               ; preds = %40
  %51 = load i32, ptr %5, align 4, !tbaa !5
  %52 = load ptr, ptr %7, align 8, !tbaa !11
  %53 = load i64, ptr %4, align 8, !tbaa !9
  %54 = trunc i64 %53 to i32
  %55 = load ptr, ptr %9, align 8, !tbaa !11
  %56 = load i32, ptr %2, align 4, !tbaa !5
  %57 = call ptr @simdpackFOR_length(i32 noundef %51, ptr noundef %52, i32 noundef %54, ptr noundef %55, i32 noundef %56)
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = load ptr, ptr %9, align 8, !tbaa !11
  %60 = load i64, ptr %4, align 8, !tbaa !9
  %61 = trunc i64 %60 to i32
  %62 = load ptr, ptr %8, align 8, !tbaa !11
  %63 = load i32, ptr %2, align 4, !tbaa !5
  %64 = call ptr @simdunpackFOR_length(i32 noundef %58, ptr noundef %59, i32 noundef %61, ptr noundef %62, i32 noundef %63)
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %65

65:                                               ; preds = %81, %50
  %66 = load i64, ptr %3, align 8, !tbaa !9
  %67 = load i64, ptr %4, align 8, !tbaa !9
  %68 = icmp ult i64 %66, %67
  br i1 %68, label %69, label %84

69:                                               ; preds = %65
  %70 = load ptr, ptr %7, align 8, !tbaa !11
  %71 = load i64, ptr %3, align 8, !tbaa !9
  %72 = getelementptr inbounds i32, ptr %70, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = load ptr, ptr %8, align 8, !tbaa !11
  %75 = load i64, ptr %3, align 8, !tbaa !9
  %76 = getelementptr inbounds i32, ptr %74, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = icmp ne i32 %73, %77
  br i1 %78, label %79, label %80

79:                                               ; preds = %69
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %10, align 4
  br label %92

80:                                               ; preds = %69
  br label %81

81:                                               ; preds = %80
  %82 = load i64, ptr %3, align 8, !tbaa !9
  %83 = add i64 %82, 1
  store i64 %83, ptr %3, align 8, !tbaa !9
  br label %65, !llvm.loop !16

84:                                               ; preds = %65
  br label %85

85:                                               ; preds = %84
  %86 = load i64, ptr %4, align 8, !tbaa !9
  %87 = add i64 %86, 1
  store i64 %87, ptr %4, align 8, !tbaa !9
  br label %36, !llvm.loop !17

88:                                               ; preds = %36
  %89 = load ptr, ptr %7, align 8, !tbaa !11
  call void @free(ptr noundef %89) #5
  %90 = load ptr, ptr %8, align 8, !tbaa !11
  call void @free(ptr noundef %90) #5
  %91 = load ptr, ptr %9, align 8, !tbaa !11
  call void @free(ptr noundef %91) #5
  store i32 0, ptr %10, align 4
  br label %92

92:                                               ; preds = %88, %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  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
  %93 = load i32, ptr %10, align 4
  switch i32 %93, label %99 [
    i32 0, label %94
  ]

94:                                               ; preds = %92
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %2, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !18

98:                                               ; preds = %11
  store i32 0, ptr %1, align 4
  store i32 1, ptr %10, align 4
  br label %99

99:                                               ; preds = %98, %92
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  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
  %100 = load i32, ptr %1, align 4
  ret i32 %100
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = { "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
declare void @srand(i32 noundef) local_unnamed_addr #0

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

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

1:                                                ; preds = %0, %.thread
  %.03646 = phi i32 [ 0, %0 ], [ %22, %.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, %.03646
  %5 = xor i32 %notmask, -1
  br label %6

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

.preheader:                                       ; preds = %6, %._crit_edge
  %.04045 = phi i64 [ %21, %._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
  %12 = trunc nuw nsw i64 %.04045 to i32
  %13 = tail call ptr @simdpackFOR_length(i32 noundef 7, ptr noundef %2, i32 noundef %12, ptr noundef %4, i32 noundef %.03646) #6
  %14 = tail call ptr @simdunpackFOR_length(i32 noundef 7, ptr noundef %4, i32 noundef %12, ptr noundef %3, i32 noundef %.03646) #6
  %.not47 = icmp eq i64 %.04045, 0
  br i1 %.not47, label %._crit_edge, label %.lr.ph

15:                                               ; preds = %.lr.ph
  %16 = add nuw nsw i64 %.23944, 1
  %exitcond49.not = icmp eq i64 %16, %.04045
  br i1 %exitcond49.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

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

._crit_edge:                                      ; preds = %15, %.preheader
  %21 = add nuw nsw i64 %.04045, 1
  %exitcond50 = icmp eq i64 %21, 129
  br i1 %exitcond50, 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
  %22 = add nuw nsw i32 %.03646, 1
  %exitcond51.not = icmp eq i32 %22, 32
  br i1 %exitcond51.not, label %.loopexit, label %1, !llvm.loop !13

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

declare ptr @simdpackFOR_length(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

declare ptr @simdunpackFOR_length(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 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 "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 = { 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 #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 = { 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 = { "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