; LLVM IR from kazunetakahashi/atcoder :: 201610_12/1203_DDCC2016_final/A.ll (Z2okii)

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

@R = external dso_local global i32, align 4
@C = external dso_local global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z2okii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %50, %2
  %10 = load i32, ptr %6, align 4, !tbaa !5
  %11 = icmp slt i32 %10, 2
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  store i32 2, ptr %7, align 4
  br label %53

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %44, %13
  %15 = load i32, ptr %8, align 4, !tbaa !5
  %16 = icmp slt i32 %15, 2
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  store i32 5, ptr %7, align 4
  br label %47

18:                                               ; preds = %14
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = add nsw i32 %19, %20
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = add nsw i32 %22, %23
  %25 = mul nsw i32 %21, %24
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = load i32, ptr %8, align 4, !tbaa !5
  %28 = add nsw i32 %26, %27
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = load i32, ptr %8, align 4, !tbaa !5
  %31 = add nsw i32 %29, %30
  %32 = mul nsw i32 %28, %31
  %33 = add nsw i32 %25, %32
  %34 = load i32, ptr @C, align 4, !tbaa !5
  %35 = mul nsw i32 %33, %34
  %36 = load i32, ptr @C, align 4, !tbaa !5
  %37 = mul nsw i32 %35, %36
  %38 = load i32, ptr @R, align 4, !tbaa !5
  %39 = load i32, ptr @R, align 4, !tbaa !5
  %40 = mul nsw i32 %38, %39
  %41 = icmp sgt i32 %37, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %18
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %47

43:                                               ; preds = %18
  br label %44

44:                                               ; preds = %43
  %45 = load i32, ptr %8, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %8, align 4, !tbaa !5
  br label %14, !llvm.loop !9

47:                                               ; preds = %42, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %48 = load i32, ptr %7, align 4
  switch i32 %48, label %53 [
    i32 5, label %49
  ]

49:                                               ; preds = %47
  br label %50

50:                                               ; preds = %49
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %6, align 4, !tbaa !5
  br label %9, !llvm.loop !11

53:                                               ; preds = %47, %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %54 = load i32, ptr %7, align 4
  switch i32 %54, label %58 [
    i32 2, label %55
    i32 1, label %56
  ]

55:                                               ; preds = %53
  store i1 true, ptr %3, align 1
  br label %56

56:                                               ; preds = %55, %53
  %57 = load i1, ptr %3, align 1
  ret i1 %57

58:                                               ; preds = %53
  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"

@R = external dso_local local_unnamed_addr global i32, align 4
@C = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_Z2okii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
.preheader:
  %2 = load i32, ptr @C, align 4, !tbaa !5
  %factor.op.mul = mul i32 %2, %2
  %3 = load i32, ptr @R, align 4, !tbaa !5
  %4 = mul nsw i32 %3, %3
  %5 = mul nsw i32 %0, %0
  %6 = mul nsw i32 %1, %1
  %7 = add nuw nsw i32 %6, %5
  %.reass = mul i32 %factor.op.mul, %7
  %8 = icmp sgt i32 %.reass, %4
  br i1 %8, label %.loopexit.loopexit, label %9

9:                                                ; preds = %.preheader
  %10 = add nsw i32 %1, 1
  %11 = mul nsw i32 %10, %10
  %12 = add nuw nsw i32 %11, %5
  %.reass.1 = mul i32 %factor.op.mul, %12
  %13 = icmp sgt i32 %.reass.1, %4
  br i1 %13, label %.loopexit.loopexit, label %.preheader.1

.preheader.1:                                     ; preds = %9
  %14 = add nsw i32 %0, 1
  %15 = mul nsw i32 %14, %14
  %16 = add nuw nsw i32 %6, %15
  %.reass.126 = mul i32 %factor.op.mul, %16
  %17 = icmp sgt i32 %.reass.126, %4
  br i1 %17, label %.loopexit.loopexit, label %18

18:                                               ; preds = %.preheader.1
  %19 = add nuw nsw i32 %11, %15
  %.reass.1.1 = mul i32 %factor.op.mul, %19
  %20 = icmp sgt i32 %.reass.1.1, %4
  br i1 %20, label %.loopexit.loopexit, label %.loopexit

.loopexit.loopexit:                               ; preds = %18, %.preheader.1, %9, %.preheader
  br label %.loopexit

.loopexit:                                        ; preds = %18, %.loopexit.loopexit
  %21 = phi i1 [ false, %.loopexit.loopexit ], [ true, %18 ]
  ret i1 %21
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: 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 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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