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

%union.JsonData = type { double }
%struct.JSONNode = type { %union.anon.0, i8, ptr }
%union.anon.0 = type { double }
%struct.ArrayNode = type <{ %union.JsonData, i8, i32, [3 x i8] }>

@.str = external hidden unnamed_addr constant [76 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [12 x i8], align 1
@__FUNCTION__.JSONArrayRead2 = external hidden unnamed_addr constant [15 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: nounwind uwtable
declare dso_local ptr @StringNumber(ptr noundef, ptr noundef, ptr noundef) #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @JSONArrayRead2(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %union.JsonData, align 8
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %16, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %18, ptr %7, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.JSONNode, ptr %20, i32 0, i32 1
  %22 = load i8, ptr %21, align 8, !tbaa !9
  %23 = zext i8 %22 to i32
  %24 = icmp ne i32 %23, 12
  br i1 %24, label %25, label %31

25:                                               ; preds = %19
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.JSONNode, ptr %26, i32 0, i32 1
  %28 = load i8, ptr %27, align 8, !tbaa !9
  %29 = zext i8 %28 to i32
  %30 = icmp ne i32 %29, 13
  br label %31

31:                                               ; preds = %25, %19
  %32 = phi i1 [ false, %19 ], [ %30, %25 ]
  %33 = zext i1 %32 to i32
  store i32 %33, ptr %8, align 4, !tbaa !11
  %34 = load i32, ptr %8, align 4, !tbaa !11
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %31
  %37 = load i32, ptr %8, align 4, !tbaa !11
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %37, i32 noundef -1, ptr noundef @.str, i32 noundef 628, ptr noundef @__FUNCTION__.JSONArrayRead2, ptr noundef @.str.8)
  br label %38

38:                                               ; preds = %36, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %39

39:                                               ; preds = %38
  br label %40

40:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %41, i64 1
  %43 = call ptr @StringNumber(ptr noundef %42, ptr noundef %9, ptr noundef %10)
  %44 = getelementptr inbounds i8, ptr %43, i64 1
  store ptr %44, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %45 = load i32, ptr %9, align 8, !tbaa !13
  store i32 %45, ptr %11, align 4, !tbaa !11
  %46 = load i32, ptr %11, align 4, !tbaa !11
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.JSONNode, ptr %47, i32 0, i32 0
  %49 = load i16, ptr %48, align 8, !tbaa !13
  %50 = zext i16 %49 to i32
  %51 = icmp sge i32 %46, %50
  br i1 %51, label %52, label %53

52:                                               ; preds = %40
  store ptr null, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %103

53:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = call ptr @JSONSubNode(ptr noundef %54)
  %56 = load i32, ptr %11, align 4, !tbaa !11
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds %struct.ArrayNode, ptr %55, i64 %57
  store ptr %58, ptr %13, align 8, !tbaa !5
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %59, ptr %60, align 8, !tbaa !5
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %61, i64 0
  %63 = load i8, ptr %62, align 1, !tbaa !13
  %64 = sext i8 %63 to i32
  %65 = icmp eq i32 %64, 46
  br i1 %65, label %66, label %73

66:                                               ; preds = %53
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %67, i64 1
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %68, ptr %69, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = call ptr @JSONListRead2(ptr noundef %70, ptr noundef %71)
  store ptr %72, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %102

73:                                               ; preds = %53
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds i8, ptr %74, i64 0
  %76 = load i8, ptr %75, align 1, !tbaa !13
  %77 = sext i8 %76 to i32
  %78 = icmp eq i32 %77, 91
  br i1 %78, label %79, label %85

79:                                               ; preds = %73
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %80, ptr %81, align 8, !tbaa !5
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = call ptr @JSONArrayRead2(ptr noundef %82, ptr noundef %83)
  store ptr %84, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %102

85:                                               ; preds = %73
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = getelementptr inbounds i8, ptr %86, i64 0
  %88 = load i8, ptr %87, align 1, !tbaa !13
  %89 = sext i8 %88 to i32
  %90 = icmp eq i32 %89, 0
  br i1 %90, label %91, label %93

91:                                               ; preds = %85
  %92 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %92, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %102

93:                                               ; preds = %85
  br label %94

94:                                               ; preds = %93
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 1, ptr %14, align 4, !tbaa !11
  %95 = load i32, ptr %14, align 4, !tbaa !11
  %96 = icmp ne i32 %95, 0
  br i1 %96, label %97, label %99

97:                                               ; preds = %94
  %98 = load i32, ptr %14, align 4, !tbaa !11
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %98, i32 noundef -1, ptr noundef @.str, i32 noundef 637, ptr noundef @__FUNCTION__.JSONArrayRead2, ptr noundef @.str.8)
  br label %99

