; LLVM IR from scemama/slaterlib :: src (test)

; 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.18 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @random_int() #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @random_det(i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @random_single_exc(i32 noundef, ptr noundef, ptr noundef) #0

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

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

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) #3

declare void @debug_det(i32 noundef, ptr noundef) #4

declare i32 @get_holes_particles(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #4

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

21:                                               ; preds = %72, %1
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = icmp ult i32 %22, 10000
  br i1 %23, label %24, label %75

24:                                               ; preds = %21
  %25 = call i32 @random_int()
  store i32 %25, ptr %8, align 4, !tbaa !5
  %26 = load i32, ptr %8, align 4, !tbaa !5
  %27 = icmp ult i32 %26, 4
  br i1 %27, label %28, label %29

28:                                               ; preds = %24
  br label %32

29:                                               ; preds = %24
  %30 = load i32, ptr %8, align 4, !tbaa !5
  %31 = sub i32 %30, 2
  br label %32

32:                                               ; preds = %29, %28
  %33 = phi i32 [ 4, %28 ], [ %31, %29 ]
  store i32 %33, ptr %8, align 4, !tbaa !5
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %44, %32
  %35 = load i32, ptr %9, align 4, !tbaa !5
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = icmp ult i32 %35, %36
  br i1 %37, label %38, label %47

38:                                               ; preds = %34
  %39 = load i32, ptr %8, align 4, !tbaa !5
  %40 = call i64 @random_det(i32 noundef %39)
  %41 = load i32, ptr %9, align 4, !tbaa !5
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds i64, ptr %17, i64 %42
  store i64 %40, ptr %43, align 8, !tbaa !9
  br label %44

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

47:                                               ; preds = %34
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = call i32 @random_single_exc(i32 noundef %48, ptr noundef %17, ptr noundef %20)
  store i32 %49, ptr %12, align 4, !tbaa !5
  %50 = load i32, ptr %2, align 4, !tbaa !5
  %51 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 0
  %52 = getelementptr inbounds [2 x i32], ptr %11, i64 0, i64 0
  %53 = call i32 @get_holes_particles(i32 noundef %50, ptr noundef %17, ptr noundef %20, ptr noundef %51, ptr noundef %52)
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 0
  %56 = getelementptr inbounds [2 x i32], ptr %11, i64 0, i64 0
  %57 = call i32 @get_nperm_single(i32 noundef %54, ptr noundef %17, ptr noundef %20, ptr noundef %55, ptr noundef %56)
  store i32 %57, ptr %13, align 4, !tbaa !5
  %58 = load i32, ptr %12, align 4, !tbaa !5
  %59 = load i32, ptr %13, align 4, !tbaa !5
  %60 = icmp ne i32 %58, %59
  br i1 %60, label %61, label %71

61:                                               ; preds = %47
  %62 = load i32, ptr %2, align 4, !tbaa !5
  call void @debug_det(i32 noundef %62, ptr noundef %17)
  %63 = load i32, ptr %2, align 4, !tbaa !5
  call void @debug_det(i32 noundef %63, ptr noundef %20)
  store i32 -1, ptr %3, align 4, !tbaa !5
  store i32 10000, ptr %4, align 4, !tbaa !5
  %64 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 0
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = getelementptr inbounds [2 x i32], ptr %11, i64 0, i64 0
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = call i32 (ptr, ...) @printf(ptr noundef @.str.18, i32 noundef %65, i32 noundef %67)
  %69 = load i32, ptr %12, align 4, !tbaa !5
  %70 = load i32, ptr %13, align 4, !tbaa !5
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.19, i32 noundef %69, i32 noundef %70) #6
  unreachable

71:                                               ; preds = %47
  br label %72

72:                                               ; preds = %71
  %73 = load i32, ptr %4, align 4, !tbaa !5
  %74 = add i32 %73, 1
  store i32 %74, ptr %4, align 4, !tbaa !5
  br label %21, !llvm.loop !13

75:                                               ; preds = %21
  %76 = load i32, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %77 = load ptr, ptr %5, align 8
  call void @llvm.stackrestore.p0(ptr %77)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret i32 %76
}

declare i32 @get_nperm_single(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #4

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

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 memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind willreturn }
attributes #3 = { noreturn "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 = { "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 }
attributes #6 = { noreturn }

!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 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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.18 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @random_int() local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @random_det(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @random_single_exc(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) local_unnamed_addr #2

declare void @debug_det(i32 noundef, ptr noundef) local_unnamed_addr #3

declare i32 @get_holes_particles(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @test_nperm(i32 noundef %0) local_unnamed_addr #0 {
  %2 = alloca [2 x i32], align 4
  %3 = alloca [2 x i32], align 4
  %4 = zext i32 %0 to i64
  %5 = alloca i64, i64 %4, align 16
  %6 = alloca i64, i64 %4, align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %.not33 = icmp eq i32 %0, 0
  br i1 %.not33, label %.split, label %.lr.ph.us

.lr.ph.us:                                        ; preds = %1, %11
  %.027.us = phi i32 [ %12, %11 ], [ 0, %1 ]
  %7 = call i32 @random_int()
  %8 = icmp ult i32 %7, 4
  %9 = add i32 %7, -2
  %10 = select i1 %8, i32 4, i32 %9
  br label %13

11:                                               ; preds = %._crit_edge.us
  %12 = add nuw nsw i32 %.027.us, 1
  %exitcond44.not = icmp eq i32 %12, 10000
  br i1 %exitcond44.not, label %.split29.us, label %.lr.ph.us, !llvm.loop !5

13:                                               ; preds = %.lr.ph.us, %13
  %indvars.iv = phi i64 [ 0, %.lr.ph.us ], [ %indvars.iv.next, %13 ]
  %14 = call i64 @random_det(i32 noundef %10)
  %15 = getelementptr inbounds i64, ptr %5, i64 %indvars.iv
  store i64 %14, ptr %15, align 8, !tbaa !7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %4
  br i1 %exitcond.not, label %._crit_edge.us, label %13, !llvm.loop !11

._crit_edge.us:                                   ; preds = %13
  %16 = call i32 @random_single_exc(i32 noundef %0, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %17 = call i32 @get_holes_particles(i32 noundef %0, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %2, ptr noundef nonnull %3) #5
  %18 = call i32 @get_nperm_single(i32 noundef %0, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %2, ptr noundef nonnull %3) #5
  %.not.us = icmp eq i32 %16, %18
  br i1 %.not.us, label %11, label %.split31.us

19:                                               ; preds = %.split
  %20 = add nuw nsw i32 %.027, 1
  %exitcond45.not = icmp eq i32 %20, 10000
  br i1 %exitcond45.not, label %.split29.us, label %.split, !llvm.loop !5

.split:                                           ; preds = %1, %19
  %.027 = phi i32 [ %20, %19 ], [ 0, %1 ]
  %21 = call i32 @random_int()
  %22 = call i32 @random_single_exc(i32 noundef 0, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %23 = call i32 @get_holes_particles(i32 noundef 0, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %2, ptr noundef nonnull %3) #5
  %24 = call i32 @get_nperm_single(i32 noundef 0, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %2, ptr noundef nonnull %3) #5
  %.not = icmp eq i32 %22, %24
  br i1 %.not, label %19, label %.split31.us

.split31.us:                                      ; preds = %._crit_edge.us, %.split
  %.us-phi = phi i32 [ %22, %.split ], [ %16, %._crit_edge.us ]
  %.us-phi32 = phi i32 [ %24, %.split ], [ %18, %._crit_edge.us ]
  call void @debug_det(i32 noundef %0, ptr noundef nonnull %5) #5
  call void @debug_det(i32 noundef %0, ptr noundef nonnull %6) #5
  %25 = load i32, ptr %2, align 4, !tbaa !12
  %26 = load i32, ptr %3, align 4, !tbaa !12
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.18, i32 noundef %25, i32 noundef %26)
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.19, i32 noundef %.us-phi, i32 noundef %.us-phi32) #6
  unreachable

.split29.us:                                      ; preds = %11, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  ret i32 0
}

declare i32 @get_nperm_single(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass