; LLVM IR from niessner/Matterport :: code/gaps/pkgs/RNBasics/json.ll (ZN4Json5ValueD2Ev)

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

%"class.Json::Value" = type { %"union.Json::Value::ValueHolder", i16, ptr, i64, i64 }
%"union.Json::Value::ValueHolder" = type { i64 }
%"struct.Json::Value::CommentInfo" = type { ptr }

@.str.8 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [6 x i8], align 1
@__PRETTY_FUNCTION__._ZN4Json5ValueD2Ev = external hidden unnamed_addr constant [22 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZN4JsonL18releaseStringValueEPc(ptr noundef) #2

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #3

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPvm(ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4Json5ValueD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %0) unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %"class.Json::Value", ptr %3, i32 0, i32 1
  %5 = load i16, ptr %4, align 8
  %6 = and i16 %5, 255
  %7 = zext i16 %6 to i32
  switch i32 %7, label %27 [
    i32 0, label %8
    i32 1, label %8
    i32 2, label %8
    i32 3, label %8
    i32 5, label %8
    i32 4, label %9
    i32 6, label %21
    i32 7, label %21
  ]

8:                                                ; preds = %1, %1, %1, %1, %1
  br label %28

9:                                                ; preds = %1
  %10 = getelementptr inbounds %"class.Json::Value", ptr %3, i32 0, i32 1
  %11 = load i16, ptr %10, align 8
  %12 = lshr i16 %11, 8
  %13 = and i16 %12, 1
  %14 = zext i16 %13 to i32
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %20

16:                                               ; preds = %9
  %17 = getelementptr inbounds %"class.Json::Value", ptr %3, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  invoke void @_ZN4JsonL18releaseStringValueEPc(ptr noundef %18)
          to label %19 unwind label %50

19:                                               ; preds = %16
  br label %20

20:                                               ; preds = %19, %9
  br label %28

21:                                               ; preds = %1, %1
  %22 = getelementptr inbounds %"class.Json::Value", ptr %3, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = icmp eq ptr %23, null
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  call void @_ZNSt3mapIN4Json5Value8CZStringES1_St4lessIS2_ESaISt4pairIKS2_S1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %23) #5
  call void @_ZdlPvm(ptr noundef %23, i64 noundef 48) #6
  br label %26

26:                                               ; preds = %25, %21
  br label %28

27:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.48, ptr noundef @.str.8, i32 noundef 2880, ptr noundef @__PRETTY_FUNCTION__._ZN4Json5ValueD2Ev) #7
  unreachable

28:                                               ; preds = %26, %20, %8
  %29 = getelementptr inbounds %"class.Json::Value", ptr %3, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !10
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %49

32:                                               ; preds = %28
  %33 = getelementptr inbounds %"class.Json::Value", ptr %3, i32 0, i32 2
  %34 = load ptr, ptr %33, align 8, !tbaa !10
  %35 = icmp eq ptr %34, null
  br i1 %35, label %48, label %36

36:                                               ; preds = %32
  %37 = getelementptr inbounds i8, ptr %34, i64 -8
  %38 = load i64, ptr %37, align 8
  %39 = getelementptr inbounds %"struct.Json::Value::CommentInfo", ptr %34, i64 %38
  %40 = icmp eq ptr %34, %39
  br i1 %40, label %45, label %41

41:                                               ; preds = %41, %36
  %42 = phi ptr [ %39, %36 ], [ %43, %41 ]
  %43 = getelementptr inbounds %"struct.Json::Value::CommentInfo", ptr %42, i64 -1
  call void @_ZN4Json5Value11CommentInfoD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %43) #5
  %44 = icmp eq ptr %43, %34
  br i1 %44, label %45, label %41

45:                                               ; preds = %41, %36
  %46 = mul i64 8, %38
  %47 = add i64 %46, 8
  call void @_ZdaPvm(ptr noundef %37, i64 noundef %47) #6
  br label %48

48:                                               ; preds = %45, %32
  br label %49

49:                                               ; preds = %48, %28
  ret void

50:                                               ; preds = %16
  %51 = landingpad { ptr, i32 }
          catch ptr null
  %52 = extractvalue { ptr, i32 } %51, 0
  call void @__clang_call_terminate(ptr %52) #7
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapIN4Json5Value8CZStringES1_St4lessIS2_ESaISt4pairIKS2_S1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #4 align 2

declare void @_ZN4Json5Value11CommentInfoD1Ev(ptr)

attributes #0 = { noreturn 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 #1 = { nobuiltin 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 #2 = { inlinehint mustprogress 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 = { noinline noreturn nounwind uwtable "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 = { mustprogress 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 = { builtin nounwind }
attributes #7 = { noreturn 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++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 16}
!11 = !{!"_ZTSN4Json5ValueE", !7, i64 0, !12, i64 8, !13, i64 9, !6, i64 16, !14, i64 24, !14, i64 32}
!12 = !{!"_ZTSN4Json9ValueTypeE", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"long", !7, i64 0}


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

%"struct.Json::Value::CommentInfo" = type { ptr }

@.str.8 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [6 x i8], align 1
@__PRETTY_FUNCTION__._ZN4Json5ValueD2Ev = external hidden unnamed_addr constant [22 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZN4JsonL18releaseStringValueEPc(ptr noundef) local_unnamed_addr #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4Json5ValueD2Ev(ptr nocapture noundef nonnull readonly align 8 dereferenceable(40) %0) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i16, ptr %2, align 8
  %trunc = trunc i16 %3 to i8
  switch i8 %trunc, label %12 [
    i8 0, label %13
    i8 1, label %13
    i8 2, label %13
    i8 3, label %13
    i8 5, label %13
    i8 4, label %4
    i8 6, label %8
    i8 7, label %8
  ]

4:                                                ; preds = %1
  %5 = and i16 %3, 256
  %.not = icmp eq i16 %5, 0
  br i1 %.not, label %13, label %6

6:                                                ; preds = %4
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  tail call void @_ZN4JsonL18releaseStringValueEPc(ptr noundef %7)
  br label %13

8:                                                ; preds = %1, %1
  %9 = load ptr, ptr %0, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %13, label %11

11:                                               ; preds = %8
  tail call void @_ZNSt3mapIN4Json5Value8CZStringES1_St4lessIS2_ESaISt4pairIKS2_S1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %9) #4
  tail call void @_ZdlPvm(ptr noundef nonnull %9, i64 noundef 48) #5
  br label %13

12:                                               ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.48, ptr noundef nonnull @.str.8, i32 noundef 2880, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4Json5ValueD2Ev) #6
  unreachable

13:                                               ; preds = %8, %11, %4, %6, %1, %1, %1, %1, %1
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !8
  %.not3 = icmp eq ptr %15, null
  br i1 %.not3, label %26, label %16

16:                                               ; preds = %13
  %17 = getelementptr inbounds i8, ptr %15, i64 -8
  %18 = load i64, ptr %17, align 8
  %19 = icmp eq i64 %18, 0
  br i1 %19, label %.loopexit, label %.preheader.preheader

.preheader.preheader:                             ; preds = %16
  %20 = getelementptr inbounds %"struct.Json::Value::CommentInfo", ptr %15, i64 %18
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %21 = phi ptr [ %22, %.preheader ], [ %20, %.preheader.preheader ]
  %22 = getelementptr inbounds i8, ptr %21, i64 -8
  tail call void @_ZN4Json5Value11CommentInfoD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %22) #4
  %23 = icmp eq ptr %22, %15
  br i1 %23, label %.loopexit, label %.preheader

.loopexit:                                        ; preds = %.preheader, %16
  %24 = shl i64 %18, 3
  %25 = add i64 %24, 8
  tail call void @_ZdaPvm(ptr noundef nonnull %17, i64 noundef %25) #5
  br label %26

26:                                               ; preds = %.loopexit, %13
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapIN4Json5Value8CZStringES1_St4lessIS2_ESaISt4pairIKS2_S1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #3 align 2

declare void @_ZN4Json5Value11CommentInfoD1Ev(ptr) local_unnamed_addr

attributes #0 = { noreturn 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 #1 = { nobuiltin 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 #2 = { inlinehint mustprogress 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 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 }
attributes #5 = { builtin nounwind }
attributes #6 = { noreturn 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !12, i64 16}
!9 = !{!"_ZTSN4Json5ValueE", !6, i64 0, !10, i64 8, !11, i64 9, !12, i64 16, !13, i64 24, !13, i64 32}
!10 = !{!"_ZTSN4Json9ValueTypeE", !6, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = !{!"any pointer", !6, i64 0}
!13 = !{!"long", !6, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass