; LLVM IR from Softmotions/iowow :: src/json (iwjser)

; 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.jbn_as_xml_spec = type { ptr, ptr, ptr, ptr, i8, ptr, i32, i8 }

@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [39 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

; Function Attrs: nounwind uwtable
define dso_local i64 @jbn_as_xml(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.jbn_as_xml_spec, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %19

11:                                               ; preds = %2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %19

14:                                               ; preds = %11
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.jbn_as_xml_spec, ptr %15, i32 0, i32 7
  %17 = load i8, ptr %16, align 4, !tbaa !9, !range !13, !noundef !14
  %18 = trunc i8 %17 to i1
  br i1 %18, label %20, label %19

19:                                               ; preds = %14, %11, %2
  store i64 70017, ptr %3, align 8
  br label %73

20:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 56, ptr %6) #4
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %21, i64 56, i1 false)
  %22 = getelementptr inbounds %struct.jbn_as_xml_spec, ptr %6, i32 0, i32 4
  %23 = load i8, ptr %22, align 8, !tbaa !15
  %24 = icmp ne i8 %23, 0
  br i1 %24, label %27, label %25

25:                                               ; preds = %20
  %26 = getelementptr inbounds %struct.jbn_as_xml_spec, ptr %6, i32 0, i32 4
  store i8 62, ptr %26, align 8, !tbaa !15
  br label %27

27:                                               ; preds = %25, %20
  %28 = getelementptr inbounds %struct.jbn_as_xml_spec, ptr %6, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !16
  %30 = icmp ne ptr %29, null
  br i1 %30, label %33, label %31

31:                                               ; preds = %27
  %32 = getelementptr inbounds %struct.jbn_as_xml_spec, ptr %6, i32 0, i32 2
  store ptr @.str, ptr %32, align 8, !tbaa !16
  br label %33

33:                                               ; preds = %31, %27
  %34 = getelementptr inbounds %struct.jbn_as_xml_spec, ptr %6, i32 0, i32 3
  %35 = load ptr, ptr %34, align 8, !tbaa !17
  %36 = icmp ne ptr %35, null
  br i1 %36, label %39, label %37

37:                                               ; preds = %33
  %38 = getelementptr inbounds %struct.jbn_as_xml_spec, ptr %6, i32 0, i32 3
  store ptr @.str.1, ptr %38, align 8, !tbaa !17
  br label %39

39:                                               ; preds = %37, %33
  %40 = getelementptr inbounds %struct.jbn_as_xml_spec, ptr %6, i32 0, i32 5
  %41 = load ptr, ptr %40, align 8, !tbaa !18
  %42 = icmp ne ptr %41, null
  br i1 %42, label %45, label %43

43:                                               ; preds = %39
  %44 = getelementptr inbounds %struct.jbn_as_xml_spec, ptr %6, i32 0, i32 5
  store ptr @.str.2, ptr %44, align 8, !tbaa !18
  br label %45

45:                                               ; preds = %43, %39
  %46 = getelementptr inbounds %struct.jbn_as_xml_spec, ptr %6, i32 0, i32 7
  %47 = load i8, ptr %46, align 4, !tbaa !9, !range !13, !noundef !14
  %48 = trunc i8 %47 to i1
  br i1 %48, label %49, label %69

49:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %50 = getelementptr inbounds %struct.jbn_as_xml_spec, ptr %6, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !19
  %52 = getelementptr inbounds %struct.jbn_as_xml_spec, ptr %6, i32 0, i32 1
  %53 = load ptr, ptr %52, align 8, !tbaa !20
  %54 = call i64 %51(ptr noundef @.str.3, i32 noundef 38, i8 noundef signext 0, i32 noundef 0, ptr noundef %53)
  store i64 %54, ptr %7, align 8, !tbaa !21
  %55 = load i64, ptr %7, align 8, !tbaa !21
  %56 = icmp ne i64 %55, 0
  %57 = xor i1 %56, true
  %58 = xor i1 %57, true
  %59 = zext i1 %58 to i32
  %60 = sext i32 %59 to i64
  %61 = call i64 @llvm.expect.i64(i64 %60, i64 0)
  %62 = icmp ne i64 %61, 0
  br i1 %62, label %63, label %65

63:                                               ; preds = %49
  %64 = load i64, ptr %7, align 8, !tbaa !21
  store i64 %64, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %66

65:                                               ; preds = %49
  store i32 0, ptr %8, align 4
  br label %66

66:                                               ; preds = %65, %63
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  %67 = load i32, ptr %8, align 4
  switch i32 %67, label %72 [
    i32 0, label %68
  ]

68:                                               ; preds = %66
  br label %69

69:                                               ; preds = %68, %45
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = call i64 @_jbn_as_xml(ptr noundef %70, ptr noundef %6, i32 noundef 0)
  store i64 %71, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %72

72:                                               ; preds = %69, %66
  call void @llvm.lifetime.end.p0(i64 56, ptr %6) #4
  br label %73

