; LLVM IR from clibs/clib :: deps/parson (parson)

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

@parson_free = external hidden global ptr, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = 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: nounwind uwtable
define dso_local ptr @json_parse_string_with_comments(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store ptr null, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store ptr null, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = call ptr @parson_strdup(ptr noundef %8)
  store ptr %9, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %50

13:                                               ; preds = %1
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  call void @remove_comments(ptr noundef %14, ptr noundef @.str, ptr noundef @.str.1)
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  call void @remove_comments(ptr noundef %15, ptr noundef @.str.2, ptr noundef @.str.3)
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %16, ptr %6, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %29, %13
  %18 = call ptr @__ctype_b_loc() #4
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = load i8, ptr %20, align 1, !tbaa !9
  %22 = sext i8 %21 to i32
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds i16, ptr %19, i64 %23
  %25 = load i16, ptr %24, align 2, !tbaa !10
  %26 = zext i16 %25 to i32
  %27 = and i32 %26, 8192
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %32

29:                                               ; preds = %17
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %30, i32 1
  store ptr %31, ptr %6, align 8, !tbaa !5
  br label %17, !llvm.loop !12

32:                                               ; preds = %17
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load i8, ptr %33, align 1, !tbaa !9
  %35 = sext i8 %34 to i32
  %36 = icmp ne i32 %35, 123
  br i1 %36, label %37, label %45

37:                                               ; preds = %32
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load i8, ptr %38, align 1, !tbaa !9
  %40 = sext i8 %39 to i32
  %41 = icmp ne i32 %40, 91
  br i1 %41, label %42, label %45

42:                                               ; preds = %37
  %43 = load ptr, ptr @parson_free, align 8, !tbaa !5
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  call void %43(ptr noundef %44)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %50

45:                                               ; preds = %37, %32
  %46 = call ptr @parse_value(ptr noundef %6, i64 noundef 0)
  store ptr %46, ptr %4, align 8, !tbaa !5
  %47 = load ptr, ptr @parson_free, align 8, !tbaa !5
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  call void %47(ptr noundef %48)
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %49, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %50

50:                                               ; preds = %45, %42, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %51 = load ptr, ptr %2, align 8
  ret ptr %51
}

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #2

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

; Function Attrs: nounwind uwtable
declare hidden ptr @parson_strdup(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @remove_comments(ptr noundef, 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 = { nounwind willreturn memory(none) "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(none) }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

@parson_free = external hidden local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = 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: nounwind uwtable
define dso_local ptr @json_parse_string_with_comments(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %3 = tail call ptr @parson_strdup(ptr noundef %0)
  %4 = icmp eq ptr %3, null
  br i1 %4, label %20, label %5

5:                                                ; preds = %1
  tail call void @remove_comments(ptr noundef nonnull %3, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1)
  tail call void @remove_comments(ptr noundef nonnull %3, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3)
  %6 = tail call ptr @__ctype_b_loc() #4
  %.pre = load ptr, ptr %6, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %7, %5
  %storemerge = phi ptr [ %3, %5 ], [ %13, %7 ]
  store ptr %storemerge, ptr %2, align 8, !tbaa !5
  %8 = load i8, ptr %storemerge, align 1, !tbaa !9
  %9 = sext i8 %8 to i64
  %10 = getelementptr inbounds i16, ptr %.pre, i64 %9
  %11 = load i16, ptr %10, align 2, !tbaa !10
  %12 = and i16 %11, 8192
  %.not = icmp eq i16 %12, 0
  %13 = getelementptr inbounds i8, ptr %storemerge, i64 1
  br i1 %.not, label %14, label %7, !llvm.loop !12

14:                                               ; preds = %7
  switch i8 %8, label %15 [
    i8 123, label %17
    i8 91, label %17
  ]

15:                                               ; preds = %14
  %16 = load ptr, ptr @parson_free, align 8, !tbaa !5
  tail call void %16(ptr noundef nonnull %3) #3
  br label %20

17:                                               ; preds = %14, %14
  %18 = call ptr @parse_value(ptr noundef nonnull %2, i64 noundef 0)
  %19 = load ptr, ptr @parson_free, align 8, !tbaa !5
  call void %19(ptr noundef nonnull %3) #3
  br label %20

20:                                               ; preds = %1, %17, %15
  %.0 = phi ptr [ null, %15 ], [ %18, %17 ], [ null, %1 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret ptr %.0
}

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden ptr @parse_value(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @parson_strdup(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @remove_comments(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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(none) }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass