; 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_bool(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2, ptr noundef %3, ptr noundef %4) #6 {
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  %15 = zext i1 %2 to i8
  store i8 %15, ptr %9, align 1, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %23

18:                                               ; preds = %5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.jbl_node, ptr %19, i32 0, i32 8
  %21 = load i32, ptr %20, align 4, !tbaa !11
  %22 = icmp ult i32 %21, 6
  br i1 %22, label %23, label %24

23:                                               ; preds = %18, %5
  store i64 70017, ptr %6, align 8
  br label %117

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

33:                                               ; preds = %24
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  %35 = call ptr @iwpool_calloc(i64 noundef 64, ptr noundef %34)
  store ptr %35, ptr %13, align 8, !tbaa !5
  br label %38

36:                                               ; preds = %24
  %37 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 64) #9
  store ptr %37, ptr %13, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %36, %33
  %39 = load ptr, ptr %13, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %45, label %41

41:                                               ; preds = %38
  %42 = call ptr @__errno_location() #10
  %43 = load i32, ptr %42, align 4, !tbaa !16
  %44 = call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %43)
  store i64 %44, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %116

45:                                               ; preds = %38
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.jbl_node, ptr %46, i32 0, i32 8
  %48 = load i32, ptr %47, align 4, !tbaa !11
  %49 = icmp eq i32 %48, 6
  br i1 %49, label %50, label %98

50:                                               ; preds = %45
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = icmp ne ptr %51, null
  br i1 %52, label %54, label %53

53:                                               ; preds = %50
  store i64 70017, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %116

54:                                               ; preds = %50
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = icmp ne ptr %55, null
  %57 = xor i1 %56, true
  %58 = xor i1 %57, true
  %59 = zext i1 %58 to i32
  %60 = sext i32 %59 to i64
  %61 = call i64 @llvm.expect.i64(i64 %60, i64 1)
  %62 = icmp ne i64 %61, 0
  br i1 %62, label %63, label %79

63:                                               ; preds = %54
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = call ptr @iwpool_strdup(ptr noundef %64, ptr noundef %65, ptr noundef %12)
  %67 = load ptr, ptr %13, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.jbl_node, ptr %67, i32 0, i32 3
  store ptr %66, ptr %68, align 8, !tbaa !17
  %69 = load i64, ptr %12, align 8, !tbaa !14
  %70 = icmp ne i64 %69, 0
  %71 = xor i1 %70, true
  %72 = xor i1 %71, true
  %73 = zext i1 %72 to i32
  %74 = sext i32 %73 to i64
  %75 = call i64 @llvm.expect.i64(i64 %74, i64 0)
  %76 = icmp ne i64 %75, 0
  br i1 %76, label %77, label %78

77:                                               ; preds = %63
  br label %114

78:                                               ; preds = %63
  br label %90

79:                                               ; preds = %54
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = call noalias ptr @strdup(ptr noundef %80) #8
  %82 = load ptr, ptr %13, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.jbl_node, ptr %82, i32 0, i32 3
  store ptr %81, ptr %83, align 8, !tbaa !17
  %84 = icmp ne ptr %81, null
  br i1 %84, label %89, label %85

85:                                               ; preds = %79
  %86 = call ptr @__errno_location() #10
  %87 = load i32, ptr %86, align 4, !tbaa !16
  %88 = call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %87)
  store i64 %88, ptr %12, align 8, !tbaa !14
  br label %114

89:                                               ; preds = %79
  br label %90

90:                                               ; preds = %89, %78
  %91 = load ptr, ptr %13, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.jbl_node, ptr %91, i32 0, i32 3
  %93 = load ptr, ptr %92, align 8, !tbaa !17
  %94 = call i64 @strlen(ptr noundef %93) #11
  %95 = trunc i64 %94 to i32
  %96 = load ptr, ptr %13, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.jbl_node, ptr %96, i32 0, i32 4
  store i32 %95, ptr %97, align 8, !tbaa !18
  br label %98

98:                                               ; preds = %90, %45
  %99 = load ptr, ptr %13, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.jbl_node, ptr %99, i32 0, i32 8
  store i32 2, ptr %100, align 4, !tbaa !11
  %101 = load i8, ptr %9, align 1, !tbaa !9, !range !19, !noundef !20
  %102 = trunc i8 %101 to i1
  %103 = load ptr, ptr %13, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.jbl_node, ptr %103, i32 0, i32 9
  %105 = zext i1 %102 to i8
  store i8 %105, ptr %104, align 8, !tbaa !21
  %106 = load ptr, ptr %7, align 8, !tbaa !5
  %107 = load ptr, ptr %13, align 8, !tbaa !5
  call void @jbn_add_item(ptr noundef %106, ptr noundef %107)
  %108 = load ptr, ptr %10, align 8, !tbaa !5
  %109 = icmp ne ptr %108, null
  br i1 %109, label %110, label %113

110:                                              ; preds = %98
  %111 = load ptr, ptr %13, align 8, !tbaa !5
  %112 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %111, ptr %112, align 8, !tbaa !5
  br label %113

113:                                              ; preds = %110, %98
  br label %114

114:                                              ; preds = %113, %85, %77
  %115 = load i64, ptr %12, align 8, !tbaa !14
  store i64 %115, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %116

116:                                              ; preds = %114, %53, %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #8
  br label %117

117:                                              ; preds = %116, %23
  %118 = load i64, ptr %6, align 8
  ret i64 %118
}

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, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !13, i64 52}
!12 = !{!"jbl_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !13, i64 36, !6, i64 40, !13, i64 48, !13, i64 52, !7, i64 56}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!13, !13, i64 0}
!17 = !{!12, !6, i64 24}
!18 = !{!12, !13, i64 32}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!7, !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"

; 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_bool(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2, ptr noundef writeonly %3, ptr noundef %4) local_unnamed_addr #5 {
  %6 = alloca i64, align 8
  %7 = zext i1 %2 to i8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %49, label %8

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

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

13:                                               ; preds = %12
  %14 = tail call ptr @iwpool_calloc(i64 noundef 64, ptr noundef nonnull %4) #7
  br label %17

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

17:                                               ; preds = %15, %13
  %.0 = phi ptr [ %14, %13 ], [ %16, %15 ]
  %.not30 = icmp eq ptr %.0, null
  br i1 %.not30, label %18, label %22

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

22:                                               ; preds = %17
  %23 = load i32, ptr %9, align 4, !tbaa !5
  %24 = icmp eq i32 %23, 6
  br i1 %24, label %25, label %42

25:                                               ; preds = %22
  %.not31 = icmp eq ptr %1, null
  br i1 %.not31, label %48, label %26

26:                                               ; preds = %25
  %27 = getelementptr inbounds i8, ptr %.0, i64 24
  br i1 %.not29, label %31, label %28, !prof !13

28:                                               ; preds = %26
  %29 = call ptr @iwpool_strdup(ptr noundef nonnull %4, ptr noundef nonnull %1, ptr noundef nonnull %6) #7
  store ptr %29, ptr %27, align 8, !tbaa !15
  %30 = load i64, ptr %6, align 8, !tbaa !11
  %.not33 = icmp eq i64 %30, 0
  br i1 %.not33, label %37, label %46, !prof !16

31:                                               ; preds = %26
  %32 = tail call noalias ptr @strdup(ptr noundef nonnull %1) #7
  store ptr %32, ptr %27, align 8, !tbaa !15
  %.not32 = icmp eq ptr %32, null
  br i1 %.not32, label %33, label %37

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

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

42:                                               ; preds = %37, %22
  %43 = getelementptr inbounds i8, ptr %.0, i64 52
  store i32 2, ptr %43, align 4, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %.0, i64 56
  store i8 %7, ptr %44, align 8, !tbaa !18
  call void @jbn_add_item(ptr noundef nonnull %0, ptr noundef nonnull %.0)
  %.not34 = icmp eq ptr %3, null
  br i1 %.not34, label %46, label %45

45:                                               ; preds = %42
  store ptr %.0, ptr %3, align 8, !tbaa !19
  br label %46

46:                                               ; preds = %42, %45, %28, %33
  %47 = load i64, ptr %6, align 8, !tbaa !11
  br label %48

48:                                               ; preds = %25, %46, %18
  %.023 = phi i64 [ %47, %46 ], [ %21, %18 ], [ 70017, %25 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  br label %49

49:                                               ; preds = %5, %8, %48
  %.1 = phi i64 [ %.023, %48 ], [ 70017, %8 ], [ 70017, %5 ]
  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 = !{!8, !8, i64 0}
!19 = !{!7, !7, i64 0}


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