; LLVM IR from fast-pack/simdcomp :: tests (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"

@stdout = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [6 x i8], align 1
@__func__.testshortpack = external hidden unnamed_addr constant [14 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [5 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 i32 @printf(ptr noundef, ...) #1

declare i32 @fflush(ptr noundef) #1

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

declare i32 @simdpack_compressedbytes(i32 noundef, i32 noundef) #1

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

; 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 @testshortpack() #4 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %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 8, ptr %5) #5
  call void @srand(i32 noundef 0) #5
  %11 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, ptr noundef @__func__.testshortpack)
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %12

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

15:                                               ; preds = %12
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, i32 noundef %16)
  %18 = load ptr, ptr @stdout, align 8, !tbaa !9
  %19 = call i32 @fflush(ptr noundef %18)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store i64 128, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %20 = call noalias ptr @malloc(i64 noundef 512) #6
  store ptr %20, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %21 = call noalias ptr @malloc(i64 noundef 512) #6
  store ptr %21, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %22 = call noalias ptr @malloc(i64 noundef 5120) #6
  store ptr %22, ptr %9, align 8, !tbaa !9
  store i64 0, ptr %3, align 8, !tbaa !11
  br label %23

23:                                               ; preds = %35, %15
  %24 = load i64, ptr %3, align 8, !tbaa !11
  %25 = icmp ult i64 %24, 128
  br i1 %25, label %26, label %38

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

35:                                               ; preds = %26
  %36 = load i64, ptr %3, align 8, !tbaa !11
  %37 = add i64 %36, 1
  store i64 %37, ptr %3, align 8, !tbaa !11
  br label %23, !llvm.loop !13

38:                                               ; preds = %23
  store i64 0, ptr %4, align 8, !tbaa !11
  br label %39

39:                                               ; preds = %103, %38
  %40 = load i64, ptr %4, align 8, !tbaa !11
  %41 = icmp ule i64 %40, 128
  br i1 %41, label %42, label %106

42:                                               ; preds = %39
  store i64 0, ptr %3, align 8, !tbaa !11
  br label %43

43:                                               ; preds = %50, %42
  %44 = load i64, ptr %3, align 8, !tbaa !11
  %45 = icmp ult i64 %44, 128
  br i1 %45, label %46, label %53

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

50:                                               ; preds = %46
  %51 = load i64, ptr %3, align 8, !tbaa !11
  %52 = add i64 %51, 1
  store i64 %52, ptr %3, align 8, !tbaa !11
  br label %43, !llvm.loop !15

53:                                               ; preds = %43
  %54 = load ptr, ptr %7, align 8, !tbaa !9
  %55 = load i64, ptr %4, align 8, !tbaa !11
  %56 = trunc i64 %55 to i32
  %57 = load ptr, ptr %9, align 8, !tbaa !9
  %58 = load i32, ptr %2, align 4, !tbaa !5
  %59 = call ptr @simdpack_shortlength(ptr noundef %54, i32 noundef %56, ptr noundef %57, i32 noundef %58)
  store ptr %59, ptr %5, align 8, !tbaa !9
  %60 = load ptr, ptr %5, align 8, !tbaa !9
  %61 = load ptr, ptr %9, align 8, !tbaa !9
  %62 = ptrtoint ptr %60 to i64
  %63 = ptrtoint ptr %61 to i64
  %64 = sub i64 %62, %63
  %65 = sdiv exact i64 %64, 16
  %66 = mul i64 %65, 16
  %67 = load i64, ptr %4, align 8, !tbaa !11
  %68 = trunc i64 %67 to i32
  %69 = load i32, ptr %2, align 4, !tbaa !5
  %70 = call i32 @simdpack_compressedbytes(i32 noundef %68, i32 noundef %69)
  %71 = zext i32 %70 to i64
  %72 = icmp ne i64 %66, %71
  br i1 %72, label %73, label %75

73:                                               ; preds = %53
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %10, align 4
  br label %110

75:                                               ; preds = %53
  %76 = load ptr, ptr %9, align 8, !tbaa !9
  %77 = load i64, ptr %4, align 8, !tbaa !11
  %78 = trunc i64 %77 to i32
  %79 = load ptr, ptr %8, align 8, !tbaa !9
  %80 = load i32, ptr %2, align 4, !tbaa !5
  %81 = call ptr @simdunpack_shortlength(ptr noundef %76, i32 noundef %78, ptr noundef %79, i32 noundef %80)
  store i64 0, ptr %3, align 8, !tbaa !11
  br label %82

82:                                               ; preds = %99, %75
  %83 = load i64, ptr %3, align 8, !tbaa !11
  %84 = load i64, ptr %4, align 8, !tbaa !11
  %85 = icmp ult i64 %83, %84
  br i1 %85, label %86, label %102

86:                                               ; preds = %82
  %87 = load ptr, ptr %7, align 8, !tbaa !9
  %88 = load i64, ptr %3, align 8, !tbaa !11
  %89 = getelementptr inbounds i32, ptr %87, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = load ptr, ptr %8, align 8, !tbaa !9
  %92 = load i64, ptr %3, align 8, !tbaa !11
  %93 = getelementptr inbounds i32, ptr %91, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = icmp ne i32 %90, %94
  br i1 %95, label %96, label %98

96:                                               ; preds = %86
  %97 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %10, align 4
  br label %110

98:                                               ; preds = %86
  br label %99

99:                                               ; preds = %98
  %100 = load i64, ptr %3, align 8, !tbaa !11
  %101 = add i64 %100, 1
  store i64 %101, ptr %3, align 8, !tbaa !11
  br label %82, !llvm.loop !16

102:                                              ; preds = %82
  br label %103

103:                                              ; preds = %102
  %104 = load i64, ptr %4, align 8, !tbaa !11
  %105 = add i64 %104, 1
  store i64 %105, ptr %4, align 8, !tbaa !11
  br label %39, !llvm.loop !17

106:                                              ; preds = %39
  %107 = load ptr, ptr %7, align 8, !tbaa !9
  call void @free(ptr noundef %107) #5
  %108 = load ptr, ptr %8, align 8, !tbaa !9
  call void @free(ptr noundef %108) #5
  %109 = load ptr, ptr %9, align 8, !tbaa !9
  call void @free(ptr noundef %109) #5
  store i32 0, ptr %10, align 4
  br label %110

110:                                              ; preds = %106, %96, %73
  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
  %111 = load i32, ptr %10, align 4
  switch i32 %111, label %117 [
    i32 0, label %112
  ]

112:                                              ; preds = %110
  br label %113

113:                                              ; preds = %112
  %114 = load i32, ptr %2, align 4, !tbaa !5
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !18

116:                                              ; preds = %12
  store i32 0, ptr %1, align 4
  store i32 1, ptr %10, align 4
  br label %117

117:                                              ; preds = %116, %110
  call void @llvm.lifetime.end.p0(i64 8, 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
  %118 = load i32, ptr %1, align 4
  ret i32 %118
}

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

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

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

declare ptr @simdunpack_shortlength(ptr noundef, i32 noundef, ptr noundef, i32 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 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 "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 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 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !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"

@stdout = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [6 x i8], align 1
@__func__.testshortpack = external hidden unnamed_addr constant [14 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture 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

declare i32 @simdpack_compressedbytes(i32 noundef, i32 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @testshortpack() local_unnamed_addr #4 {
  tail call void @srand(i32 noundef 0) #7
  %1 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, ptr noundef nonnull @__func__.testshortpack)
  br label %2

2:                                                ; preds = %0, %.thread
  %.03849 = phi i32 [ 0, %0 ], [ %31, %.thread ]
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, i32 noundef %.03849)
  %4 = load ptr, ptr @stdout, align 8, !tbaa !5
  %5 = tail call i32 @fflush(ptr noundef %4)
  %6 = tail call noalias dereferenceable_or_null(512) ptr @malloc(i64 noundef 512) #8
  %7 = tail call noalias dereferenceable_or_null(512) ptr @malloc(i64 noundef 512) #8
  %8 = tail call noalias dereferenceable_or_null(5120) ptr @malloc(i64 noundef 5120) #8
  %notmask = shl nsw i32 -1, %.03849
  %9 = xor i32 %notmask, -1
  br label %11

.preheader44:                                     ; preds = %11
  %10 = ptrtoint ptr %8 to i64
  br label %.preheader

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

.preheader:                                       ; preds = %.preheader44, %._crit_edge
  %.04248 = phi i64 [ 0, %.preheader44 ], [ %30, %._crit_edge ]
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(512) %7, i8 0, i64 512, i1 false), !tbaa !9
  %16 = trunc nuw nsw i64 %.04248 to i32
  %17 = tail call ptr @simdpack_shortlength(ptr noundef %6, i32 noundef %16, ptr noundef %8, i32 noundef %.03849) #7
  %18 = ptrtoint ptr %17 to i64
  %19 = sub i64 %18, %10
  %20 = tail call i32 @simdpack_compressedbytes(i32 noundef %16, i32 noundef %.03849) #7
  %21 = zext i32 %20 to i64
  %.not = icmp eq i64 %19, %21
  br i1 %.not, label %22, label %.loopexit.sink.split

22:                                               ; preds = %.preheader
  %23 = tail call ptr @simdunpack_shortlength(ptr noundef %8, i32 noundef %16, ptr noundef nonnull %7, i32 noundef %.03849) #7
  %.not51 = icmp eq i64 %.04248, 0
  br i1 %.not51, label %._crit_edge, label %.lr.ph

24:                                               ; preds = %.lr.ph
  %25 = add nuw nsw i64 %.24147, 1
  %exitcond52.not = icmp eq i64 %25, %.04248
  br i1 %exitcond52.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

.lr.ph:                                           ; preds = %22, %24
  %.24147 = phi i64 [ %25, %24 ], [ 0, %22 ]
  %26 = getelementptr inbounds i32, ptr %6, i64 %.24147
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = getelementptr inbounds i32, ptr %7, i64 %.24147
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %.not43 = icmp eq i32 %27, %29
  br i1 %.not43, label %24, label %.loopexit.sink.split

._crit_edge:                                      ; preds = %24, %22
  %30 = add nuw nsw i64 %.04248, 1
  %exitcond53 = icmp eq i64 %30, 129
  br i1 %exitcond53, label %.thread, label %.preheader, !llvm.loop !14

.thread:                                          ; preds = %._crit_edge
  tail call void @free(ptr noundef %6) #7
  tail call void @free(ptr noundef nonnull %7) #7
  tail call void @free(ptr noundef %8) #7
  %31 = add nuw nsw i32 %.03849, 1
  %exitcond54.not = icmp eq i32 %31, 32
  br i1 %exitcond54.not, label %.loopexit, label %2, !llvm.loop !15

.loopexit.sink.split:                             ; preds = %.preheader, %.lr.ph
  %32 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %.loopexit

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

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

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

declare ptr @simdpack_shortlength(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare ptr @simdunpack_shortlength(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

attributes #0 = { nofree 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 = { "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 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 #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 "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind }
attributes #8 = { 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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


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