; 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

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

; Function Attrs: nounwind uwtable
define dso_local i64 @iwjsreg_at_i64(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) #4
  store i64 0, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %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 %101

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

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 %79 [
    i32 3, label %53
    i32 4, label %58
    i32 1, label %64
    i32 2, label %66
    i32 5, label %73
  ]

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 i64, ptr %55, align 8, !tbaa !20
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %56, ptr %57, align 8, !tbaa !9
  br label %80

58:                                               ; preds = %49
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.jbl_node, ptr %59, i32 0, i32 9
  %61 = load double, ptr %60, align 8, !tbaa !20
  %62 = fptosi double %61 to i64
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %62, ptr %63, align 8, !tbaa !9
  br label %80

64:                                               ; preds = %49
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 0, ptr %65, align 8, !tbaa !9
  br label %80

66:                                               ; preds = %49
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.jbl_node, ptr %67, i32 0, i32 9
  %69 = load i8, ptr %68, align 8, !tbaa !20, !range !21, !noundef !22
  %70 = trunc i8 %69 to i1
  %71 = zext i1 %70 to i64
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %71, ptr %72, align 8, !tbaa !9
  br label %80

73:                                               ; preds = %49
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.jbl_node, ptr %74, i32 0, i32 9
  %76 = load ptr, ptr %75, align 8, !tbaa !20
  %77 = call i64 @iw_strtoll(ptr noundef %76, i32 noundef 10, ptr noundef %8)
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %77, ptr %78, align 8, !tbaa !9
  br label %80

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

80:                                               ; preds = %79, %73, %66, %64, %58, %53
  br label %81

81:                                               ; preds = %80, %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.iwjsreg, ptr %82, i32 0, i32 9
  %84 = load ptr, ptr %83, align 8, !tbaa !23
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.iwjsreg, ptr %85, i32 0, i32 10
  %87 = load ptr, ptr %86, align 8, !tbaa !16
  %88 = call i64 %84(ptr noundef %87)
  store i64 %88, ptr %11, align 8, !tbaa !9
  %89 = load i64, ptr %11, align 8, !tbaa !9
  %90 = icmp ne i64 %89, 0
  br i1 %90, label %91, label %99

91:                                               ; preds = %81
  %92 = load i64, ptr %8, align 8, !tbaa !9
  %93 = icmp ne i64 %92, 0
  br i1 %93, label %96, label %94

94:                                               ; preds = %91
  %95 = load i64, ptr %11, align 8, !tbaa !9
  store i64 %95, ptr %8, align 8, !tbaa !9
  br label %98

96:                                               ; preds = %91
  %97 = load i64, ptr %11, align 8, !tbaa !9
  call void @iwlog3(i32 noundef 0, i64 noundef %97, ptr noundef @.str.3, i32 noundef 416, ptr noundef @.str.4)
  br label %98

98:                                               ; preds = %96, %94
  br label %99

99:                                               ; preds = %98, %81
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  %100 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %100, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %101

101:                                              ; preds = %99, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %102 = load i64, ptr %4, align 8
  ret i64 %102
}

declare i64 @iw_strtoll(ptr noundef, i32 noundef, ptr noundef) #2

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 }

!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 = !{!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

; 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_i64(ptr nocapture noundef readonly %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #2 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 120
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 144
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  %10 = tail call i64 %7(ptr noundef %9) #3
  %.not = icmp eq i64 %10, 0
  br i1 %.not, label %15, label %11, !prof !14

11:                                               ; preds = %3
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = load ptr, ptr %8, align 8, !tbaa !13
  %14 = tail call i64 %12(ptr noundef %13) #3
  br label %47

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

19:                                               ; preds = %15
  %20 = load ptr, ptr %5, align 8, !tbaa !18
  %21 = getelementptr inbounds i8, ptr %20, i64 52
  %22 = load i32, ptr %21, align 4, !tbaa !19
  switch i32 %22, label %39 [
    i32 3, label %23
    i32 4, label %26
    i32 1, label %30
    i32 2, label %31
    i32 5, label %35
  ]

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %20, i64 56
  %25 = load i64, ptr %24, align 8, !tbaa !21
  store i64 %25, ptr %2, align 8, !tbaa !16
  br label %40

26:                                               ; preds = %19
  %27 = getelementptr inbounds i8, ptr %20, i64 56
  %28 = load double, ptr %27, align 8, !tbaa !21
  %29 = fptosi double %28 to i64
  store i64 %29, ptr %2, align 8, !tbaa !16
  br label %40

30:                                               ; preds = %19
  store i64 0, ptr %2, align 8, !tbaa !16
  br label %40

31:                                               ; preds = %19
  %32 = getelementptr inbounds i8, ptr %20, i64 56
  %33 = load i8, ptr %32, align 8, !tbaa !21, !range !22, !noundef !23
  %34 = zext nneg i8 %33 to i64
  store i64 %34, ptr %2, align 8, !tbaa !16
  br label %40

35:                                               ; preds = %19
  %36 = getelementptr inbounds i8, ptr %20, i64 56
  %37 = load ptr, ptr %36, align 8, !tbaa !21
  %38 = call i64 @iw_strtoll(ptr noundef %37, i32 noundef 10, ptr noundef nonnull %4) #3
  store i64 %38, ptr %2, align 8, !tbaa !16
  br label %40

39:                                               ; preds = %19
  store i64 70030, ptr %4, align 8, !tbaa !16
  br label %40

40:                                               ; preds = %23, %26, %30, %31, %35, %39, %15
  %41 = getelementptr inbounds i8, ptr %0, i64 136
  %42 = load ptr, ptr %41, align 8, !tbaa !24
  %43 = load ptr, ptr %8, align 8, !tbaa !13
  %44 = call i64 %42(ptr noundef %43) #3
  %.not18 = icmp eq i64 %44, 0
  %.pre20 = load i64, ptr %4, align 8, !tbaa !16
  br i1 %.not18, label %47, label %45

45:                                               ; preds = %40
  %.not19 = icmp eq i64 %.pre20, 0
  br i1 %.not19, label %47, label %46

46:                                               ; preds = %45
  call void @iwlog3(i32 noundef 0, i64 noundef %44, ptr noundef nonnull @.str.3, i32 noundef 416, ptr noundef nonnull @.str.4) #3
  %.pre = load i64, ptr %4, align 8, !tbaa !16
  br label %47

47:                                               ; preds = %45, %40, %46, %11
  %.0 = phi i64 [ %14, %11 ], [ %.pre, %46 ], [ %.pre20, %40 ], [ %44, %45 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i64 %.0
}

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

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 = { 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 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 = !{!17, !17, i64 0}
!17 = !{!"long", !8, i64 0}
!18 = !{!7, !7, i64 0}
!19 = !{!20, !11, i64 52}
!20 = !{!"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}
!21 = !{!8, !8, i64 0}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!6, !7, i64 136}


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