; LLVM IR from xirc/cp-algorithm :: spoj/pon/main.ll (Z17satisfy_compositemmmi)

; 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: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3powmmm(i64 noundef, i64 noundef, i64 noundef) #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: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z17satisfy_compositemmmi(i64 noundef %0, i64 noundef %1, i64 noundef %2, i32 noundef %3) #0 {
  %5 = alloca i1, align 1
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i64 %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %13 = load i64, ptr %7, align 8, !tbaa !5
  %14 = load i64, ptr %8, align 8, !tbaa !5
  %15 = load i64, ptr %6, align 8, !tbaa !5
  %16 = call noundef i64 @_Z3powmmm(i64 noundef %13, i64 noundef %14, i64 noundef %15)
  store i64 %16, ptr %10, align 8, !tbaa !5
  %17 = load i64, ptr %10, align 8, !tbaa !5
  %18 = icmp eq i64 %17, 1
  br i1 %18, label %24, label %19

19:                                               ; preds = %4
  %20 = load i64, ptr %10, align 8, !tbaa !5
  %21 = load i64, ptr %6, align 8, !tbaa !5
  %22 = sub i64 %21, 1
  %23 = icmp eq i64 %20, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %19, %4
  store i1 false, ptr %5, align 1
  store i32 1, ptr %11, align 4
  br label %53

25:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  store i32 1, ptr %12, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %47, %25
  %27 = load i32, ptr %12, align 4, !tbaa !9
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  store i32 2, ptr %11, align 4
  br label %50

31:                                               ; preds = %26
  %32 = load i64, ptr %10, align 8, !tbaa !5
  %33 = zext i64 %32 to i128
  %34 = load i64, ptr %10, align 8, !tbaa !5
  %35 = zext i64 %34 to i128
  %36 = mul nsw i128 %33, %35
  %37 = load i64, ptr %6, align 8, !tbaa !5
  %38 = zext i64 %37 to i128
  %39 = srem i128 %36, %38
  %40 = trunc i128 %39 to i64
  store i64 %40, ptr %10, align 8, !tbaa !5
  %41 = load i64, ptr %10, align 8, !tbaa !5
  %42 = load i64, ptr %6, align 8, !tbaa !5
  %43 = sub i64 %42, 1
  %44 = icmp eq i64 %41, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %31
  store i1 false, ptr %5, align 1
  store i32 1, ptr %11, align 4
  br label %50

46:                                               ; preds = %31
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %12, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %12, align 4, !tbaa !9
  br label %26, !llvm.loop !11

50:                                               ; preds = %45, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  %51 = load i32, ptr %11, align 4
  switch i32 %51, label %53 [
    i32 2, label %52
  ]

52:                                               ; preds = %50
  store i1 true, ptr %5, align 1
  store i32 1, ptr %11, align 4
  br label %53

53:                                               ; preds = %52, %50, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  %54 = load i1, ptr %5, align 1
  ret i1 %54
}

attributes #0 = { mustprogress 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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3powmmm(i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z17satisfy_compositemmmi(i64 noundef %0, i64 noundef %1, i64 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = tail call noundef i64 @_Z3powmmm(i64 noundef %1, i64 noundef %2, i64 noundef %0)
  %6 = icmp eq i64 %5, 1
  br i1 %6, label %.loopexit, label %7

7:                                                ; preds = %4
  %8 = add i64 %0, -1
  %9 = icmp eq i64 %5, %8
  br i1 %9, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %7
  %.not21 = icmp slt i32 %3, 2
  br i1 %.not21, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %10 = zext i64 %0 to i128
  br label %11

11:                                               ; preds = %11, %.lr.ph
  %.023 = phi i32 [ 1, %.lr.ph ], [ %17, %11 ]
  %.01622 = phi i64 [ %5, %.lr.ph ], [ %15, %11 ]
  %12 = zext i64 %.01622 to i128
  %13 = mul nuw nsw i128 %12, %12
  %14 = urem i128 %13, %10
  %15 = trunc nuw i128 %14 to i64
  %16 = icmp ne i64 %8, %15
  %.not = xor i1 %16, true
  %17 = add nuw nsw i32 %.023, 1
  %exitcond = icmp eq i32 %17, %3
  %or.cond = select i1 %.not, i1 true, i1 %exitcond
  br i1 %or.cond, label %.loopexit, label %11, !llvm.loop !5

.loopexit:                                        ; preds = %11, %.preheader, %4, %7
  %.1 = phi i1 [ false, %7 ], [ false, %4 ], [ true, %.preheader ], [ %16, %11 ]
  ret i1 %.1
}

attributes #0 = { mustprogress 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"}


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