; 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

; 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

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

; Function Attrs: nounwind uwtable
define dso_local i64 @iwjsreg_get_bool(ptr noundef %0, ptr noundef %1, ptr noundef %2) #4 {
  %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 i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  %12 = 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
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %21

15:                                               ; preds = %3
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %21

18:                                               ; preds = %15
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %22, label %21

21:                                               ; preds = %18, %15, %3
  store i64 70017, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %115

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #5
  store i8 0, ptr %10, align 1, !tbaa !11
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 0, ptr %23, align 1, !tbaa !11
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.iwjsreg, ptr %24, i32 0, i32 7
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.iwjsreg, ptr %27, i32 0, i32 10
  %29 = load ptr, ptr %28, align 8, !tbaa !17
  %30 = call i64 %26(ptr noundef %29)
  %31 = icmp ne i64 %30, 0
  %32 = xor i1 %31, true
  %33 = xor i1 %32, true
  %34 = zext i1 %33 to i32
  %35 = sext i32 %34 to i64
  %36 = call i64 @llvm.expect.i64(i64 %35, i64 0)
  %37 = icmp ne i64 %36, 0
  br i1 %37, label %38, label %46

38:                                               ; preds = %22
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.iwjsreg, ptr %39, i32 0, i32 7
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.iwjsreg, ptr %42, i32 0, i32 10
  %44 = load ptr, ptr %43, align 8, !tbaa !17
  %45 = call i64 %41(ptr noundef %44)
  store i64 %45, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %114

46:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.iwjsreg, ptr %47, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !18
  %50 = getelementptr inbounds %struct.jbl_node, ptr %49, i32 0, i32 6
  %51 = load ptr, ptr %50, align 8, !tbaa !19
  store ptr %51, ptr %11, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %82, %46
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %56, label %55

55:                                               ; preds = %52
  store i32 2, ptr %9, align 4
  br label %86

56:                                               ; preds = %52
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.jbl_node, ptr %57, i32 0, i32 3
  %59 = load ptr, ptr %58, align 8, !tbaa !21
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %81

61:                                               ; preds = %56
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.jbl_node, ptr %62, i32 0, i32 3
  %64 = load ptr, ptr %63, align 8, !tbaa !21
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = call i32 @strcmp(ptr noundef %64, ptr noundef %65) #6
  %67 = icmp eq i32 %66, 0
  br i1 %67, label %68, label %81

68:                                               ; preds = %61
  %69 = load ptr, ptr %11, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.jbl_node, ptr %69, i32 0, i32 8
  %71 = load i32, ptr %70, align 4, !tbaa !22
  %72 = icmp eq i32 %71, 2
  br i1 %72, label %73, label %80

73:                                               ; preds = %68
  %74 = load ptr, ptr %11, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.jbl_node, ptr %74, i32 0, i32 9
  %76 = load i8, ptr %75, align 8, !tbaa !23, !range !24, !noundef !25
  %77 = trunc i8 %76 to i1
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = zext i1 %77 to i8
  store i8 %79, ptr %78, align 1, !tbaa !11
  store i8 1, ptr %10, align 1, !tbaa !11
  store i32 2, ptr %9, align 4
  br label %86

80:                                               ; preds = %68
  br label %81

81:                                               ; preds = %80, %61, %56
  br label %82

82:                                               ; preds = %81
  %83 = load ptr, ptr %11, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.jbl_node, ptr %83, i32 0, i32 0
  %85 = load ptr, ptr %84, align 8, !tbaa !26
  store ptr %85, ptr %11, align 8, !tbaa !5
  br label %52, !llvm.loop !27

86:                                               ; preds = %73, %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %87

87:                                               ; preds = %86
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #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 !29
  %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 !17
  %94 = call i64 %90(ptr noundef %93)
  store i64 %94, ptr %12, align 8, !tbaa !9
  %95 = load i64, ptr %12, 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 %12, align 8, !tbaa !9
  store i64 %101, ptr %8, align 8, !tbaa !9
  br label %104

102:                                              ; preds = %97
  %103 = load i64, ptr %12, align 8, !tbaa !9
  call void @iwlog3(i32 noundef 0, i64 noundef %103, ptr noundef @.str.3, i32 noundef 751, 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 %12) #5
  %106 = load i64, ptr %8, align 8, !tbaa !9
  %107 = icmp ne i64 %106, 0
  br i1 %107, label %112, label %108

108:                                              ; preds = %105
  %109 = load i8, ptr %10, align 1, !tbaa !11, !range !24, !noundef !25
  %110 = trunc i8 %109 to i1
  br i1 %110, label %112, label %111

111:                                              ; preds = %108
  store i64 70004, ptr %8, align 8, !tbaa !9
  br label %112

112:                                              ; preds = %111, %108, %105
  %113 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %113, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %114

114:                                              ; preds = %112, %38
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #5
  br label %115

115:                                              ; preds = %114, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %116 = load i64, ptr %4, align 8
  ret i64 %116
}

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 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 #4 = { 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 #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, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !6, i64 120}
!14 = !{!"iwjsreg", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !7, i64 40, !15, i64 96, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !16, i64 152, !12, i64 156}
!15 = !{!"iwref_holder", !6, i64 0, !7, i64 8, !6, i64 16}
!16 = !{!"int", !7, i64 0}
!17 = !{!14, !6, i64 144}
!18 = !{!14, !6, i64 8}
!19 = !{!20, !6, i64 40}
!20 = !{!"jbl_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !16, i64 32, !16, i64 36, !6, i64 40, !16, i64 48, !16, i64 52, !7, i64 56}
!21 = !{!20, !6, i64 24}
!22 = !{!20, !16, i64 52}
!23 = !{!7, !7, i64 0}
!24 = !{i8 0, i8 2}
!25 = !{}
!26 = !{!20, !6, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!14, !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"

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

; Function Attrs: nounwind uwtable
define dso_local i64 @iwjsreg_get_bool(ptr noundef readonly %0, ptr noundef readonly %1, ptr noundef writeonly %2) local_unnamed_addr #1 {
  %4 = icmp ne ptr %0, null
  %5 = icmp ne ptr %1, null
  %or.cond = and i1 %4, %5
  %6 = icmp ne ptr %2, null
  %or.cond3 = and i1 %or.cond, %6
  br i1 %or.cond3, label %7, label %38

7:                                                ; preds = %3
  store i8 0, ptr %2, align 1, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 120
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %0, i64 144
  %11 = load ptr, ptr %10, align 8, !tbaa !14
  %12 = tail call i64 %9(ptr noundef %11) #2
  %.not = icmp eq i64 %12, 0
  br i1 %.not, label %17, label %13, !prof !15

13:                                               ; preds = %7
  %14 = load ptr, ptr %8, align 8, !tbaa !9
  %15 = load ptr, ptr %10, align 8, !tbaa !14
  %16 = tail call i64 %14(ptr noundef %15) #2
  br label %38

17:                                               ; preds = %7
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  %20 = getelementptr inbounds i8, ptr %19, i64 40
  %.02944 = load ptr, ptr %20, align 8, !tbaa !17
  %.not38.not45 = icmp eq ptr %.02944, null
  br i1 %.not38.not45, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %17, %33
  %.02946 = phi ptr [ %.029, %33 ], [ %.02944, %17 ]
  %21 = getelementptr inbounds i8, ptr %.02946, i64 24
  %22 = load ptr, ptr %21, align 8, !tbaa !18
  %.not39 = icmp eq ptr %22, null
  br i1 %.not39, label %33, label %23

23:                                               ; preds = %.lr.ph
  %24 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %22, ptr noundef nonnull dereferenceable(1) %1) #3
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %33

26:                                               ; preds = %23
  %27 = getelementptr inbounds i8, ptr %.02946, i64 52
  %28 = load i32, ptr %27, align 4, !tbaa !20
  %29 = icmp eq i32 %28, 2
  br i1 %29, label %30, label %33

30:                                               ; preds = %26
  %31 = getelementptr inbounds i8, ptr %.02946, i64 56
  %32 = load i8, ptr %31, align 8, !tbaa !21, !range !22, !noundef !23
  store i8 %32, ptr %2, align 1, !tbaa !5
  br label %.loopexit

33:                                               ; preds = %.lr.ph, %23, %26
  %.029 = load ptr, ptr %.02946, align 8, !tbaa !17
  %.not38.not = icmp eq ptr %.029, null
  br i1 %.not38.not, label %.loopexit, label %.lr.ph, !llvm.loop !24

.loopexit:                                        ; preds = %33, %17, %30
  %spec.select = phi i64 [ 0, %30 ], [ 70004, %17 ], [ 70004, %33 ]
  %34 = getelementptr inbounds i8, ptr %0, i64 136
  %35 = load ptr, ptr %34, align 8, !tbaa !26
  %36 = load ptr, ptr %10, align 8, !tbaa !14
  %37 = tail call i64 %35(ptr noundef %36) #2
  %.not40 = icmp eq i64 %37, 0
  %spec.select42 = select i1 %.not40, i64 %spec.select, i64 %37
  br label %38

38:                                               ; preds = %.loopexit, %13, %3
  %.1 = phi i64 [ 70017, %3 ], [ %16, %13 ], [ %spec.select42, %.loopexit ]
  ret i64 %.1
}

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LowerExpectIntrinsicPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass