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

; 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: nounwind uwtable
declare dso_local i32 @random_single_exc(i32 noundef, ptr noundef, ptr noundef) #1

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

24:                                               ; preds = %52, %3
  %25 = load i32, ptr %9, align 4, !tbaa !5
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %53

27:                                               ; preds = %24
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = load ptr, ptr %6, align 8, !tbaa !9
  %30 = call i32 @random_single_exc(i32 noundef %28, ptr noundef %20, ptr noundef %29)
  store i32 %30, ptr %12, align 4, !tbaa !5
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %49, %27
  %32 = load i32, ptr %10, align 4, !tbaa !5
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = icmp ult i32 %32, %33
  br i1 %34, label %35, label %52

35:                                               ; preds = %31
  %36 = load ptr, ptr %6, align 8, !tbaa !9
  %37 = load i32, ptr %10, align 4, !tbaa !5
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds i64, ptr %36, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !11
  %41 = load ptr, ptr %5, align 8, !tbaa !9
  %42 = load i32, ptr %10, align 4, !tbaa !5
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds i64, ptr %41, i64 %43
  %45 = load i64, ptr %44, align 8, !tbaa !11
  %46 = icmp ne i64 %40, %45
  br i1 %46, label %47, label %48

47:                                               ; preds = %35
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %52

48:                                               ; preds = %35
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %10, align 4, !tbaa !5
  %51 = add i32 %50, 1
  store i32 %51, ptr %10, align 4, !tbaa !5
  br label %31, !llvm.loop !13

52:                                               ; preds = %47, %31
  br label %24, !llvm.loop !15

53:                                               ; preds = %24
  %54 = load i32, ptr %11, align 4, !tbaa !5
  %55 = load i32, ptr %12, align 4, !tbaa !5
  %56 = add i32 %54, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %57 = load ptr, ptr %7, align 8
  call void @llvm.stackrestore.p0(ptr %57)
  ret i32 %56
}

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


; 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
declare dso_local i32 @random_single_exc(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @random_double_exc(i32 noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = zext i32 %0 to i64
  %5 = alloca i64, i64 %4, align 16
  %6 = call i32 @random_single_exc(i32 noundef %0, ptr noundef %1, ptr noundef nonnull %5)
  %7 = icmp ugt i32 %0, 1
  br i1 %7, label %.lr.ph.us, label %.split.split

.lr.ph.us.loopexit:                               ; preds = %9
  br label %.lr.ph.us, !llvm.loop !5

.lr.ph.us:                                        ; preds = %3, %.lr.ph.us.loopexit
  %8 = call i32 @random_single_exc(i32 noundef %0, ptr noundef nonnull %5, ptr noundef %2)
  br label %10

9:                                                ; preds = %10
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %4
  br i1 %exitcond.not, label %.lr.ph.us.loopexit, label %10, !llvm.loop !5

10:                                               ; preds = %.lr.ph.us, %9
  %indvars.iv = phi i64 [ 1, %.lr.ph.us ], [ %indvars.iv.next, %9 ]
  %11 = getelementptr inbounds i64, ptr %2, i64 %indvars.iv
  %12 = load i64, ptr %11, align 8, !tbaa !7
  %13 = getelementptr inbounds i64, ptr %1, i64 %indvars.iv
  %14 = load i64, ptr %13, align 8, !tbaa !7
  %.not19.us.not = icmp eq i64 %12, %14
  br i1 %.not19.us.not, label %9, label %.split24.us

.split.split:                                     ; preds = %3, %.split.split
  %15 = call i32 @random_single_exc(i32 noundef %0, ptr noundef nonnull %5, ptr noundef %2)
  br label %.split.split

.split24.us:                                      ; preds = %10
  %16 = add i32 %8, %6
  ret i32 %16
}

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


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