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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #1

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

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

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local void @jbn_add_item(ptr noundef, ptr noundef) #6

declare ptr @iwpool_calloc(i64 noundef, ptr noundef) #2

declare ptr @iwpool_strdup(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare noalias ptr @strdup(ptr noundef) #7

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

15:                                               ; preds = %4
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.jbl_node, ptr %16, i32 0, i32 8
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = icmp ult i32 %18, 6
  br i1 %19, label %20, label %21

20:                                               ; preds = %15, %4
  store i64 70017, ptr %5, align 8
  br label %109

21:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #8
  store i64 0, ptr %10, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #8
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  %24 = xor i1 %23, true
  %25 = xor i1 %24, true
  %26 = zext i1 %25 to i32
  %27 = sext i32 %26 to i64
  %28 = call i64 @llvm.expect.i64(i64 %27, i64 1)
  %29 = icmp ne i64 %28, 0
  br i1 %29, label %30, label %33

30:                                               ; preds = %21
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = call ptr @iwpool_calloc(i64 noundef 64, ptr noundef %31)
  store ptr %32, ptr %11, align 8, !tbaa !5
  br label %35

33:                                               ; preds = %21
  %34 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 64) #9
  store ptr %34, ptr %11, align 8, !tbaa !5
  br label %35

35:                                               ; preds = %33, %30
  %36 = load ptr, ptr %11, align 8, !tbaa !5
  %37 = icmp ne ptr %36, null
  br i1 %37, label %42, label %38

38:                                               ; preds = %35
  %39 = call ptr @__errno_location() #10
  %40 = load i32, ptr %39, align 4, !tbaa !14
  %41 = call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %40)
  store i64 %41, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %108

42:                                               ; preds = %35
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.jbl_node, ptr %43, i32 0, i32 8
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = icmp eq i32 %45, 6
  br i1 %46, label %47, label %95

47:                                               ; preds = %42
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = icmp ne ptr %48, null
  br i1 %49, label %51, label %50

50:                                               ; preds = %47
  store i64 70017, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %108

51:                                               ; preds = %47
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  %54 = xor i1 %53, true
  %55 = xor i1 %54, true
  %56 = zext i1 %55 to i32
  %57 = sext i32 %56 to i64
  %58 = call i64 @llvm.expect.i64(i64 %57, i64 1)
  %59 = icmp ne i64 %58, 0
  br i1 %59, label %60, label %76

60:                                               ; preds = %51
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = call ptr @iwpool_strdup(ptr noundef %61, ptr noundef %62, ptr noundef %10)
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.jbl_node, ptr %64, i32 0, i32 3
  store ptr %63, ptr %65, align 8, !tbaa !15
  %66 = load i64, ptr %10, align 8, !tbaa !12
  %67 = icmp ne i64 %66, 0
  %68 = xor i1 %67, true
  %69 = xor i1 %68, true
  %70 = zext i1 %69 to i32
  %71 = sext i32 %70 to i64
  %72 = call i64 @llvm.expect.i64(i64 %71, i64 0)
  %73 = icmp ne i64 %72, 0
  br i1 %73, label %74, label %75

74:                                               ; preds = %60
  br label %106

75:                                               ; preds = %60
  br label %87

76:                                               ; preds = %51
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = call noalias ptr @strdup(ptr noundef %77) #8
  %79 = load ptr, ptr %11, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.jbl_node, ptr %79, i32 0, i32 3
  store ptr %78, ptr %80, align 8, !tbaa !15
  %81 = icmp ne ptr %78, null
  br i1 %81, label %86, label %82

82:                                               ; preds = %76
  %83 = call ptr @__errno_location() #10
  %84 = load i32, ptr %83, align 4, !tbaa !14
  %85 = call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %84)
  store i64 %85, ptr %10, align 8, !tbaa !12
  br label %106

86:                                               ; preds = %76
  br label %87

87:                                               ; preds = %86, %75
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.jbl_node, ptr %88, i32 0, i32 3
  %90 = load ptr, ptr %89, align 8, !tbaa !15
  %91 = call i64 @strlen(ptr noundef %90) #11
  %92 = trunc i64 %91 to i32
  %93 = load ptr, ptr %11, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.jbl_node, ptr %93, i32 0, i32 4
  store i32 %92, ptr %94, align 8, !tbaa !16
  br label %95

95:                                               ; preds = %87, %42
  %96 = load ptr, ptr %11, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.jbl_node, ptr %96, i32 0, i32 8
  store i32 7, ptr %97, align 4, !tbaa !9
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  %99 = load ptr, ptr %11, align 8, !tbaa !5
  call void @jbn_add_item(ptr noundef %98, ptr noundef %99)
  %100 = load ptr, ptr %8, align 8, !tbaa !5
  %101 = icmp ne ptr %100, null
  br i1 %101, label %102, label %105

102:                                              ; preds = %95
  %103 = load ptr, ptr %11, align 8, !tbaa !5
  %104 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %103, ptr %104, align 8, !tbaa !5
  br label %105

105:                                              ; preds = %102, %95
  br label %106

106:                                              ; preds = %105, %82, %74
  %107 = load i64, ptr %10, align 8, !tbaa !12
  store i64 %107, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %108

108:                                              ; preds = %106, %50, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #8
  br label %109

109:                                              ; preds = %108, %20
  %110 = load i64, ptr %5, align 8
  ret i64 %110
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(0,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 = { "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 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 #6 = { 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { nounwind allocsize(0,1) }
attributes #10 = { nounwind willreturn memory(none) }
attributes #11 = { 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/C++ TBAA"}
!9 = !{!10, !11, i64 52}
!10 = !{!"jbl_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !6, i64 40, !11, i64 48, !11, i64 52, !7, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !6, i64 24}
!16 = !{!10, !11, i64 32}


; 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"

; 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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local void @jbn_add_item(ptr noundef, ptr noundef) local_unnamed_addr #5

declare ptr @iwpool_calloc(i64 noundef, ptr noundef) local_unnamed_addr #2

declare ptr @iwpool_strdup(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias ptr @strdup(ptr nocapture noundef readonly) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
define dso_local i64 @jbn_add_item_arr(ptr noundef %0, ptr noundef %1, ptr noundef writeonly %2, ptr noundef %3) local_unnamed_addr #5 {
  %5 = alloca i64, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %46, label %6

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 52
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = icmp ult i32 %8, 6
  br i1 %9, label %46, label %10

10:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  store i64 0, ptr %5, align 8, !tbaa !11
  %.not27 = icmp eq ptr %3, null
  br i1 %.not27, label %13, label %11, !prof !13

11:                                               ; preds = %10
  %12 = tail call ptr @iwpool_calloc(i64 noundef 64, ptr noundef nonnull %3) #7
  br label %15

13:                                               ; preds = %10
  %14 = tail call noalias dereferenceable_or_null(64) ptr @calloc(i64 noundef 1, i64 noundef 64) #8
  br label %15

15:                                               ; preds = %13, %11
  %.0 = phi ptr [ %12, %11 ], [ %14, %13 ]
  %.not28 = icmp eq ptr %.0, null
  br i1 %.not28, label %16, label %20

16:                                               ; preds = %15
  %17 = tail call ptr @__errno_location() #9
  %18 = load i32, ptr %17, align 4, !tbaa !14
  %19 = tail call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %18) #7
  br label %45

20:                                               ; preds = %15
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = icmp eq i32 %21, 6
  br i1 %22, label %23, label %40

23:                                               ; preds = %20
  %.not29 = icmp eq ptr %1, null
  br i1 %.not29, label %45, label %24

24:                                               ; preds = %23
  %25 = getelementptr inbounds i8, ptr %.0, i64 24
  br i1 %.not27, label %29, label %26, !prof !13

26:                                               ; preds = %24
  %27 = call ptr @iwpool_strdup(ptr noundef nonnull %3, ptr noundef nonnull %1, ptr noundef nonnull %5) #7
  store ptr %27, ptr %25, align 8, !tbaa !15
  %28 = load i64, ptr %5, align 8, !tbaa !11
  %.not31 = icmp eq i64 %28, 0
  br i1 %.not31, label %35, label %43, !prof !16

29:                                               ; preds = %24
  %30 = tail call noalias ptr @strdup(ptr noundef nonnull %1) #7
  store ptr %30, ptr %25, align 8, !tbaa !15
  %.not30 = icmp eq ptr %30, null
  br i1 %.not30, label %31, label %35

31:                                               ; preds = %29
  %32 = tail call ptr @__errno_location() #9
  %33 = load i32, ptr %32, align 4, !tbaa !14
  %34 = tail call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %33) #7
  store i64 %34, ptr %5, align 8, !tbaa !11
  br label %43

35:                                               ; preds = %29, %26
  %36 = phi ptr [ %30, %29 ], [ %27, %26 ]
  %37 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %36) #10
  %38 = trunc i64 %37 to i32
  %39 = getelementptr inbounds i8, ptr %.0, i64 32
  store i32 %38, ptr %39, align 8, !tbaa !17
  br label %40

40:                                               ; preds = %35, %20
  %41 = getelementptr inbounds i8, ptr %.0, i64 52
  store i32 7, ptr %41, align 4, !tbaa !5
  call void @jbn_add_item(ptr noundef nonnull %0, ptr noundef nonnull %.0)
  %.not32 = icmp eq ptr %2, null
  br i1 %.not32, label %43, label %42

42:                                               ; preds = %40
  store ptr %.0, ptr %2, align 8, !tbaa !18
  br label %43

43:                                               ; preds = %40, %42, %26, %31
  %44 = load i64, ptr %5, align 8, !tbaa !11
  br label %45

45:                                               ; preds = %23, %43, %16
  %.021 = phi i64 [ %44, %43 ], [ %19, %16 ], [ 70017, %23 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  br label %46

46:                                               ; preds = %4, %6, %45
  %.1 = phi i64 [ %.021, %45 ], [ 70017, %6 ], [ 70017, %4 ]
  ret i64 %.1
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { "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 = { 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 #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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 }
attributes #8 = { nounwind allocsize(0,1) }
attributes #9 = { nounwind willreturn memory(none) }
attributes #10 = { 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 52}
!6 = !{!"jbl_node", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !7, i64 40, !10, i64 48, !10, i64 52, !8, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!14 = !{!10, !10, i64 0}
!15 = !{!6, !7, i64 24}
!16 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!17 = !{!6, !10, i64 32}
!18 = !{!7, !7, i64 0}


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