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

; 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.iwjsreg = type { ptr, ptr, ptr, ptr, ptr, %union.pthread_rwlock_t, %struct.iwref_holder, ptr, ptr, ptr, ptr, i32, i8 }
%union.pthread_rwlock_t = type { %struct.__pthread_rwlock_arch_t }
%struct.__pthread_rwlock_arch_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i8, [7 x i8], i64, i32 }
%struct.iwref_holder = type { ptr, i64, ptr }
%struct.jbl_node = type { ptr, ptr, ptr, ptr, i32, i32, ptr, i32, i32, %union.anon }
%union.anon = type { ptr }

@.str.3 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 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(none)
declare i64 @llvm.expect.i64(i64, i64) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare void @iwlog3(i32 noundef, i64 noundef, ptr noundef, i32 noundef, ptr noundef) #2

declare i64 @jbn_at(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @iwjsreg_at_bool(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 0, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.iwjsreg, ptr %12, i32 0, i32 7
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.iwjsreg, ptr %15, i32 0, i32 10
  %17 = load ptr, ptr %16, align 8, !tbaa !16
  %18 = call i64 %14(ptr noundef %17)
  %19 = icmp ne i64 %18, 0
  %20 = xor i1 %19, true
  %21 = xor i1 %20, true
  %22 = zext i1 %21 to i32
  %23 = sext i32 %22 to i64
  %24 = call i64 @llvm.expect.i64(i64 %23, i64 0)
  %25 = icmp ne i64 %24, 0
  br i1 %25, label %26, label %34

26:                                               ; preds = %3
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.iwjsreg, ptr %27, i32 0, i32 7
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.iwjsreg, ptr %30, i32 0, i32 10
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = call i64 %29(ptr noundef %32)
  store i64 %33, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %107

34:                                               ; preds = %3
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.iwjsreg, ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !17
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = call i64 @jbn_at(ptr noundef %37, ptr noundef %38, ptr noundef %9)
  store i64 %39, ptr %8, align 8, !tbaa !9
  %40 = load i64, ptr %8, align 8, !tbaa !9
  %41 = icmp ne i64 %40, 0
  %42 = xor i1 %41, true
  %43 = xor i1 %42, true
  %44 = zext i1 %43 to i32
  %45 = sext i32 %44 to i64
  %46 = call i64 @llvm.expect.i64(i64 %45, i64 0)
  %47 = icmp ne i64 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %34
  br label %87

49:                                               ; preds = %34
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.jbl_node, ptr %50, i32 0, i32 8
  %52 = load i32, ptr %51, align 4, !tbaa !18
  switch i32 %52, label %85 [
    i32 2, label %53
    i32 4, label %60
    i32 3, label %67
    i32 1, label %75
    i32 5, label %77
  ]

53:                                               ; preds = %49
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.jbl_node, ptr %54, i32 0, i32 9
  %56 = load i8, ptr %55, align 8, !tbaa !20, !range !21, !noundef !22
  %57 = trunc i8 %56 to i1
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = zext i1 %57 to i8
  store i8 %59, ptr %58, align 1, !tbaa !23
  br label %86

60:                                               ; preds = %49
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.jbl_node, ptr %61, i32 0, i32 9
  %63 = load double, ptr %62, align 8, !tbaa !20
  %64 = fcmp une double %63, 0.000000e+00
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = zext i1 %64 to i8
  store i8 %66, ptr %65, align 1, !tbaa !23
  br label %86

67:                                               ; preds = %49
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.jbl_node, ptr %68, i32 0, i32 9
  %70 = load i64, ptr %69, align 8, !tbaa !20
  %71 = sitofp i64 %70 to double
  %72 = fcmp une double %71, 0.000000e+00
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = zext i1 %72 to i8
  store i8 %74, ptr %73, align 1, !tbaa !23
  br label %86

75:                                               ; preds = %49
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 0, ptr %76, align 1, !tbaa !23
  br label %86

77:                                               ; preds = %49
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.jbl_node, ptr %78, i32 0, i32 9
  %80 = load ptr, ptr %79, align 8, !tbaa !20
  %81 = call i32 @strcmp(ptr noundef %80, ptr noundef @.str.5) #6
  %82 = icmp eq i32 %81, 0
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = zext i1 %82 to i8
  store i8 %84, ptr %83, align 1, !tbaa !23
  br label %86

85:                                               ; preds = %49
  store i64 70030, ptr %8, align 8, !tbaa !9
  br label %86

86:                                               ; preds = %85, %77, %75, %67, %60, %53
  br label %87

87:                                               ; preds = %86, %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.iwjsreg, ptr %88, i32 0, i32 9
  %90 = load ptr, ptr %89, align 8, !tbaa !24
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.iwjsreg, ptr %91, i32 0, i32 10
  %93 = load ptr, ptr %92, align 8, !tbaa !16
  %94 = call i64 %90(ptr noundef %93)
  store i64 %94, ptr %11, align 8, !tbaa !9
  %95 = load i64, ptr %11, align 8, !tbaa !9
  %96 = icmp ne i64 %95, 0
  br i1 %96, label %97, label %105

97:                                               ; preds = %87
  %98 = load i64, ptr %8, align 8, !tbaa !9
  %99 = icmp ne i64 %98, 0
  br i1 %99, label %102, label %100

100:                                              ; preds = %97
  %101 = load i64, ptr %11, align 8, !tbaa !9
  store i64 %101, ptr %8, align 8, !tbaa !9
  br label %104

102:                                              ; preds = %97
  %103 = load i64, ptr %11, align 8, !tbaa !9
  call void @iwlog3(i32 noundef 0, i64 noundef %103, ptr noundef @.str.3, i32 noundef 482, ptr noundef @.str.4)
  br label %104

104:                                              ; preds = %102, %100
  br label %105

105:                                              ; preds = %104, %87
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  %106 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %106, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %107

107:                                              ; preds = %105, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %108 = load i64, ptr %4, align 8
  ret i64 %108
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 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 #4 = { nounwind willreturn memory(read) "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 #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 120}
!12 = !{!"iwjsreg", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !7, i64 40, !13, i64 96, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !14, i64 152, !15, i64 156}
!13 = !{!"iwref_holder", !6, i64 0, !7, i64 8, !6, i64 16}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!12, !6, i64 144}
!17 = !{!12, !6, i64 8}
!18 = !{!19, !14, i64 52}
!19 = !{!"jbl_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !14, i64 32, !14, i64 36, !6, i64 40, !14, i64 48, !14, i64 52, !7, i64 56}
!20 = !{!7, !7, i64 0}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!15, !15, i64 0}
!24 = !{!12, !6, i64 136}


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

@.str.3 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 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

declare void @iwlog3(i32 noundef, i64 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare i64 @jbn_at(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i64 @iwjsreg_at_bool(ptr nocapture noundef readonly %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #2 {
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %5 = getelementptr inbounds i8, ptr %0, i64 120
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 144
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = tail call i64 %6(ptr noundef %8) #4
  %.not = icmp eq i64 %9, 0
  br i1 %.not, label %14, label %10, !prof !14

10:                                               ; preds = %3
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %7, align 8, !tbaa !13
  %13 = tail call i64 %11(ptr noundef %12) #4
  br label %48

14:                                               ; preds = %3
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !15
  %17 = call i64 @jbn_at(ptr noundef %16, ptr noundef %1, ptr noundef nonnull %4) #4
  %.not23 = icmp eq i64 %17, 0
  br i1 %.not23, label %18, label %41, !prof !14

18:                                               ; preds = %14
  %19 = load ptr, ptr %4, align 8, !tbaa !16
  %20 = getelementptr inbounds i8, ptr %19, i64 52
  %21 = load i32, ptr %20, align 4, !tbaa !17
  switch i32 %21, label %41 [
    i32 2, label %22
    i32 4, label %25
    i32 3, label %30
    i32 1, label %.sink.split
    i32 5, label %35
  ]

22:                                               ; preds = %18
  %23 = getelementptr inbounds i8, ptr %19, i64 56
  %24 = load i8, ptr %23, align 8, !tbaa !19, !range !20, !noundef !21
  br label %.sink.split

25:                                               ; preds = %18
  %26 = getelementptr inbounds i8, ptr %19, i64 56
  %27 = load double, ptr %26, align 8, !tbaa !19
  %28 = fcmp une double %27, 0.000000e+00
  %29 = zext i1 %28 to i8
  br label %.sink.split

30:                                               ; preds = %18
  %31 = getelementptr inbounds i8, ptr %19, i64 56
  %32 = load i64, ptr %31, align 8, !tbaa !19
  %33 = icmp ne i64 %32, 0
  %34 = zext i1 %33 to i8
  br label %.sink.split

35:                                               ; preds = %18
  %36 = getelementptr inbounds i8, ptr %19, i64 56
  %37 = load ptr, ptr %36, align 8, !tbaa !19
  %38 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %37, ptr noundef nonnull dereferenceable(1) @.str.5) #5
  %39 = icmp eq i32 %38, 0
  %40 = zext i1 %39 to i8
  br label %.sink.split

.sink.split:                                      ; preds = %18, %35, %30, %25, %22
  %.sink = phi i8 [ %24, %22 ], [ %29, %25 ], [ %34, %30 ], [ %40, %35 ], [ 0, %18 ]
  store i8 %.sink, ptr %2, align 1, !tbaa !22
  br label %41

41:                                               ; preds = %.sink.split, %18, %14
  %.019 = phi i64 [ %17, %14 ], [ 70030, %18 ], [ 0, %.sink.split ]
  %42 = getelementptr inbounds i8, ptr %0, i64 136
  %43 = load ptr, ptr %42, align 8, !tbaa !23
  %44 = load ptr, ptr %7, align 8, !tbaa !13
  %45 = call i64 %43(ptr noundef %44) #4
  %.not24 = icmp eq i64 %45, 0
  br i1 %.not24, label %48, label %46

46:                                               ; preds = %41
  %.not25 = icmp eq i64 %.019, 0
  br i1 %.not25, label %48, label %47

47:                                               ; preds = %46
  call void @iwlog3(i32 noundef 0, i64 noundef %45, ptr noundef nonnull @.str.3, i32 noundef 482, ptr noundef nonnull @.str.4) #4
  br label %48

48:                                               ; preds = %41, %47, %46, %10
  %.0 = phi i64 [ %13, %10 ], [ %.019, %47 ], [ %.019, %41 ], [ %45, %46 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  ret i64 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 }
attributes #5 = { nounwind willreturn memory(read) }

!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 120}
!6 = !{!"iwjsreg", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !8, i64 40, !10, i64 96, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !11, i64 152, !12, i64 156}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"iwref_holder", !7, i64 0, !8, i64 8, !7, i64 16}
!11 = !{!"int", !8, i64 0}
!12 = !{!"_Bool", !8, i64 0}
!13 = !{!6, !7, i64 144}
!14 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!15 = !{!6, !7, i64 8}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !11, i64 52}
!18 = !{!"jbl_node", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !11, i64 32, !11, i64 36, !7, i64 40, !11, i64 48, !11, i64 52, !8, i64 56}
!19 = !{!8, !8, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!12, !12, i64 0}
!23 = !{!6, !7, i64 136}


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