; LLVM IR from Softmotions/iowow :: src/json (iwjser)

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

; Function Attrs: nounwind uwtable
define dso_local i64 @jbn_clone(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct.jbn_vctx, align 8
  %11 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr null, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = call ptr @_jbl_clone_node_struct(ptr noundef %13, ptr noundef %14)
  store ptr %15, ptr %8, align 8, !tbaa !5
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %22, label %18

18:                                               ; preds = %3
  %19 = call ptr @__errno_location() #6
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %20)
  store i64 %21, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %48

22:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 40, ptr %10) #5
  %23 = getelementptr inbounds %struct.jbn_vctx, ptr %10, i32 0, i32 0
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %24, ptr %23, align 8, !tbaa !11
  %25 = getelementptr inbounds %struct.jbn_vctx, ptr %10, i32 0, i32 1
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %26, ptr %25, align 8, !tbaa !14
  %27 = getelementptr inbounds %struct.jbn_vctx, ptr %10, i32 0, i32 2
  store ptr null, ptr %27, align 8, !tbaa !15
  %28 = getelementptr inbounds %struct.jbn_vctx, ptr %10, i32 0, i32 3
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %29, ptr %28, align 8, !tbaa !16
  %30 = getelementptr inbounds %struct.jbn_vctx, ptr %10, i32 0, i32 4
  store i32 0, ptr %30, align 8, !tbaa !17
  %31 = getelementptr inbounds %struct.jbn_vctx, ptr %10, i32 0, i32 5
  store i8 0, ptr %31, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = call i64 @jbn_visit(ptr noundef %32, i32 noundef 0, ptr noundef %10, ptr noundef @_jbl_clone_node_visit)
  store i64 %33, ptr %11, align 8, !tbaa !19
  %34 = load i64, ptr %11, align 8, !tbaa !19
  %35 = icmp ne i64 %34, 0
  %36 = xor i1 %35, true
  %37 = xor i1 %36, true
  %38 = zext i1 %37 to i32
  %39 = sext i32 %38 to i64
  %40 = call i64 @llvm.expect.i64(i64 %39, i64 0)
  %41 = icmp ne i64 %40, 0
  br i1 %41, label %42, label %44

42:                                               ; preds = %22
  %43 = load i64, ptr %11, align 8, !tbaa !19
  store i64 %43, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %47

44:                                               ; preds = %22
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %45, ptr %46, align 8, !tbaa !5
  store i64 0, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %47

47:                                               ; preds = %44, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %10) #5
  br label %48

48:                                               ; preds = %47, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %49 = load i64, ptr %4, align 8
  ret i64 %49
}

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

; Function Attrs: nounwind uwtable
declare hidden ptr @_jbl_clone_node_struct(ptr noundef, ptr noundef) #0

declare i64 @iwrc_set_errno(i64 noundef, i32 noundef) #2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #3

declare i64 @jbn_visit(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @_jbl_clone_node_visit(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #0

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

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

attributes #0 = { 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 = { "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(none) "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 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(none) }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"jbn_vctx", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !13, i64 36}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!12, !6, i64 8}
!15 = !{!12, !6, i64 16}
!16 = !{!12, !6, i64 24}
!17 = !{!12, !10, i64 32}
!18 = !{!12, !13, i64 36}
!19 = !{!20, !20, i64 0}
!20 = !{!"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"

%struct.jbn_vctx = type { ptr, ptr, ptr, ptr, i32, i8 }

; Function Attrs: nounwind uwtable
define dso_local i64 @jbn_clone(ptr noundef %0, ptr nocapture noundef writeonly %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct.jbn_vctx, align 8
  store ptr null, ptr %1, align 8, !tbaa !5
  %5 = tail call ptr @_jbl_clone_node_struct(ptr noundef %0, ptr noundef %2)
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %6, label %10

6:                                                ; preds = %3
  %7 = tail call ptr @__errno_location() #4
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = tail call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %8) #5
  br label %19

10:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #5
  store ptr %5, ptr %4, align 8, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %5, ptr %11, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %4, i64 16
  store ptr null, ptr %12, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %4, i64 24
  store ptr %2, ptr %13, align 8, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %4, i64 32
  store i32 0, ptr %14, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %4, i64 36
  store i8 0, ptr %15, align 4, !tbaa !18
  %16 = call i64 @jbn_visit(ptr noundef %0, i32 noundef 0, ptr noundef nonnull %4, ptr noundef nonnull @_jbl_clone_node_visit) #5
  %.not14 = icmp eq i64 %16, 0
  br i1 %.not14, label %17, label %18, !prof !19

17:                                               ; preds = %10
  store ptr %5, ptr %1, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %10, %17
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #5
  br label %19

19:                                               ; preds = %18, %6
  %.1 = phi i64 [ %16, %18 ], [ %9, %6 ]
  ret i64 %.1
}

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

; Function Attrs: nounwind uwtable
declare hidden ptr @_jbl_clone_node_struct(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i64 @iwrc_set_errno(i64 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #3

declare i64 @jbn_visit(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @_jbl_clone_node_visit(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #0

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

attributes #0 = { 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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 nofree nosync nounwind willreturn memory(none) "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 willreturn memory(none) }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"jbn_vctx", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !13, i64 36}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!12, !6, i64 8}
!15 = !{!12, !6, i64 16}
!16 = !{!12, !6, i64 24}
!17 = !{!12, !10, i64 32}
!18 = !{!12, !13, i64 36}
!19 = !{!"branch_weights", !"expected", i32 2000, i32 1}


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