; 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
declare noalias ptr @strdup(ptr noundef) #3

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

; Function Attrs: nounwind uwtable
define dso_local i64 @iwjsreg_get_str(ptr noundef %0, ptr noundef %1, ptr noundef %2) #5 {
  %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) #6
  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 %114

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #6
  store i8 0, ptr %10, align 1, !tbaa !11
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr null, ptr %23, align 8, !tbaa !5
  %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 %113

46:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %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 = %81, %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 %85

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

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) #7
  %67 = icmp eq i32 %66, 0
  br i1 %67, label %68, label %80

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, 5
  br i1 %72, label %73, label %79

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 ptr, ptr %75, align 8, !tbaa !23
  %77 = call noalias ptr @strdup(ptr noundef %76) #6
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %77, ptr %78, align 8, !tbaa !5
  store i8 1, ptr %10, align 1, !tbaa !11
  store i32 2, ptr %9, align 4
  br label %85

79:                                               ; preds = %68
  br label %80

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

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

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

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

96:                                               ; preds = %86
  %97 = load i64, ptr %8, align 8, !tbaa !9
  %98 = icmp ne i64 %97, 0
  br i1 %98, label %101, label %99

99:                                               ; preds = %96
  %100 = load i64, ptr %12, align 8, !tbaa !9
  store i64 %100, ptr %8, align 8, !tbaa !9
  br label %103

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

103:                                              ; preds = %101, %99
  br label %104

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

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

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

111:                                              ; preds = %110, %107, %104
  %112 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %112, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %113

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

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

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 "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 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 #6 = { nounwind }
attributes #7 = { 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: readwrite, inaccessiblemem: readwrite)
declare noalias ptr @strdup(ptr nocapture noundef readonly) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local i64 @iwjsreg_get_str(ptr noundef readonly %0, ptr noundef readonly %1, ptr noundef writeonly %2) local_unnamed_addr #2 {
  %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 %39

7:                                                ; preds = %3
  store ptr null, 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 !14
  %12 = tail call i64 %9(ptr noundef %11) #3
  %.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) #3
  br label %39

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 !5
  %.not38.not45 = icmp eq ptr %.02944, null
  br i1 %.not38.not45, label %.loopexit, label %.lr.ph

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

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

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

30:                                               ; preds = %26
  %31 = getelementptr inbounds i8, ptr %.02946, i64 56
  %32 = load ptr, ptr %31, align 8, !tbaa !20
  %33 = tail call noalias ptr @strdup(ptr noundef %32) #3
  store ptr %33, ptr %2, align 8, !tbaa !5
  br label %.loopexit

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

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

39:                                               ; 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: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #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 = { nounwind }
attributes #4 = { 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, !6, i64 120}
!10 = !{!"iwjsreg", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !7, i64 40, !11, i64 96, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !12, i64 152, !13, i64 156}
!11 = !{!"iwref_holder", !6, i64 0, !7, i64 8, !6, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!10, !6, i64 144}
!15 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!16 = !{!10, !6, i64 8}
!17 = !{!18, !6, i64 24}
!18 = !{!"jbl_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !12, i64 36, !6, i64 40, !12, i64 48, !12, i64 52, !7, i64 56}
!19 = !{!18, !12, i64 52}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!10, !6, i64 136}


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