; LLVM IR from kazunetakahashi/atcoder :: 201610_12/1002_KUPC2016/E.ll (Z12is_minus_onev)

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

%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@H = external dso_local global i32, align 4
@W = external dso_local global i32, align 4
@_Z1SB5cxx11 = external dso_local global [110 x %"class.std::__cxx11::basic_string"], align 16

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

5:                                                ; preds = %31, %0
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = load i32, ptr @H, align 4, !tbaa !5
  %8 = icmp slt i32 %6, %7
  br i1 %8, label %10, label %9

9:                                                ; preds = %5
  store i32 2, ptr %3, align 4
  br label %34

10:                                               ; preds = %5
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [110 x %"class.std::__cxx11::basic_string"], ptr @_Z1SB5cxx11, i64 0, i64 %12
  %14 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %13, i64 noundef 0)
  %15 = load i8, ptr %14, align 1, !tbaa !9
  %16 = sext i8 %15 to i32
  %17 = icmp eq i32 %16, 88
  br i1 %17, label %29, label %18

18:                                               ; preds = %10
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [110 x %"class.std::__cxx11::basic_string"], ptr @_Z1SB5cxx11, i64 0, i64 %20
  %22 = load i32, ptr @W, align 4, !tbaa !5
  %23 = sub nsw i32 %22, 1
  %24 = sext i32 %23 to i64
  %25 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %21, i64 noundef %24)
  %26 = load i8, ptr %25, align 1, !tbaa !9
  %27 = sext i8 %26 to i32
  %28 = icmp eq i32 %27, 88
  br i1 %28, label %29, label %30

29:                                               ; preds = %18, %10
  store i1 true, ptr %1, align 1
  store i32 1, ptr %3, align 4
  br label %34

30:                                               ; preds = %18
  br label %31

31:                                               ; preds = %30
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %2, align 4, !tbaa !5
  br label %5, !llvm.loop !10

34:                                               ; preds = %29, %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %35 = load i32, ptr %3, align 4
  switch i32 %35, label %70 [
    i32 2, label %36
    i32 1, label %68
  ]

36:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %62, %36
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = load i32, ptr @W, align 4, !tbaa !5
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %37
  store i32 5, ptr %3, align 4
  br label %65

42:                                               ; preds = %37
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1SB5cxx11, i64 noundef %44)
  %46 = load i8, ptr %45, align 1, !tbaa !9
  %47 = sext i8 %46 to i32
  %48 = icmp eq i32 %47, 88
  br i1 %48, label %60, label %49

49:                                               ; preds = %42
  %50 = load i32, ptr @H, align 4, !tbaa !5
  %51 = sub nsw i32 %50, 1
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [110 x %"class.std::__cxx11::basic_string"], ptr @_Z1SB5cxx11, i64 0, i64 %52
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %53, i64 noundef %55)
  %57 = load i8, ptr %56, align 1, !tbaa !9
  %58 = sext i8 %57 to i32
  %59 = icmp eq i32 %58, 88
  br i1 %59, label %60, label %61

60:                                               ; preds = %49, %42
  store i1 true, ptr %1, align 1
  store i32 1, ptr %3, align 4
  br label %65

61:                                               ; preds = %49
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %4, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %4, align 4, !tbaa !5
  br label %37, !llvm.loop !12

65:                                               ; preds = %60, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %66 = load i32, ptr %3, align 4
  switch i32 %66, label %70 [
    i32 5, label %67
    i32 1, label %68
  ]

67:                                               ; preds = %65
  store i1 false, ptr %1, align 1
  br label %68

68:                                               ; preds = %67, %65, %34
  %69 = load i1, ptr %1, align 1
  ret i1 %69

70:                                               ; preds = %65, %34
  unreachable
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #2 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


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

%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@H = external dso_local local_unnamed_addr global i32, align 4
@W = external dso_local local_unnamed_addr global i32, align 4
@_Z1SB5cxx11 = external dso_local global [110 x %"class.std::__cxx11::basic_string"], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z12is_minus_onev() local_unnamed_addr #0 {
  %1 = load i32, ptr @H, align 4, !tbaa !5
  %2 = icmp sgt i32 %1, 0
  br i1 %2, label %.lr.ph, label %.preheader

3:                                                ; preds = %12
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %4 = load i32, ptr @H, align 4, !tbaa !5
  %5 = sext i32 %4 to i64
  %6 = icmp slt i64 %indvars.iv.next, %5
  br i1 %6, label %.lr.ph, label %.preheader, !llvm.loop !9

.preheader:                                       ; preds = %3, %0
  %7 = load i32, ptr @W, align 4, !tbaa !5
  %.not21 = icmp sgt i32 %7, 0
  br i1 %.not21, label %.lr.ph23, label %.thread

.lr.ph:                                           ; preds = %0, %3
  %indvars.iv = phi i64 [ %indvars.iv.next, %3 ], [ 0, %0 ]
  %8 = getelementptr inbounds [110 x %"class.std::__cxx11::basic_string"], ptr @_Z1SB5cxx11, i64 0, i64 %indvars.iv
  %9 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %8, i64 noundef 0)
  %10 = load i8, ptr %9, align 1, !tbaa !11
  %11 = icmp eq i8 %10, 88
  br i1 %11, label %.thread, label %12

12:                                               ; preds = %.lr.ph
  %13 = load i32, ptr @W, align 4, !tbaa !5
  %14 = add nsw i32 %13, -1
  %15 = sext i32 %14 to i64
  %16 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %8, i64 noundef %15)
  %17 = load i8, ptr %16, align 1, !tbaa !11
  %18 = icmp eq i8 %17, 88
  br i1 %18, label %.thread, label %3

19:                                               ; preds = %25
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %20 = load i32, ptr @W, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %.not = icmp slt i64 %indvars.iv.next31, %21
  br i1 %.not, label %.lr.ph23, label %.thread, !llvm.loop !12

.lr.ph23:                                         ; preds = %.preheader, %19
  %indvars.iv30 = phi i64 [ %indvars.iv.next31, %19 ], [ 0, %.preheader ]
  %22 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1SB5cxx11, i64 noundef %indvars.iv30)
  %23 = load i8, ptr %22, align 1, !tbaa !11
  %24 = icmp eq i8 %23, 88
  br i1 %24, label %.thread, label %25

25:                                               ; preds = %.lr.ph23
  %26 = load i32, ptr @H, align 4, !tbaa !5
  %27 = add nsw i32 %26, -1
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [110 x %"class.std::__cxx11::basic_string"], ptr @_Z1SB5cxx11, i64 0, i64 %28
  %30 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %29, i64 noundef %indvars.iv30)
  %31 = load i8, ptr %30, align 1, !tbaa !11
  %32 = icmp eq i8 %31, 88
  br i1 %32, label %.thread, label %19

.thread:                                          ; preds = %.lr.ph, %12, %.lr.ph23, %25, %19, %.preheader
  %.2 = phi i1 [ false, %.preheader ], [ true, %.lr.ph23 ], [ true, %25 ], [ false, %19 ], [ true, %12 ], [ true, %.lr.ph ]
  ret i1 %.2
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #0 align 2

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"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}


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