; LLVM IR from Mohammed-Shoaib/Coding-Problems :: Gulf Programming Contest/2015/dance/dance.ll (Z8in_rangeSt4pairIiiES0_i)

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

%"struct.std::pair" = type { i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z8in_rangeSt4pairIiiES0_i(i64 %0, i64 %1, i32 noundef %2) #0 {
  %4 = alloca %"struct.std::pair", align 4
  %5 = alloca %"struct.std::pair", align 4
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca double, align 8
  store i64 %0, ptr %4, align 4
  store i64 %1, ptr %5, align 4
  store i32 %2, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %10 = getelementptr inbounds %"struct.std::pair", ptr %4, i32 0, i32 0
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 0
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = sub nsw i32 %11, %13
  %15 = getelementptr inbounds %"struct.std::pair", ptr %4, i32 0, i32 0
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 0
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = sub nsw i32 %16, %18
  %20 = mul nsw i32 %14, %19
  %21 = sext i32 %20 to i64
  store i64 %21, ptr %7, align 8, !tbaa !11
  %22 = getelementptr inbounds %"struct.std::pair", ptr %4, i32 0, i32 1
  %23 = load i32, ptr %22, align 4, !tbaa !13
  %24 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 1
  %25 = load i32, ptr %24, align 4, !tbaa !13
  %26 = sub nsw i32 %23, %25
  %27 = getelementptr inbounds %"struct.std::pair", ptr %4, i32 0, i32 1
  %28 = load i32, ptr %27, align 4, !tbaa !13
  %29 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !13
  %31 = sub nsw i32 %28, %30
  %32 = mul nsw i32 %26, %31
  %33 = sext i32 %32 to i64
  store i64 %33, ptr %8, align 8, !tbaa !11
  %34 = load i64, ptr %7, align 8, !tbaa !11
  %35 = load i64, ptr %8, align 8, !tbaa !11
  %36 = add nsw i64 %34, %35
  %37 = call noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %36)
  store double %37, ptr %9, align 8, !tbaa !14
  %38 = load double, ptr %9, align 8, !tbaa !14
  %39 = load i32, ptr %6, align 4, !tbaa !5
  %40 = sitofp i32 %39 to double
  %41 = fcmp ole double %38, %40
  %42 = zext i1 %41 to i64
  %43 = select i1 %41, i1 true, i1 false
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i1 %43
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef) #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 = { inlinehint 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 = !{!10, !6, i64 0}
!10 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!10, !6, i64 4}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, 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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z8in_rangeSt4pairIiiES0_i(i64 %0, i64 %1, i32 noundef %2) local_unnamed_addr #0 {
  %.sroa.05.0.extract.trunc = trunc i64 %0 to i32
  %.sroa.37.0.extract.shift = lshr i64 %0, 32
  %.sroa.37.0.extract.trunc = trunc nuw i64 %.sroa.37.0.extract.shift to i32
  %.sroa.0.0.extract.trunc = trunc i64 %1 to i32
  %.sroa.3.0.extract.shift = lshr i64 %1, 32
  %.sroa.3.0.extract.trunc = trunc nuw i64 %.sroa.3.0.extract.shift to i32
  %4 = sub nsw i32 %.sroa.05.0.extract.trunc, %.sroa.0.0.extract.trunc
  %5 = mul nsw i32 %4, %4
  %6 = sub nsw i32 %.sroa.37.0.extract.trunc, %.sroa.3.0.extract.trunc
  %7 = mul nsw i32 %6, %6
  %narrow = add nuw i32 %7, %5
  %8 = zext i32 %narrow to i64
  %9 = tail call noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %8)
  %10 = sitofp i32 %2 to double
  %11 = fcmp ole double %9, %10
  ret i1 %11
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef) local_unnamed_addr #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 = { inlinehint 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,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass