; LLVM IR from Slingshot-Physics/slingshot-community :: datamodel (helper_json_to_data)

; 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.json_value_s = type { i32, ptr, %union.anon }
%union.anon = type { %struct.json_object_s }
%struct.json_object_s = type { i32, i32, ptr, ptr }
%struct.json_array_s = type { i32, i32, ptr }

@.str.4 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [46 x i8], align 1

declare i32 @printf(ptr noundef, ...) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @get_const_field_by_name(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @copy_filled_dynamic_object_array_field(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, i32 noundef %6) #2 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store i32 %2, ptr %11, align 4, !tbaa !9
  store i32 %3, ptr %12, align 4, !tbaa !9
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store i32 %6, ptr %15, align 4, !tbaa !9
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.json_value_s, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !11
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %26

24:                                               ; preds = %7
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  store i32 0, ptr %8, align 4
  br label %110

26:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  %29 = call ptr @get_const_field_by_name(ptr noundef %27, ptr noundef %28)
  store ptr %29, ptr %16, align 8, !tbaa !5
  %30 = load ptr, ptr %16, align 8, !tbaa !5
  %31 = icmp eq ptr %30, null
  br i1 %31, label %44, label %32

32:                                               ; preds = %26
  %33 = load ptr, ptr %16, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.json_value_s, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 8, !tbaa !11
  %36 = icmp ne i32 %35, 1
  br i1 %36, label %44, label %37

37:                                               ; preds = %32
  %38 = load ptr, ptr %16, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.json_value_s, ptr %38, i32 0, i32 2
  %40 = getelementptr inbounds %struct.json_array_s, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 8, !tbaa !13
  %42 = load i32, ptr %11, align 4, !tbaa !9
  %43 = icmp ult i32 %41, %42
  br i1 %43, label %44, label %68

44:                                               ; preds = %37, %32, %26
  %45 = load ptr, ptr %16, align 8, !tbaa !5
  %46 = icmp eq ptr %45, null
  br i1 %46, label %47, label %50

47:                                               ; preds = %44
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, ptr noundef %48)
  br label %67

50:                                               ; preds = %44
  %51 = load ptr, ptr %16, align 8, !tbaa !5
  %52 = icmp eq ptr %51, null
  %53 = zext i1 %52 to i32
  %54 = load ptr, ptr %16, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.json_value_s, ptr %54, i32 0, i32 0
  %56 = load i32, ptr %55, align 8, !tbaa !11
  %57 = icmp ne i32 %56, 1
  %58 = zext i1 %57 to i32
  %59 = load ptr, ptr %16, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.json_value_s, ptr %59, i32 0, i32 2
  %61 = getelementptr inbounds %struct.json_array_s, ptr %60, i32 0, i32 0
  %62 = load i32, ptr %61, align 8, !tbaa !13
  %63 = load i32, ptr %11, align 4, !tbaa !9
  %64 = icmp ult i32 %62, %63
  %65 = zext i1 %64 to i32
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %53, i32 noundef %58, i32 noundef %65)
  br label %67

67:                                               ; preds = %50, %47
  store i32 0, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %109

68:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %103, %68
  %70 = load i32, ptr %18, align 4, !tbaa !9
  %71 = load i32, ptr %11, align 4, !tbaa !9
  %72 = icmp ult i32 %70, %71
  br i1 %72, label %73, label %77

73:                                               ; preds = %69
  %74 = load i32, ptr %18, align 4, !tbaa !9
  %75 = load i32, ptr %12, align 4, !tbaa !9
  %76 = icmp ult i32 %74, %75
  br label %77

77:                                               ; preds = %73, %69
  %78 = phi i1 [ false, %69 ], [ %76, %73 ]
  br i1 %78, label %80, label %79

79:                                               ; preds = %77
  store i32 2, ptr %17, align 4
  br label %106

80:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  %81 = load ptr, ptr %16, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.json_value_s, ptr %81, i32 0, i32 2
  %83 = getelementptr inbounds %struct.json_array_s, ptr %82, i32 0, i32 2
  %84 = load ptr, ptr %83, align 8, !tbaa !13
  %85 = load i32, ptr %18, align 4, !tbaa !9
  %86 = zext i32 %85 to i64
  %87 = getelementptr inbounds %struct.json_value_s, ptr %84, i64 %86
  store ptr %87, ptr %19, align 8, !tbaa !5
  %88 = load ptr, ptr %13, align 8, !tbaa !5
  %89 = load ptr, ptr %19, align 8, !tbaa !5
  %90 = load ptr, ptr %14, align 8, !tbaa !5
  %91 = load i32, ptr %18, align 4, !tbaa !9
  %92 = load i32, ptr %15, align 4, !tbaa !9
  %93 = mul i32 %91, %92
  %94 = zext i32 %93 to i64
  %95 = getelementptr inbounds i8, ptr %90, i64 %94
  %96 = call i32 %88(ptr noundef %89, ptr noundef %95)
  %97 = icmp ne i32 %96, 0
  br i1 %97, label %99, label %98

98:                                               ; preds = %80
  store i32 0, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %100

99:                                               ; preds = %80
  store i32 0, ptr %17, align 4
  br label %100

100:                                              ; preds = %99, %98
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  %101 = load i32, ptr %17, align 4
  switch i32 %101, label %106 [
    i32 0, label %102
  ]

102:                                              ; preds = %100
  br label %103

103:                                              ; preds = %102
  %104 = load i32, ptr %18, align 4, !tbaa !9
  %105 = add i32 %104, 1
  store i32 %105, ptr %18, align 4, !tbaa !9
  br label %69, !llvm.loop !14

106:                                              ; preds = %100, %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  %107 = load i32, ptr %17, align 4
  switch i32 %107, label %109 [
    i32 2, label %108
  ]

108:                                              ; preds = %106
  store i32 1, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %109

109:                                              ; preds = %108, %106, %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  br label %110

110:                                              ; preds = %109, %24
  %111 = load i32, ptr %8, align 4
  ret i32 %111
}

attributes #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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"json_value_s", !10, i64 0, !6, i64 8, !7, i64 16}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

%struct.json_value_s = type { i32, ptr, %union.anon }
%union.anon = type { %struct.json_object_s }
%struct.json_object_s = type { i32, i32, ptr, ptr }

@.str.4 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [46 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @get_const_field_by_name(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @copy_filled_dynamic_object_array_field(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef readonly %4, ptr noundef %5, i32 noundef %6) local_unnamed_addr #1 {
  %8 = load i32, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %11, label %9

9:                                                ; preds = %7
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %._crit_edge

11:                                               ; preds = %7
  %12 = tail call ptr @get_const_field_by_name(ptr noundef nonnull %0, ptr noundef %1)
  %13 = icmp eq ptr %12, null
  br i1 %13, label %.critedge, label %14

14:                                               ; preds = %11
  %15 = load i32, ptr %12, align 8, !tbaa !5
  %.not34 = icmp ne i32 %15, 1
  %16 = getelementptr inbounds i8, ptr %12, i64 16
  %17 = load i32, ptr %16, align 8, !tbaa !11
  %18 = icmp ult i32 %17, %2
  %or.cond = select i1 %.not34, i1 true, i1 %18
  br i1 %or.cond, label %._crit_edge44, label %.preheader

.preheader:                                       ; preds = %14
  %19 = getelementptr inbounds i8, ptr %12, i64 24
  %invariant.umin = tail call i32 @llvm.umin.i32(i32 %2, i32 %3)
  %.not3839 = icmp eq i32 %invariant.umin, 0
  br i1 %.not3839, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader
  %20 = zext i32 %invariant.umin to i64
  %21 = load ptr, ptr %19, align 8, !tbaa !11
  %22 = tail call i32 %4(ptr noundef %21, ptr noundef %5) #3
  %.not35.not45 = icmp eq i32 %22, 0
  br i1 %.not35.not45, label %._crit_edge, label %.lr.ph47

.critedge:                                        ; preds = %11
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, ptr noundef %1)
  br label %._crit_edge

._crit_edge44:                                    ; preds = %14
  %24 = icmp ne i32 %15, 1
  %25 = zext i1 %24 to i32
  %26 = icmp ult i32 %17, %2
  %27 = zext i1 %26 to i32
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i32 noundef 0, i32 noundef %25, i32 noundef %27)
  br label %._crit_edge

.lr.ph47:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv46 = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv46, 1
  %exitcond = icmp eq i64 %indvars.iv.next, %20
  br i1 %exitcond, label %._crit_edge.loopexit.loopexit, label %.lr.ph, !llvm.loop !12

.lr.ph:                                           ; preds = %.lr.ph47
  %29 = load ptr, ptr %19, align 8, !tbaa !11
  %30 = getelementptr inbounds %struct.json_value_s, ptr %29, i64 %indvars.iv.next
  %31 = trunc nuw i64 %indvars.iv.next to i32
  %32 = mul i32 %31, %6
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds i8, ptr %5, i64 %33
  %35 = tail call i32 %4(ptr noundef nonnull %30, ptr noundef %34) #3
  %.not35.not = icmp eq i32 %35, 0
  br i1 %.not35.not, label %._crit_edge.loopexit.loopexit, label %.lr.ph47, !llvm.loop !12

._crit_edge.loopexit.loopexit:                    ; preds = %.lr.ph47, %.lr.ph
  %.not38.le = icmp uge i64 %indvars.iv.next, %20
  %36 = zext i1 %.not38.le to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.preheader, %._crit_edge.loopexit.loopexit, %.preheader, %._crit_edge44, %.critedge, %9
  %.4 = phi i32 [ 0, %9 ], [ 0, %._crit_edge44 ], [ 0, %.critedge ], [ 1, %.preheader ], [ 0, %.lr.ph.preheader ], [ %36, %._crit_edge.loopexit.loopexit ]
  ret i32 %.4
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #2

attributes #0 = { nofree 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 0}
!6 = !{!"json_value_s", !7, i64 0, !10, i64 8, !8, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!8, !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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