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

; 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.binn_struct = type { i32, i32, i32, i32, ptr, i32, i32, i32, i32, ptr, i32, i32, ptr, ptr, ptr, %union.anon }
%union.anon = type { i64 }
%struct.jbl = type { %struct.binn_struct, ptr }

; 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(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

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

; 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) #4

declare void @binn_free(ptr noundef) #1

declare ptr @iwpool_create(i64 noundef) #1

declare zeroext i1 @iwpool_destroy(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @_jbl_node_from_binn(ptr noundef, ptr noundef, i1 noundef zeroext, ptr noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local i64 @_jbl_binn_from_node(ptr noundef, ptr noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local i64 @jbn_merge_patch_from_json(ptr noundef, ptr noundef, ptr noundef) #5

; Function Attrs: nounwind uwtable
define dso_local i64 @jbl_merge_patch(ptr noundef %0, ptr noundef %1) #5 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.binn_struct, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %16

13:                                               ; preds = %2
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %17, label %16

16:                                               ; preds = %13, %2
  store i64 70017, ptr %3, align 8
  br label %83

17:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 88, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.jbl, ptr %18, i32 0, i32 0
  %20 = getelementptr inbounds %struct.binn_struct, ptr %19, i32 0, i32 10
  %21 = load i32, ptr %20, align 8, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = mul i64 2, %22
  %24 = call ptr @iwpool_create(i64 noundef %23)
  store ptr %24, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %31, label %27

27:                                               ; preds = %17
  %28 = call ptr @__errno_location() #7
  %29 = load i32, ptr %28, align 4, !tbaa !13
  %30 = call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %29)
  store i64 %30, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %82

31:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.jbl, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = call i64 @_jbl_node_from_binn(ptr noundef %33, ptr noundef %7, i1 noundef zeroext false, ptr noundef %34)
  store i64 %35, ptr %10, align 8, !tbaa !14
  %36 = load i64, ptr %10, align 8, !tbaa !14
  %37 = icmp ne i64 %36, 0
  %38 = xor i1 %37, true
  %39 = xor i1 %38, true
  %40 = zext i1 %39 to i32
  %41 = sext i32 %40 to i64
  %42 = call i64 @llvm.expect.i64(i64 %41, i64 0)
  %43 = icmp ne i64 %42, 0
  br i1 %43, label %44, label %45

44:                                               ; preds = %31
  br label %79

45:                                               ; preds = %31
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = call i64 @jbn_merge_patch_from_json(ptr noundef %46, ptr noundef %47, ptr noundef %48)
  store i64 %49, ptr %10, align 8, !tbaa !14
  %50 = load i64, ptr %10, align 8, !tbaa !14
  %51 = icmp ne i64 %50, 0
  %52 = xor i1 %51, true
  %53 = xor i1 %52, true
  %54 = zext i1 %53 to i32
  %55 = sext i32 %54 to i64
  %56 = call i64 @llvm.expect.i64(i64 %55, i64 0)
  %57 = icmp ne i64 %56, 0
  br i1 %57, label %58, label %59

58:                                               ; preds = %45
  br label %79

59:                                               ; preds = %45
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = call i64 @_jbl_binn_from_node(ptr noundef %6, ptr noundef %60)
  store i64 %61, ptr %10, align 8, !tbaa !14
  %62 = load i64, ptr %10, align 8, !tbaa !14
  %63 = icmp ne i64 %62, 0
  %64 = xor i1 %63, true
  %65 = xor i1 %64, true
  %66 = zext i1 %65 to i32
  %67 = sext i32 %66 to i64
  %68 = call i64 @llvm.expect.i64(i64 %67, i64 0)
  %69 = icmp ne i64 %68, 0
  br i1 %69, label %70, label %71

70:                                               ; preds = %59
  br label %79

71:                                               ; preds = %59
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.jbl, ptr %72, i32 0, i32 0
  call void @binn_free(ptr noundef %73)
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.jbl, ptr %74, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %75, ptr align 8 %6, i64 88, i1 false)
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.jbl, ptr %76, i32 0, i32 0
  %78 = getelementptr inbounds %struct.binn_struct, ptr %77, i32 0, i32 1
  store i32 0, ptr %78, align 4, !tbaa !16
  br label %79

79:                                               ; preds = %71, %70, %58, %44
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = call zeroext i1 @iwpool_destroy(ptr noundef %80)
  store i64 0, ptr %3, align 8
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %82

82:                                               ; preds = %79, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 88, ptr %6) #6
  br label %83

83:                                               ; preds = %82, %16
  %84 = load i64, ptr %3, align 8
  ret i64 %84
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #3 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { nounwind }
attributes #7 = { 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, !12, i64 48}
!10 = !{!"jbl", !11, i64 0, !6, i64 88}
!11 = !{!"binn_struct", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !6, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !6, i64 40, !12, i64 48, !12, i64 52, !6, i64 56, !6, i64 64, !6, i64 72, !7, i64 80}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!10, !12, i64 4}


; 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.binn_struct = type { i32, i32, i32, i32, ptr, i32, i32, i32, i32, ptr, i32, i32, ptr, ptr, ptr, %union.anon }
%union.anon = type { i64 }

; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

; 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) #3

declare void @binn_free(ptr noundef) local_unnamed_addr #1

declare ptr @iwpool_create(i64 noundef) local_unnamed_addr #1

declare zeroext i1 @iwpool_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @_jbl_node_from_binn(ptr noundef, ptr noundef, i1 noundef zeroext, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local i64 @_jbl_binn_from_node(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local i64 @jbn_merge_patch_from_json(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local i64 @jbl_merge_patch(ptr noundef %0, ptr noundef %1) local_unnamed_addr #4 {
  %3 = alloca %struct.binn_struct, align 8
  %4 = alloca ptr, align 8
  %5 = icmp ne ptr %0, null
  %6 = icmp ne ptr %1, null
  %or.cond = and i1 %5, %6
  br i1 %or.cond, label %7, label %30

7:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 88, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = shl nsw i64 %10, 1
  %12 = tail call ptr @iwpool_create(i64 noundef %11) #5
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %13, label %17

13:                                               ; preds = %7
  %14 = tail call ptr @__errno_location() #6
  %15 = load i32, ptr %14, align 4, !tbaa !12
  %16 = tail call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %15) #5
  br label %29

17:                                               ; preds = %7
  %18 = call i64 @_jbl_node_from_binn(ptr noundef nonnull %0, ptr noundef nonnull %4, i1 noundef zeroext false, ptr noundef nonnull %12)
  %.not19 = icmp eq i64 %18, 0
  br i1 %.not19, label %19, label %27, !prof !13

19:                                               ; preds = %17
  %20 = load ptr, ptr %4, align 8, !tbaa !14
  %21 = call i64 @jbn_merge_patch_from_json(ptr noundef %20, ptr noundef nonnull %1, ptr noundef nonnull %12)
  %.not20 = icmp eq i64 %21, 0
  br i1 %.not20, label %22, label %27, !prof !13

22:                                               ; preds = %19
  %23 = load ptr, ptr %4, align 8, !tbaa !14
  %24 = call i64 @_jbl_binn_from_node(ptr noundef nonnull %3, ptr noundef %23)
  %.not21 = icmp eq i64 %24, 0
  br i1 %.not21, label %25, label %27, !prof !13

25:                                               ; preds = %22
  call void @binn_free(ptr noundef nonnull %0) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 8 dereferenceable(88) %3, i64 88, i1 false)
  %26 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 0, ptr %26, align 4, !tbaa !15
  br label %27

27:                                               ; preds = %22, %19, %17, %25
  %28 = call zeroext i1 @iwpool_destroy(ptr noundef nonnull %12) #5
  br label %29

29:                                               ; preds = %27, %13
  %.0 = phi i64 [ 0, %27 ], [ %16, %13 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 88, ptr nonnull %3) #5
  br label %30

30:                                               ; preds = %2, %29
  %.1 = phi i64 [ %.0, %29 ], [ 70017, %2 ]
  ret i64 %.1
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #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, !8, i64 48}
!6 = !{!"jbl", !7, i64 0, !11, i64 88}
!7 = !{!"binn_struct", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !11, i64 16, !8, i64 24, !8, i64 28, !8, i64 32, !8, i64 36, !11, i64 40, !8, i64 48, !8, i64 52, !11, i64 56, !11, i64 64, !11, i64 72, !9, i64 80}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!8, !8, i64 0}
!13 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!14 = !{!11, !11, i64 0}
!15 = !{!6, !8, i64 4}


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