; LLVM IR from jgaeddert/liquid-dsp :: src/random/tests (scramble_autotest)

; 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 = external hidden unnamed_addr constant [91 x i8], align 1
@liquid_autotest_verbose = external global i32, align 4
@.str.5 = external hidden unnamed_addr constant [36 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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #2

declare void @scramble_data(ptr noundef, i32 noundef) #3

declare i32 @liquid_autotest_same_data(ptr noundef, ptr noundef, i32 noundef) #3

declare void @liquid_autotest_failed_msg(ptr noundef, i32 noundef, ptr noundef) #3

declare void @liquid_autotest_print_array(ptr noundef, i32 noundef) #3

declare void @liquid_autotest_passed(...) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #1

; Function Attrs: nounwind uwtable
define dso_local void @liquid_scramble_soft_test(i32 noundef %0) #4 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = zext i32 %10 to i64
  %12 = call ptr @llvm.stacksave.p0()
  store ptr %12, ptr %3, align 8
  %13 = alloca i8, i64 %11, align 16
  store i64 %11, ptr %4, align 8
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = zext i32 %14 to i64
  %16 = alloca i8, i64 %15, align 16
  store i64 %15, ptr %5, align 8
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = mul i32 8, %17
  %19 = zext i32 %18 to i64
  %20 = alloca i8, i64 %19, align 16
  store i64 %19, ptr %6, align 8
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = zext i32 %21 to i64
  %23 = alloca i8, i64 %22, align 16
  store i64 %22, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %35, %1
  %25 = load i32, ptr %8, align 4, !tbaa !5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = icmp ult i32 %25, %26
  br i1 %27, label %28, label %38

28:                                               ; preds = %24
  %29 = call i32 @rand() #6
  %30 = and i32 %29, 255
  %31 = trunc i32 %30 to i8
  %32 = load i32, ptr %8, align 4, !tbaa !5
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds i8, ptr %13, i64 %33
  store i8 %31, ptr %34, align 1, !tbaa !9
  br label %35

35:                                               ; preds = %28
  %36 = load i32, ptr %8, align 4, !tbaa !5
  %37 = add i32 %36, 1
  store i32 %37, ptr %8, align 4, !tbaa !5
  br label %24, !llvm.loop !10

38:                                               ; preds = %24
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = zext i32 %39 to i64
  call void @llvm.memmove.p0.p0.i64(ptr align 16 %16, ptr align 16 %13, i64 %40, i1 false)
  %41 = load i32, ptr %2, align 4, !tbaa !5
  call void @scramble_data(ptr noundef %16, i32 noundef %41)
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %57, %38
  %43 = load i32, ptr %8, align 4, !tbaa !5
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = icmp ult i32 %43, %44
  br i1 %45, label %46, label %60

46:                                               ; preds = %42
  %47 = load i32, ptr %8, align 4, !tbaa !5
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds i8, ptr %16, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !9
  %51 = zext i8 %50 to i32
  %52 = load i32, ptr %8, align 4, !tbaa !5
  %53 = mul i32 8, %52
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds i8, ptr %20, i64 %54
  %56 = call i32 @liquid_unpack_soft_bits(i32 noundef %51, i32 noundef 8, ptr noundef %55)
  br label %57

57:                                               ; preds = %46
  %58 = load i32, ptr %8, align 4, !tbaa !5
  %59 = add i32 %58, 1
  store i32 %59, ptr %8, align 4, !tbaa !5
  br label %42, !llvm.loop !12

60:                                               ; preds = %42
  %61 = load i32, ptr %2, align 4, !tbaa !5
  call void @unscramble_data_soft(ptr noundef %20, i32 noundef %61)
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %62

62:                                               ; preds = %77, %60
  %63 = load i32, ptr %8, align 4, !tbaa !5
  %64 = load i32, ptr %2, align 4, !tbaa !5
  %65 = icmp ult i32 %63, %64
  br i1 %65, label %66, label %80

66:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = mul i32 8, %67
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds i8, ptr %20, i64 %69
  %71 = call i32 @liquid_pack_soft_bits(ptr noundef %70, i32 noundef 8, ptr noundef %9)
  %72 = load i32, ptr %9, align 4, !tbaa !5
  %73 = trunc i32 %72 to i8
  %74 = load i32, ptr %8, align 4, !tbaa !5
  %75 = zext i32 %74 to i64
  %76 = getelementptr inbounds i8, ptr %23, i64 %75
  store i8 %73, ptr %76, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %77

77:                                               ; preds = %66
  %78 = load i32, ptr %8, align 4, !tbaa !5
  %79 = add i32 %78, 1
  store i32 %79, ptr %8, align 4, !tbaa !5
  br label %62, !llvm.loop !13

80:                                               ; preds = %62
  %81 = load i32, ptr %2, align 4, !tbaa !5
  %82 = call i32 @liquid_autotest_same_data(ptr noundef %13, ptr noundef %23, i32 noundef %81)
  %83 = icmp ne i32 %82, 0
  br i1 %83, label %91, label %84

84:                                               ; preds = %80
  call void @liquid_autotest_failed_msg(ptr noundef @.str, i32 noundef 111, ptr noundef @.str.5)
  %85 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %87, label %90

87:                                               ; preds = %84
  %88 = load i32, ptr %2, align 4, !tbaa !5
  call void @liquid_autotest_print_array(ptr noundef %13, i32 noundef %88)
  %89 = load i32, ptr %2, align 4, !tbaa !5
  call void @liquid_autotest_print_array(ptr noundef %23, i32 noundef %89)
  br label %90

90:                                               ; preds = %87, %84
  br label %92

91:                                               ; preds = %80
  call void (...) @liquid_autotest_passed()
  br label %92

92:                                               ; preds = %91, %90
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  %93 = load ptr, ptr %3, align 8
  call void @llvm.stackrestore.p0(ptr %93)
  ret void
}

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

declare i32 @liquid_unpack_soft_bits(i32 noundef, i32 noundef, ptr noundef) #3

declare void @unscramble_data_soft(ptr noundef, i32 noundef) #3

declare i32 @liquid_pack_soft_bits(ptr noundef, i32 noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}


; 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 = external hidden unnamed_addr constant [91 x i8], align 1
@liquid_autotest_verbose = external local_unnamed_addr global i32, align 4
@.str.5 = external hidden unnamed_addr constant [36 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare void @scramble_data(ptr noundef, i32 noundef) local_unnamed_addr #1

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

declare void @liquid_autotest_failed_msg(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @liquid_autotest_print_array(ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @liquid_autotest_passed(...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @liquid_scramble_soft_test(i32 noundef %0) local_unnamed_addr #2 {
  %2 = alloca i32, align 4
  %3 = zext i32 %0 to i64
  %4 = alloca i8, i64 %3, align 16
  %5 = alloca i8, i64 %3, align 16
  %6 = shl i32 %0, 3
  %7 = zext i32 %6 to i64
  %8 = alloca i8, i64 %7, align 16
  %9 = alloca i8, i64 %3, align 16
  %.not35 = icmp eq i32 %0, 0
  br i1 %.not35, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %1
  call void @scramble_data(ptr noundef nonnull %5, i32 noundef %0) #5
  br label %._crit_edge30.thread

.lr.ph:                                           ; preds = %1, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %1 ]
  %10 = tail call i32 @rand() #5
  %11 = trunc i32 %10 to i8
  %12 = getelementptr inbounds i8, ptr %4, i64 %indvars.iv
  store i8 %11, ptr %12, align 1, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %3
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %.lr.ph
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %5, ptr nonnull align 16 %4, i64 %3, i1 false)
  call void @scramble_data(ptr noundef nonnull %5, i32 noundef %0) #5
  br i1 %.not35, label %._crit_edge30.thread, label %.lr.ph29

.lr.ph29:                                         ; preds = %._crit_edge, %.lr.ph29
  %indvars.iv39 = phi i64 [ %indvars.iv.next40, %.lr.ph29 ], [ 0, %._crit_edge ]
  %13 = getelementptr inbounds i8, ptr %5, i64 %indvars.iv39
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %15 = zext i8 %14 to i32
  %16 = shl i64 %indvars.iv39, 3
  %17 = and i64 %16, 4294967288
  %18 = getelementptr inbounds i8, ptr %8, i64 %17
  %19 = call i32 @liquid_unpack_soft_bits(i32 noundef %15, i32 noundef 8, ptr noundef nonnull %18) #5
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %exitcond43.not = icmp eq i64 %indvars.iv.next40, %3
  br i1 %exitcond43.not, label %._crit_edge30, label %.lr.ph29, !llvm.loop !10

._crit_edge30.thread:                             ; preds = %._crit_edge.thread, %._crit_edge
  call void @unscramble_data_soft(ptr noundef nonnull %8, i32 noundef %0) #5
  br label %._crit_edge34

._crit_edge30:                                    ; preds = %.lr.ph29
  call void @unscramble_data_soft(ptr noundef nonnull %8, i32 noundef %0) #5
  br i1 %.not35, label %._crit_edge34, label %.lr.ph33

.lr.ph33:                                         ; preds = %._crit_edge30, %.lr.ph33
  %indvars.iv44 = phi i64 [ %indvars.iv.next45, %.lr.ph33 ], [ 0, %._crit_edge30 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %20 = shl i64 %indvars.iv44, 3
  %21 = and i64 %20, 4294967288
  %22 = getelementptr inbounds i8, ptr %8, i64 %21
  %23 = call i32 @liquid_pack_soft_bits(ptr noundef nonnull %22, i32 noundef 8, ptr noundef nonnull %2) #5
  %24 = load i32, ptr %2, align 4, !tbaa !11
  %25 = trunc i32 %24 to i8
  %26 = getelementptr inbounds i8, ptr %9, i64 %indvars.iv44
  store i8 %25, ptr %26, align 1, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %exitcond48.not = icmp eq i64 %indvars.iv.next45, %3
  br i1 %exitcond48.not, label %._crit_edge34, label %.lr.ph33, !llvm.loop !13

._crit_edge34:                                    ; preds = %.lr.ph33, %._crit_edge30.thread, %._crit_edge30
  %27 = call i32 @liquid_autotest_same_data(ptr noundef nonnull %4, ptr noundef nonnull %9, i32 noundef %0) #5
  %.not = icmp eq i32 %27, 0
  br i1 %.not, label %28, label %31

28:                                               ; preds = %._crit_edge34
  call void @liquid_autotest_failed_msg(ptr noundef nonnull @.str, i32 noundef 111, ptr noundef nonnull @.str.5) #5
  %29 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !11
  %.not25 = icmp eq i32 %29, 0
  br i1 %.not25, label %32, label %30

30:                                               ; preds = %28
  call void @liquid_autotest_print_array(ptr noundef nonnull %4, i32 noundef %0) #5
  call void @liquid_autotest_print_array(ptr noundef nonnull %9, i32 noundef %0) #5
  br label %32

31:                                               ; preds = %._crit_edge34
  call void (...) @liquid_autotest_passed() #5
  br label %32

32:                                               ; preds = %28, %30, %31
  ret void
}

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

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

declare void @unscramble_data_soft(ptr noundef, i32 noundef) local_unnamed_addr #1

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

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

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 = { 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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !6, i64 0}
!13 = distinct !{!13, !9}


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