; LLVM IR from Water-Melon/Melon :: src (mln_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.mln_json_s = type { i32, %union.anon }
%union.anon = type { ptr }
%struct.mln_array_t = type { ptr, i64, i64, i64, ptr, ptr, ptr, ptr }
%struct.mln_string_t = type { ptr, i64, i32 }

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [11 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
define dso_local void @mln_json_dump(ptr noundef %0, i32 noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  br label %101

14:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = add nsw i32 %15, 2
  store i32 %16, ptr %8, align 4, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %23, %14
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %21, label %26

21:                                               ; preds = %17
  %22 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  br label %23

23:                                               ; preds = %21
  %24 = load i32, ptr %7, align 4, !tbaa !9
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %7, align 4, !tbaa !9
  br label %17, !llvm.loop !11

26:                                               ; preds = %17
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %32

29:                                               ; preds = %26
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, ptr noundef %30)
  br label %32

32:                                               ; preds = %29, %26
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.mln_json_s, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 8, !tbaa !13
  switch i32 %35, label %98 [
    i32 1, label %36
    i32 2, label %42
    i32 3, label %67
    i32 4, label %87
    i32 5, label %92
    i32 6, label %94
    i32 7, label %96
  ]

36:                                               ; preds = %32
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.mln_json_s, ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !15
  %41 = call i32 @mln_rbtree_iterate(ptr noundef %40, ptr noundef @mln_json_dump_obj_iterate_handler, ptr noundef %8)
  br label %100

42:                                               ; preds = %32
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.mln_json_s, ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !15
  %47 = getelementptr inbounds %struct.mln_array_t, ptr %46, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !16
  store ptr %48, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.mln_json_s, ptr %50, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !15
  %53 = getelementptr inbounds %struct.mln_array_t, ptr %52, i32 0, i32 3
  %54 = load i64, ptr %53, align 8, !tbaa !19
  %55 = getelementptr inbounds %struct.mln_json_s, ptr %49, i64 %54
  store ptr %55, ptr %10, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %63, %42
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = icmp ult ptr %57, %58
  br i1 %59, label %60, label %66

60:                                               ; preds = %56
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load i32, ptr %8, align 4, !tbaa !9
  call void @mln_json_dump(ptr noundef %61, i32 noundef %62, ptr noundef @.str.4)
  br label %63

63:                                               ; preds = %60
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.mln_json_s, ptr %64, i32 1
  store ptr %65, ptr %9, align 8, !tbaa !5
  br label %56, !llvm.loop !20

66:                                               ; preds = %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %100

67:                                               ; preds = %32
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.mln_json_s, ptr %68, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !15
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %86

72:                                               ; preds = %67
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.mln_json_s, ptr %73, i32 0, i32 1
  %75 = load ptr, ptr %74, align 8, !tbaa !15
  %76 = getelementptr inbounds %struct.mln_string_t, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !21
  %78 = icmp ne ptr %77, null
  br i1 %78, label %79, label %86

79:                                               ; preds = %72
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.mln_json_s, ptr %80, i32 0, i32 1
  %82 = load ptr, ptr %81, align 8, !tbaa !15
  %83 = getelementptr inbounds %struct.mln_string_t, ptr %82, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !21
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, ptr noundef %84)
  br label %86

86:                                               ; preds = %79, %72, %67
  br label %100

87:                                               ; preds = %32
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.mln_json_s, ptr %88, i32 0, i32 1
  %90 = load double, ptr %89, align 8, !tbaa !15
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, double noundef %90)
  br label %100

92:                                               ; preds = %32
  %93 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  br label %100

94:                                               ; preds = %32
  %95 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  br label %100

96:                                               ; preds = %32
  %97 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  br label %100

98:                                               ; preds = %32
  %99 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  br label %100

100:                                              ; preds = %98, %96, %94, %92, %87, %86, %66, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %101

101:                                              ; preds = %100, %13
  ret void
}

declare i32 @printf(ptr noundef, ...) #2

declare i32 @mln_rbtree_iterate(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @mln_json_dump_obj_iterate_handler(ptr noundef, ptr noundef) #1

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 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 0}
!14 = !{!"mln_json_s", !10, i64 0, !7, i64 8}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !6, i64 0}
!17 = !{!"", !6, i64 0, !18, i64 8, !18, i64 16, !18, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!18 = !{!"long", !7, i64 0}
!19 = !{!17, !18, i64 24}
!20 = distinct !{!20, !12}
!21 = !{!22, !6, i64 0}
!22 = !{!"", !6, i64 0, !18, i64 8, !18, i64 16, !18, i64 16, !18, i64 16}


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

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [11 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
define dso_local void @mln_json_dump(ptr noundef readonly %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = alloca i32, align 4
  %5 = icmp eq ptr %0, null
  br i1 %5, label %50, label %6

6:                                                ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  %7 = add nsw i32 %1, 2
  store i32 %7, ptr %4, align 4, !tbaa !5
  %8 = icmp sgt i32 %1, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %6, %.lr.ph
  %.026 = phi i32 [ %10, %.lr.ph ], [ 0, %6 ]
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %10 = add nuw nsw i32 %.026, 1
  %exitcond.not = icmp eq i32 %10, %1
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %6
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %13, label %11

11:                                               ; preds = %._crit_edge
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, ptr noundef nonnull %2)
  br label %13

13:                                               ; preds = %11, %._crit_edge
  %14 = load i32, ptr %0, align 8, !tbaa !11
  switch i32 %14, label %48 [
    i32 1, label %15
    i32 2, label %20
    i32 3, label %31
    i32 4, label %38
    i32 5, label %42
    i32 6, label %44
    i32 7, label %46
  ]

15:                                               ; preds = %13
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = call i32 @mln_rbtree_iterate(ptr noundef %18, ptr noundef nonnull @mln_json_dump_obj_iterate_handler, ptr noundef nonnull %4) #4
  br label %.loopexit

20:                                               ; preds = %13
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %22 = getelementptr inbounds i8, ptr %0, i64 8
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %23, i64 24
  %26 = load i64, ptr %25, align 8, !tbaa !18
  %27 = getelementptr inbounds %struct.mln_json_s, ptr %24, i64 %26
  %28 = icmp sgt i64 %26, 0
  br i1 %28, label %.lr.ph29, label %.loopexit

.lr.ph29:                                         ; preds = %20, %.lr.ph29
  %.01927 = phi ptr [ %29, %.lr.ph29 ], [ %24, %20 ]
  tail call void @mln_json_dump(ptr noundef %.01927, i32 noundef %7, ptr noundef nonnull @.str.4)
  %29 = getelementptr inbounds i8, ptr %.01927, i64 16
  %30 = icmp ult ptr %29, %27
  br i1 %30, label %.lr.ph29, label %.loopexit, !llvm.loop !19

31:                                               ; preds = %13
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %.not24 = icmp eq ptr %33, null
  br i1 %.not24, label %.loopexit, label %34

34:                                               ; preds = %31
  %35 = load ptr, ptr %33, align 8, !tbaa !20
  %.not25 = icmp eq ptr %35, null
  br i1 %.not25, label %.loopexit, label %36

36:                                               ; preds = %34
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, ptr noundef nonnull %35)
  br label %.loopexit

38:                                               ; preds = %13
  %39 = getelementptr inbounds i8, ptr %0, i64 8
  %40 = load double, ptr %39, align 8, !tbaa !13
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, double noundef %40)
  br label %.loopexit

42:                                               ; preds = %13
  %43 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  br label %.loopexit

44:                                               ; preds = %13
  %45 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  br label %.loopexit

46:                                               ; preds = %13
  %47 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  br label %.loopexit

48:                                               ; preds = %13
  %49 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph29, %20, %31, %34, %36, %48, %46, %44, %42, %38, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  br label %50

50:                                               ; preds = %3, %.loopexit
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

declare i32 @mln_rbtree_iterate(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @mln_json_dump_obj_iterate_handler(ptr noundef, ptr noundef) #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 = { nofree 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 #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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 0}
!12 = !{!"mln_json_s", !6, i64 0, !7, i64 8}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !16, i64 0}
!15 = !{!"", !16, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !16, i64 32, !16, i64 40, !16, i64 48, !16, i64 56}
!16 = !{!"any pointer", !7, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!15, !17, i64 24}
!19 = distinct !{!19, !10}
!20 = !{!21, !16, i64 0}
!21 = !{!"", !16, i64 0, !17, i64 8, !17, i64 16, !17, i64 16, !17, i64 16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass