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

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

; 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
define dso_local i32 @exc_degree_simple(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 i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  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
  %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
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  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 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = mul i32 %19, 64
  %21 = zext i32 %20 to i64
  %22 = call ptr @llvm.stacksave.p0()
  store ptr %22, ptr %12, align 8
  %23 = alloca i32, i64 %21, align 16
  store i64 %21, ptr %13, align 8
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = mul i32 %24, 64
  %26 = zext i32 %25 to i64
  %27 = alloca i32, i64 %26, align 16
  store i64 %26, ptr %14, align 8
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = load ptr, ptr %5, align 8, !tbaa !9
  %30 = call i32 @to_orbital_list(i32 noundef %28, ptr noundef %29, ptr noundef %23)
  store i32 %30, ptr %9, align 4, !tbaa !5
  %31 = load i32, ptr %9, align 4, !tbaa !5
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = load ptr, ptr %6, align 8, !tbaa !9
  %34 = call i32 @to_orbital_list(i32 noundef %32, ptr noundef %33, ptr noundef %27)
  %35 = icmp ne i32 %31, %34
  br i1 %35, label %36, label %46

36:                                               ; preds = %3
  %37 = load i32, ptr %9, align 4, !tbaa !5
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = load ptr, ptr %6, align 8, !tbaa !9
  %40 = call i32 @to_orbital_list(i32 noundef %38, ptr noundef %39, ptr noundef %27)
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %37, i32 noundef %40)
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = load ptr, ptr %5, align 8, !tbaa !9
  call void @debug_det(i32 noundef %42, ptr noundef %43)
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = load ptr, ptr %6, align 8, !tbaa !9
  call void @debug_det(i32 noundef %44, ptr noundef %45)
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef @.str.1) #6
  unreachable

46:                                               ; preds = %3
  %47 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %47, ptr %11, align 4, !tbaa !5
  store i32 0, ptr %10, align 4, !tbaa !5
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %89, %46
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = load i32, ptr %9, align 4, !tbaa !5
  %51 = icmp ult i32 %49, %50
  br i1 %51, label %52, label %92

52:                                               ; preds = %48
  %53 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %53, ptr %8, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %85, %52
  %55 = load i32, ptr %8, align 4, !tbaa !5
  %56 = load i32, ptr %9, align 4, !tbaa !5
  %57 = icmp ult i32 %55, %56
  br i1 %57, label %58, label %88

58:                                               ; preds = %54
  %59 = load i32, ptr %8, align 4, !tbaa !5
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds i32, ptr %27, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds i32, ptr %23, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = icmp ugt i32 %62, %66
  br i1 %67, label %68, label %69

68:                                               ; preds = %58
  br label %88

69:                                               ; preds = %58
  %70 = load i32, ptr %7, align 4, !tbaa !5
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds i32, ptr %23, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = load i32, ptr %8, align 4, !tbaa !5
  %75 = zext i32 %74 to i64
  %76 = getelementptr inbounds i32, ptr %27, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = icmp eq i32 %73, %77
  br i1 %78, label %79, label %83

79:                                               ; preds = %69
  %80 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %80, ptr %10, align 4, !tbaa !5
  %81 = load i32, ptr %11, align 4, !tbaa !5
  %82 = add i32 %81, -1
  store i32 %82, ptr %11, align 4, !tbaa !5
  br label %88

83:                                               ; preds = %69
  br label %84

84:                                               ; preds = %83
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %8, align 4, !tbaa !5
  %87 = add i32 %86, 1
  store i32 %87, ptr %8, align 4, !tbaa !5
  br label %54, !llvm.loop !11

88:                                               ; preds = %79, %68, %54
  br label %89

89:                                               ; preds = %88
  %90 = load i32, ptr %7, align 4, !tbaa !5
  %91 = add i32 %90, 1
  store i32 %91, ptr %7, align 4, !tbaa !5
  br label %48, !llvm.loop !13

92:                                               ; preds = %48
  %93 = load i32, ptr %11, align 4, !tbaa !5
  %94 = load ptr, ptr %12, align 8
  call void @llvm.stackrestore.p0(ptr %94)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, 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
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret i32 %93
}

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

declare i32 @to_orbital_list(i32 noundef, ptr noundef, ptr noundef) #3

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

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

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

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

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 = { "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 = { 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 #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 = !{!"any pointer", !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 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [60 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @exc_degree_simple(i32 noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = shl i32 %0, 6
  %5 = zext i32 %4 to i64
  %6 = alloca i32, i64 %5, align 16
  %7 = alloca i32, i64 %5, align 16
  %8 = call i32 @to_orbital_list(i32 noundef %0, ptr noundef %1, ptr noundef nonnull %6) #4
  %9 = call i32 @to_orbital_list(i32 noundef %0, ptr noundef %2, ptr noundef nonnull %7) #4
  %.not = icmp eq i32 %8, %9
  br i1 %.not, label %.preheader39, label %10

.preheader39:                                     ; preds = %3
  %.not47 = icmp eq i32 %8, 0
  br i1 %.not47, label %._crit_edge, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader39
  %wide.trip.count = zext i32 %8 to i64
  br label %.preheader

10:                                               ; preds = %3
  %11 = call i32 @to_orbital_list(i32 noundef %0, ptr noundef %2, ptr noundef nonnull %7) #4
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %8, i32 noundef %11)
  call void @debug_det(i32 noundef %0, ptr noundef %1) #4
  call void @debug_det(i32 noundef %0, ptr noundef %2) #4
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef nonnull @.str.1) #5
  unreachable

.preheader:                                       ; preds = %.preheader.preheader, %.loopexit
  %indvars.iv50 = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next51, %.loopexit ]
  %.03244 = phi i32 [ 0, %.preheader.preheader ], [ %.1, %.loopexit ]
  %.03343 = phi i32 [ %8, %.preheader.preheader ], [ %.134, %.loopexit ]
  %13 = icmp ult i32 %.03244, %8
  br i1 %13, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %14 = getelementptr inbounds i32, ptr %6, i64 %indvars.iv50
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = zext i32 %.03244 to i64
  br label %17

17:                                               ; preds = %.lr.ph, %26
  %indvars.iv = phi i64 [ %16, %.lr.ph ], [ %indvars.iv.next, %26 ]
  %18 = getelementptr inbounds i32, ptr %7, i64 %indvars.iv
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = icmp ugt i32 %19, %15
  br i1 %20, label %.loopexit, label %21

21:                                               ; preds = %17
  %22 = icmp eq i32 %15, %19
  br i1 %22, label %23, label %26

23:                                               ; preds = %21
  %24 = trunc nuw i64 %indvars.iv to i32
  %25 = add i32 %.03343, -1
  br label %.loopexit

26:                                               ; preds = %21
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond.not = icmp eq i32 %8, %lftr.wideiv
  br i1 %exitcond.not, label %.loopexit, label %17, !llvm.loop !9

.loopexit:                                        ; preds = %17, %26, %.preheader, %23
  %.134 = phi i32 [ %25, %23 ], [ %.03343, %.preheader ], [ %.03343, %26 ], [ %.03343, %17 ]
  %.1 = phi i32 [ %24, %23 ], [ %.03244, %.preheader ], [ %.03244, %26 ], [ %.03244, %17 ]
  %indvars.iv.next51 = add nuw nsw i64 %indvars.iv50, 1
  %exitcond53.not = icmp eq i64 %indvars.iv.next51, %wide.trip.count
  br i1 %exitcond53.not, label %._crit_edge, label %.preheader, !llvm.loop !11

._crit_edge:                                      ; preds = %.loopexit, %.preheader39
  %.033.lcssa = phi i32 [ 0, %.preheader39 ], [ %.134, %.loopexit ]
  ret i32 %.033.lcssa
}

declare i32 @to_orbital_list(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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

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 = { "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 = { 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 = { nounwind }
attributes #5 = { 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 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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