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

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

16:                                               ; preds = %4
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %16, %4
  store i64 70017, ptr %5, align 8
  br label %88

20:                                               ; preds = %16
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr null, ptr %21, align 8, !tbaa !5
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.jbl_node, ptr %22, i32 0, i32 8
  %24 = load i32, ptr %23, align 4, !tbaa !11
  switch i32 %24, label %86 [
    i32 6, label %25
    i32 7, label %60
  ]

25:                                               ; preds = %20
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %59

28:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.jbl_node, ptr %29, i32 0, i32 6
  %31 = load ptr, ptr %30, align 8, !tbaa !13
  store ptr %31, ptr %10, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %52, %28
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %36, label %35

35:                                               ; preds = %32
  store i32 3, ptr %11, align 4
  br label %56

36:                                               ; preds = %32
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.jbl_node, ptr %37, i32 0, i32 3
  %39 = load ptr, ptr %38, align 8, !tbaa !14
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %51

41:                                               ; preds = %36
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.jbl_node, ptr %42, i32 0, i32 3
  %44 = load ptr, ptr %43, align 8, !tbaa !14
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = call i32 @strcmp(ptr noundef %44, ptr noundef %45) #4
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %51

48:                                               ; preds = %41
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %49, ptr %50, align 8, !tbaa !5
  store i64 0, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %56

51:                                               ; preds = %41, %36
  br label %52

52:                                               ; preds = %51
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.jbl_node, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !15
  store ptr %55, ptr %10, align 8, !tbaa !5
  br label %32, !llvm.loop !16

56:                                               ; preds = %48, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %57 = load i32, ptr %11, align 4
  switch i32 %57, label %90 [
    i32 3, label %58
    i32 1, label %88
  ]

58:                                               ; preds = %56
  br label %59

59:                                               ; preds = %58, %25
  br label %87

60:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.jbl_node, ptr %61, i32 0, i32 6
  %63 = load ptr, ptr %62, align 8, !tbaa !13
  store ptr %63, ptr %13, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %77, %60
  %65 = load ptr, ptr %13, align 8, !tbaa !5
  %66 = icmp ne ptr %65, null
  br i1 %66, label %68, label %67

67:                                               ; preds = %64
  store i32 6, ptr %11, align 4
  br label %81

68:                                               ; preds = %64
  %69 = load i32, ptr %8, align 4, !tbaa !9
  %70 = load i32, ptr %12, align 4, !tbaa !9
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %12, align 4, !tbaa !9
  %72 = icmp eq i32 %69, %70
  br i1 %72, label %73, label %76

73:                                               ; preds = %68
  %74 = load ptr, ptr %13, align 8, !tbaa !5
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %74, ptr %75, align 8, !tbaa !5
  store i64 0, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %81

76:                                               ; preds = %68
  br label %77

77:                                               ; preds = %76
  %78 = load ptr, ptr %13, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.jbl_node, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !15
  store ptr %80, ptr %13, align 8, !tbaa !5
  br label %64, !llvm.loop !18

81:                                               ; preds = %73, %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  %82 = load i32, ptr %11, align 4
  switch i32 %82, label %84 [
    i32 6, label %83
  ]

83:                                               ; preds = %81
  store i32 2, ptr %11, align 4
  br label %84

84:                                               ; preds = %83, %81
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %85 = load i32, ptr %11, align 4
  switch i32 %85, label %90 [
    i32 1, label %88
    i32 2, label %87
  ]

86:                                               ; preds = %20
  br label %87

87:                                               ; preds = %86, %84, %59
  store i64 76009, ptr %5, align 8
  br label %88

88:                                               ; preds = %87, %84, %56, %19
  %89 = load i64, ptr %5, align 8
  ret i64 %89

90:                                               ; preds = %84, %56
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { nounwind }
attributes #4 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 52}
!12 = !{!"jbl_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !6, i64 40, !10, i64 48, !10, i64 52, !7, i64 56}
!13 = !{!12, !6, i64 40}
!14 = !{!12, !6, i64 24}
!15 = !{!12, !6, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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

; Function Attrs: nofree nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local range(i64 0, 76010) i64 @jbn_get(ptr nocapture noundef readonly %0, ptr noundef readonly %1, i32 noundef %2, ptr noundef writeonly %3) local_unnamed_addr #1 {
  %5 = icmp ne ptr %1, null
  %6 = icmp ne ptr %3, null
  %or.cond = and i1 %5, %6
  br i1 %or.cond, label %7, label %.thread

7:                                                ; preds = %4
  store ptr null, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 52
  %9 = load i32, ptr %8, align 4, !tbaa !9
  switch i32 %9, label %.thread [
    i32 6, label %10
    i32 7, label %18
  ]

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %.02650 = load ptr, ptr %11, align 8, !tbaa !5
  %.not3251 = icmp eq ptr %.02650, null
  br i1 %.not3251, label %.thread, label %.lr.ph53

.lr.ph53:                                         ; preds = %10, %17
  %.02652 = phi ptr [ %.026, %17 ], [ %.02650, %10 ]
  %12 = getelementptr inbounds i8, ptr %.02652, i64 24
  %13 = load ptr, ptr %12, align 8, !tbaa !12
  %.not33 = icmp eq ptr %13, null
  br i1 %.not33, label %17, label %14

14:                                               ; preds = %.lr.ph53
  %15 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %13, ptr noundef nonnull dereferenceable(1) %1) #2
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %.thread.sink.split, label %17

17:                                               ; preds = %.lr.ph53, %14
  %.026 = load ptr, ptr %.02652, align 8, !tbaa !5
  %.not32 = icmp eq ptr %.026, null
  br i1 %.not32, label %.thread, label %.lr.ph53, !llvm.loop !13

18:                                               ; preds = %7
  %19 = getelementptr inbounds i8, ptr %0, i64 40
  %.046 = load ptr, ptr %19, align 8, !tbaa !5
  %.not47 = icmp eq ptr %.046, null
  br i1 %.not47, label %.thread, label %.lr.ph

20:                                               ; preds = %.lr.ph
  %21 = add nuw nsw i32 %.02448, 1
  %.0 = load ptr, ptr %.049, align 8, !tbaa !5
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %.thread, label %.lr.ph, !llvm.loop !15

.lr.ph:                                           ; preds = %18, %20
  %.049 = phi ptr [ %.0, %20 ], [ %.046, %18 ]
  %.02448 = phi i32 [ %21, %20 ], [ 0, %18 ]
  %22 = icmp eq i32 %.02448, %2
  br i1 %22, label %.thread.sink.split, label %20

.thread.sink.split:                               ; preds = %.lr.ph, %14
  %.049.lcssa.sink = phi ptr [ %.02652, %14 ], [ %.049, %.lr.ph ]
  store ptr %.049.lcssa.sink, ptr %3, align 8, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %20, %17, %.thread.sink.split, %18, %10, %7, %4
  %.2 = phi i64 [ 70017, %4 ], [ 76009, %7 ], [ 76009, %10 ], [ 76009, %18 ], [ 0, %.thread.sink.split ], [ 76009, %17 ], [ 76009, %20 ]
  ret i64 %.2
}

attributes #0 = { 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 #1 = { nofree nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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 #2 = { 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 = !{!10, !6, i64 24}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass