; LLVM IR from thuhcsi/Crystal.TTVS :: TinyXML/tinystr.ll (ZNK11TiXmlStringeqERKS_)

; 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.TiXmlString = type { ptr, i64, i64 }

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@__PRETTY_FUNCTION__._ZNK11TiXmlStringeqERKS_ = external hidden unnamed_addr constant [56 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK11TiXmlString6lengthEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK11TiXmlStringeqERKS_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) #1 align 2 {
  %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 = load ptr, ptr %4, align 8
  %7 = getelementptr inbounds %class.TiXmlString, ptr %6, i32 0, i32 1
  %8 = load i64, ptr %7, align 8, !tbaa !9
  %9 = icmp ne i64 %8, 0
  br i1 %9, label %10, label %38

10:                                               ; preds = %2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %class.TiXmlString, ptr %11, i32 0, i32 1
  %13 = load i64, ptr %12, align 8, !tbaa !9
  %14 = icmp ne i64 %13, 0
  br i1 %14, label %15, label %38

15:                                               ; preds = %10
  %16 = getelementptr inbounds %class.TiXmlString, ptr %6, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !12
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %15
  br label %22

20:                                               ; preds = %15
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 267, ptr noundef @__PRETTY_FUNCTION__._ZNK11TiXmlStringeqERKS_) #4
  unreachable

21:                                               ; No predecessors!
  br label %22

22:                                               ; preds = %21, %19
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %class.TiXmlString, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %28

27:                                               ; preds = %22
  br label %30

28:                                               ; preds = %22
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 268, ptr noundef @__PRETTY_FUNCTION__._ZNK11TiXmlStringeqERKS_) #4
  unreachable

29:                                               ; No predecessors!
  br label %30

30:                                               ; preds = %29, %27
  %31 = getelementptr inbounds %class.TiXmlString, ptr %6, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !12
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %class.TiXmlString, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !12
  %36 = call i32 @strcmp(ptr noundef %32, ptr noundef %35) #5
  %37 = icmp eq i32 %36, 0
  store i1 %37, ptr %3, align 1
  br label %48

38:                                               ; preds = %10, %2
  %39 = call noundef i64 @_ZNK11TiXmlString6lengthEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %40 = icmp eq i64 %39, 0
  br i1 %40, label %41, label %46

41:                                               ; preds = %38
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = call noundef i64 @_ZNK11TiXmlString6lengthEv(ptr noundef nonnull align 8 dereferenceable(24) %42)
  %44 = icmp eq i64 %43, 0
  br i1 %44, label %45, label %46

45:                                               ; preds = %41
  store i1 true, ptr %3, align 1
  br label %48

46:                                               ; preds = %41, %38
  br label %47

47:                                               ; preds = %46
  store i1 false, ptr %3, align 1
  br label %48

48:                                               ; preds = %47, %45, %30
  %49 = load i1, ptr %3, align 1
  ret i1 %49
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

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 = { 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 #2 = { noreturn nounwind "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 willreturn memory(read) "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 #4 = { noreturn nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!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, !11, i64 8}
!10 = !{!"_ZTS11TiXmlString", !6, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, 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"

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@__PRETTY_FUNCTION__._ZNK11TiXmlStringeqERKS_ = external hidden unnamed_addr constant [56 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK11TiXmlString6lengthEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK11TiXmlStringeqERKS_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i64 %4, 0
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load i64, ptr %5, align 8
  %.not8 = icmp eq i64 %6, 0
  %or.cond = select i1 %.not, i1 true, i1 %.not8
  br i1 %or.cond, label %16, label %7

7:                                                ; preds = %2
  %8 = load ptr, ptr %0, align 8, !tbaa !11
  %.not9 = icmp eq ptr %8, null
  br i1 %.not9, label %9, label %10

9:                                                ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 267, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK11TiXmlStringeqERKS_) #3
  unreachable

10:                                               ; preds = %7
  %11 = load ptr, ptr %1, align 8, !tbaa !11
  %.not10 = icmp eq ptr %11, null
  br i1 %.not10, label %12, label %13

12:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 268, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK11TiXmlStringeqERKS_) #3
  unreachable

13:                                               ; preds = %10
  %14 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) %11) #4
  %15 = icmp eq i32 %14, 0
  br label %23

16:                                               ; preds = %2
  %17 = tail call noundef i64 @_ZNK11TiXmlString6lengthEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %18 = icmp eq i64 %17, 0
  br i1 %18, label %19, label %22

19:                                               ; preds = %16
  %20 = tail call noundef i64 @_ZNK11TiXmlString6lengthEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %21 = icmp eq i64 %20, 0
  br i1 %21, label %23, label %22

22:                                               ; preds = %16, %19
  br label %23

23:                                               ; preds = %19, %22, %13
  %.0 = phi i1 [ %15, %13 ], [ false, %22 ], [ true, %19 ]
  ret i1 %.0
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #2

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 = { noreturn nounwind "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 nofree nounwind willreturn memory(argmem: read) "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 = { noreturn nounwind }
attributes #4 = { nounwind willreturn memory(read) }

!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, !10, i64 8}
!6 = !{!"_ZTS11TiXmlString", !7, i64 0, !10, i64 8, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !7, i64 0}


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