; LLVM IR from tangjz/acm-icpc :: hdu/5447.ll (Z5iscubn)

; 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 speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5iscubn(i64 noundef %0, i64 noundef %1) #2 {
  %3 = alloca i128, align 16
  %4 = alloca i128, align 16
  %5 = alloca i128, align 16
  %6 = getelementptr inbounds { i64, i64 }, ptr %3, i32 0, i32 0
  store i64 %0, ptr %6, align 16
  %7 = getelementptr inbounds { i64, i64 }, ptr %3, i32 0, i32 1
  store i64 %1, ptr %7, align 8
  %8 = load i128, ptr %3, align 16, !tbaa !5
  store i128 %8, ptr %4, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #4
  %9 = load i128, ptr %4, align 16, !tbaa !5
  %10 = sitofp i128 %9 to x86_fp80
  %11 = fptrunc x86_fp80 %10 to double
  %12 = call double @pow(double noundef %11, double noundef 0x3FD5555555555555) #4
  %13 = call double @llvm.ceil.f64(double %12)
  %14 = fptosi double %13 to i128
  store i128 %14, ptr %5, align 16, !tbaa !5
  br label %15

15:                                               ; preds = %24, %2
  %16 = load i128, ptr %5, align 16, !tbaa !5
  %17 = load i128, ptr %5, align 16, !tbaa !5
  %18 = mul nsw i128 %16, %17
  %19 = load i128, ptr %5, align 16, !tbaa !5
  %20 = mul nsw i128 %18, %19
  %21 = load i128, ptr %4, align 16, !tbaa !5
  %22 = icmp sle i128 %20, %21
  br i1 %22, label %23, label %27

23:                                               ; preds = %15
  br label %24

24:                                               ; preds = %23
  %25 = load i128, ptr %5, align 16, !tbaa !5
  %26 = add nsw i128 %25, 1
  store i128 %26, ptr %5, align 16, !tbaa !5
  br label %15, !llvm.loop !9

27:                                               ; preds = %15
  %28 = load i128, ptr %5, align 16, !tbaa !5
  %29 = add nsw i128 %28, -1
  store i128 %29, ptr %5, align 16, !tbaa !5
  br label %30

30:                                               ; preds = %39, %27
  %31 = load i128, ptr %5, align 16, !tbaa !5
  %32 = load i128, ptr %5, align 16, !tbaa !5
  %33 = mul nsw i128 %31, %32
  %34 = load i128, ptr %5, align 16, !tbaa !5
  %35 = mul nsw i128 %33, %34
  %36 = load i128, ptr %4, align 16, !tbaa !5
  %37 = icmp sgt i128 %35, %36
  br i1 %37, label %38, label %42

38:                                               ; preds = %30
  br label %39

39:                                               ; preds = %38
  %40 = load i128, ptr %5, align 16, !tbaa !5
  %41 = add nsw i128 %40, -1
  store i128 %41, ptr %5, align 16, !tbaa !5
  br label %30, !llvm.loop !11

42:                                               ; preds = %30
  %43 = load i128, ptr %5, align 16, !tbaa !5
  %44 = load i128, ptr %5, align 16, !tbaa !5
  %45 = mul nsw i128 %43, %44
  %46 = load i128, ptr %5, align 16, !tbaa !5
  %47 = mul nsw i128 %45, %46
  %48 = load i128, ptr %4, align 16, !tbaa !5
  %49 = icmp eq i128 %47, %48
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  ret i1 %49
}

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { 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 #4 = { 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 = !{!"__int128", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #0

; Function Attrs: mustprogress nofree nounwind memory(write) uwtable
define dso_local noundef zeroext i1 @_Z5iscubn(i64 noundef %0, i64 noundef %1) local_unnamed_addr #1 {
  %.sroa.2.0.insert.ext = zext i64 %1 to i128
  %.sroa.2.0.insert.shift = shl nuw i128 %.sroa.2.0.insert.ext, 64
  %.sroa.0.0.insert.ext = zext i64 %0 to i128
  %.sroa.0.0.insert.insert = or disjoint i128 %.sroa.2.0.insert.shift, %.sroa.0.0.insert.ext
  %3 = sitofp i128 %.sroa.0.0.insert.insert to x86_fp80
  %4 = fptrunc x86_fp80 %3 to double
  %5 = tail call double @pow(double noundef %4, double noundef 0x3FD5555555555555) #3
  %6 = tail call double @llvm.ceil.f64(double %5)
  %7 = fptosi double %6 to i128
  br label %8

8:                                                ; preds = %8, %2
  %.0 = phi i128 [ %7, %2 ], [ %11, %8 ]
  %9 = mul nsw i128 %.0, %.0
  %10 = mul nsw i128 %9, %.0
  %.not = icmp sgt i128 %10, %.sroa.0.0.insert.insert
  %11 = add nsw i128 %.0, 1
  br i1 %.not, label %.preheader, label %8, !llvm.loop !5

.preheader:                                       ; preds = %8, %.preheader
  %.1.in = phi i128 [ %.1, %.preheader ], [ %.0, %8 ]
  %.1 = add nsw i128 %.1.in, -1
  %12 = mul nsw i128 %.1, %.1
  %13 = mul nsw i128 %12, %.1
  %14 = icmp sgt i128 %13, %.sroa.0.0.insert.insert
  br i1 %14, label %.preheader, label %15, !llvm.loop !7

15:                                               ; preds = %.preheader
  %16 = icmp eq i128 %13, %.sroa.0.0.insert.insert
  ret i1 %16
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind memory(write) 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 = { mustprogress nofree nounwind willreturn memory(write) "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 = { 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 = distinct !{!7, !6}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass