; LLVM IR from upupming/algorithm :: CCCC-GPLT/L2-021 点赞狂魔.ll (Z3cmp3stuS_)

; 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.stu = type { %"class.std::__cxx11::basic_string", i32, i32 }
%"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] }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z3cmp3stuS_(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.stu, ptr %0, i32 0, i32 2
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = getelementptr inbounds %struct.stu, ptr %1, i32 0, i32 2
  %9 = load i32, ptr %8, align 4, !tbaa !9
  %10 = icmp ne i32 %7, %9
  br i1 %10, label %11, label %17

11:                                               ; preds = %2
  %12 = getelementptr inbounds %struct.stu, ptr %0, i32 0, i32 2
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = getelementptr inbounds %struct.stu, ptr %1, i32 0, i32 2
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = icmp sgt i32 %13, %15
  store i1 %16, ptr %3, align 1
  br label %35

17:                                               ; preds = %2
  %18 = getelementptr inbounds %struct.stu, ptr %0, i32 0, i32 1
  %19 = load i32, ptr %18, align 8, !tbaa !15
  %20 = sitofp i32 %19 to double
  %21 = fmul double 1.000000e+00, %20
  %22 = getelementptr inbounds %struct.stu, ptr %0, i32 0, i32 2
  %23 = load i32, ptr %22, align 4, !tbaa !9
  %24 = sitofp i32 %23 to double
  %25 = fdiv double %21, %24
  %26 = getelementptr inbounds %struct.stu, ptr %1, i32 0, i32 1
  %27 = load i32, ptr %26, align 8, !tbaa !15
  %28 = sitofp i32 %27 to double
  %29 = fmul double 1.000000e+00, %28
  %30 = getelementptr inbounds %struct.stu, ptr %1, i32 0, i32 2
  %31 = load i32, ptr %30, align 4, !tbaa !9
  %32 = sitofp i32 %31 to double
  %33 = fdiv double %29, %32
  %34 = fcmp olt double %25, %33
  store i1 %34, ptr %3, align 1
  br label %35

35:                                               ; preds = %17, %11
  %36 = load i1, ptr %3, align 1
  ret i1 %36
}

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !14, i64 36}
!10 = !{!"_ZTS3stu", !11, i64 0, !14, i64 32, !14, i64 36}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !12, i64 0, !13, i64 8, !7, i64 16}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!10, !14, i64 32}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef zeroext i1 @_Z3cmp3stuS_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 36
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 36
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not = icmp eq i32 %4, %6
  br i1 %.not, label %9, label %7

7:                                                ; preds = %2
  %8 = icmp sgt i32 %4, %6
  br label %24

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  %11 = load i32, ptr %10, align 8, !tbaa !14
  %12 = sitofp i32 %4 to double
  %13 = getelementptr inbounds i8, ptr %1, i64 32
  %14 = load i32, ptr %13, align 8, !tbaa !14
  %15 = insertelement <2 x i32> poison, i32 %11, i64 0
  %16 = insertelement <2 x i32> %15, i32 %14, i64 1
  %17 = sitofp <2 x i32> %16 to <2 x double>
  %18 = insertelement <2 x double> poison, double %12, i64 0
  %19 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> zeroinitializer
  %20 = fdiv <2 x double> %17, %19
  %21 = extractelement <2 x double> %20, i64 0
  %22 = extractelement <2 x double> %20, i64 1
  %23 = fcmp olt double %21, %22
  br label %24

24:                                               ; preds = %9, %7
  %.0 = phi i1 [ %8, %7 ], [ %23, %9 ]
  ret i1 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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, !13, i64 36}
!6 = !{!"_ZTS3stu", !7, i64 0, !13, i64 32, !13, i64 36}
!7 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !8, i64 0, !12, i64 8, !10, i64 16}
!8 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"long", !10, i64 0}
!13 = !{!"int", !10, i64 0}
!14 = !{!6, !13, i64 32}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass