; 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 uwtable
declare dso_local i64 @jbn_at(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @jbn_paths_compare(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5) #1 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store i32 %4, ptr %12, align 4, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !5
  %18 = load ptr, ptr %13, align 8, !tbaa !5
  store i64 0, ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  store ptr null, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  store ptr null, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = call i64 @jbn_at(ptr noundef %19, ptr noundef %20, ptr noundef %14)
  store i64 %21, ptr %16, align 8, !tbaa !11
  %22 = load i64, ptr %16, align 8, !tbaa !11
  %23 = icmp ne i64 %22, 0
  br i1 %23, label %24, label %30

24:                                               ; preds = %6
  %25 = load i64, ptr %16, align 8, !tbaa !11
  %26 = icmp ne i64 %25, 76009
  br i1 %26, label %27, label %30

27:                                               ; preds = %24
  %28 = load i64, ptr %16, align 8, !tbaa !11
  %29 = load ptr, ptr %13, align 8, !tbaa !5
  store i64 %28, ptr %29, align 8, !tbaa !11
  store i32 -2, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %71

30:                                               ; preds = %24, %6
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = call i64 @jbn_at(ptr noundef %31, ptr noundef %32, ptr noundef %15)
  store i64 %33, ptr %16, align 8, !tbaa !11
  %34 = load i64, ptr %16, align 8, !tbaa !11
  %35 = icmp ne i64 %34, 0
  br i1 %35, label %36, label %42

36:                                               ; preds = %30
  %37 = load i64, ptr %16, align 8, !tbaa !11
  %38 = icmp ne i64 %37, 76009
  br i1 %38, label %39, label %42

39:                                               ; preds = %36
  %40 = load i64, ptr %16, align 8, !tbaa !11
  %41 = load ptr, ptr %13, align 8, !tbaa !5
  store i64 %40, ptr %41, align 8, !tbaa !11
  store i32 -2, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %71

42:                                               ; preds = %36, %30
  %43 = load i32, ptr %12, align 4, !tbaa !9
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %66

45:                                               ; preds = %42
  %46 = load ptr, ptr %14, align 8, !tbaa !5
  %47 = icmp eq ptr %46, null
  br i1 %47, label %63, label %48

48:                                               ; preds = %45
  %49 = load ptr, ptr %14, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.jbl_node, ptr %49, i32 0, i32 8
  %51 = load i32, ptr %50, align 4, !tbaa !13
  %52 = load i32, ptr %12, align 4, !tbaa !9
  %53 = icmp ne i32 %51, %52
  br i1 %53, label %63, label %54

54:                                               ; preds = %48
  %55 = load ptr, ptr %15, align 8, !tbaa !5
  %56 = icmp eq ptr %55, null
  br i1 %56, label %63, label %57

57:                                               ; preds = %54
  %58 = load ptr, ptr %15, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.jbl_node, ptr %58, i32 0, i32 8
  %60 = load i32, ptr %59, align 4, !tbaa !13
  %61 = load i32, ptr %12, align 4, !tbaa !9
  %62 = icmp ne i32 %60, %61
  br i1 %62, label %63, label %65

63:                                               ; preds = %57, %54, %48, %45
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  store i64 76017, ptr %64, align 8, !tbaa !11
  store i32 -2, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %71

65:                                               ; preds = %57
  br label %66

66:                                               ; preds = %65, %42
  %67 = load ptr, ptr %14, align 8, !tbaa !5
  %68 = load ptr, ptr %15, align 8, !tbaa !5
  %69 = load ptr, ptr %13, align 8, !tbaa !5
  %70 = call i32 @_jbl_compare_nodes(ptr noundef %67, ptr noundef %68, ptr noundef %69)
  store i32 %70, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %71

71:                                               ; preds = %66, %63, %39, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  %72 = load i32, ptr %7, align 4
  ret i32 %72
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @_jbl_compare_nodes(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 }

!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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 52}
!14 = !{!"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}


; 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 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 i64 @jbn_at(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @jbn_paths_compare(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5) local_unnamed_addr #1 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store i64 0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #2
  store ptr null, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #2
  store ptr null, ptr %8, align 8, !tbaa !9
  %9 = call i64 @jbn_at(ptr noundef %0, ptr noundef %1, ptr noundef nonnull %7)
  switch i64 %9, label %10 [
    i64 76009, label %11
    i64 0, label %11
  ]

10:                                               ; preds = %6
  store i64 %9, ptr %5, align 8, !tbaa !5
  br label %30

11:                                               ; preds = %6, %6
  %12 = call i64 @jbn_at(ptr noundef %2, ptr noundef %3, ptr noundef nonnull %8)
  switch i64 %12, label %13 [
    i64 76009, label %14
    i64 0, label %14
  ]

13:                                               ; preds = %11
  store i64 %12, ptr %5, align 8, !tbaa !5
  br label %30

14:                                               ; preds = %11, %11
  %.not = icmp eq i32 %4, 0
  %.pre = load ptr, ptr %7, align 8, !tbaa !9
  br i1 %.not, label %._crit_edge, label %15

._crit_edge:                                      ; preds = %14
  %.pre29 = load ptr, ptr %8, align 8, !tbaa !9
  br label %27

15:                                               ; preds = %14
  %16 = icmp eq ptr %.pre, null
  br i1 %16, label %26, label %17

17:                                               ; preds = %15
  %18 = getelementptr inbounds i8, ptr %.pre, i64 52
  %19 = load i32, ptr %18, align 4, !tbaa !11
  %20 = icmp ne i32 %19, %4
  %21 = load ptr, ptr %8, align 8
  %22 = icmp eq ptr %21, null
  %or.cond5 = select i1 %20, i1 true, i1 %22
  br i1 %or.cond5, label %26, label %23

23:                                               ; preds = %17
  %24 = getelementptr inbounds i8, ptr %21, i64 52
  %25 = load i32, ptr %24, align 4, !tbaa !11
  %.not28 = icmp eq i32 %25, %4
  br i1 %.not28, label %27, label %26

26:                                               ; preds = %23, %17, %15
  store i64 76017, ptr %5, align 8, !tbaa !5
  br label %30

27:                                               ; preds = %._crit_edge, %23
  %28 = phi ptr [ %.pre29, %._crit_edge ], [ %21, %23 ]
  %29 = call i32 @_jbl_compare_nodes(ptr noundef %.pre, ptr noundef %28, ptr noundef nonnull %5)
  br label %30

30:                                               ; preds = %27, %26, %13, %10
  %.0 = phi i32 [ -2, %10 ], [ -2, %13 ], [ -2, %26 ], [ %29, %27 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #2
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @_jbl_compare_nodes(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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !13, i64 52}
!12 = !{!"jbl_node", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !13, i64 32, !13, i64 36, !10, i64 40, !13, i64 48, !13, i64 52, !7, i64 56}
!13 = !{!"int", !7, i64 0}


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