99:                                               ; preds = %97, %94
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %100

100:                                              ; preds = %99
  br label %101

101:                                              ; preds = %100
  store ptr null, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %102

102:                                              ; preds = %101, %91, %79, %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %103

103:                                              ; preds = %102, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %104 = load ptr, ptr %3, align 8
  ret ptr %104
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 }

!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}


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

%union.JsonData = type { double }
%struct.ArrayNode = type <{ %union.JsonData, i8, i32, [3 x i8] }>

@.str = external hidden unnamed_addr constant [76 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [12 x i8], align 1
@__FUNCTION__.JSONArrayRead2 = external hidden unnamed_addr constant [15 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: nounwind uwtable
declare dso_local ptr @StringNumber(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @JSONArrayRead2(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca %union.JsonData, align 8
  %4 = alloca i8, align 1
  %5 = load ptr, ptr %0, align 8, !tbaa !5
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %5, i64 8
  %8 = load i8, ptr %7, align 8, !tbaa !9
  %9 = add i8 %8, -14
  %spec.select = icmp ult i8 %9, -2
  br i1 %spec.select, label %10, label %11

10:                                               ; preds = %2
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 628, ptr noundef nonnull @__FUNCTION__.JSONArrayRead2, ptr noundef nonnull @.str.8) #4
  br label %11

11:                                               ; preds = %10, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #4
  %12 = getelementptr inbounds i8, ptr %6, i64 1
  %13 = call ptr @StringNumber(ptr noundef nonnull %12, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %14 = getelementptr inbounds i8, ptr %13, i64 1
  %15 = load i32, ptr %3, align 8, !tbaa !11
  %16 = load i16, ptr %5, align 8, !tbaa !11
  %17 = zext i16 %16 to i32
  %.not30 = icmp slt i32 %15, %17
  br i1 %.not30, label %18, label %29

18:                                               ; preds = %11
  %19 = call ptr @JSONSubNode(ptr noundef nonnull %5)
  %20 = sext i32 %15 to i64
  %21 = getelementptr inbounds %struct.ArrayNode, ptr %19, i64 %20
  store ptr %21, ptr %0, align 8, !tbaa !5
  %22 = load i8, ptr %14, align 1, !tbaa !11
  switch i8 %22, label %28 [
    i8 46, label %23
    i8 91, label %26
    i8 0, label %29
  ]

23:                                               ; preds = %18
  %24 = getelementptr inbounds i8, ptr %13, i64 2
  store ptr %24, ptr %1, align 8, !tbaa !5
  %25 = call ptr @JSONListRead2(ptr noundef nonnull %0, ptr noundef nonnull %1)
  br label %29

26:                                               ; preds = %18
  store ptr %14, ptr %1, align 8, !tbaa !5
  %27 = call ptr @JSONArrayRead2(ptr noundef nonnull %0, ptr noundef nonnull %1)
  br label %29

28:                                               ; preds = %18
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 637, ptr noundef nonnull @__FUNCTION__.JSONArrayRead2, ptr noundef nonnull @.str.8) #4
  br label %29

29:                                               ; preds = %23, %26, %28, %18, %11
  %.1 = phi ptr [ null, %11 ], [ %25, %23 ], [ %27, %26 ], [ null, %28 ], [ %21, %18 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  ret ptr %.1
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 }

!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 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass