; LLVM IR from xirc/cp-algorithm :: atcoder/abc105/B/main.ll (Z5solvei)

; 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
define dso_local noundef zeroext i1 @_Z5solvei(i32 noundef %0) #0 {
  %2 = alloca i1, align 1
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %47, %1
  %8 = load i32, ptr %4, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 30
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  store i32 2, ptr %5, align 4
  br label %50

11:                                               ; preds = %7
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = mul nsw i32 %12, 4
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = icmp sgt i32 %13, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %11
  br label %47

17:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %41, %17
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = icmp slt i32 %19, 20
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  store i32 5, ptr %5, align 4
  br label %44

22:                                               ; preds = %18
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = mul nsw i32 %23, 4
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = mul nsw i32 %25, 7
  %27 = add nsw i32 %24, %26
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = icmp sgt i32 %27, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %22
  br label %41

31:                                               ; preds = %22
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = mul nsw i32 %32, 4
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = mul nsw i32 %34, 7
  %36 = add nsw i32 %33, %35
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = icmp eq i32 %36, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %31
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %44

40:                                               ; preds = %31
  br label %41

41:                                               ; preds = %40, %30
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %6, align 4, !tbaa !5
  br label %18, !llvm.loop !9

44:                                               ; preds = %39, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %45 = load i32, ptr %5, align 4
  switch i32 %45, label %50 [
    i32 5, label %46
  ]

46:                                               ; preds = %44
  br label %47

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

50:                                               ; preds = %44, %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %51 = load i32, ptr %5, align 4
  switch i32 %51, label %55 [
    i32 2, label %52
    i32 1, label %53
  ]

52:                                               ; preds = %50
  store i1 false, ptr %2, align 1
  br label %53

53:                                               ; preds = %52, %50
  %54 = load i1, ptr %2, align 1
  ret i1 %54

55:                                               ; preds = %50
  unreachable
}

; 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

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 = !{!"int", !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 nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef zeroext i1 @_Z5solvei(i32 noundef %0) local_unnamed_addr #0 {
  %2 = mul i32 %0, -1227133513
  %3 = icmp sgt i32 %0, -1
  %switch49 = icmp ult i32 %2, 20
  %or.cond50 = and i1 %3, %switch49
  br i1 %or.cond50, label %.loopexit, label %.thread

.thread.1:                                        ; preds = %.thread
  %indvars.iv.next.1 = add i32 %2, 1227133512
  %4 = icmp sgt i32 %0, 7
  %switch.1 = icmp ult i32 %indvars.iv.next.1, 20
  %or.cond.1 = and i1 %4, %switch.1
  br i1 %or.cond.1, label %.loopexit, label %.thread.2, !llvm.loop !5

.thread.2:                                        ; preds = %.thread.1
  %indvars.iv.next.2 = add i32 %2, 1840700268
  %5 = icmp sgt i32 %0, 11
  %switch.2 = icmp ult i32 %indvars.iv.next.2, 20
  %or.cond.2 = and i1 %5, %switch.2
  br i1 %or.cond.2, label %.loopexit, label %.thread.3, !llvm.loop !5

.thread.3:                                        ; preds = %.thread.2
  %indvars.iv.next.3 = add i32 %2, -1840700272
  %6 = icmp sgt i32 %0, 15
  %switch.3 = icmp ult i32 %indvars.iv.next.3, 20
  %or.cond.3 = and i1 %6, %switch.3
  br i1 %or.cond.3, label %.loopexit, label %.thread.4, !llvm.loop !5

.thread.4:                                        ; preds = %.thread.3
  %indvars.iv.next.4 = add i32 %2, -1227133516
  %7 = icmp sgt i32 %0, 19
  %switch.4 = icmp ult i32 %indvars.iv.next.4, 20
  %or.cond.4 = and i1 %7, %switch.4
  br i1 %or.cond.4, label %.loopexit, label %.thread.5, !llvm.loop !5

.thread.5:                                        ; preds = %.thread.4
  %indvars.iv.next.5 = add i32 %2, -613566760
  %8 = icmp sgt i32 %0, 23
  %switch.5 = icmp ult i32 %indvars.iv.next.5, 20
  %or.cond.5 = and i1 %8, %switch.5
  br i1 %or.cond.5, label %.loopexit, label %.thread.6, !llvm.loop !5

.thread.6:                                        ; preds = %.thread.5
  %indvars.iv.next.6 = add i32 %2, -4
  %9 = icmp sgt i32 %0, 27
  %switch.6 = icmp ult i32 %indvars.iv.next.6, 20
  %or.cond.6 = and i1 %9, %switch.6
  br i1 %or.cond.6, label %.loopexit, label %.thread.7, !llvm.loop !5

.thread.7:                                        ; preds = %.thread.6
  %indvars.iv.next.7 = add i32 %2, 613566752
  %10 = icmp sgt i32 %0, 31
  %switch.7 = icmp ult i32 %indvars.iv.next.7, 20
  %or.cond.7 = and i1 %10, %switch.7
  br i1 %or.cond.7, label %.loopexit, label %.thread.8, !llvm.loop !5

.thread.8:                                        ; preds = %.thread.7
  %indvars.iv.next.8 = add i32 %2, 1227133508
  %11 = icmp sgt i32 %0, 35
  %switch.8 = icmp ult i32 %indvars.iv.next.8, 20
  %or.cond.8 = and i1 %11, %switch.8
  br i1 %or.cond.8, label %.loopexit, label %.thread.9, !llvm.loop !5

.thread.9:                                        ; preds = %.thread.8
  %indvars.iv.next.9 = add i32 %2, 1840700264
  %12 = icmp sgt i32 %0, 39
  %switch.9 = icmp ult i32 %indvars.iv.next.9, 20
  %or.cond.9 = and i1 %12, %switch.9
  br i1 %or.cond.9, label %.loopexit, label %.thread.10, !llvm.loop !5

.thread.10:                                       ; preds = %.thread.9
  %indvars.iv.next.10 = add i32 %2, -1840700276
  %13 = icmp sgt i32 %0, 43
  %switch.10 = icmp ult i32 %indvars.iv.next.10, 20
  %or.cond.10 = and i1 %13, %switch.10
  br i1 %or.cond.10, label %.loopexit, label %.thread.11, !llvm.loop !5

.thread.11:                                       ; preds = %.thread.10
  %indvars.iv.next.11 = add i32 %2, -1227133520
  %14 = icmp sgt i32 %0, 47
  %switch.11 = icmp ult i32 %indvars.iv.next.11, 20
  %or.cond.11 = and i1 %14, %switch.11
  br i1 %or.cond.11, label %.loopexit, label %.thread.12, !llvm.loop !5

.thread.12:                                       ; preds = %.thread.11
  %indvars.iv.next.12 = add i32 %2, -613566764
  %15 = icmp sgt i32 %0, 51
  %switch.12 = icmp ult i32 %indvars.iv.next.12, 20
  %or.cond.12 = and i1 %15, %switch.12
  br i1 %or.cond.12, label %.loopexit, label %.thread.13, !llvm.loop !5

.thread.13:                                       ; preds = %.thread.12
  %indvars.iv.next.13 = add i32 %2, -8
  %16 = icmp sgt i32 %0, 55
  %switch.13 = icmp ult i32 %indvars.iv.next.13, 20
  %or.cond.13 = and i1 %16, %switch.13
  br i1 %or.cond.13, label %.loopexit, label %.thread.14, !llvm.loop !5

.thread.14:                                       ; preds = %.thread.13
  %indvars.iv.next.14 = add i32 %2, 613566748
  %17 = icmp sgt i32 %0, 59
  %switch.14 = icmp ult i32 %indvars.iv.next.14, 20
  %or.cond.14 = and i1 %17, %switch.14
  br i1 %or.cond.14, label %.loopexit, label %.thread.15, !llvm.loop !5

.thread.15:                                       ; preds = %.thread.14
  %indvars.iv.next.15 = add i32 %2, 1227133504
  %18 = icmp sgt i32 %0, 63
  %switch.15 = icmp ult i32 %indvars.iv.next.15, 20
  %or.cond.15 = and i1 %18, %switch.15
  br i1 %or.cond.15, label %.loopexit, label %.thread.16, !llvm.loop !5

.thread.16:                                       ; preds = %.thread.15
  %indvars.iv.next.16 = add i32 %2, 1840700260
  %19 = icmp sgt i32 %0, 67
  %switch.16 = icmp ult i32 %indvars.iv.next.16, 20
  %or.cond.16 = and i1 %19, %switch.16
  br i1 %or.cond.16, label %.loopexit, label %.thread.17, !llvm.loop !5

.thread.17:                                       ; preds = %.thread.16
  %indvars.iv.next.17 = add i32 %2, -1840700280
  %20 = icmp sgt i32 %0, 71
  %switch.17 = icmp ult i32 %indvars.iv.next.17, 20
  %or.cond.17 = and i1 %20, %switch.17
  br i1 %or.cond.17, label %.loopexit, label %.thread.18, !llvm.loop !5

.thread.18:                                       ; preds = %.thread.17
  %indvars.iv.next.18 = add i32 %2, -1227133524
  %21 = icmp sgt i32 %0, 75
  %switch.18 = icmp ult i32 %indvars.iv.next.18, 20
  %or.cond.18 = and i1 %21, %switch.18
  br i1 %or.cond.18, label %.loopexit, label %.thread.19, !llvm.loop !5

.thread.19:                                       ; preds = %.thread.18
  %indvars.iv.next.19 = add i32 %2, -613566768
  %22 = icmp sgt i32 %0, 79
  %switch.19 = icmp ult i32 %indvars.iv.next.19, 20
  %or.cond.19 = and i1 %22, %switch.19
  br i1 %or.cond.19, label %.loopexit, label %.thread.20, !llvm.loop !5

.thread.20:                                       ; preds = %.thread.19
  %indvars.iv.next.20 = add i32 %2, -12
  %23 = icmp sgt i32 %0, 83
  %switch.20 = icmp ult i32 %indvars.iv.next.20, 20
  %or.cond.20 = and i1 %23, %switch.20
  br i1 %or.cond.20, label %.loopexit, label %.thread.21, !llvm.loop !5

.thread.21:                                       ; preds = %.thread.20
  %indvars.iv.next.21 = add i32 %2, 613566744
  %24 = icmp sgt i32 %0, 87
  %switch.21 = icmp ult i32 %indvars.iv.next.21, 20
  %or.cond.21 = and i1 %24, %switch.21
  br i1 %or.cond.21, label %.loopexit, label %.thread.22, !llvm.loop !5

.thread.22:                                       ; preds = %.thread.21
  %indvars.iv.next.22 = add i32 %2, 1227133500
  %25 = icmp sgt i32 %0, 91
  %switch.22 = icmp ult i32 %indvars.iv.next.22, 20
  %or.cond.22 = and i1 %25, %switch.22
  br i1 %or.cond.22, label %.loopexit, label %.thread.23, !llvm.loop !5

.thread.23:                                       ; preds = %.thread.22
  %indvars.iv.next.23 = add i32 %2, 1840700256
  %26 = icmp sgt i32 %0, 95
  %switch.23 = icmp ult i32 %indvars.iv.next.23, 20
  %or.cond.23 = and i1 %26, %switch.23
  br i1 %or.cond.23, label %.loopexit, label %.thread.24, !llvm.loop !5

.thread.24:                                       ; preds = %.thread.23
  %indvars.iv.next.24 = add i32 %2, -1840700284
  %27 = icmp sgt i32 %0, 99
  %switch.24 = icmp ult i32 %indvars.iv.next.24, 20
  %or.cond.24 = and i1 %27, %switch.24
  br i1 %or.cond.24, label %.loopexit, label %.thread.25, !llvm.loop !5

.thread.25:                                       ; preds = %.thread.24
  %indvars.iv.next.25 = add i32 %2, -1227133528
  %28 = icmp sgt i32 %0, 103
  %switch.25 = icmp ult i32 %indvars.iv.next.25, 20
  %or.cond.25 = and i1 %28, %switch.25
  br i1 %or.cond.25, label %.loopexit, label %.thread.26, !llvm.loop !5

.thread.26:                                       ; preds = %.thread.25
  %indvars.iv.next.26 = add i32 %2, -613566772
  %29 = icmp sgt i32 %0, 107
  %switch.26 = icmp ult i32 %indvars.iv.next.26, 20
  %or.cond.26 = and i1 %29, %switch.26
  br i1 %or.cond.26, label %.loopexit, label %.thread.27, !llvm.loop !5

.thread.27:                                       ; preds = %.thread.26
  %indvars.iv.next.27 = add i32 %2, -16
  %30 = icmp sgt i32 %0, 111
  %switch.27 = icmp ult i32 %indvars.iv.next.27, 20
  %or.cond.27 = and i1 %30, %switch.27
  br i1 %or.cond.27, label %.loopexit, label %.thread.28, !llvm.loop !5

.thread.28:                                       ; preds = %.thread.27
  %indvars.iv.next.28 = add i32 %2, 613566740
  %31 = icmp sgt i32 %0, 115
  %switch.28 = icmp ult i32 %indvars.iv.next.28, 20
  %or.cond.28 = and i1 %31, %switch.28
  %spec.select = select i1 %or.cond.28, i1 true, i1 false
  br label %.loopexit, !llvm.loop !5

.thread:                                          ; preds = %1
  %indvars.iv.next = add i32 %2, 613566756
  %32 = icmp sgt i32 %0, 3
  %switch = icmp ult i32 %indvars.iv.next, 20
  %or.cond = and i1 %32, %switch
  br i1 %or.cond, label %.loopexit, label %.thread.1, !llvm.loop !5

.loopexit:                                        ; preds = %.thread.28, %.thread, %.thread.1, %.thread.2, %.thread.3, %.thread.4, %.thread.5, %.thread.6, %.thread.7, %.thread.8, %.thread.9, %.thread.10, %.thread.11, %.thread.12, %.thread.13, %.thread.14, %.thread.15, %.thread.16, %.thread.17, %.thread.18, %.thread.19, %.thread.20, %.thread.21, %.thread.22, %.thread.23, %.thread.24, %.thread.25, %.thread.26, %.thread.27, %1
  %33 = phi i1 [ true, %1 ], [ true, %.thread ], [ true, %.thread.1 ], [ true, %.thread.2 ], [ true, %.thread.3 ], [ true, %.thread.4 ], [ true, %.thread.5 ], [ true, %.thread.6 ], [ true, %.thread.7 ], [ true, %.thread.8 ], [ true, %.thread.9 ], [ true, %.thread.10 ], [ true, %.thread.11 ], [ true, %.thread.12 ], [ true, %.thread.13 ], [ true, %.thread.14 ], [ true, %.thread.15 ], [ true, %.thread.16 ], [ true, %.thread.17 ], [ true, %.thread.18 ], [ true, %.thread.19 ], [ true, %.thread.20 ], [ true, %.thread.21 ], [ true, %.thread.22 ], [ true, %.thread.23 ], [ true, %.thread.24 ], [ true, %.thread.25 ], [ true, %.thread.26 ], [ true, %.thread.27 ], [ %spec.select, %.thread.28 ]
  ret i1 %33
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass