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

@.str.7 = external hidden unnamed_addr constant [6 x i8], align 1
@__func__.test_simdmaxbitsd1_length = external hidden unnamed_addr constant [26 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [26 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

; 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 @test_simdmaxbitsd1_length() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [301 x i32], align 16
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 1204, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %7 = getelementptr inbounds [301 x i32], ptr %3, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %7, i8 -1, i64 1204, i1 false)
  %8 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, ptr noundef @__func__.test_simdmaxbitsd1_length)
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %43, %0
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = icmp slt i32 %10, 300
  br i1 %11, label %12, label %46

12:                                               ; preds = %9
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %23, %12
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = icmp slt i32 %14, %15
  br i1 %16, label %17, label %26

17:                                               ; preds = %13
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [301 x i32], ptr %3, i64 0, i64 %21
  store i32 %19, ptr %22, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %17
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %5, align 4, !tbaa !5
  br label %13, !llvm.loop !9

26:                                               ; preds = %13
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = add nsw i32 %27, 2
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [301 x i32], ptr %3, i64 0, i64 %30
  store i32 %28, ptr %31, align 4, !tbaa !5
  %32 = getelementptr inbounds [301 x i32], ptr %3, i64 0, i64 0
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  %35 = call i32 @simdmaxbitsd1_length(i32 noundef 0, ptr noundef %32, i32 noundef %34)
  store i32 %35, ptr %2, align 4, !tbaa !5
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = icmp ne i32 %36, 2
  br i1 %37, label %38, label %42

38:                                               ; preds = %26
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.16, i32 noundef %39, i32 noundef %40)
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %48

42:                                               ; preds = %26
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %4, align 4, !tbaa !5
  br label %9, !llvm.loop !11

46:                                               ; preds = %9
  %47 = call i32 (ptr, ...) @printf(ptr noundef @.str.17)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %48

48:                                               ; preds = %46, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 1204, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %49 = load i32, ptr %1, align 4
  ret i32 %49
}

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

declare i32 @simdmaxbitsd1_length(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 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"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}


; 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.7 = external hidden unnamed_addr constant [6 x i8], align 1
@__func__.test_simdmaxbitsd1_length = external hidden unnamed_addr constant [26 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [26 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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) 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: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @test_simdmaxbitsd1_length() local_unnamed_addr #2 {
  %1 = alloca [301 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 1204, ptr nonnull %1) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1204) %1, i8 -1, i64 1204, i1 false)
  %2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, ptr noundef nonnull @__func__.test_simdmaxbitsd1_length)
  br label %3

3:                                                ; preds = %._crit_edge, %0
  %indvars.iv22 = phi i64 [ %indvars.iv.next23, %._crit_edge ], [ 0, %0 ]
  switch i64 %indvars.iv22, label %.lr.ph.preheader [
    i64 300, label %21
    i64 0, label %._crit_edge
  ]

.lr.ph.preheader:                                 ; preds = %3
  %min.iters.check = icmp ult i64 %indvars.iv22, 8
  br i1 %min.iters.check, label %.lr.ph.preheader29, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %indvars.iv22, 9223372036854775800
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i64> [ <i64 0, i64 1, i64 2, i64 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %4 = getelementptr inbounds [301 x i32], ptr %1, i64 0, i64 %index
  %5 = trunc <4 x i64> %vec.ind to <4 x i32>
  %6 = add <4 x i32> %5, <i32 1, i32 1, i32 1, i32 1>
  %7 = trunc <4 x i64> %vec.ind to <4 x i32>
  %8 = add <4 x i32> %7, <i32 5, i32 5, i32 5, i32 5>
  %9 = getelementptr inbounds i8, ptr %4, i64 16
  store <4 x i32> %6, ptr %4, align 16, !tbaa !5
  store <4 x i32> %8, ptr %9, align 16, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i64> %vec.ind, <i64 8, i64 8, i64 8, i64 8>
  %10 = icmp eq i64 %index.next, %n.vec
  br i1 %10, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %indvars.iv22, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader29

.lr.ph.preheader29:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader29, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader29 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %11 = getelementptr inbounds [301 x i32], ptr %1, i64 0, i64 %indvars.iv
  %12 = trunc nuw nsw i64 %indvars.iv.next to i32
  store i32 %12, ptr %11, align 4, !tbaa !5
  %exitcond.not = icmp eq i64 %indvars.iv.next, %indvars.iv22
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %3
  %13 = getelementptr inbounds [301 x i32], ptr %1, i64 0, i64 %indvars.iv22
  %14 = trunc i64 %indvars.iv22 to i32
  %15 = add i32 %14, 2
  store i32 %15, ptr %13, align 4, !tbaa !5
  %indvars.iv.next23 = add nuw nsw i64 %indvars.iv22, 1
  %16 = trunc nuw nsw i64 %indvars.iv.next23 to i32
  %17 = call i32 @simdmaxbitsd1_length(i32 noundef 0, ptr noundef nonnull %1, i32 noundef %16) #5
  %.not = icmp eq i32 %17, 2
  br i1 %.not, label %3, label %18, !llvm.loop !14

18:                                               ; preds = %._crit_edge
  %19 = trunc nuw nsw i64 %indvars.iv22 to i32
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16, i32 noundef %17, i32 noundef %19)
  br label %23

21:                                               ; preds = %3
  %22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17)
  br label %23

23:                                               ; preds = %21, %18
  %.015 = phi i32 [ -1, %18 ], [ 0, %21 ]
  call void @llvm.lifetime.end.p0(i64 1204, ptr nonnull %1) #5
  ret i32 %.015
}

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

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

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

!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, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass,TailCallElimPass