; 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 hidden i32 @type_family(i32 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @binn_get_bool(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = 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) #2
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %13, label %10

10:                                               ; preds = %2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %10, %2
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %69

14:                                               ; preds = %10
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.binn_struct, ptr %15, i32 0, i32 8
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = call i32 @type_family(i32 noundef %17)
  %19 = icmp eq i32 %18, 242
  br i1 %19, label %20, label %36

20:                                               ; preds = %14
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.binn_struct, ptr %21, i32 0, i32 9
  %23 = load ptr, ptr %22, align 8, !tbaa !12
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.binn_struct, ptr %24, i32 0, i32 8
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = call i32 @copy_int_value(ptr noundef %23, ptr noundef %6, i32 noundef %26, i32 noundef 129)
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %20
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %69

30:                                               ; preds = %20
  %31 = load i64, ptr %6, align 8, !tbaa !13
  %32 = icmp ne i64 %31, 0
  %33 = zext i1 %32 to i64
  %34 = select i1 %32, i32 1, i32 0
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  store i32 %34, ptr %35, align 4, !tbaa !15
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %69

36:                                               ; preds = %14
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.binn_struct, ptr %37, i32 0, i32 8
  %39 = load i32, ptr %38, align 4, !tbaa !9
  switch i32 %39, label %67 [
    i32 524385, label %40
    i32 98, label %45
    i32 130, label %53
    i32 160, label %61
  ]

40:                                               ; preds = %36
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.binn_struct, ptr %41, i32 0, i32 15
  %43 = load i32, ptr %42, align 8, !tbaa !16
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  store i32 %43, ptr %44, align 4, !tbaa !15
  br label %68

45:                                               ; preds = %36
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.binn_struct, ptr %46, i32 0, i32 15
  %48 = load float, ptr %47, align 8, !tbaa !16
  %49 = fcmp une float %48, 0.000000e+00
  %50 = zext i1 %49 to i64
  %51 = select i1 %49, i32 1, i32 0
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  store i32 %51, ptr %52, align 4, !tbaa !15
  br label %68

53:                                               ; preds = %36
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.binn_struct, ptr %54, i32 0, i32 15
  %56 = load double, ptr %55, align 8, !tbaa !16
  %57 = fcmp une double %56, 0.000000e+00
  %58 = zext i1 %57 to i64
  %59 = select i1 %57, i32 1, i32 0
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  store i32 %59, ptr %60, align 4, !tbaa !15
  br label %68

61:                                               ; preds = %36
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.binn_struct, ptr %62, i32 0, i32 9
  %64 = load ptr, ptr %63, align 8, !tbaa !12
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = call i32 @is_bool_str(ptr noundef %64, ptr noundef %65)
  store i32 %66, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %69

67:                                               ; preds = %36
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %69

68:                                               ; preds = %53, %45, %40
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %69

69:                                               ; preds = %68, %67, %61, %30, %29, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %70 = load i32, ptr %3, align 4
  ret i32 %70
}

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

; 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 hidden i32 @type_family(i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @binn_get_bool(ptr noundef readonly %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #2
  %4 = icmp eq ptr %0, null
  %5 = icmp eq ptr %1, null
  %or.cond = or i1 %4, %5
  br i1 %or.cond, label %39, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 36
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = tail call i32 @type_family(i32 noundef %8)
  %10 = icmp eq i32 %9, 242
  br i1 %10, label %11, label %20

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = load i32, ptr %7, align 4, !tbaa !5
  %15 = call i32 @copy_int_value(ptr noundef %13, ptr noundef nonnull %3, i32 noundef %14, i32 noundef 129)
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %39, label %17

17:                                               ; preds = %11
  %18 = load i64, ptr %3, align 8, !tbaa !12
  %.not = icmp ne i64 %18, 0
  %19 = zext i1 %.not to i32
  store i32 %19, ptr %1, align 4, !tbaa !14
  br label %39

20:                                               ; preds = %6
  %21 = load i32, ptr %7, align 4, !tbaa !5
  switch i32 %21, label %39 [
    i32 524385, label %22
    i32 98, label %25
    i32 130, label %30
    i32 160, label %35
  ]

22:                                               ; preds = %20
  %23 = getelementptr inbounds i8, ptr %0, i64 80
  %24 = load i32, ptr %23, align 8, !tbaa !15
  store i32 %24, ptr %1, align 4, !tbaa !14
  br label %39

25:                                               ; preds = %20
  %26 = getelementptr inbounds i8, ptr %0, i64 80
  %27 = load float, ptr %26, align 8, !tbaa !15
  %28 = fcmp une float %27, 0.000000e+00
  %29 = zext i1 %28 to i32
  store i32 %29, ptr %1, align 4, !tbaa !14
  br label %39

30:                                               ; preds = %20
  %31 = getelementptr inbounds i8, ptr %0, i64 80
  %32 = load double, ptr %31, align 8, !tbaa !15
  %33 = fcmp une double %32, 0.000000e+00
  %34 = zext i1 %33 to i32
  store i32 %34, ptr %1, align 4, !tbaa !14
  br label %39

35:                                               ; preds = %20
  %36 = getelementptr inbounds i8, ptr %0, i64 40
  %37 = load ptr, ptr %36, align 8, !tbaa !11
  %38 = tail call i32 @is_bool_str(ptr noundef %37, ptr noundef nonnull %1)
  br label %39

39:                                               ; preds = %22, %25, %30, %20, %11, %2, %35, %17
  %.0 = phi i32 [ 1, %17 ], [ %38, %35 ], [ 0, %2 ], [ 0, %11 ], [ 0, %20 ], [ 1, %30 ], [ 1, %25 ], [ 1, %22 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #2
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @is_bool_str(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, !7, i64 36}
!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, !10, i64 40}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!8, !8, i64 0}


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