73:                                               ; preds = %72, %19
  %74 = load i64, ptr %3, align 8
  ret i64 %74
}

; 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) #3

; Function Attrs: nounwind uwtable
declare hidden i64 @_jbn_as_xml(ptr noundef, ptr noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !12, i64 52}
!10 = !{!"jbn_as_xml_spec", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !7, i64 32, !6, i64 40, !11, i64 48, !12, i64 52}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!10, !7, i64 32}
!16 = !{!10, !6, i64 16}
!17 = !{!10, !6, i64 24}
!18 = !{!10, !6, i64 40}
!19 = !{!10, !6, i64 0}
!20 = !{!10, !6, i64 8}
!21 = !{!22, !22, i64 0}
!22 = !{!"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.jbn_as_xml_spec = type { ptr, ptr, ptr, ptr, i8, ptr, i32, i8 }

@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [39 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

; Function Attrs: nounwind uwtable
define dso_local i64 @jbn_as_xml(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #1 {
  %3 = alloca %struct.jbn_as_xml_spec, align 8
  %4 = icmp ne ptr %0, null
  %5 = icmp ne ptr %1, null
  %or.cond = and i1 %4, %5
  br i1 %or.cond, label %6, label %38

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 52
  %8 = load i8, ptr %7, align 4, !tbaa !5, !range !12, !noundef !13
  %9 = trunc nuw i8 %8 to i1
  br i1 %9, label %10, label %38

10:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %3) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %3, ptr noundef nonnull align 8 dereferenceable(56) %1, i64 56, i1 false)
  %11 = getelementptr inbounds i8, ptr %3, i64 32
  %12 = load i8, ptr %11, align 8, !tbaa !14
  %.not = icmp eq i8 %12, 0
  br i1 %.not, label %13, label %14

13:                                               ; preds = %10
  store i8 62, ptr %11, align 8, !tbaa !14
  br label %14

14:                                               ; preds = %13, %10
  %15 = getelementptr inbounds i8, ptr %3, i64 16
  %16 = load ptr, ptr %15, align 8, !tbaa !15
  %.not12 = icmp eq ptr %16, null
  br i1 %.not12, label %17, label %18

17:                                               ; preds = %14
  store ptr @.str, ptr %15, align 8, !tbaa !15
  br label %18

18:                                               ; preds = %17, %14
  %19 = getelementptr inbounds i8, ptr %3, i64 24
  %20 = load ptr, ptr %19, align 8, !tbaa !16
  %.not13 = icmp eq ptr %20, null
  br i1 %.not13, label %21, label %22

21:                                               ; preds = %18
  store ptr @.str.1, ptr %19, align 8, !tbaa !16
  br label %22

22:                                               ; preds = %21, %18
  %23 = getelementptr inbounds i8, ptr %3, i64 40
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %.not14 = icmp eq ptr %24, null
  br i1 %.not14, label %25, label %26

25:                                               ; preds = %22
  store ptr @.str.2, ptr %23, align 8, !tbaa !17
  br label %26

26:                                               ; preds = %25, %22
  %27 = getelementptr inbounds i8, ptr %3, i64 52
  %28 = load i8, ptr %27, align 4, !tbaa !5, !range !12, !noundef !13
  %29 = trunc nuw i8 %28 to i1
  br i1 %29, label %30, label %35

30:                                               ; preds = %26
  %31 = load ptr, ptr %3, align 8, !tbaa !18
  %32 = getelementptr inbounds i8, ptr %3, i64 8
  %33 = load ptr, ptr %32, align 8, !tbaa !19
  %34 = tail call i64 %31(ptr noundef nonnull @.str.3, i32 noundef 38, i8 noundef signext 0, i32 noundef 0, ptr noundef %33) #3
  %.not15 = icmp eq i64 %34, 0
  br i1 %.not15, label %35, label %37

35:                                               ; preds = %30, %26
  %36 = call i64 @_jbn_as_xml(ptr noundef nonnull %0, ptr noundef nonnull %3, i32 noundef 0)
  br label %37

37:                                               ; preds = %30, %35
  %.1 = phi i64 [ %36, %35 ], [ %34, %30 ]
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %3) #3
  br label %38

38:                                               ; preds = %2, %6, %37
  %.2 = phi i64 [ %.1, %37 ], [ 70017, %6 ], [ 70017, %2 ]
  ret i64 %.2
}

; Function Attrs: mustprogress 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) #2

; Function Attrs: nounwind uwtable
declare hidden i64 @_jbn_as_xml(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !11, i64 52}
!6 = !{!"jbn_as_xml_spec", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !8, i64 32, !7, i64 40, !10, i64 48, !11, i64 52}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!6, !8, i64 32}
!15 = !{!6, !7, i64 16}
!16 = !{!6, !7, i64 24}
!17 = !{!6, !7, i64 40}
!18 = !{!6, !7, i64 0}
!19 = !{!6, !7, i64 8}


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