; LLVM IR from tangjz/acm-icpc :: projecteuler/432.ll (Z1Gix)

; 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::map.0" = type { %"class.std::_Rb_tree.1" }
%"class.std::_Rb_tree.1" = type { %"struct.std::_Rb_tree<std::pair<int, long long>, std::pair<const std::pair<int, long long>, int>, std::_Select1st<std::pair<const std::pair<int, long long>, int>>, std::less<std::pair<int, long long>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, long long>, std::pair<const std::pair<int, long long>, int>, std::_Select1st<std::pair<const std::pair<int, long long>, int>>, std::less<std::pair<int, long long>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i64 }

@d = external dso_local global [23333333 x i32], align 16
@Hash2 = external dso_local global %"class.std::map.0", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z1Fx(i64 noundef) #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z1Gix(i32 noundef %0, i64 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca %"struct.std::pair", align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %10 = load i64, ptr %5, align 8, !tbaa !9
  %11 = icmp ne i64 %10, 0
  br i1 %11, label %13, label %12

12:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  br label %84

13:                                               ; preds = %2
  %14 = load i64, ptr %5, align 8, !tbaa !9
  %15 = icmp eq i64 %14, 1
  br i1 %15, label %16, label %34

16:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = call noundef i32 @_Z1Fx(i64 noundef %18)
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = sub nsw i32 %20, 1
  %22 = sext i32 %21 to i64
  %23 = call noundef i32 @_Z1Fx(i64 noundef %22)
  %24 = sub nsw i32 %19, %23
  store i32 %24, ptr %6, align 4, !tbaa !5
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = icmp slt i32 %25, 0
  br i1 %26, label %27, label %30

27:                                               ; preds = %16
  %28 = load i32, ptr %6, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1000000000
  br label %32

30:                                               ; preds = %16
  %31 = load i32, ptr %6, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %30, %27
  %33 = phi i32 [ %29, %27 ], [ %31, %30 ]
  store i32 %33, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %84

34:                                               ; preds = %13
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %37, label %40

37:                                               ; preds = %34
  %38 = load i64, ptr %5, align 8, !tbaa !9
  %39 = call noundef i32 @_Z1Fx(i64 noundef %38)
  store i32 %39, ptr %3, align 4
  br label %84

40:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #2
  %41 = 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)
  %42 = getelementptr inbounds { i32, i64 }, ptr %7, i32 0, i32 0
  %43 = extractvalue { i32, i64 } %41, 0
  store i32 %43, ptr %42, align 8
  %44 = getelementptr inbounds { i32, i64 }, ptr %7, i32 0, i32 1
  %45 = extractvalue { i32, i64 } %41, 1
  store i64 %45, ptr %44, align 8
  %46 = call noundef i64 @_ZNKSt3mapISt4pairIixEiSt4lessIS1_ESaIS0_IKS1_iEEE5countERS4_(ptr noundef nonnull align 8 dereferenceable(48) @Hash2, ptr noundef nonnull align 8 dereferenceable(16) %7)
  %47 = icmp ne i64 %46, 0
  br i1 %47, label %48, label %51

48:                                               ; preds = %40
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIixEiSt4lessIS1_ESaIS0_IKS1_iEEEixERS4_(ptr noundef nonnull align 8 dereferenceable(48) @Hash2, ptr noundef nonnull align 8 dereferenceable(16) %7)
  %50 = load i32, ptr %49, align 4, !tbaa !5
  store i32 %50, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %83

51:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = load i64, ptr %5, align 8, !tbaa !9
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [23333333 x i32], ptr @d, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = sdiv i64 %53, %58
  %60 = call noundef i32 @_Z1Gix(i32 noundef %52, i64 noundef %59)
  %61 = sext i32 %60 to i64
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [23333333 x i32], ptr @d, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = sub nsw i64 %66, 1
  %68 = load i32, ptr %4, align 4, !tbaa !5
  %69 = load i32, ptr %4, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [23333333 x i32], ptr @d, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = sdiv i32 %68, %72
  %74 = load i64, ptr %5, align 8, !tbaa !9
  %75 = call noundef i32 @_Z1Gix(i32 noundef %73, i64 noundef %74)
  %76 = sext i32 %75 to i64
  %77 = mul nsw i64 %67, %76
  %78 = add nsw i64 %61, %77
  %79 = srem i64 %78, 1000000000
  %80 = trunc i64 %79 to i32
  store i32 %80, ptr %9, align 4, !tbaa !5
  %81 = load i32, ptr %9, align 4, !tbaa !5
  %82 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIixEiSt4lessIS1_ESaIS0_IKS1_iEEEixERS4_(ptr noundef nonnull align 8 dereferenceable(48) @Hash2, ptr noundef nonnull align 8 dereferenceable(16) %7)
  store i32 %81, ptr %82, align 4, !tbaa !5
  store i32 %81, ptr %3, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  br label %83

83:                                               ; preds = %51, %48
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #2
  br label %84

84:                                               ; preds = %83, %37, %32, %12
  %85 = load i32, ptr %3, align 4
  ret i32 %85
}

; 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: mustprogress uwtable
declare dso_local noundef i64 @_ZNKSt3mapISt4pairIixEiSt4lessIS1_ESaIS0_IKS1_iEEE5countERS4_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIixEiSt4lessIS1_ESaIS0_IKS1_iEEEixERS4_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(16)) #0 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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, !10, i64 0}
!10 = !{!"long long", !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"

%"class.std::map.0" = type { %"class.std::_Rb_tree.1" }
%"class.std::_Rb_tree.1" = type { %"struct.std::_Rb_tree<std::pair<int, long long>, std::pair<const std::pair<int, long long>, int>, std::_Select1st<std::pair<const std::pair<int, long long>, int>>, std::less<std::pair<int, long long>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, long long>, std::pair<const std::pair<int, long long>, int>, std::_Select1st<std::pair<const std::pair<int, long long>, int>>, std::less<std::pair<int, long long>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i64 }

@d = external dso_local local_unnamed_addr global [23333333 x i32], align 16
@Hash2 = external dso_local global %"class.std::map.0", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z1Fx(i64 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z1Gix(i32 noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca %"struct.std::pair", align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  switch i64 %1, label %16 [
    i64 0, label %55
    i64 1, label %6
  ]

6:                                                ; preds = %2
  %7 = sext i32 %0 to i64
  %8 = tail call noundef i32 @_Z1Fx(i64 noundef %7)
  %9 = add nsw i32 %0, -1
  %10 = sext i32 %9 to i64
  %11 = tail call noundef i32 @_Z1Fx(i64 noundef %10)
  %12 = sub nsw i32 %8, %11
  %13 = icmp slt i32 %12, 0
  %14 = add nsw i32 %12, 1000000000
  %15 = select i1 %13, i32 %14, i32 %12
  br label %55

16:                                               ; preds = %2
  %17 = icmp eq i32 %0, 1
  br i1 %17, label %18, label %20

18:                                               ; preds = %16
  %19 = tail call noundef i32 @_Z1Fx(i64 noundef %1)
  br label %55

20:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #2
  %21 = 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)
  %22 = extractvalue { i32, i64 } %21, 0
  store i32 %22, ptr %5, align 8
  %23 = getelementptr inbounds i8, ptr %5, i64 8
  %24 = extractvalue { i32, i64 } %21, 1
  store i64 %24, ptr %23, align 8
  %25 = call noundef i64 @_ZNKSt3mapISt4pairIixEiSt4lessIS1_ESaIS0_IKS1_iEEE5countERS4_(ptr noundef nonnull align 8 dereferenceable(48) @Hash2, ptr noundef nonnull align 8 dereferenceable(16) %5)
  %.not6 = icmp eq i64 %25, 0
  br i1 %.not6, label %29, label %26

26:                                               ; preds = %20
  %27 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIixEiSt4lessIS1_ESaIS0_IKS1_iEEEixERS4_(ptr noundef nonnull align 8 dereferenceable(48) @Hash2, ptr noundef nonnull align 8 dereferenceable(16) %5)
  %28 = load i32, ptr %27, align 4, !tbaa !5
  br label %54

29:                                               ; preds = %20
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = load i64, ptr %4, align 8, !tbaa !9
  %32 = sext i32 %30 to i64
  %33 = getelementptr inbounds [23333333 x i32], ptr @d, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = sdiv i64 %31, %35
  %37 = call noundef i32 @_Z1Gix(i32 noundef %30, i64 noundef %36)
  %38 = sext i32 %37 to i64
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [23333333 x i32], ptr @d, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = add nsw i64 %43, -1
  %45 = sdiv i32 %39, %42
  %46 = load i64, ptr %4, align 8, !tbaa !9
  %47 = call noundef i32 @_Z1Gix(i32 noundef %45, i64 noundef %46)
  %48 = sext i32 %47 to i64
  %49 = mul nsw i64 %44, %48
  %50 = add nsw i64 %49, %38
  %51 = srem i64 %50, 1000000000
  %52 = trunc nsw i64 %51 to i32
  %53 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIixEiSt4lessIS1_ESaIS0_IKS1_iEEEixERS4_(ptr noundef nonnull align 8 dereferenceable(48) @Hash2, ptr noundef nonnull align 8 dereferenceable(16) %5)
  store i32 %52, ptr %53, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %29, %26
  %.0 = phi i32 [ %28, %26 ], [ %52, %29 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #2
  br label %55

55:                                               ; preds = %2, %54, %18, %6
  %.1 = phi i32 [ %15, %6 ], [ %19, %18 ], [ %.0, %54 ], [ 0, %2 ]
  ret i32 %.1
}

; 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: mustprogress uwtable
declare dso_local noundef i64 @_ZNKSt3mapISt4pairIixEiSt4lessIS1_ESaIS0_IKS1_iEEE5countERS4_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIixEiSt4lessIS1_ESaIS0_IKS1_iEEEixERS4_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}


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