; LLVM IR from alibaba/BladeDISC :: tao_compiler/mlir/ral (ral_api)

; 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.anon.17 = type { i8 }
%"struct.tao::ral::internal::Voidifier" = type { i8 }
%"class.tao::ral::internal::LogMessage" = type { %"class.std::__cxx11::basic_ostringstream.base", ptr, i32, i32, %"class.std::basic_ios" }
%"class.std::__cxx11::basic_ostringstream.base" = type { %"class.std::basic_ostream.base", %"class.std::__cxx11::basic_stringbuf" }
%"class.std::basic_ostream.base" = type { ptr }
%"class.std::__cxx11::basic_stringbuf" = type { %"class.std::basic_streambuf", i32, %"class.std::__cxx11::basic_string" }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%"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] }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }

@.str.1 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [41 x i8], align 1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK3tao3ral8internal9VoidifieranINS1_10LogMessageEEEvRKT_(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 8 dereferenceable(128)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(128) ptr @_ZStlsIN3tao3ral8internal10LogMessageEPvEOT_S6_RKT0_(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef nonnull align 8 dereferenceable(8)) #3

declare void @_ZN3tao3ral8internal10LogMessageC1EPKcii(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef, i32 noundef, i32 noundef) unnamed_addr #4

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN3tao3ral8internal10LogMessageD1Ev(ptr noundef nonnull align 8 dereferenceable(128)) unnamed_addr #5

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

; Function Attrs: mustprogress uwtable
define dso_local i32 @tao_ral_last_error(ptr noundef %0, ptr noundef %1) #6 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %class.anon.17, align 1
  %6 = alloca %"struct.tao::ral::internal::Voidifier", align 1
  %7 = alloca %"class.tao::ral::internal::LogMessage", align 8
  %8 = alloca i1, align 1
  %9 = alloca i1, align 1
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #7
  %13 = call noundef zeroext i1 @"_ZZ18tao_ral_last_errorENK3$_0clEiPKc"(ptr noundef nonnull align 1 dereferenceable(1) %5, i32 noundef 1, ptr noundef @.str.1)
  %14 = xor i1 %13, true
  %15 = xor i1 %14, true
  %16 = xor i1 %15, true
  %17 = zext i1 %16 to i64
  %18 = call i64 @llvm.expect.i64(i64 %17, i64 1)
  %19 = icmp ne i64 %18, 0
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #7
  store i1 false, ptr %8, align 1
  store i1 false, ptr %9, align 1
  br i1 %19, label %20, label %21

20:                                               ; preds = %2
  br label %27

21:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 392, ptr %7) #7
  store i1 true, ptr %8, align 1
  call void @_ZN3tao3ral8internal10LogMessageC1EPKcii(ptr noundef nonnull align 8 dereferenceable(128) %7, ptr noundef @.str.1, i32 noundef 41, i32 noundef 0)
  store i1 true, ptr %9, align 1
  %22 = invoke noundef nonnull align 8 dereferenceable(128) ptr @_ZStlsIN3tao3ral8internal10LogMessageEA41_cEOT_S6_RKT0_(ptr noundef nonnull align 8 dereferenceable(128) %7, ptr noundef nonnull align 1 dereferenceable(41) @.str.5)
          to label %23 unwind label %38

23:                                               ; preds = %21
  %24 = invoke noundef nonnull align 8 dereferenceable(128) ptr @_ZStlsIN3tao3ral8internal10LogMessageEPvEOT_S6_RKT0_(ptr noundef nonnull align 8 dereferenceable(128) %22, ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %25 unwind label %38

25:                                               ; preds = %23
  invoke void @_ZNK3tao3ral8internal9VoidifieranINS1_10LogMessageEEEvRKT_(ptr noundef nonnull align 1 dereferenceable(1) %6, ptr noundef nonnull align 8 dereferenceable(128) %24)
          to label %26 unwind label %38

26:                                               ; preds = %25
  br label %27

27:                                               ; preds = %26, %20
  %28 = load i1, ptr %9, align 1
  br i1 %28, label %29, label %30

29:                                               ; preds = %27
  call void @_ZN3tao3ral8internal10LogMessageD1Ev(ptr noundef nonnull align 8 dereferenceable(128) %7) #7
  br label %30

30:                                               ; preds = %29, %27
  %31 = load i1, ptr %8, align 1
  br i1 %31, label %32, label %33

32:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 392, ptr %7) #7
  br label %33

33:                                               ; preds = %32, %30
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %34, ptr %12, align 8, !tbaa !5
  %35 = load ptr, ptr %12, align 8, !tbaa !5
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = call noundef i32 @_ZN3tao3ral7Context12getLastErrorEPPKc(ptr noundef nonnull align 8 dereferenceable(56) %35, ptr noundef %36)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  ret i32 %37

38:                                               ; preds = %25, %23, %21
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %10, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %11, align 4
  %42 = load i1, ptr %9, align 1
  br i1 %42, label %43, label %44

43:                                               ; preds = %38
  call void @_ZN3tao3ral8internal10LogMessageD1Ev(ptr noundef nonnull align 8 dereferenceable(128) %7) #7
  br label %44

44:                                               ; preds = %43, %38
  %45 = load i1, ptr %8, align 1
  br i1 %45, label %46, label %47

46:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 392, ptr %7) #7
  br label %47

47:                                               ; preds = %46, %44
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #7
  br label %48

48:                                               ; preds = %47
  %49 = load ptr, ptr %10, align 8
  %50 = load i32, ptr %11, align 4
  %51 = insertvalue { ptr, i32 } poison, ptr %49, 0
  %52 = insertvalue { ptr, i32 } %51, i32 %50, 1
  resume { ptr, i32 } %52
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef zeroext i1 @"_ZZ18tao_ral_last_errorENK3$_0clEiPKc"(ptr noundef nonnull align 1 dereferenceable(1), i32 noundef, ptr noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(128) ptr @_ZStlsIN3tao3ral8internal10LogMessageEA41_cEOT_S6_RKT0_(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef nonnull align 1 dereferenceable(41)) #3

declare noundef i32 @_ZN3tao3ral7Context12getLastErrorEPPKc(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #2 = { 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 = { inlinehint 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 #4 = { "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 #5 = { 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 #6 = { 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 #7 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; 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.anon.17 = type { i8 }
%"struct.tao::ral::internal::Voidifier" = type { i8 }
%"class.tao::ral::internal::LogMessage" = type { %"class.std::__cxx11::basic_ostringstream.base", ptr, i32, i32, %"class.std::basic_ios" }
%"class.std::__cxx11::basic_ostringstream.base" = type { %"class.std::basic_ostream.base", %"class.std::__cxx11::basic_stringbuf" }
%"class.std::basic_ostream.base" = type { ptr }
%"class.std::__cxx11::basic_stringbuf" = type { %"class.std::basic_streambuf", i32, %"class.std::__cxx11::basic_string" }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%"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] }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }

@.str.1 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [41 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK3tao3ral8internal9VoidifieranINS1_10LogMessageEEEvRKT_(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 8 dereferenceable(128)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(128) ptr @_ZStlsIN3tao3ral8internal10LogMessageEPvEOT_S6_RKT0_(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

declare void @_ZN3tao3ral8internal10LogMessageC1EPKcii(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef, i32 noundef, i32 noundef) unnamed_addr #3

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN3tao3ral8internal10LogMessageD1Ev(ptr noundef nonnull align 8 dereferenceable(128)) unnamed_addr #4

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @tao_ral_last_error(ptr noundef %0, ptr noundef %1) local_unnamed_addr #5 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca %class.anon.17, align 1
  %5 = alloca %"struct.tao::ral::internal::Voidifier", align 1
  %6 = alloca %"class.tao::ral::internal::LogMessage", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #6
  %7 = call noundef zeroext i1 @"_ZZ18tao_ral_last_errorENK3$_0clEiPKc"(ptr noundef nonnull align 1 dereferenceable(1) %4, i32 noundef 1, ptr noundef nonnull @.str.1)
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #6
  br i1 %7, label %8, label %.critedge8, !prof !9

8:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 392, ptr nonnull %6) #6
  call void @_ZN3tao3ral8internal10LogMessageC1EPKcii(ptr noundef nonnull align 8 dereferenceable(128) %6, ptr noundef nonnull @.str.1, i32 noundef 41, i32 noundef 0)
  %9 = invoke noundef nonnull align 8 dereferenceable(128) ptr @_ZStlsIN3tao3ral8internal10LogMessageEA41_cEOT_S6_RKT0_(ptr noundef nonnull align 8 dereferenceable(128) %6, ptr noundef nonnull align 1 dereferenceable(41) @.str.5)
          to label %10 unwind label %14

10:                                               ; preds = %8
  %11 = invoke noundef nonnull align 8 dereferenceable(128) ptr @_ZStlsIN3tao3ral8internal10LogMessageEPvEOT_S6_RKT0_(ptr noundef nonnull align 8 dereferenceable(128) %9, ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %.critedge unwind label %14

.critedge:                                        ; preds = %10
  call void @_ZNK3tao3ral8internal9VoidifieranINS1_10LogMessageEEEvRKT_(ptr noundef nonnull align 1 dereferenceable(1) %5, ptr noundef nonnull align 8 dereferenceable(128) %11)
  call void @_ZN3tao3ral8internal10LogMessageD1Ev(ptr noundef nonnull align 8 dereferenceable(128) %6) #6
  call void @llvm.lifetime.end.p0(i64 392, ptr nonnull %6) #6
  %.pre = load ptr, ptr %3, align 8, !tbaa !5
  br label %.critedge8

.critedge8:                                       ; preds = %2, %.critedge
  %12 = phi ptr [ %0, %2 ], [ %.pre, %.critedge ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #6
  %13 = call noundef i32 @_ZN3tao3ral7Context12getLastErrorEPPKc(ptr noundef nonnull align 8 dereferenceable(56) %12, ptr noundef %1)
  ret i32 %13

14:                                               ; preds = %10, %8
  %15 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3tao3ral8internal10LogMessageD1Ev(ptr noundef nonnull align 8 dereferenceable(128) %6) #6
  call void @llvm.lifetime.end.p0(i64 392, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #6
  resume { ptr, i32 } %15
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef zeroext i1 @"_ZZ18tao_ral_last_errorENK3$_0clEiPKc"(ptr noundef nonnull align 1 dereferenceable(1), i32 noundef, ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(128) ptr @_ZStlsIN3tao3ral8internal10LogMessageEA41_cEOT_S6_RKT0_(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef nonnull align 1 dereferenceable(41)) local_unnamed_addr #2

declare noundef i32 @_ZN3tao3ral7Context12getLastErrorEPPKc(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 #3 = { "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 = { 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 #5 = { 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 #6 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"branch_weights", !"expected", i32 1, i32 2000}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LowerExpectIntrinsicPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass