; 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_i64(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 %113

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 i64 0, ptr %23, align 8, !tbaa !9
  %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 %112

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 = %80, %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 %84

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 %79

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 %79

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, 3
  br i1 %72, label %73, label %78

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 i64, ptr %75, align 8, !tbaa !23
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %76, ptr %77, align 8, !tbaa !9
  store i8 1, ptr %10, align 1, !tbaa !11
  store i32 2, ptr %9, align 4
  br label %84

78:                                               ; preds = %68
  br label %79

79:                                               ; preds = %78, %61, %56
  br label %80

80:                                               ; preds = %79
  %81 = load ptr, ptr %11, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.jbl_node, ptr %81, i32 0, i32 0
  %83 = load ptr, ptr %82, align 8, !tbaa !24
  store ptr %83, ptr %11, align 8, !tbaa !5
  br label %52, !llvm.loop !25

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

85:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.iwjsreg, ptr %86, i32 0, i32 9
  %88 = load ptr, ptr %87, align 8, !tbaa !27
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.iwjsreg, ptr %89, i32 0, i32 10
  %91 = load ptr, ptr %90, align 8, !tbaa !17
  %92 = call i64 %88(ptr noundef %91)
  store i64 %92, ptr %12, align 8, !tbaa !9
  %93 = load i64, ptr %12, align 8, !tbaa !9
  %94 = icmp ne i64 %93, 0
  br i1 %94, label %95, label %103

95:                                               ; preds = %85
  %96 = load i64, ptr %8, align 8, !tbaa !9
  %97 = icmp ne i64 %96, 0
  br i1 %97, label %100, label %98

98:                                               ; preds = %95
  %99 = load i64, ptr %12, align 8, !tbaa !9
  store i64 %99, ptr %8, align 8, !tbaa !9
  br label %102

100:                                              ; preds = %95
  %101 = load i64, ptr %12, align 8, !tbaa !9
  call void @iwlog3(i32 noundef 0, i64 noundef %101, ptr noundef @.str.3, i32 noundef 727, ptr noundef @.str.4)
  br label %102

102:                                              ; preds = %100, %98
  br label %103

103:                                              ; preds = %102, %85
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  %104 = load i64, ptr %8, align 8, !tbaa !9
  %105 = icmp ne i64 %104, 0
  br i1 %105, label %110, label %106

106:                                              ; preds = %103
  %107 = load i8, ptr %10, align 1, !tbaa !11, !range !28, !noundef !29
  %108 = trunc i8 %107 to i1
  br i1 %108, label %110, label %109

109:                                              ; preds = %106
  store i64 70004, ptr %8, align 8, !tbaa !9
  br label %110

110:                                              ; preds = %109, %106, %103
  %111 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %111, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %112

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

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

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 = !{!20, !6, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!14, !6, i64 136}
!28 = !{i8 0, i8 2}
!29 = !{}


; 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_i64(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 i64 0, ptr %2, align 8, !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 !15
  %12 = tail call i64 %9(ptr noundef %11) #2
  %.not = icmp eq i64 %12, 0
  br i1 %.not, label %17, label %13, !prof !16

13:                                               ; preds = %7
  %14 = load ptr, ptr %8, align 8, !tbaa !9
  %15 = load ptr, ptr %10, align 8, !tbaa !15
  %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 !17
  %20 = getelementptr inbounds i8, ptr %19, i64 40
  %.02944 = load ptr, ptr %20, align 8, !tbaa !18
  %.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 !19
  %.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 !21
  %29 = icmp eq i32 %28, 3
  br i1 %29, label %30, label %33

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

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

.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 !25
  %36 = load ptr, ptr %10, align 8, !tbaa !15
  %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 = !{!"long", !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, !14, 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 = !{!"_Bool", !7, i64 0}
!15 = !{!10, !11, i64 144}
!16 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!17 = !{!10, !11, i64 8}
!18 = !{!11, !11, i64 0}
!19 = !{!20, !11, i64 24}
!20 = !{!"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}
!21 = !{!20, !13, i64 52}
!22 = !{!7, !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!10, !11, i64 136}


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