; LLVM IR from IBM/optimized-number-theoretic-transform-implementations :: tests (test_correctness)

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

%struct.test_case_s = type { i64, i64, i64, i64, %struct.mul_op_s, i64, i64, i64, i64, %struct.aligned64_ptr_s, %struct.aligned64_ptr_s, %struct.aligned64_ptr_s, %struct.aligned64_ptr_s, %struct.aligned64_ptr_s, %struct.aligned64_ptr_s, %struct.aligned64_ptr_s, %struct.aligned64_ptr_s }
%struct.mul_op_s = type { i128, i128 }
%struct.aligned64_ptr_s = type { ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @test_correctness(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.test_case_s, ptr %10, i32 0, i32 5
  %12 = load i64, ptr %11, align 16, !tbaa !9
  %13 = call ptr @llvm.stacksave.p0()
  store ptr %13, ptr %4, align 8
  %14 = alloca i64, i64 %12, align 16
  store i64 %12, ptr %5, align 8
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.test_case_s, ptr %15, i32 0, i32 5
  %17 = load i64, ptr %16, align 16, !tbaa !9
  %18 = alloca i64, i64 %17, align 16
  store i64 %17, ptr %6, align 8
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.test_case_s, ptr %19, i32 0, i32 5
  %21 = load i64, ptr %20, align 16, !tbaa !9
  %22 = alloca i64, i64 %21, align 16
  store i64 %21, ptr %7, align 8
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.test_case_s, ptr %23, i32 0, i32 5
  %25 = load i64, ptr %24, align 16, !tbaa !9
  %26 = alloca i64, i64 %25, align 16
  store i64 %25, ptr %8, align 8
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.test_case_s, ptr %27, i32 0, i32 5
  %29 = load i64, ptr %28, align 16, !tbaa !9
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.test_case_s, ptr %30, i32 0, i32 1
  %32 = load i64, ptr %31, align 8, !tbaa !15
  call void @random_buf(ptr noundef %14, i64 noundef %29, i64 noundef %32)
  %33 = mul nuw i64 8, %12
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %26, ptr align 16 %14, i64 %33, i1 false)
  %34 = mul nuw i64 8, %12
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %18, ptr align 16 %14, i64 %34, i1 false)
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.test_case_s, ptr %35, i32 0, i32 5
  %37 = load i64, ptr %36, align 16, !tbaa !9
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.test_case_s, ptr %38, i32 0, i32 1
  %40 = load i64, ptr %39, align 8, !tbaa !15
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.test_case_s, ptr %41, i32 0, i32 9
  %43 = getelementptr inbounds %struct.aligned64_ptr_s, ptr %42, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !16
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.test_case_s, ptr %45, i32 0, i32 10
  %47 = getelementptr inbounds %struct.aligned64_ptr_s, ptr %46, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8, !tbaa !17
  call void @fwd_ntt_ref_harvey(ptr noundef %26, i64 noundef %37, i64 noundef %40, ptr noundef %44, ptr noundef %48)
  %49 = mul nuw i64 8, %25
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %22, ptr align 16 %26, i64 %49, i1 false)
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = call i32 @test_radix2_scalar(ptr noundef %50, ptr noundef %14)
  %52 = icmp ne i32 0, %51
  br i1 %52, label %53, label %54

53:                                               ; preds = %1
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %75

54:                                               ; preds = %1
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = call i32 @test_radix2_scalar_dbl(ptr noundef %55, ptr noundef %14, ptr noundef %18, ptr noundef %22)
  %57 = icmp ne i32 0, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %54
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %75

59:                                               ; preds = %54
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = call i32 @test_radix2_scalar_seal(ptr noundef %60, ptr noundef %14, ptr noundef %22)
  %62 = icmp ne i32 0, %61
  br i1 %62, label %63, label %64

63:                                               ; preds = %59
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %75

64:                                               ; preds = %59
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = call i32 @test_radix4_scalar(ptr noundef %65, ptr noundef %14, ptr noundef %22)
  %67 = icmp ne i32 0, %66
  br i1 %67, label %68, label %69

68:                                               ; preds = %64
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %75

69:                                               ; preds = %64
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = call i32 @test_radix4x4_scalar(ptr noundef %70, ptr noundef %14, ptr noundef %22)
  %72 = icmp ne i32 0, %71
  br i1 %72, label %73, label %74

73:                                               ; preds = %69
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %75

74:                                               ; preds = %69
  store i32 0, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %75

75:                                               ; preds = %74, %73, %68, %63, %58, %53
  %76 = load ptr, ptr %4, align 8
  call void @llvm.stackrestore.p0(ptr %76)
  %77 = load i32, ptr %2, align 4
  ret i32 %77
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @random_buf(ptr noundef, i64 noundef, i64 noundef) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @fwd_ntt_ref_harvey(ptr noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @test_radix2_scalar(ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @test_radix2_scalar_dbl(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @test_radix2_scalar_seal(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @test_radix4_scalar(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @test_radix4x4_scalar(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #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 }
attributes #2 = { inlinehint 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: readwrite) }

!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, !11, i64 64}
!10 = !{!"test_case_s", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !14, i64 96, !14, i64 112, !14, i64 128, !14, i64 144, !14, i64 160, !14, i64 176, !14, i64 192, !14, i64 208}
!11 = !{!"long", !7, i64 0}
!12 = !{!"mul_op_s", !13, i64 0, !13, i64 16}
!13 = !{!"__int128", !7, i64 0}
!14 = !{!"aligned64_ptr_s", !6, i64 0, !6, i64 8}
!15 = !{!10, !11, i64 8}
!16 = !{!10, !6, i64 104}
!17 = !{!10, !6, i64 120}


; 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 range(i32 -1, 1) i32 @test_correctness(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 64
  %3 = load i64, ptr %2, align 16, !tbaa !5
  %4 = alloca i64, i64 %3, align 16
  %5 = alloca i64, i64 %3, align 16
  %6 = alloca i64, i64 %3, align 16
  %7 = alloca i64, i64 %3, align 16
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i64, ptr %8, align 8, !tbaa !14
  call void @random_buf(ptr noundef nonnull %4, i64 noundef %3, i64 noundef %9)
  %10 = shl nuw i64 %3, 3
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %7, ptr nonnull align 16 %4, i64 %10, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %5, ptr nonnull align 16 %4, i64 %10, i1 false)
  %11 = load i64, ptr %2, align 16, !tbaa !5
  %12 = load i64, ptr %8, align 8, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %0, i64 104
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %0, i64 120
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  call void @fwd_ntt_ref_harvey(ptr noundef nonnull %7, i64 noundef %11, i64 noundef %12, ptr noundef %14, ptr noundef %16)
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %6, ptr nonnull align 16 %7, i64 %10, i1 false)
  %17 = call i32 @test_radix2_scalar(ptr noundef %0, ptr noundef nonnull %4)
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %18, label %26

18:                                               ; preds = %1
  %19 = call i32 @test_radix2_scalar_dbl(ptr noundef nonnull %0, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %.not16 = icmp eq i32 %19, 0
  br i1 %.not16, label %20, label %26

20:                                               ; preds = %18
  %21 = call i32 @test_radix2_scalar_seal(ptr noundef nonnull %0, ptr noundef nonnull %4, ptr noundef nonnull %6)
  %.not17 = icmp eq i32 %21, 0
  br i1 %.not17, label %22, label %26

22:                                               ; preds = %20
  %23 = call i32 @test_radix4_scalar(ptr noundef nonnull %0, ptr noundef nonnull %4, ptr noundef nonnull %6)
  %.not18 = icmp eq i32 %23, 0
  br i1 %.not18, label %24, label %26

24:                                               ; preds = %22
  %25 = call i32 @test_radix4x4_scalar(ptr noundef nonnull %0, ptr noundef nonnull %4, ptr noundef nonnull %6)
  %.not19 = icmp ne i32 %25, 0
  %. = sext i1 %.not19 to i32
  br label %26

26:                                               ; preds = %24, %22, %20, %18, %1
  %.0 = phi i32 [ -1, %1 ], [ -1, %18 ], [ -1, %20 ], [ -1, %22 ], [ %., %24 ]
  ret i32 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @random_buf(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress 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) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @fwd_ntt_ref_harvey(ptr noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @test_radix2_scalar(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @test_radix2_scalar_dbl(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @test_radix2_scalar_seal(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @test_radix4_scalar(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @test_radix4x4_scalar(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #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 = { inlinehint 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!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, !7, i64 64}
!6 = !{!"test_case_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !12, i64 96, !12, i64 112, !12, i64 128, !12, i64 144, !12, i64 160, !12, i64 176, !12, i64 192, !12, i64 208}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"mul_op_s", !11, i64 0, !11, i64 16}
!11 = !{!"__int128", !8, i64 0}
!12 = !{!"aligned64_ptr_s", !13, i64 0, !13, i64 8}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !13, i64 104}
!16 = !{!6, !13, i64 120}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass