; LLVM IR from kazunetakahashi/atcoder :: 201510_201609/0131/ARC005_C.ll (Z5valid5point)

; 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] }
%struct.point = type { i32, i32 }

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z5valid5point(i64 %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca %struct.point, align 4
  store i64 %0, ptr %3, align 4
  %4 = getelementptr inbounds %struct.point, ptr %3, i32 0, i32 0
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = icmp sle i32 0, %5
  br i1 %6, label %7, label %21

7:                                                ; preds = %1
  %8 = getelementptr inbounds %struct.point, ptr %3, i32 0, i32 0
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = load i32, ptr @H, align 4, !tbaa !10
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %12, label %21

12:                                               ; preds = %7
  %13 = getelementptr inbounds %struct.point, ptr %3, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = icmp sle i32 0, %14
  br i1 %15, label %16, label %21

16:                                               ; preds = %12
  %17 = getelementptr inbounds %struct.point, ptr %3, i32 0, i32 1
  %18 = load i32, ptr %17, align 4, !tbaa !11
  %19 = load i32, ptr @W, align 4, !tbaa !10
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %16, %12, %7, %1
  store i32 -1, ptr %2, align 4
  br label %36

22:                                               ; preds = %16
  %23 = getelementptr inbounds %struct.point, ptr %3, i32 0, i32 0
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [510 x %"class.std::__cxx11::basic_string"], ptr @_Z1cB5cxx11, i64 0, i64 %25
  %27 = getelementptr inbounds %struct.point, ptr %3, i32 0, i32 1
  %28 = load i32, ptr %27, align 4, !tbaa !11
  %29 = sext i32 %28 to i64
  %30 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %26, i64 noundef %29)
  %31 = load i8, ptr %30, align 1, !tbaa !12
  %32 = sext i8 %31 to i32
  %33 = icmp eq i32 %32, 35
  br i1 %33, label %34, label %35

34:                                               ; preds = %22
  store i32 1, ptr %2, align 4
  br label %36

35:                                               ; preds = %22
  store i32 0, ptr %2, align 4
  br label %36

36:                                               ; preds = %35, %34, %21
  %37 = load i32, ptr %2, align 4
  ret i32 %37
}

; 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) #1 align 2

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


; 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
@_Z1cB5cxx11 = external dso_local global [510 x %"class.std::__cxx11::basic_string"], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 -1, 2) i32 @_Z5valid5point(i64 %0) local_unnamed_addr #0 {
  %.sroa.0.0.extract.trunc = trunc i64 %0 to i32
  %.sroa.4.0.extract.shift = lshr i64 %0, 32
  %2 = icmp sgt i32 %.sroa.0.0.extract.trunc, -1
  br i1 %2, label %3, label %15

3:                                                ; preds = %1
  %.sroa.4.0.extract.trunc = trunc nuw i64 %.sroa.4.0.extract.shift to i32
  %4 = load i32, ptr @H, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, %.sroa.0.0.extract.trunc
  %6 = icmp sgt i64 %0, -1
  %or.cond = and i1 %6, %5
  %7 = load i32, ptr @W, align 4
  %8 = icmp sgt i32 %7, %.sroa.4.0.extract.trunc
  %or.cond8 = select i1 %or.cond, i1 %8, i1 false
  br i1 %or.cond8, label %9, label %15

9:                                                ; preds = %3
  %10 = and i64 %0, 2147483647
  %11 = getelementptr inbounds [510 x %"class.std::__cxx11::basic_string"], ptr @_Z1cB5cxx11, i64 0, i64 %10
  %12 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %11, i64 noundef %.sroa.4.0.extract.shift)
  %13 = load i8, ptr %12, align 1, !tbaa !9
  %14 = icmp eq i8 %13, 35
  %. = zext i1 %14 to i32
  br label %15

15:                                               ; preds = %9, %1, %3
  %.0 = phi i32 [ -1, %3 ], [ -1, %1 ], [ %., %9 ]
  ret i32 %.0
}

; 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 = !{!7, !7, i64 0}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass