; LLVM IR from jingweizhanghuai/Morn :: src/util (morn_JSON)

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

@.str = external hidden unnamed_addr constant [76 x i8], align 1
@__FUNCTION__.JSONListRead = external hidden unnamed_addr constant [13 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [12 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

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @JSONListRead(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.JSONNode, ptr %13, i32 0, i32 1
  %15 = load i8, ptr %14, align 8, !tbaa !9
  %16 = zext i8 %15 to i32
  %17 = icmp ne i32 %16, 10
  br i1 %17, label %18, label %24

18:                                               ; preds = %12
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.JSONNode, ptr %19, i32 0, i32 1
  %21 = load i8, ptr %20, align 8, !tbaa !9
  %22 = zext i8 %21 to i32
  %23 = icmp ne i32 %22, 11
  br label %24

24:                                               ; preds = %18, %12
  %25 = phi i1 [ false, %12 ], [ %23, %18 ]
  %26 = zext i1 %25 to i32
  store i32 %26, ptr %6, align 4, !tbaa !11
  %27 = load i32, ptr %6, align 4, !tbaa !11
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %24
  %30 = load i32, ptr %6, align 4, !tbaa !11
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %30, i32 noundef -1, ptr noundef @.str, i32 noundef 498, ptr noundef @__FUNCTION__.JSONListRead, ptr noundef @.str.8)
  br label %31

31:                                               ; preds = %29, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %32

32:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = call ptr @JSONSubNode(ptr noundef %33)
  store ptr %34, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %35

35:                                               ; preds = %93, %32
  %36 = load i32, ptr %8, align 4, !tbaa !11
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.JSONNode, ptr %37, i32 0, i32 0
  %39 = load i16, ptr %38, align 8, !tbaa !13
  %40 = zext i16 %39 to i32
  %41 = icmp slt i32 %36, %40
  br i1 %41, label %42, label %96

42:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.JSONNode, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !14
  %46 = getelementptr inbounds i8, ptr %45, i64 -1
  %47 = load i8, ptr %46, align 1, !tbaa !13
  %48 = sext i8 %47 to i32
  store i32 %48, ptr %9, align 4, !tbaa !11
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.JSONNode, ptr %50, i32 0, i32 2
  %52 = load ptr, ptr %51, align 8, !tbaa !14
  %53 = load i32, ptr %9, align 4, !tbaa !11
  %54 = sext i32 %53 to i64
  %55 = call i32 @memcmp(ptr noundef %49, ptr noundef %52, i64 noundef %54) #6
  %56 = icmp eq i32 %55, 0
  br i1 %56, label %57, label %87

57:                                               ; preds = %42
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = load i32, ptr %9, align 4, !tbaa !11
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds i8, ptr %58, i64 %60
  %62 = load i8, ptr %61, align 1, !tbaa !13
  %63 = sext i8 %62 to i32
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %81, label %65

65:                                               ; preds = %57
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = load i32, ptr %9, align 4, !tbaa !11
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds i8, ptr %66, i64 %68
  %70 = load i8, ptr %69, align 1, !tbaa !13
  %71 = sext i8 %70 to i32
  %72 = icmp eq i32 %71, 91
  br i1 %72, label %81, label %73

73:                                               ; preds = %65
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = load i32, ptr %9, align 4, !tbaa !11
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds i8, ptr %74, i64 %76
  %78 = load i8, ptr %77, align 1, !tbaa !13
  %79 = sext i8 %78 to i32
  %80 = icmp eq i32 %79, 46
  br i1 %80, label %81, label %86

81:                                               ; preds = %73, %65, %57
  %82 = load i32, ptr %9, align 4, !tbaa !11
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = sext i32 %82 to i64
  %85 = getelementptr inbounds i8, ptr %83, i64 %84
  store ptr %85, ptr %5, align 8, !tbaa !5
  store i32 4, ptr %10, align 4
  br label %90

86:                                               ; preds = %73
  br label %87

87:                                               ; preds = %86, %42
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.JSONNode, ptr %88, i32 1
  store ptr %89, ptr %7, align 8, !tbaa !5
  store i32 0, ptr %10, align 4
  br label %90

90:                                               ; preds = %87, %81
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  %91 = load i32, ptr %10, align 4
  switch i32 %91, label %144 [
    i32 0, label %92
    i32 4, label %96
  ]

92:                                               ; preds = %90
  br label %93

93:                                               ; preds = %92
  %94 = load i32, ptr %8, align 4, !tbaa !11
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %8, align 4, !tbaa !11
  br label %35, !llvm.loop !15

96:                                               ; preds = %90, %35
  %97 = load i32, ptr %8, align 4, !tbaa !11
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.JSONNode, ptr %98, i32 0, i32 0
  %100 = load i16, ptr %99, align 8, !tbaa !13
  %101 = zext i16 %100 to i32
  %102 = icmp eq i32 %97, %101
  br i1 %102, label %103, label %104

103:                                              ; preds = %96
  store ptr null, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %142

104:                                              ; preds = %96
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = getelementptr inbounds i8, ptr %105, i64 0
  %107 = load i8, ptr %106, align 1, !tbaa !13
  %108 = sext i8 %107 to i32
  %109 = icmp eq i32 %108, 0
  br i1 %109, label %110, label %112

110:                                              ; preds = %104
  %111 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %111, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %142

112:                                              ; preds = %104
  %113 = load ptr, ptr %5, align 8, !tbaa !5
  %114 = getelementptr inbounds i8, ptr %113, i64 0
  %115 = load i8, ptr %114, align 1, !tbaa !13
  %116 = sext i8 %115 to i32
  %117 = icmp eq i32 %116, 46
  br i1 %117, label %118, label %123

118:                                              ; preds = %112
  %119 = load ptr, ptr %7, align 8, !tbaa !5
  %120 = load ptr, ptr %5, align 8, !tbaa !5
  %121 = getelementptr inbounds i8, ptr %120, i64 1
  %122 = call ptr @JSONListRead(ptr noundef %119, ptr noundef %121)
  store ptr %122, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %142

123:                                              ; preds = %112
  %124 = load ptr, ptr %5, align 8, !tbaa !5
  %125 = getelementptr inbounds i8, ptr %124, i64 0
  %126 = load i8, ptr %125, align 1, !tbaa !13
  %127 = sext i8 %126 to i32
  %128 = icmp eq i32 %127, 91
  br i1 %128, label %129, label %133

129:                                              ; preds = %123
  %130 = load ptr, ptr %7, align 8, !tbaa !5
  %131 = load ptr, ptr %5, align 8, !tbaa !5
  %132 = call ptr @JSONArrayRead(ptr noundef %130, ptr noundef %131)
  store ptr %132, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %142

133:                                              ; preds = %123
  br label %134

134:                                              ; preds = %133
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 1, ptr %11, align 4, !tbaa !11
  %135 = load i32, ptr %11, align 4, !tbaa !11
  %136 = icmp ne i32 %135, 0
  br i1 %136, label %137, label %139

137:                                              ; preds = %134
  %138 = load i32, ptr %11, align 4, !tbaa !11
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %138, i32 noundef -1, ptr noundef @.str, i32 noundef 512, ptr noundef @__FUNCTION__.JSONListRead, ptr noundef @.str.8)
  br label %139

139:                                              ; preds = %137, %134
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %140

140:                                              ; preds = %139
  br label %141

141:                                              ; preds = %140
  store ptr null, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %142

142:                                              ; preds = %141, %129, %118, %110, %103
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  %143 = load ptr, ptr %3, align 8
  ret ptr %143

144:                                              ; preds = %90
  unreachable
}

; Function Attrs: inlinehint nounwind uwtable
declare ptr @JSONSubNode(ptr noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #4

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

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 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 = { inlinehint 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 = { 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 #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, !7, i64 8}
!10 = !{!"JSONNode", !7, i64 0, !7, i64 8, !6, i64 16}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!10, !6, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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

@.str = external hidden unnamed_addr constant [76 x i8], align 1
@__FUNCTION__.JSONListRead = external hidden unnamed_addr constant [13 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [12 x i8], align 1

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @JSONListRead(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  br label %tailrecurse

tailrecurse:                                      ; preds = %27, %2
  %.tr = phi ptr [ %0, %2 ], [ %.037.lcssa, %27 ]
  %.tr49 = phi ptr [ %1, %2 ], [ %28, %27 ]
  %3 = getelementptr inbounds i8, ptr %.tr, i64 8
  %4 = load i8, ptr %3, align 8, !tbaa !5
  %5 = add i8 %4, -12
  %spec.select = icmp ult i8 %5, -2
  br i1 %spec.select, label %6, label %7

6:                                                ; preds = %tailrecurse
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 498, ptr noundef nonnull @__FUNCTION__.JSONListRead, ptr noundef nonnull @.str.8) #4
  br label %7

7:                                                ; preds = %6, %tailrecurse
  %8 = tail call ptr @JSONSubNode(ptr noundef nonnull %.tr)
  %9 = load i16, ptr %.tr, align 8, !tbaa !10
  %10 = zext i16 %9 to i32
  %.not = icmp eq i16 %9, 0
  br i1 %.not, label %.split.loop.exit54, label %.lr.ph

.lr.ph:                                           ; preds = %7, %20
  %.03661 = phi i32 [ %22, %20 ], [ 0, %7 ]
  %.03760 = phi ptr [ %21, %20 ], [ %8, %7 ]
  %11 = getelementptr inbounds i8, ptr %.03760, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %12, i64 -1
  %14 = load i8, ptr %13, align 1, !tbaa !10
  %15 = sext i8 %14 to i64
  %bcmp = tail call i32 @bcmp(ptr %.tr49, ptr %12, i64 %15)
  %16 = icmp eq i32 %bcmp, 0
  br i1 %16, label %17, label %20

17:                                               ; preds = %.lr.ph
  %18 = getelementptr inbounds i8, ptr %.tr49, i64 %15
  %19 = load i8, ptr %18, align 1, !tbaa !10
  switch i8 %19, label %20 [
    i8 0, label %.split.loop.exit54.loopexit
    i8 91, label %.split.loop.exit54.loopexit
    i8 46, label %.split.loop.exit54.loopexit
  ]

20:                                               ; preds = %.lr.ph, %17
  %21 = getelementptr inbounds i8, ptr %.03760, i64 24
  %22 = add nuw nsw i32 %.03661, 1
  %exitcond.not = icmp eq i32 %22, %10
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !12

.split.loop.exit54.loopexit:                      ; preds = %17, %17, %17
  %23 = getelementptr inbounds i8, ptr %.tr49, i64 %15
  br label %.split.loop.exit54

.split.loop.exit54:                               ; preds = %.split.loop.exit54.loopexit, %7
  %.037.lcssa = phi ptr [ %8, %7 ], [ %.03760, %.split.loop.exit54.loopexit ]
  %.036.lcssa = phi i32 [ 0, %7 ], [ %.03661, %.split.loop.exit54.loopexit ]
  %.2 = phi ptr [ %.tr49, %7 ], [ %23, %.split.loop.exit54.loopexit ]
  %24 = icmp eq i32 %.036.lcssa, %10
  br i1 %24, label %.loopexit, label %25

25:                                               ; preds = %.split.loop.exit54
  %26 = load i8, ptr %.2, align 1, !tbaa !10
  switch i8 %26, label %31 [
    i8 0, label %.loopexit
    i8 46, label %27
    i8 91, label %29
  ]

27:                                               ; preds = %25
  %28 = getelementptr inbounds i8, ptr %.2, i64 1
  br label %tailrecurse

29:                                               ; preds = %25
  %30 = tail call ptr @JSONArrayRead(ptr noundef %.037.lcssa, ptr noundef nonnull %.2)
  br label %.loopexit

31:                                               ; preds = %25
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 512, ptr noundef nonnull @__FUNCTION__.JSONListRead, ptr noundef nonnull @.str.8) #4
  br label %.loopexit

.loopexit:                                        ; preds = %25, %.split.loop.exit54, %20, %31, %29
  %.0 = phi ptr [ %30, %29 ], [ null, %31 ], [ null, %20 ], [ %.037.lcssa, %25 ], [ null, %.split.loop.exit54 ]
  ret ptr %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare ptr @JSONSubNode(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @JSONArrayRead(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #3

attributes #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 #1 = { 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 #2 = { inlinehint 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 = { nofree nounwind willreturn memory(argmem: read) }
attributes #4 = { nounwind }

!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, !7, i64 8}
!6 = !{!"JSONNode", !7, i64 0, !7, i64 8, !9, i64 16}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"any pointer", !7, i64 0}
!10 = !{!7, !7, i64 0}
!11 = !{!6, !9, i64 16}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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