; LLVM IR from huawei-noah/bolt :: inference/engine/src (bolt_c)

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

@.str.21 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [13 x i8], align 1
@__FUNCTION__.CloneResultHandle = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z18assert_not_nullptrPKcS0_PKv(ptr noundef, ptr noundef, ptr 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_Z10UNI_MALLOCm(i64 noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z10UNI_MEMCPYPvPKvm(ptr noundef, ptr noundef, i64 noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z19print_result_handleP17ResultHandleInner(ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local ptr @CloneResultHandle(ptr noundef %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  store ptr null, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %7, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_Z18assert_not_nullptrPKcS0_PKv(ptr noundef @__FUNCTION__.CloneResultHandle, ptr noundef @.str.22, ptr noundef %8)
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_Z19print_result_handleP17ResultHandleInner(ptr noundef %9)
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %44

12:                                               ; preds = %1
  %13 = call noundef ptr @_Z10UNI_MALLOCm(i64 noundef 24)
  store ptr %13, ptr %3, align 8, !tbaa !5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 8 %14, i64 24, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ResultHandleInner, ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !14
  %19 = zext i32 %18 to i64
  %20 = mul i64 232, %19
  %21 = trunc i64 %20 to i32
  store i32 %21, ptr %5, align 4, !tbaa !10
  %22 = load i32, ptr %5, align 4, !tbaa !10
  %23 = icmp ugt i32 %22, 0
  br i1 %23, label %24, label %40

24:                                               ; preds = %12
  %25 = load i32, ptr %5, align 4, !tbaa !10
  %26 = zext i32 %25 to i64
  %27 = call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %26)
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ResultHandleInner, ptr %28, i32 0, i32 1
  store ptr %27, ptr %29, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ResultHandleInner, ptr %30, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  store ptr %32, ptr %6, align 8, !tbaa !5
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_Z18assert_not_nullptrPKcS0_PKv(ptr noundef @__FUNCTION__.CloneResultHandle, ptr noundef @.str.21, ptr noundef %33)
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ResultHandleInner, ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !16
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load i32, ptr %5, align 4, !tbaa !10
  %39 = zext i32 %38 to i64
  call void @_Z10UNI_MEMCPYPvPKvm(ptr noundef %36, ptr noundef %37, i64 noundef %39)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %43

40:                                               ; preds = %12
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ResultHandleInner, ptr %41, i32 0, i32 1
  store ptr null, ptr %42, align 8, !tbaa !16
  br label %43

43:                                               ; preds = %40, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %44

44:                                               ; preds = %43, %1
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_Z19print_result_handleP17ResultHandleInner(ptr noundef %45)
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret ptr %46
}

attributes #0 = { 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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #5 = { 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 = !{i64 0, i64 4, !10, i64 8, i64 8, !5, i64 16, i64 4, !12}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"_ZTS13HARDWARE_TYPE", !7, i64 0}
!14 = !{!15, !11, i64 0}
!15 = !{!"_ZTS17ResultHandleInner", !11, i64 0, !6, i64 8, !13, i64 16}
!16 = !{!15, !6, 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"

@.str.21 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [13 x i8], align 1
@__FUNCTION__.CloneResultHandle = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z18assert_not_nullptrPKcS0_PKv(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_Z10UNI_MALLOCm(i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z10UNI_MEMCPYPvPKvm(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z19print_result_handleP17ResultHandleInner(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @CloneResultHandle(ptr noundef %0) local_unnamed_addr #3 {
  tail call void @_Z18assert_not_nullptrPKcS0_PKv(ptr noundef nonnull @__FUNCTION__.CloneResultHandle, ptr noundef nonnull @.str.22, ptr noundef %0)
  tail call void @_Z19print_result_handleP17ResultHandleInner(ptr noundef %0)
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %15, label %2

2:                                                ; preds = %1
  %3 = tail call noundef ptr @_Z10UNI_MALLOCm(i64 noundef 24)
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) %0, i64 24, i1 false), !tbaa.struct !5
  %4 = load i32, ptr %3, align 8, !tbaa !14
  %5 = mul i32 %4, 232
  %.not19 = icmp eq i32 %5, 0
  br i1 %.not19, label %13, label %6

6:                                                ; preds = %2
  %7 = zext i32 %5 to i64
  %8 = tail call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %7)
  %9 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %8, ptr %9, align 8, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !16
  tail call void @_Z18assert_not_nullptrPKcS0_PKv(ptr noundef nonnull @__FUNCTION__.CloneResultHandle, ptr noundef nonnull @.str.21, ptr noundef %11)
  %12 = load ptr, ptr %9, align 8, !tbaa !16
  tail call void @_Z10UNI_MEMCPYPvPKvm(ptr noundef %12, ptr noundef %11, i64 noundef %7)
  br label %15

13:                                               ; preds = %2
  %14 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr null, ptr %14, align 8, !tbaa !16
  br label %15

15:                                               ; preds = %6, %13, %1
  %.0 = phi ptr [ null, %1 ], [ %3, %13 ], [ %3, %6 ]
  tail call void @_Z19print_result_handleP17ResultHandleInner(ptr noundef %.0)
  ret ptr %.0
}

attributes #0 = { 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" }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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" }

!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 = !{i64 0, i64 4, !6, i64 8, i64 8, !10, i64 16, i64 4, !12}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"_ZTS13HARDWARE_TYPE", !8, i64 0}
!14 = !{!15, !7, i64 0}
!15 = !{!"_ZTS17ResultHandleInner", !7, i64 0, !11, i64 8, !13, i64 16}
!16 = !{!15, !11, i64 8}


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