; LLVM IR from chensoft/libsocket :: lib/libchen/src/data (json)

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

@__const._ZN4chen4json6decodeEbRKNS_8iterator7erasureISt18input_iterator_tagKhS4_PS4_lEERS6_S9_.t = external hidden unnamed_addr constant [5 x i8], align 1
@__const._ZN4chen4json6decodeEbRKNS_8iterator7erasureISt18input_iterator_tagKhS4_PS4_lEERS6_S9_.f = external hidden unnamed_addr constant [6 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(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4chen4json9exceptionERKNS_8iterator7erasureISt18input_iterator_tagKhS4_PS4_lEERS6_S9_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZNK4chen8iterator7erasureISt18input_iterator_tagKhS3_PS3_lEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK4chen8iterator7erasureISt18input_iterator_tagKhS3_PS3_lEeqERKS5_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN4chen8iterator7erasureISt18input_iterator_tagKhS3_PS3_lEppEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4chen4json6decodeEbRKNS_8iterator7erasureISt18input_iterator_tagKhS4_PS4_lEERS6_S9_(i1 noundef zeroext %0, ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #2 align 2 {
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca [5 x i8], align 1
  %10 = alloca [6 x i8], align 1
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = zext i1 %0 to i8
  store i8 %14, ptr %5, align 1, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 5, ptr %9) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %9, ptr align 1 @__const._ZN4chen4json6decodeEbRKNS_8iterator7erasureISt18input_iterator_tagKhS4_PS4_lEERS6_S9_.t, i64 5, i1 false)
  call void @llvm.lifetime.start.p0(i64 6, ptr %10) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %10, ptr align 1 @__const._ZN4chen4json6decodeEbRKNS_8iterator7erasureISt18input_iterator_tagKhS4_PS4_lEERS6_S9_.f, i64 6, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %15 = load i8, ptr %5, align 1, !tbaa !5, !range !11, !noundef !12
  %16 = trunc i8 %15 to i1
  br i1 %16, label %17, label %19

17:                                               ; preds = %4
  %18 = getelementptr inbounds [5 x i8], ptr %9, i64 0, i64 0
  br label %21

19:                                               ; preds = %4
  %20 = getelementptr inbounds [6 x i8], ptr %10, i64 0, i64 0
  br label %21

21:                                               ; preds = %19, %17
  %22 = phi ptr [ %18, %17 ], [ %20, %19 ]
  store ptr %22, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %23 = load i8, ptr %5, align 1, !tbaa !5, !range !11, !noundef !12
  %24 = trunc i8 %23 to i1
  %25 = zext i1 %24 to i64
  %26 = select i1 %24, i64 4, i64 5
  store i64 %26, ptr %12, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  store i64 0, ptr %13, align 8, !tbaa !13
  br label %27

27:                                               ; preds = %51, %21
  %28 = load i64, ptr %13, align 8, !tbaa !13
  %29 = load i64, ptr %12, align 8, !tbaa !13
  %30 = icmp ult i64 %28, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %56

32:                                               ; preds = %27
  %33 = load ptr, ptr %7, align 8, !tbaa !9
  %34 = load ptr, ptr %8, align 8, !tbaa !9
  %35 = call noundef zeroext i1 @_ZNK4chen8iterator7erasureISt18input_iterator_tagKhS3_PS3_lEeqERKS5_(ptr noundef nonnull align 8 dereferenceable(8) %33, ptr noundef nonnull align 8 dereferenceable(8) %34)
  br i1 %35, label %46, label %36

36:                                               ; preds = %32
  %37 = load ptr, ptr %7, align 8, !tbaa !9
  %38 = call noundef zeroext i8 @_ZNK4chen8iterator7erasureISt18input_iterator_tagKhS3_PS3_lEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %37)
  %39 = zext i8 %38 to i32
  %40 = load ptr, ptr %11, align 8, !tbaa !9
  %41 = load i64, ptr %13, align 8, !tbaa !13
  %42 = getelementptr inbounds i8, ptr %40, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !15
  %44 = sext i8 %43 to i32
  %45 = icmp ne i32 %39, %44
  br i1 %45, label %46, label %50

46:                                               ; preds = %36, %32
  %47 = load ptr, ptr %6, align 8, !tbaa !9
  %48 = load ptr, ptr %7, align 8, !tbaa !9
  %49 = load ptr, ptr %8, align 8, !tbaa !9
  call void @_ZN4chen4json9exceptionERKNS_8iterator7erasureISt18input_iterator_tagKhS4_PS4_lEERS6_S9_(ptr noundef nonnull align 8 dereferenceable(8) %47, ptr noundef nonnull align 8 dereferenceable(8) %48, ptr noundef nonnull align 8 dereferenceable(8) %49)
  br label %50

50:                                               ; preds = %46, %36
  br label %51

51:                                               ; preds = %50
  %52 = load i64, ptr %13, align 8, !tbaa !13
  %53 = add i64 %52, 1
  store i64 %53, ptr %13, align 8, !tbaa !13
  %54 = load ptr, ptr %7, align 8, !tbaa !9
  %55 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4chen8iterator7erasureISt18input_iterator_tagKhS3_PS3_lEppEv(ptr noundef nonnull align 8 dereferenceable(8) %54)
  br label %27, !llvm.loop !16

56:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 6, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 5, ptr %9) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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, !6, i64 0}
!6 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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

@__const._ZN4chen4json6decodeEbRKNS_8iterator7erasureISt18input_iterator_tagKhS4_PS4_lEERS6_S9_.t = external hidden unnamed_addr constant [5 x i8], align 1
@__const._ZN4chen4json6decodeEbRKNS_8iterator7erasureISt18input_iterator_tagKhS4_PS4_lEERS6_S9_.f = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4chen4json9exceptionERKNS_8iterator7erasureISt18input_iterator_tagKhS4_PS4_lEERS6_S9_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZNK4chen8iterator7erasureISt18input_iterator_tagKhS3_PS3_lEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK4chen8iterator7erasureISt18input_iterator_tagKhS3_PS3_lEeqERKS5_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN4chen8iterator7erasureISt18input_iterator_tagKhS3_PS3_lEppEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4chen4json6decodeEbRKNS_8iterator7erasureISt18input_iterator_tagKhS4_PS4_lEERS6_S9_(i1 noundef zeroext %0, ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) local_unnamed_addr #0 align 2 {
  %5 = select i1 %0, ptr @__const._ZN4chen4json6decodeEbRKNS_8iterator7erasureISt18input_iterator_tagKhS4_PS4_lEERS6_S9_.t, ptr @__const._ZN4chen4json6decodeEbRKNS_8iterator7erasureISt18input_iterator_tagKhS4_PS4_lEERS6_S9_.f
  %6 = select i1 %0, i64 4, i64 5
  br label %8

7:                                                ; preds = %17
  ret void

8:                                                ; preds = %4, %17
  %.013 = phi i64 [ 0, %4 ], [ %18, %17 ]
  %9 = tail call noundef zeroext i1 @_ZNK4chen8iterator7erasureISt18input_iterator_tagKhS3_PS3_lEeqERKS5_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3)
  br i1 %9, label %16, label %10

10:                                               ; preds = %8
  %11 = tail call noundef zeroext i8 @_ZNK4chen8iterator7erasureISt18input_iterator_tagKhS3_PS3_lEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %2)
  %12 = zext i8 %11 to i32
  %13 = getelementptr inbounds i8, ptr %5, i64 %.013
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %15 = sext i8 %14 to i32
  %.not = icmp eq i32 %12, %15
  br i1 %.not, label %17, label %16

16:                                               ; preds = %10, %8
  tail call void @_ZN4chen4json9exceptionERKNS_8iterator7erasureISt18input_iterator_tagKhS4_PS4_lEERS6_S9_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3)
  br label %17

17:                                               ; preds = %10, %16
  %18 = add nuw nsw i64 %.013, 1
  %19 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4chen8iterator7erasureISt18input_iterator_tagKhS3_PS3_lEppEv(ptr noundef nonnull align 8 dereferenceable(8) %2)
  %exitcond.not = icmp eq i64 %18, %6
  br i1 %exitcond.not, label %7, label %8, !llvm.loop !8
}

attributes #0 = { mustprogress 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" }

!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 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass