; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/Other/HFCQ/Problem B/B.ll (Z6Millerxi)

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

@__const._Z6Millerxi.test = external hidden unnamed_addr constant [9 x i32], align 16

; 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: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z7witnessxxxi(i64 noundef, i64 noundef, i64 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z6Millerxi(i64 noundef %0, i32 noundef %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca [9 x i32], align 16
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  store i64 %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %12 = load i64, ptr %4, align 8, !tbaa !5
  %13 = icmp slt i64 %12, 2
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %62

15:                                               ; preds = %2
  %16 = load i64, ptr %4, align 8, !tbaa !5
  %17 = and i64 %16, 1
  %18 = icmp ne i64 %17, 0
  br i1 %18, label %22, label %19

19:                                               ; preds = %15
  %20 = load i64, ptr %4, align 8, !tbaa !5
  %21 = icmp eq i64 %20, 2
  store i1 %21, ptr %3, align 1
  br label %62

22:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %23 = load i64, ptr %4, align 8, !tbaa !5
  %24 = sub nsw i64 %23, 1
  store i64 %24, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %29, %22
  %26 = load i64, ptr %6, align 8, !tbaa !5
  %27 = and i64 %26, 1
  %28 = icmp ne i64 %27, 0
  br i1 %28, label %29, label %34

29:                                               ; preds = %25
  %30 = load i64, ptr %6, align 8, !tbaa !5
  %31 = ashr i64 %30, 1
  store i64 %31, ptr %6, align 8, !tbaa !5
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %7, align 4, !tbaa !9
  br label %25, !llvm.loop !11

34:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 36, ptr %8) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %8, ptr align 16 @__const._Z6Millerxi.test, i64 36, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %55, %34
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = icmp slt i32 %36, 9
  br i1 %37, label %39, label %38

38:                                               ; preds = %35
  store i32 4, ptr %10, align 4
  br label %58

39:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [9 x i32], ptr %8, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  store i64 %44, ptr %11, align 8, !tbaa !5
  %45 = load i64, ptr %11, align 8, !tbaa !5
  %46 = load i64, ptr %4, align 8, !tbaa !5
  %47 = load i64, ptr %6, align 8, !tbaa !5
  %48 = load i32, ptr %7, align 4, !tbaa !9
  %49 = call noundef zeroext i1 @_Z7witnessxxxi(i64 noundef %45, i64 noundef %46, i64 noundef %47, i32 noundef %48)
  br i1 %49, label %50, label %51

50:                                               ; preds = %39
  store i1 false, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %52

51:                                               ; preds = %39
  store i32 0, ptr %10, align 4
  br label %52

52:                                               ; preds = %51, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  %53 = load i32, ptr %10, align 4
  switch i32 %53, label %58 [
    i32 0, label %54
  ]

54:                                               ; preds = %52
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %9, align 4, !tbaa !9
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %9, align 4, !tbaa !9
  br label %35, !llvm.loop !13

58:                                               ; preds = %52, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %59 = load i32, ptr %10, align 4
  switch i32 %59, label %61 [
    i32 4, label %60
  ]

60:                                               ; preds = %58
  store i1 true, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %61

61:                                               ; preds = %60, %58
  call void @llvm.lifetime.end.p0(i64 36, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %62

62:                                               ; preds = %61, %19, %14
  %63 = load i1, ptr %3, align 1
  ret i1 %63
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 nounwind willreturn memory(argmem: readwrite) }
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 = !{!6, !6, i64 0}
!6 = !{!"long 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"}
!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"

@__const._Z6Millerxi.test = external hidden unnamed_addr constant [9 x i32], align 16

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z7witnessxxxi(i64 noundef, i64 noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z6Millerxi(i64 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = icmp slt i64 %0, 2
  br i1 %3, label %.critedge, label %4

4:                                                ; preds = %2
  %5 = and i64 %0, 1
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %6, label %.preheader

6:                                                ; preds = %4
  %7 = icmp eq i64 %0, 2
  br label %.critedge

.preheader:                                       ; preds = %4
  %8 = add nsw i64 %0, -1
  %9 = load i32, ptr @__const._Z6Millerxi.test, align 16, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = tail call noundef zeroext i1 @_Z7witnessxxxi(i64 noundef %10, i64 noundef %0, i64 noundef %8, i32 noundef 0)
  br i1 %11, label %.critedge, label %12

12:                                               ; preds = %.preheader
  %13 = load i32, ptr getelementptr inbounds (i8, ptr @__const._Z6Millerxi.test, i64 4), align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = tail call noundef zeroext i1 @_Z7witnessxxxi(i64 noundef %14, i64 noundef %0, i64 noundef %8, i32 noundef 0)
  br i1 %15, label %.critedge, label %16

16:                                               ; preds = %12
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @__const._Z6Millerxi.test, i64 8), align 8, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = tail call noundef zeroext i1 @_Z7witnessxxxi(i64 noundef %18, i64 noundef %0, i64 noundef %8, i32 noundef 0)
  br i1 %19, label %.critedge, label %20

20:                                               ; preds = %16
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @__const._Z6Millerxi.test, i64 12), align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = tail call noundef zeroext i1 @_Z7witnessxxxi(i64 noundef %22, i64 noundef %0, i64 noundef %8, i32 noundef 0)
  br i1 %23, label %.critedge, label %24

24:                                               ; preds = %20
  %25 = load i32, ptr getelementptr inbounds (i8, ptr @__const._Z6Millerxi.test, i64 16), align 16, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = tail call noundef zeroext i1 @_Z7witnessxxxi(i64 noundef %26, i64 noundef %0, i64 noundef %8, i32 noundef 0)
  br i1 %27, label %.critedge, label %28

28:                                               ; preds = %24
  %29 = load i32, ptr getelementptr inbounds (i8, ptr @__const._Z6Millerxi.test, i64 20), align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = tail call noundef zeroext i1 @_Z7witnessxxxi(i64 noundef %30, i64 noundef %0, i64 noundef %8, i32 noundef 0)
  br i1 %31, label %.critedge, label %32

32:                                               ; preds = %28
  %33 = load i32, ptr getelementptr inbounds (i8, ptr @__const._Z6Millerxi.test, i64 24), align 8, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = tail call noundef zeroext i1 @_Z7witnessxxxi(i64 noundef %34, i64 noundef %0, i64 noundef %8, i32 noundef 0)
  br i1 %35, label %.critedge, label %36

36:                                               ; preds = %32
  %37 = load i32, ptr getelementptr inbounds (i8, ptr @__const._Z6Millerxi.test, i64 28), align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = tail call noundef zeroext i1 @_Z7witnessxxxi(i64 noundef %38, i64 noundef %0, i64 noundef %8, i32 noundef 0)
  br i1 %39, label %.critedge, label %40

40:                                               ; preds = %36
  %41 = load i32, ptr getelementptr inbounds (i8, ptr @__const._Z6Millerxi.test, i64 32), align 16, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = tail call noundef zeroext i1 @_Z7witnessxxxi(i64 noundef %42, i64 noundef %0, i64 noundef %8, i32 noundef 0)
  %not. = xor i1 %43, true
  br label %.critedge

.critedge:                                        ; preds = %40, %.preheader, %12, %16, %20, %24, %28, %32, %36, %2, %6
  %.4 = phi i1 [ %7, %6 ], [ false, %2 ], [ false, %.preheader ], [ false, %12 ], [ false, %16 ], [ false, %20 ], [ false, %24 ], [ false, %28 ], [ false, %32 ], [ false, %36 ], [ %not., %40 ]
  ret i1 %.4
}

attributes #0 = { mustprogress 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,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass