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

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

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@tests = external hidden global [19 x %struct.test_case_s], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %8 = call i32 @init_test_cases()
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !11
  br label %9

9:                                                ; preds = %22, %2
  %10 = load i64, ptr %6, align 8, !tbaa !11
  %11 = icmp ult i64 %10, 19
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  store i32 2, ptr %7, align 4
  br label %25

13:                                               ; preds = %9
  %14 = load i64, ptr %6, align 8, !tbaa !11
  %15 = call i32 (ptr, ...) @printf(ptr noundef @.str, i64 noundef %14)
  %16 = load i64, ptr %6, align 8, !tbaa !11
  %17 = getelementptr inbounds [19 x %struct.test_case_s], ptr @tests, i64 0, i64 %16
  %18 = call i32 @test_correctness(ptr noundef %17)
  %19 = icmp ne i32 0, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %13
  call void @destroy_test_cases()
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %25

21:                                               ; preds = %13
  br label %22

22:                                               ; preds = %21
  %23 = load i64, ptr %6, align 8, !tbaa !11
  %24 = add i64 %23, 1
  store i64 %24, ptr %6, align 8, !tbaa !11
  br label %9, !llvm.loop !13

25:                                               ; preds = %20, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %26 = load i32, ptr %7, align 4
  switch i32 %26, label %30 [
    i32 2, label %27
    i32 1, label %28
  ]

27:                                               ; preds = %25
  call void @destroy_test_cases()
  store i32 0, ptr %3, align 4
  br label %28

28:                                               ; preds = %27, %25
  %29 = load i32, ptr %3, align 4
  ret i32 %29

30:                                               ; preds = %25
  unreachable
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @init_test_cases() #1

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

declare i32 @printf(ptr noundef, ...) #3

declare i32 @test_correctness(ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @destroy_test_cases() #1

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

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 = { nocallback nofree nosync 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 }

!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"}


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

%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 }

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@tests = external hidden global [19 x %struct.test_case_s], align 16

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = tail call i32 @init_test_cases()
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 0)
  %5 = tail call i32 @test_correctness(ptr noundef nonnull @tests) #4
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %60

6:                                                ; preds = %2
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 1)
  %8 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 224)) #4
  %.not.1 = icmp eq i32 %8, 0
  br i1 %.not.1, label %9, label %60

9:                                                ; preds = %6
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 2)
  %11 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 448)) #4
  %.not.2 = icmp eq i32 %11, 0
  br i1 %.not.2, label %12, label %60

12:                                               ; preds = %9
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 3)
  %14 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 672)) #4
  %.not.3 = icmp eq i32 %14, 0
  br i1 %.not.3, label %15, label %60

15:                                               ; preds = %12
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 4)
  %17 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 896)) #4
  %.not.4 = icmp eq i32 %17, 0
  br i1 %.not.4, label %18, label %60

18:                                               ; preds = %15
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 5)
  %20 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 1120)) #4
  %.not.5 = icmp eq i32 %20, 0
  br i1 %.not.5, label %21, label %60

21:                                               ; preds = %18
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 6)
  %23 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 1344)) #4
  %.not.6 = icmp eq i32 %23, 0
  br i1 %.not.6, label %24, label %60

24:                                               ; preds = %21
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 7)
  %26 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 1568)) #4
  %.not.7 = icmp eq i32 %26, 0
  br i1 %.not.7, label %27, label %60

27:                                               ; preds = %24
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 8)
  %29 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 1792)) #4
  %.not.8 = icmp eq i32 %29, 0
  br i1 %.not.8, label %30, label %60

30:                                               ; preds = %27
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 9)
  %32 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 2016)) #4
  %.not.9 = icmp eq i32 %32, 0
  br i1 %.not.9, label %33, label %60

33:                                               ; preds = %30
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 10)
  %35 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 2240)) #4
  %.not.10 = icmp eq i32 %35, 0
  br i1 %.not.10, label %36, label %60

36:                                               ; preds = %33
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 11)
  %38 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 2464)) #4
  %.not.11 = icmp eq i32 %38, 0
  br i1 %.not.11, label %39, label %60

39:                                               ; preds = %36
  %40 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 12)
  %41 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 2688)) #4
  %.not.12 = icmp eq i32 %41, 0
  br i1 %.not.12, label %42, label %60

42:                                               ; preds = %39
  %43 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 13)
  %44 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 2912)) #4
  %.not.13 = icmp eq i32 %44, 0
  br i1 %.not.13, label %45, label %60

45:                                               ; preds = %42
  %46 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 14)
  %47 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 3136)) #4
  %.not.14 = icmp eq i32 %47, 0
  br i1 %.not.14, label %48, label %60

48:                                               ; preds = %45
  %49 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 15)
  %50 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 3360)) #4
  %.not.15 = icmp eq i32 %50, 0
  br i1 %.not.15, label %51, label %60

51:                                               ; preds = %48
  %52 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 16)
  %53 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 3584)) #4
  %.not.16 = icmp eq i32 %53, 0
  br i1 %.not.16, label %54, label %60

54:                                               ; preds = %51
  %55 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 17)
  %56 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 3808)) #4
  %.not.17 = icmp eq i32 %56, 0
  br i1 %.not.17, label %57, label %60

57:                                               ; preds = %54
  %58 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 18)
  %59 = tail call i32 @test_correctness(ptr noundef nonnull getelementptr inbounds (i8, ptr @tests, i64 4032)) #4
  br label %60

60:                                               ; preds = %57, %2, %6, %9, %12, %15, %18, %21, %24, %27, %30, %33, %36, %39, %42, %45, %48, %51, %54
  tail call void @destroy_test_cases()
  ret i32 0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @init_test_cases() local_unnamed_addr #1

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

declare i32 @test_correctness(ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @destroy_test_cases() 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 = { 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 #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 }

!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)"}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass