; LLVM IR from kazunetakahashi/atcoder :: 201510_201609/0924_code_fes_2016_qualA/D.ll (Z8root_itrix)

; 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, i64 }

@union_find = external dso_local global [100010 x i32], align 16
@mini = external dso_local global [100010 x i64], align 16
@sa = external dso_local global [100010 x i64], align 16

; Function Attrs: mustprogress uwtable
define dso_local { i32, i64 } @_Z8root_itrix(i32 noundef %0, i64 noundef %1) #0 {
  %3 = alloca %"struct.std::pair", align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %6 = load i32, ptr %4, align 4, !tbaa !5
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [100010 x i32], ptr @union_find, i64 0, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = icmp eq i32 %6, %10
  br i1 %11, label %12, label %18

12:                                               ; preds = %2
  %13 = call { i32, i64 } @_ZSt9make_pairIRiRxESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %14 = getelementptr inbounds { i32, i64 }, ptr %3, i32 0, i32 0
  %15 = extractvalue { i32, i64 } %13, 0
  store i32 %15, ptr %14, align 8
  %16 = getelementptr inbounds { i32, i64 }, ptr %3, i32 0, i32 1
  %17 = extractvalue { i32, i64 } %13, 1
  store i64 %17, ptr %16, align 8
  br label %61

18:                                               ; preds = %2
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [100010 x i32], ptr @union_find, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = load i64, ptr %5, align 8, !tbaa !9
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [100010 x i64], ptr @sa, i64 0, i64 %25
  %27 = load i64, ptr %26, align 8, !tbaa !9
  %28 = add nsw i64 %23, %27
  %29 = call { i32, i64 } @_Z8root_itrix(i32 noundef %22, i64 noundef %28)
  %30 = getelementptr inbounds { i32, i64 }, ptr %3, i32 0, i32 0
  %31 = extractvalue { i32, i64 } %29, 0
  store i32 %31, ptr %30, align 8
  %32 = getelementptr inbounds { i32, i64 }, ptr %3, i32 0, i32 1
  %33 = extractvalue { i32, i64 } %29, 1
  store i64 %33, ptr %32, align 8
  %34 = getelementptr inbounds %"struct.std::pair", ptr %3, i32 0, i32 0
  %35 = load i32, ptr %34, align 8, !tbaa !11
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [100010 x i32], ptr @union_find, i64 0, i64 %37
  store i32 %35, ptr %38, align 4, !tbaa !5
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [100010 x i64], ptr @mini, i64 0, i64 %40
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [100010 x i32], ptr @union_find, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [100010 x i64], ptr @mini, i64 0, i64 %46
  %48 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %41, ptr noundef nonnull align 8 dereferenceable(8) %47)
  %49 = load i64, ptr %48, align 8, !tbaa !9
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100010 x i32], ptr @union_find, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [100010 x i64], ptr @mini, i64 0, i64 %54
  store i64 %49, ptr %55, align 8, !tbaa !9
  %56 = getelementptr inbounds %"struct.std::pair", ptr %3, i32 0, i32 1
  %57 = load i64, ptr %56, align 8, !tbaa !13
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [100010 x i64], ptr @sa, i64 0, i64 %59
  store i64 %57, ptr %60, align 8, !tbaa !9
  br label %61

61:                                               ; preds = %18, %12
  %62 = load { i32, i64 }, ptr %3, align 8
  ret { i32, i64 } %62
}

; Function Attrs: mustprogress uwtable
declare dso_local { i32, i64 } @_ZSt9make_pairIRiRxESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(8)) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #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 = { 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSSt4pairIixE", !6, i64 0, !10, i64 8}
!13 = !{!12, !10, i64 8}


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

@union_find = external dso_local local_unnamed_addr global [100010 x i32], align 16
@mini = external dso_local global [100010 x i64], align 16
@sa = external dso_local local_unnamed_addr global [100010 x i64], align 16

; Function Attrs: mustprogress uwtable
define dso_local { i32, i64 } @_Z8root_itrix(i32 noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %5 = sext i32 %0 to i64
  %6 = getelementptr inbounds [100010 x i32], ptr @union_find, i64 0, i64 %5
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp eq i32 %7, %0
  br i1 %8, label %common.ret, label %10

common.ret:                                       ; preds = %2
  %9 = call { i32, i64 } @_ZSt9make_pairIRiRxESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  br label %common.ret3

common.ret3:                                      ; preds = %10, %common.ret
  %common.ret3.op = phi { i32, i64 } [ %9, %common.ret ], [ %14, %10 ]
  ret { i32, i64 } %common.ret3.op

10:                                               ; preds = %2
  %11 = getelementptr inbounds [100010 x i64], ptr @sa, i64 0, i64 %5
  %12 = load i64, ptr %11, align 8, !tbaa !9
  %13 = add nsw i64 %12, %1
  %14 = tail call { i32, i64 } @_Z8root_itrix(i32 noundef %7, i64 noundef %13)
  %15 = extractvalue { i32, i64 } %14, 0
  %16 = extractvalue { i32, i64 } %14, 1
  store i32 %15, ptr %6, align 4, !tbaa !5
  %17 = getelementptr inbounds [100010 x i64], ptr @mini, i64 0, i64 %5
  %18 = sext i32 %15 to i64
  %19 = getelementptr inbounds [100010 x i64], ptr @mini, i64 0, i64 %18
  %20 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %17, ptr noundef nonnull align 8 dereferenceable(8) %19)
  %21 = load i64, ptr %20, align 8, !tbaa !9
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [100010 x i64], ptr @mini, i64 0, i64 %23
  store i64 %21, ptr %24, align 8, !tbaa !9
  store i64 %16, ptr %11, align 8, !tbaa !9
  br label %common.ret3
}

; Function Attrs: mustprogress uwtable
declare dso_local { i32, i64 } @_ZSt9make_pairIRiRxESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #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 = { 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass