; LLVM IR from Softmotions/iowow :: src/json (iwbinn)

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

; 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 i32 @binn_list_get_value(ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @binn_get_read_storage(i32 noundef) #1

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

19:                                               ; preds = %5
  %20 = load ptr, ptr %10, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %50

23:                                               ; preds = %19, %5
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = load i32, ptr %9, align 4, !tbaa !9
  call void @zero_value(ptr noundef %24, i32 noundef %25)
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = call i32 @binn_list_get_value(ptr noundef %26, i32 noundef %27, ptr noundef %12)
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %23
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %50

31:                                               ; preds = %23
  %32 = getelementptr inbounds %struct.binn_struct, ptr %12, i32 0, i32 9
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.binn_struct, ptr %12, i32 0, i32 8
  %36 = load i32, ptr %35, align 4, !tbaa !13
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = load i32, ptr %13, align 4, !tbaa !9
  %39 = call i32 @copy_value(ptr noundef %33, ptr noundef %34, i32 noundef %36, i32 noundef %37, i32 noundef %38)
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %31
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %50

42:                                               ; preds = %31
  %43 = load ptr, ptr %11, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %49

45:                                               ; preds = %42
  %46 = getelementptr inbounds %struct.binn_struct, ptr %12, i32 0, i32 10
  %47 = load i32, ptr %46, align 8, !tbaa !14
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 %47, ptr %48, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %45, %42
  store i32 1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %50

50:                                               ; preds = %49, %41, %30, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 88, ptr %12) #2
  %51 = load i32, ptr %6, align 4
  ret i32 %51
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @copy_value(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 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, !6, i64 40}
!12 = !{!"binn_struct", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !6, i64 40, !10, i64 48, !10, i64 52, !6, i64 56, !6, i64 64, !6, i64 72, !7, i64 80}
!13 = !{!12, !10, i64 36}
!14 = !{!12, !10, i64 48}


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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @binn_get_read_storage(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @binn_list_get(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef writeonly %4) local_unnamed_addr #1 {
  %6 = alloca %struct.binn_struct, align 8
  call void @llvm.lifetime.start.p0(i64 88, ptr nonnull %6) #2
  %7 = tail call i32 @binn_get_read_storage(i32 noundef %2)
  %8 = icmp ne i32 %7, 0
  %9 = icmp eq ptr %3, null
  %or.cond = and i1 %9, %8
  br i1 %or.cond, label %24, label %10

10:                                               ; preds = %5
  tail call void @zero_value(ptr noundef %3, i32 noundef %2)
  %11 = call i32 @binn_list_get_value(ptr noundef %0, i32 noundef %1, ptr noundef nonnull %6)
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %24, label %13

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %6, i64 40
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %6, i64 36
  %17 = load i32, ptr %16, align 4, !tbaa !11
  %18 = call i32 @copy_value(ptr noundef %15, ptr noundef %3, i32 noundef %17, i32 noundef %2, i32 noundef %7)
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %24, label %20

20:                                               ; preds = %13
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %24, label %21

21:                                               ; preds = %20
  %22 = getelementptr inbounds i8, ptr %6, i64 48
  %23 = load i32, ptr %22, align 8, !tbaa !12
  store i32 %23, ptr %4, align 4, !tbaa !13
  br label %24

24:                                               ; preds = %20, %21, %13, %10, %5
  %.0 = phi i32 [ 0, %5 ], [ 0, %10 ], [ 0, %13 ], [ 1, %21 ], [ 1, %20 ]
  call void @llvm.lifetime.end.p0(i64 88, ptr nonnull %6) #2
  ret i32 %.0
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @copy_value(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 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, !10, i64 40}
!6 = !{!"binn_struct", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !10, i64 40, !7, i64 48, !7, i64 52, !10, i64 56, !10, i64 64, !10, i64 72, !8, i64 80}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 36}
!12 = !{!6, !7, i64 48}
!13 = !{!7, !7, i64 0}


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