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

@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1

; 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: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #1

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i64 @jbn_copy_path(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i1 noundef zeroext %4, i1 noundef zeroext %5, ptr noundef %6) #3 {
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i8, align 1
  %14 = alloca i8, align 1
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca [1 x %struct.jbl_patch], align 16
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  %22 = zext i1 %4 to i8
  store i8 %22, ptr %13, align 1, !tbaa !9
  %23 = zext i1 %5 to i8
  store i8 %23, ptr %14, align 1, !tbaa !9
  store ptr %6, ptr %15, align 8, !tbaa !5
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %38

26:                                               ; preds = %7
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %38

29:                                               ; preds = %26
  %30 = load ptr, ptr %11, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %38

32:                                               ; preds = %29
  %33 = load ptr, ptr %12, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %38

35:                                               ; preds = %32
  %36 = load ptr, ptr %15, align 8, !tbaa !5
  %37 = icmp ne ptr %36, null
  br i1 %37, label %39, label %38

38:                                               ; preds = %35, %32, %29, %26, %7
  store i64 70017, ptr %8, align 8
  br label %114

39:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  store i64 0, ptr %16, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  store i32 3, ptr %19, align 4, !tbaa !13
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = call i32 @strcmp(ptr noundef @.str.9, ptr noundef %40) #6
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %62

43:                                               ; preds = %39
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = call i64 @jbn_at(ptr noundef %44, ptr noundef %45, ptr noundef %17)
  store i64 %46, ptr %16, align 8, !tbaa !11
  %47 = load i64, ptr %16, align 8, !tbaa !11
  %48 = icmp eq i64 %47, 76009
  br i1 %48, label %49, label %50

49:                                               ; preds = %43
  store i64 0, ptr %8, align 8
  store i32 1, ptr %20, align 4
  br label %113

50:                                               ; preds = %43
  %51 = load i64, ptr %16, align 8, !tbaa !11
  %52 = icmp ne i64 %51, 0
  %53 = xor i1 %52, true
  %54 = xor i1 %53, true
  %55 = zext i1 %54 to i32
  %56 = sext i32 %55 to i64
  %57 = call i64 @llvm.expect.i64(i64 %56, i64 0)
  %58 = icmp ne i64 %57, 0
  br i1 %58, label %59, label %61

59:                                               ; preds = %50
  %60 = load i64, ptr %16, align 8, !tbaa !11
  store i64 %60, ptr %8, align 8
  store i32 1, ptr %20, align 4
  br label %113

61:                                               ; preds = %50
  br label %64

62:                                               ; preds = %39
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %63, ptr %17, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %62, %61
  %65 = load i8, ptr %13, align 1, !tbaa !9, !range !15, !noundef !16
  %66 = trunc i8 %65 to i1
  br i1 %66, label %73, label %67

67:                                               ; preds = %64
  %68 = load ptr, ptr %17, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.jbl_node, ptr %68, i32 0, i32 8
  %70 = load i32, ptr %69, align 4, !tbaa !17
  %71 = icmp ule i32 %70, 1
  br i1 %71, label %72, label %73

72:                                               ; preds = %67
  store i64 0, ptr %8, align 8
  store i32 1, ptr %20, align 4
  br label %113

73:                                               ; preds = %67, %64
  %74 = load i8, ptr %14, align 1, !tbaa !9, !range !15, !noundef !16
  %75 = trunc i8 %74 to i1
  br i1 %75, label %76, label %78

76:                                               ; preds = %73
  %77 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %77, ptr %18, align 8, !tbaa !5
  br label %93

78:                                               ; preds = %73
  %79 = load ptr, ptr %17, align 8, !tbaa !5
  %80 = load ptr, ptr %15, align 8, !tbaa !5
  %81 = call i64 @jbn_clone(ptr noundef %79, ptr noundef %18, ptr noundef %80)
  store i64 %81, ptr %16, align 8, !tbaa !11
  %82 = load i64, ptr %16, align 8, !tbaa !11
  %83 = icmp ne i64 %82, 0
  %84 = xor i1 %83, true
  %85 = xor i1 %84, true
  %86 = zext i1 %85 to i32
  %87 = sext i32 %86 to i64
  %88 = call i64 @llvm.expect.i64(i64 %87, i64 0)
  %89 = icmp ne i64 %88, 0
  br i1 %89, label %90, label %92

90:                                               ; preds = %78
  %91 = load i64, ptr %16, align 8, !tbaa !11
  store i64 %91, ptr %8, align 8
  store i32 1, ptr %20, align 4
  br label %113

92:                                               ; preds = %78
  br label %93

93:                                               ; preds = %92, %76
  %94 = load ptr, ptr %11, align 8, !tbaa !5
  %95 = load ptr, ptr %12, align 8, !tbaa !5
  %96 = call i64 @jbn_at(ptr noundef %94, ptr noundef %95, ptr noundef %17)
  store i64 %96, ptr %16, align 8, !tbaa !11
  %97 = load i64, ptr %16, align 8, !tbaa !11
  %98 = icmp eq i64 %97, 76009
  br i1 %98, label %99, label %100

99:                                               ; preds = %93
  store i64 0, ptr %16, align 8, !tbaa !11
  store i32 8, ptr %19, align 4, !tbaa !13
  br label %100

100:                                              ; preds = %99, %93
  call void @llvm.lifetime.start.p0(i64 40, ptr %21) #5
  %101 = getelementptr inbounds %struct.jbl_patch, ptr %21, i32 0, i32 0
  %102 = load i32, ptr %19, align 4, !tbaa !13
  store i32 %102, ptr %101, align 8, !tbaa !19
  %103 = getelementptr inbounds %struct.jbl_patch, ptr %21, i32 0, i32 1
  %104 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %104, ptr %103, align 8, !tbaa !21
  %105 = getelementptr inbounds %struct.jbl_patch, ptr %21, i32 0, i32 2
  store ptr null, ptr %105, align 8, !tbaa !22
  %106 = getelementptr inbounds %struct.jbl_patch, ptr %21, i32 0, i32 3
  store ptr null, ptr %106, align 8, !tbaa !23
  %107 = getelementptr inbounds %struct.jbl_patch, ptr %21, i32 0, i32 4
  %108 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr %108, ptr %107, align 8, !tbaa !24
  %109 = load ptr, ptr %11, align 8, !tbaa !5
  %110 = getelementptr inbounds [1 x %struct.jbl_patch], ptr %21, i64 0, i64 0
  %111 = load ptr, ptr %15, align 8, !tbaa !5
  %112 = call i64 @jbn_patch(ptr noundef %109, ptr noundef %110, i64 noundef 1, ptr noundef %111)
  store i64 %112, ptr %8, align 8
  store i32 1, ptr %20, align 4
  call void @llvm.lifetime.end.p0(i64 40, ptr %21) #5
  br label %113

113:                                              ; preds = %100, %90, %72, %59, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  br label %114

114:                                              ; preds = %113, %38
  %115 = load i64, ptr %8, align 8
  ret i64 %115
}

declare i64 @jbn_clone(ptr noundef, ptr noundef, ptr noundef) #4

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #2 = { 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 #3 = { 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 #4 = { "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(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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !14, i64 52}
!18 = !{!"jbl_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !14, i64 32, !14, i64 36, !6, i64 40, !14, i64 48, !14, i64 52, !7, i64 56}
!19 = !{!20, !14, i64 0}
!20 = !{!"jbl_patch", !14, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!21 = !{!20, !6, i64 8}
!22 = !{!20, !6, i64 16}
!23 = !{!20, !6, i64 24}
!24 = !{!20, !6, 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"

%struct.jbl_patch = type { i32, ptr, ptr, ptr, ptr }

@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1

; 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 memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local i64 @jbn_copy_path(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i1 noundef zeroext %4, i1 noundef zeroext %5, ptr noundef %6) local_unnamed_addr #2 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca [1 x %struct.jbl_patch], align 16
  %11 = insertelement <4 x ptr> poison, ptr %0, i64 0
  %12 = insertelement <4 x ptr> %11, ptr %1, i64 1
  %13 = insertelement <4 x ptr> %12, ptr %2, i64 2
  %14 = insertelement <4 x ptr> %13, ptr %3, i64 3
  %15 = icmp ne ptr %6, null
  %16 = icmp eq <4 x ptr> %14, zeroinitializer
  %17 = bitcast <4 x i1> %16 to i4
  %18 = icmp eq i4 %17, 0
  %op.rdx = and i1 %18, %15
  br i1 %op.rdx, label %19, label %45

19:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #5
  %20 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef nonnull dereferenceable(1) %1) #6
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %24, label %21

21:                                               ; preds = %19
  %22 = call i64 @jbn_at(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %8)
  switch i64 %22, label %23 [
    i64 76009, label %44
    i64 0, label %25
  ], !prof !5

23:                                               ; preds = %21
  br label %44

24:                                               ; preds = %19
  store ptr %0, ptr %8, align 8, !tbaa !6
  br label %25

25:                                               ; preds = %21, %24
  br i1 %4, label %31, label %26

26:                                               ; preds = %25
  %27 = load ptr, ptr %8, align 8, !tbaa !6
  %28 = getelementptr inbounds i8, ptr %27, i64 52
  %29 = load i32, ptr %28, align 4, !tbaa !10
  %30 = icmp ult i32 %29, 2
  br i1 %30, label %44, label %31

31:                                               ; preds = %26, %25
  %32 = load ptr, ptr %8, align 8, !tbaa !6
  br i1 %5, label %33, label %34

33:                                               ; preds = %31
  store ptr %32, ptr %9, align 8, !tbaa !6
  br label %36

34:                                               ; preds = %31
  %35 = call i64 @jbn_clone(ptr noundef %32, ptr noundef nonnull %9, ptr noundef nonnull %6) #5
  %.not39 = icmp eq i64 %35, 0
  br i1 %.not39, label %36, label %44, !prof !13

36:                                               ; preds = %34, %33
  %37 = call i64 @jbn_at(ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %8)
  %38 = icmp eq i64 %37, 76009
  %spec.select = select i1 %38, i32 8, i32 3
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %10) #5
  store i32 %spec.select, ptr %10, align 16, !tbaa !14
  %39 = getelementptr inbounds i8, ptr %10, i64 8
  store ptr %3, ptr %39, align 8, !tbaa !16
  %40 = getelementptr inbounds i8, ptr %10, i64 16
  %41 = getelementptr inbounds i8, ptr %10, i64 32
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %40, i8 0, i64 16, i1 false)
  %42 = load ptr, ptr %9, align 8, !tbaa !6
  store ptr %42, ptr %41, align 16, !tbaa !17
  %43 = call i64 @jbn_patch(ptr noundef nonnull %2, ptr noundef nonnull %10, i64 noundef 1, ptr noundef nonnull %6)
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %10) #5
  br label %44

44:                                               ; preds = %34, %26, %21, %36, %23
  %.031 = phi i64 [ %22, %23 ], [ %43, %36 ], [ 0, %21 ], [ 0, %26 ], [ %35, %34 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  br label %45

45:                                               ; preds = %7, %44
  %.1 = phi i64 [ %.031, %44 ], [ 70017, %7 ]
  ret i64 %.1
}

declare i64 @jbn_clone(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LowerExpectIntrinsicPass,MemCpyOptPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass