; LLVM IR from CLASS-SZ/class_sz :: class-sz/tools (r8lib)

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

@r8_factorial2_values.f_vec = external hidden global [16 x double], align 16
@r8_factorial2_values.n_vec = external hidden global [16 x i32], align 16

; Function Attrs: nounwind uwtable
define dso_local void @r8_factorial2_values(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = icmp slt i32 %8, 0
  br i1 %9, label %10, label %12

10:                                               ; preds = %3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %10, %3
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = add nsw i32 %14, 1
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  store i32 %15, ptr %16, align 4, !tbaa !9
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = icmp slt i32 16, %18
  br i1 %19, label %20, label %24

20:                                               ; preds = %12
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  store i32 0, ptr %21, align 4, !tbaa !9
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  store i32 0, ptr %22, align 4, !tbaa !9
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  store double 0.000000e+00, ptr %23, align 8, !tbaa !11
  br label %39

24:                                               ; preds = %12
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = sub nsw i32 %26, 1
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [16 x i32], ptr @r8_factorial2_values.n_vec, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  store i32 %30, ptr %31, align 4, !tbaa !9
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = sub nsw i32 %33, 1
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [16 x double], ptr @r8_factorial2_values.f_vec, i64 0, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !11
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  store double %37, ptr %38, align 8, !tbaa !11
  br label %39

39:                                               ; preds = %24, %20
  ret void
}

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

!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 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}


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

@r8_factorial2_values.f_vec = external hidden local_unnamed_addr global [16 x double], align 16
@r8_factorial2_values.n_vec = external hidden local_unnamed_addr global [16 x i32], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @r8_factorial2_values(ptr nocapture noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = load i32, ptr %0, align 4, !tbaa !5
  %5 = icmp slt i32 %4, 0
  br i1 %5, label %.thread, label %6

.thread:                                          ; preds = %3
  store i32 1, ptr %0, align 4, !tbaa !5
  br label %10

6:                                                ; preds = %3
  %7 = add nuw nsw i32 %4, 1
  store i32 %7, ptr %0, align 4, !tbaa !5
  %8 = icmp ugt i32 %4, 15
  br i1 %8, label %9, label %10

9:                                                ; preds = %6
  store i32 0, ptr %0, align 4, !tbaa !5
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %20

10:                                               ; preds = %.thread, %6
  %11 = phi i32 [ 0, %.thread ], [ %4, %6 ]
  %12 = zext nneg i32 %11 to i64
  %13 = getelementptr inbounds [16 x i32], ptr @r8_factorial2_values.n_vec, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %14, ptr %1, align 4, !tbaa !5
  %15 = load i32, ptr %0, align 4, !tbaa !5
  %16 = add nsw i32 %15, -1
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [16 x double], ptr @r8_factorial2_values.f_vec, i64 0, i64 %17
  %19 = load double, ptr %18, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %10, %9
  %storemerge = phi double [ %19, %10 ], [ 0.000000e+00, %9 ]
  store double %storemerge, ptr %2, align 8, !tbaa !9
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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" }

!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 = !{!"double", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass