; LLVM IR from kazunetakahashi/atcoder :: 201411_201509/0627_ABC025/D2_MLE.ll (Z7checkerii)

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

@_ZL2dx = external hidden constant [2 x [2 x i32]], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3sftii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z7checkerii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  %6 = alloca [2 x i32], align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca i8, align 1
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #2
  store i8 1, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = sdiv i32 %12, 5
  store i32 %13, ptr %6, align 4, !tbaa !5
  %14 = getelementptr inbounds i32, ptr %6, i64 1
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = srem i32 %15, 5
  store i32 %16, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %79, %2
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = icmp slt i32 %18, 2
  br i1 %19, label %20, label %23

20:                                               ; preds = %17
  %21 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %22 = trunc i8 %21 to i1
  br label %23

23:                                               ; preds = %20, %17
  %24 = phi i1 [ false, %17 ], [ %22, %20 ]
  br i1 %24, label %26, label %25

25:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %82

26:                                               ; preds = %23
  %27 = load i32, ptr %7, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [2 x i32], ptr %6, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %38, label %32

32:                                               ; preds = %26
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [2 x i32], ptr %6, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = icmp eq i32 %36, 4
  br i1 %37, label %38, label %39

38:                                               ; preds = %32, %26
  br label %79

39:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = load i32, ptr %7, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [2 x [2 x i32]], ptr @_ZL2dx, i64 0, i64 %42
  %44 = getelementptr inbounds [2 x i32], ptr %43, i64 0, i64 0
  %45 = load i32, ptr %44, align 8, !tbaa !5
  %46 = add nsw i32 %40, %45
  store i32 %46, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = load i32, ptr %7, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [2 x [2 x i32]], ptr @_ZL2dx, i64 0, i64 %49
  %51 = getelementptr inbounds [2 x i32], ptr %50, i64 0, i64 1
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = add nsw i32 %47, %52
  store i32 %53, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #2
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = load i32, ptr %8, align 4, !tbaa !5
  %56 = call noundef zeroext i1 @_Z3sftii(i32 noundef %54, i32 noundef %55)
  %57 = zext i1 %56 to i8
  store i8 %57, ptr %10, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #2
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = load i32, ptr %9, align 4, !tbaa !5
  %60 = call noundef zeroext i1 @_Z3sftii(i32 noundef %58, i32 noundef %59)
  %61 = zext i1 %60 to i8
  store i8 %61, ptr %11, align 1, !tbaa !9
  %62 = load i8, ptr %10, align 1, !tbaa !9, !range !11, !noundef !12
  %63 = trunc i8 %62 to i1
  br i1 %63, label %64, label %67

64:                                               ; preds = %39
  %65 = load i8, ptr %11, align 1, !tbaa !9, !range !11, !noundef !12
  %66 = trunc i8 %65 to i1
  br i1 %66, label %76, label %67

67:                                               ; preds = %64, %39
  %68 = load i8, ptr %10, align 1, !tbaa !9, !range !11, !noundef !12
  %69 = trunc i8 %68 to i1
  br i1 %69, label %74, label %70

70:                                               ; preds = %67
  %71 = load i8, ptr %11, align 1, !tbaa !9, !range !11, !noundef !12
  %72 = trunc i8 %71 to i1
  %73 = xor i1 %72, true
  br label %74

74:                                               ; preds = %70, %67
  %75 = phi i1 [ false, %67 ], [ %73, %70 ]
  br label %76

76:                                               ; preds = %74, %64
  %77 = phi i1 [ true, %64 ], [ %75, %74 ]
  %78 = zext i1 %77 to i8
  store i8 %78, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %79

79:                                               ; preds = %76, %38
  %80 = load i32, ptr %7, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %7, align 4, !tbaa !5
  br label %17, !llvm.loop !13

82:                                               ; preds = %25
  %83 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %84 = trunc i8 %83 to i1
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  ret i1 %84
}

; 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 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@_ZL2dx = external hidden local_unnamed_addr constant [2 x [2 x i32]], align 16

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z7checkerii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
.peel.begin:
  %2 = sdiv i32 %1, 5
  %3 = srem i32 %1, 5
  switch i32 %2, label %4 [
    i32 0, label %13
    i32 4, label %13
  ]

4:                                                ; preds = %.peel.begin
  %5 = load i32, ptr @_ZL2dx, align 16, !tbaa !5
  %6 = add nsw i32 %5, %1
  %7 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2dx, i64 4), align 4, !tbaa !5
  %8 = add nsw i32 %7, %1
  %9 = tail call noundef zeroext i1 @_Z3sftii(i32 noundef %0, i32 noundef %6)
  %10 = tail call noundef zeroext i1 @_Z3sftii(i32 noundef %0, i32 noundef %8)
  %11 = xor i1 %9, %10
  %12 = xor i1 %11, true
  br label %13

13:                                               ; preds = %4, %.peel.begin, %.peel.begin
  %.1.peel = phi i1 [ true, %.peel.begin ], [ %12, %4 ], [ true, %.peel.begin ]
  br i1 %.1.peel, label %.peel.newph, label %.loopexit

.peel.newph:                                      ; preds = %13
  %14 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2dx, i64 8), align 8
  %15 = add nsw i32 %14, %1
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2dx, i64 12), align 4
  %17 = add nsw i32 %16, %1
  switch i32 %3, label %18 [
    i32 0, label %.loopexit
    i32 4, label %.loopexit
  ]

.loopexit:                                        ; preds = %18, %.peel.newph, %.peel.newph, %13
  %.1.lcssa = phi i1 [ %.1.peel, %13 ], [ true, %.peel.newph ], [ %22, %18 ], [ true, %.peel.newph ]
  ret i1 %.1.lcssa

18:                                               ; preds = %.peel.newph
  %19 = tail call noundef zeroext i1 @_Z3sftii(i32 noundef %0, i32 noundef %15)
  %20 = tail call noundef zeroext i1 @_Z3sftii(i32 noundef %0, i32 noundef %17)
  %21 = xor i1 %19, %20
  %22 = xor i1 %21, true
  br label %.loopexit
}

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 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: ADCEPass,AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass