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

; 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.polygon50 = type { i32, [50 x %struct.vector3] }
%struct.vector3 = type { [3 x float] }
%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 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = 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: nounwind uwtable
define dso_local i32 @polygon50_from_json(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %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 eq ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  br label %66

12:                                               ; preds = %2
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  store i32 0, ptr %3, align 4
  br label %66

16:                                               ; preds = %12
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = call i32 @verify_typename(ptr noundef %17, ptr noundef @.str)
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  store i32 0, ptr %3, align 4
  br label %66

21:                                               ; preds = %16
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.polygon50, ptr %23, i32 0, i32 0
  %25 = call i32 @copy_uint_field(ptr noundef %22, ptr noundef @.str.1, ptr noundef %24)
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %28, label %27

27:                                               ; preds = %21
  store i32 0, ptr %3, align 4
  br label %66

28:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = call ptr @get_const_field_by_name(ptr noundef %29, ptr noundef @.str.2)
  store ptr %30, ptr %6, align 8, !tbaa !5
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %34

33:                                               ; preds = %28
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %65

34:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %59, %34
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.polygon50, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 4, !tbaa !11
  %40 = icmp ult i32 %36, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %35
  store i32 2, ptr %7, align 4
  br label %62

42:                                               ; preds = %35
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.json_value_s, ptr %43, i32 0, i32 2
  %45 = getelementptr inbounds %struct.json_array_s, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !13
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds %struct.json_value_s, ptr %46, i64 %48
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.polygon50, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds [50 x %struct.vector3], ptr %51, i64 0, i64 %53
  %55 = call i32 @anon_vector3_from_json(ptr noundef %49, ptr noundef %54)
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %58, label %57

57:                                               ; preds = %42
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %62

58:                                               ; preds = %42
  br label %59

59:                                               ; preds = %58
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = add i32 %60, 1
  store i32 %61, ptr %8, align 4, !tbaa !9
  br label %35, !llvm.loop !14

62:                                               ; preds = %57, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %63 = load i32, ptr %7, align 4
  switch i32 %63, label %65 [
    i32 2, label %64
  ]

64:                                               ; preds = %62
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %65

65:                                               ; preds = %64, %62, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %66

66:                                               ; preds = %65, %27, %20, %15, %11
  %67 = load i32, ptr %3, align 4
  ret i32 %67
}

declare i32 @verify_typename(ptr noundef, ptr noundef) #2

declare i32 @copy_uint_field(ptr noundef, ptr noundef, ptr noundef) #2

declare ptr @get_const_field_by_name(ptr noundef, ptr noundef) #2

declare i32 @anon_vector3_from_json(ptr noundef, ptr noundef) #2

attributes #0 = { 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 = { "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 = !{!"polygon50", !10, i64 0, !7, i64 4}
!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 }
%struct.vector3 = type { [3 x float] }

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @polygon50_from_json(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  %4 = icmp eq ptr %1, null
  %or.cond = or i1 %3, %4
  br i1 %or.cond, label %._crit_edge, label %5

5:                                                ; preds = %2
  %6 = tail call i32 @verify_typename(ptr noundef nonnull %0, ptr noundef nonnull @.str) #2
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %._crit_edge, label %7

7:                                                ; preds = %5
  %8 = tail call i32 @copy_uint_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.1, ptr noundef nonnull %1) #2
  %.not20 = icmp eq i32 %8, 0
  br i1 %.not20, label %._crit_edge, label %9

9:                                                ; preds = %7
  %10 = tail call ptr @get_const_field_by_name(ptr noundef nonnull %0, ptr noundef nonnull @.str.2) #2
  %11 = icmp eq ptr %10, null
  br i1 %11, label %._crit_edge, label %.preheader

.preheader:                                       ; preds = %9
  %12 = getelementptr inbounds i8, ptr %10, i64 24
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %.not2223 = icmp eq i32 %13, 0
  br i1 %.not2223, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %14 = getelementptr inbounds i8, ptr %1, i64 4
  br label %18

15:                                               ; preds = %18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = zext i32 %16 to i64
  %.not22.not = icmp ult i64 %indvars.iv.next, %17
  br i1 %.not22.not, label %18, label %._crit_edge.loopexit, !llvm.loop !10

18:                                               ; preds = %.lr.ph, %15
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %15 ]
  %19 = load ptr, ptr %12, align 8, !tbaa !12
  %20 = getelementptr inbounds %struct.json_value_s, ptr %19, i64 %indvars.iv
  %21 = getelementptr inbounds [50 x %struct.vector3], ptr %14, i64 0, i64 %indvars.iv
  %22 = tail call i32 @anon_vector3_from_json(ptr noundef %20, ptr noundef nonnull %21) #2
  %.not21 = icmp ne i32 %22, 0
  br i1 %.not21, label %15, label %._crit_edge.loopexit

._crit_edge.loopexit:                             ; preds = %18, %15
  %23 = zext i1 %.not21 to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %.preheader, %._crit_edge.loopexit, %9, %7, %5, %2
  %.2 = phi i32 [ 0, %2 ], [ 0, %5 ], [ 0, %7 ], [ 0, %9 ], [ 1, %.preheader ], [ %23, %._crit_edge.loopexit ]
  ret i32 %.2
}

declare i32 @verify_typename(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @copy_uint_field(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @get_const_field_by_name(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @anon_vector3_from_json(ptr noundef, ptr noundef) local_unnamed_addr #1

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

!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 = !{!"polygon50", !7, i64 0, !8, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!8, !8, i64 0}


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