; LLVM IR from kazunetakahashi/atcoder :: 2018/0603_AGC025/D.ll (Z5validSt7complexIiE)

; 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::complex" = type { i32, i32 }

@N = external dso_local global i32, align 4

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNKSt7complexIiE4realB5cxx11Ev(ptr noundef nonnull align 4 dereferenceable(8)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNKSt7complexIiE4imagB5cxx11Ev(ptr noundef nonnull align 4 dereferenceable(8)) #1 align 2

; 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
define dso_local noundef zeroext i1 @_Z5validSt7complexIiE(i64 %0) #2 {
  %2 = alloca %"class.std::complex", align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i64 %0, ptr %2, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %5 = call noundef i32 @_ZNKSt7complexIiE4realB5cxx11Ev(ptr noundef nonnull align 4 dereferenceable(8) %2)
  store i32 %5, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %6 = call noundef i32 @_ZNKSt7complexIiE4imagB5cxx11Ev(ptr noundef nonnull align 4 dereferenceable(8) %2)
  store i32 %6, ptr %4, align 4, !tbaa !5
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %8 = icmp sle i32 0, %7
  br i1 %8, label %9, label %24

9:                                                ; preds = %1
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = load i32, ptr @N, align 4, !tbaa !5
  %12 = mul nsw i32 2, %11
  %13 = icmp slt i32 %10, %12
  br i1 %13, label %14, label %24

14:                                               ; preds = %9
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = icmp sle i32 0, %15
  br i1 %16, label %17, label %22

17:                                               ; preds = %14
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = load i32, ptr @N, align 4, !tbaa !5
  %20 = mul nsw i32 2, %19
  %21 = icmp slt i32 %18, %20
  br label %22

22:                                               ; preds = %17, %14
  %23 = phi i1 [ false, %14 ], [ %21, %17 ]
  br label %24

24:                                               ; preds = %22, %9, %1
  %25 = phi i1 [ false, %9 ], [ false, %1 ], [ %23, %22 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret i1 %25
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #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"}


; 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::complex" = type { i32, i32 }

@N = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNKSt7complexIiE4realB5cxx11Ev(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNKSt7complexIiE4imagB5cxx11Ev(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5validSt7complexIiE(i64 %0) local_unnamed_addr #0 {
  %2 = alloca %"class.std::complex", align 8
  store i64 %0, ptr %2, align 8
  %3 = call noundef i32 @_ZNKSt7complexIiE4realB5cxx11Ev(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %4 = call noundef i32 @_ZNKSt7complexIiE4imagB5cxx11Ev(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %5 = icmp sgt i32 %3, -1
  br i1 %5, label %6, label %14

6:                                                ; preds = %1
  %7 = load i32, ptr @N, align 4
  %8 = shl nsw i32 %7, 1
  %9 = icmp slt i32 %3, %8
  br i1 %9, label %10, label %14

10:                                               ; preds = %6
  %11 = icmp sgt i32 %4, -1
  %12 = icmp slt i32 %4, %8
  %13 = and i1 %11, %12
  br label %14

14:                                               ; preds = %10, %6, %1
  %15 = phi i1 [ false, %6 ], [ false, %1 ], [ %13, %10 ]
  ret i1 %15
}

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass