; LLVM IR from kazunetakahashi/atcoder :: 2018/1123_DDCC2019-qual/D.ll (Z5checkx)

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

@a = external dso_local global [40 x i64], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3sumxx(i64 noundef, i64 noundef) #0

; 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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5checkx(i64 noundef %0) #0 {
  %2 = alloca i1, align 1
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i64 %0, ptr %3, align 8, !tbaa !5
  %6 = load i64, ptr %3, align 8, !tbaa !5
  %7 = icmp sle i64 1, %6
  br i1 %7, label %8, label %11

8:                                                ; preds = %1
  %9 = load i64, ptr %3, align 8, !tbaa !5
  %10 = icmp sle i64 %9, 1000000000000
  br i1 %10, label %12, label %11

11:                                               ; preds = %8, %1
  store i1 false, ptr %2, align 1
  br label %35

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

13:                                               ; preds = %29, %12
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = icmp sle i32 %14, 30
  br i1 %15, label %17, label %16

16:                                               ; preds = %13
  store i32 2, ptr %5, align 4
  br label %32

17:                                               ; preds = %13
  %18 = load i64, ptr %3, align 8, !tbaa !5
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = call noundef i64 @_Z3sumxx(i64 noundef %18, i64 noundef %20)
  %22 = load i32, ptr %4, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [40 x i64], ptr @a, i64 0, i64 %23
  %25 = load i64, ptr %24, align 8, !tbaa !5
  %26 = icmp ne i64 %21, %25
  br i1 %26, label %27, label %28

27:                                               ; preds = %17
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %32

28:                                               ; preds = %17
  br label %29

29:                                               ; preds = %28
  %30 = load i32, ptr %4, align 4, !tbaa !9
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %4, align 4, !tbaa !9
  br label %13, !llvm.loop !11

32:                                               ; preds = %27, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %33 = load i32, ptr %5, align 4
  switch i32 %33, label %37 [
    i32 2, label %34
    i32 1, label %35
  ]

34:                                               ; preds = %32
  store i1 true, ptr %2, align 1
  br label %35

35:                                               ; preds = %34, %32, %11
  %36 = load i1, ptr %2, align 1
  ret i1 %36

37:                                               ; preds = %32
  unreachable
}

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 = !{!"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"}


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

@a = external dso_local local_unnamed_addr global [40 x i64], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3sumxx(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5checkx(i64 noundef %0) local_unnamed_addr #0 {
  %2 = add i64 %0, -1
  %or.cond = icmp ult i64 %2, 1000000000000
  br i1 %or.cond, label %.preheader.preheader, label %.loopexit

.preheader.preheader:                             ; preds = %1
  %3 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 2)
  %4 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 16), align 16, !tbaa !5
  %.not = icmp eq i64 %3, %4
  br i1 %.not, label %.preheader.1, label %.loopexit

.preheader.1:                                     ; preds = %.preheader.preheader
  %5 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 3)
  %6 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 24), align 8, !tbaa !5
  %.not.1 = icmp eq i64 %5, %6
  br i1 %.not.1, label %.preheader.2, label %.loopexit

.preheader.2:                                     ; preds = %.preheader.1
  %7 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 4)
  %8 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 32), align 16, !tbaa !5
  %.not.2 = icmp eq i64 %7, %8
  br i1 %.not.2, label %.preheader.3, label %.loopexit

.preheader.3:                                     ; preds = %.preheader.2
  %9 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 5)
  %10 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 40), align 8, !tbaa !5
  %.not.3 = icmp eq i64 %9, %10
  br i1 %.not.3, label %.preheader.4, label %.loopexit

.preheader.4:                                     ; preds = %.preheader.3
  %11 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 6)
  %12 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 48), align 16, !tbaa !5
  %.not.4 = icmp eq i64 %11, %12
  br i1 %.not.4, label %.preheader.5, label %.loopexit

.preheader.5:                                     ; preds = %.preheader.4
  %13 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 7)
  %14 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 56), align 8, !tbaa !5
  %.not.5 = icmp eq i64 %13, %14
  br i1 %.not.5, label %.preheader.6, label %.loopexit

.preheader.6:                                     ; preds = %.preheader.5
  %15 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 8)
  %16 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 64), align 16, !tbaa !5
  %.not.6 = icmp eq i64 %15, %16
  br i1 %.not.6, label %.preheader.7, label %.loopexit

.preheader.7:                                     ; preds = %.preheader.6
  %17 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 9)
  %18 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 72), align 8, !tbaa !5
  %.not.7 = icmp eq i64 %17, %18
  br i1 %.not.7, label %.preheader.8, label %.loopexit

.preheader.8:                                     ; preds = %.preheader.7
  %19 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 10)
  %20 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 80), align 16, !tbaa !5
  %.not.8 = icmp eq i64 %19, %20
  br i1 %.not.8, label %.preheader.9, label %.loopexit

.preheader.9:                                     ; preds = %.preheader.8
  %21 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 11)
  %22 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 88), align 8, !tbaa !5
  %.not.9 = icmp eq i64 %21, %22
  br i1 %.not.9, label %.preheader.10, label %.loopexit

.preheader.10:                                    ; preds = %.preheader.9
  %23 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 12)
  %24 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 96), align 16, !tbaa !5
  %.not.10 = icmp eq i64 %23, %24
  br i1 %.not.10, label %.preheader.11, label %.loopexit

.preheader.11:                                    ; preds = %.preheader.10
  %25 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 13)
  %26 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 104), align 8, !tbaa !5
  %.not.11 = icmp eq i64 %25, %26
  br i1 %.not.11, label %.preheader.12, label %.loopexit

.preheader.12:                                    ; preds = %.preheader.11
  %27 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 14)
  %28 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 112), align 16, !tbaa !5
  %.not.12 = icmp eq i64 %27, %28
  br i1 %.not.12, label %.preheader.13, label %.loopexit

.preheader.13:                                    ; preds = %.preheader.12
  %29 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 15)
  %30 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 120), align 8, !tbaa !5
  %.not.13 = icmp eq i64 %29, %30
  br i1 %.not.13, label %.preheader.14, label %.loopexit

.preheader.14:                                    ; preds = %.preheader.13
  %31 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 16)
  %32 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 128), align 16, !tbaa !5
  %.not.14 = icmp eq i64 %31, %32
  br i1 %.not.14, label %.preheader.15, label %.loopexit

.preheader.15:                                    ; preds = %.preheader.14
  %33 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 17)
  %34 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 136), align 8, !tbaa !5
  %.not.15 = icmp eq i64 %33, %34
  br i1 %.not.15, label %.preheader.16, label %.loopexit

.preheader.16:                                    ; preds = %.preheader.15
  %35 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 18)
  %36 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 144), align 16, !tbaa !5
  %.not.16 = icmp eq i64 %35, %36
  br i1 %.not.16, label %.preheader.17, label %.loopexit

.preheader.17:                                    ; preds = %.preheader.16
  %37 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 19)
  %38 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 152), align 8, !tbaa !5
  %.not.17 = icmp eq i64 %37, %38
  br i1 %.not.17, label %.preheader.18, label %.loopexit

.preheader.18:                                    ; preds = %.preheader.17
  %39 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 20)
  %40 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 160), align 16, !tbaa !5
  %.not.18 = icmp eq i64 %39, %40
  br i1 %.not.18, label %.preheader.19, label %.loopexit

.preheader.19:                                    ; preds = %.preheader.18
  %41 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 21)
  %42 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 168), align 8, !tbaa !5
  %.not.19 = icmp eq i64 %41, %42
  br i1 %.not.19, label %.preheader.20, label %.loopexit

.preheader.20:                                    ; preds = %.preheader.19
  %43 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 22)
  %44 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 176), align 16, !tbaa !5
  %.not.20 = icmp eq i64 %43, %44
  br i1 %.not.20, label %.preheader.21, label %.loopexit

.preheader.21:                                    ; preds = %.preheader.20
  %45 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 23)
  %46 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 184), align 8, !tbaa !5
  %.not.21 = icmp eq i64 %45, %46
  br i1 %.not.21, label %.preheader.22, label %.loopexit

.preheader.22:                                    ; preds = %.preheader.21
  %47 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 24)
  %48 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 192), align 16, !tbaa !5
  %.not.22 = icmp eq i64 %47, %48
  br i1 %.not.22, label %.preheader.23, label %.loopexit

.preheader.23:                                    ; preds = %.preheader.22
  %49 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 25)
  %50 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 200), align 8, !tbaa !5
  %.not.23 = icmp eq i64 %49, %50
  br i1 %.not.23, label %.preheader.24, label %.loopexit

.preheader.24:                                    ; preds = %.preheader.23
  %51 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 26)
  %52 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 208), align 16, !tbaa !5
  %.not.24 = icmp eq i64 %51, %52
  br i1 %.not.24, label %.preheader.25, label %.loopexit

.preheader.25:                                    ; preds = %.preheader.24
  %53 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 27)
  %54 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 216), align 8, !tbaa !5
  %.not.25 = icmp eq i64 %53, %54
  br i1 %.not.25, label %.preheader.26, label %.loopexit

.preheader.26:                                    ; preds = %.preheader.25
  %55 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 28)
  %56 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 224), align 16, !tbaa !5
  %.not.26 = icmp eq i64 %55, %56
  br i1 %.not.26, label %.preheader.27, label %.loopexit

.preheader.27:                                    ; preds = %.preheader.26
  %57 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 29)
  %58 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 232), align 8, !tbaa !5
  %.not.27 = icmp eq i64 %57, %58
  br i1 %.not.27, label %.preheader.28, label %.loopexit

.preheader.28:                                    ; preds = %.preheader.27
  %59 = tail call noundef i64 @_Z3sumxx(i64 noundef %0, i64 noundef 30)
  %60 = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 240), align 16, !tbaa !5
  %.not.28 = icmp eq i64 %59, %60
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.28, %.preheader.preheader, %.preheader.1, %.preheader.2, %.preheader.3, %.preheader.4, %.preheader.5, %.preheader.6, %.preheader.7, %.preheader.8, %.preheader.9, %.preheader.10, %.preheader.11, %.preheader.12, %.preheader.13, %.preheader.14, %.preheader.15, %.preheader.16, %.preheader.17, %.preheader.18, %.preheader.19, %.preheader.20, %.preheader.21, %.preheader.22, %.preheader.23, %.preheader.24, %.preheader.25, %.preheader.26, %.preheader.27, %1
  %.1 = phi i1 [ false, %1 ], [ false, %.preheader.preheader ], [ false, %.preheader.1 ], [ false, %.preheader.2 ], [ false, %.preheader.3 ], [ false, %.preheader.4 ], [ false, %.preheader.5 ], [ false, %.preheader.6 ], [ false, %.preheader.7 ], [ false, %.preheader.8 ], [ false, %.preheader.9 ], [ false, %.preheader.10 ], [ false, %.preheader.11 ], [ false, %.preheader.12 ], [ false, %.preheader.13 ], [ false, %.preheader.14 ], [ false, %.preheader.15 ], [ false, %.preheader.16 ], [ false, %.preheader.17 ], [ false, %.preheader.18 ], [ false, %.preheader.19 ], [ false, %.preheader.20 ], [ false, %.preheader.21 ], [ false, %.preheader.22 ], [ false, %.preheader.23 ], [ false, %.preheader.24 ], [ false, %.preheader.25 ], [ false, %.preheader.26 ], [ false, %.preheader.27 ], [ %.not.28, %.preheader.28 ]
  ret i1 %.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" }

!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"}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass