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

; 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.constraintRevoluteJoint = type { i32, i32, [2 x %struct.vector3], [2 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 [31 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [16 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 @constraintRevoluteJoint_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
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

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

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

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

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

22:                                               ; preds = %18
  store i32 0, ptr %3, align 4
  br label %100

23:                                               ; preds = %18
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.constraintRevoluteJoint, ptr %25, i32 0, i32 0
  %27 = call i32 @copy_int_field(ptr noundef %24, ptr noundef @.str.1, ptr noundef %26)
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %30, label %29

29:                                               ; preds = %23
  store i32 0, ptr %3, align 4
  br label %100

30:                                               ; preds = %23
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.constraintRevoluteJoint, ptr %32, i32 0, i32 1
  %34 = call i32 @copy_int_field(ptr noundef %31, ptr noundef @.str.2, ptr noundef %33)
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %37, label %36

36:                                               ; preds = %30
  store i32 0, ptr %3, align 4
  br label %100

37:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = call ptr @get_const_field_by_name(ptr noundef %38, ptr noundef @.str.3)
  store ptr %39, ptr %6, align 8, !tbaa !5
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.json_value_s, ptr %40, i32 0, i32 0
  %42 = load i32, ptr %41, align 8, !tbaa !9
  %43 = icmp ne i32 %42, 1
  br i1 %43, label %44, label %45

44:                                               ; preds = %37
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %99

45:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !12
  br label %46

46:                                               ; preds = %64, %45
  %47 = load i32, ptr %8, align 4, !tbaa !12
  %48 = icmp ult i32 %47, 2
  br i1 %48, label %50, label %49

49:                                               ; preds = %46
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %67

50:                                               ; preds = %46
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.json_value_s, ptr %51, i32 0, i32 2
  %53 = getelementptr inbounds %struct.json_array_s, ptr %52, i32 0, i32 2
  %54 = load ptr, ptr %53, align 8, !tbaa !13
  %55 = load i32, ptr %8, align 4, !tbaa !12
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds %struct.json_value_s, ptr %54, i64 %56
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.constraintRevoluteJoint, ptr %58, i32 0, i32 2
  %60 = load i32, ptr %8, align 4, !tbaa !12
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds [2 x %struct.vector3], ptr %59, i64 0, i64 %61
  %63 = call i32 @anon_vector3_from_json(ptr noundef %57, ptr noundef %62)
  br label %64

64:                                               ; preds = %50
  %65 = load i32, ptr %8, align 4, !tbaa !12
  %66 = add i32 %65, 1
  store i32 %66, ptr %8, align 4, !tbaa !12
  br label %46, !llvm.loop !14

67:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = call ptr @get_const_field_by_name(ptr noundef %68, ptr noundef @.str.4)
  store ptr %69, ptr %9, align 8, !tbaa !5
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.json_value_s, ptr %70, i32 0, i32 0
  %72 = load i32, ptr %71, align 8, !tbaa !9
  %73 = icmp ne i32 %72, 1
  br i1 %73, label %74, label %75

74:                                               ; preds = %67
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %98

75:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !12
  br label %76

76:                                               ; preds = %94, %75
  %77 = load i32, ptr %10, align 4, !tbaa !12
  %78 = icmp ult i32 %77, 2
  br i1 %78, label %80, label %79

79:                                               ; preds = %76
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %97

80:                                               ; preds = %76
  %81 = load ptr, ptr %9, 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 %10, align 4, !tbaa !12
  %86 = zext i32 %85 to i64
  %87 = getelementptr inbounds %struct.json_value_s, ptr %84, i64 %86
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.constraintRevoluteJoint, ptr %88, i32 0, i32 3
  %90 = load i32, ptr %10, align 4, !tbaa !12
  %91 = zext i32 %90 to i64
  %92 = getelementptr inbounds [2 x %struct.vector3], ptr %89, i64 0, i64 %91
  %93 = call i32 @anon_vector3_from_json(ptr noundef %87, ptr noundef %92)
  br label %94

94:                                               ; preds = %80
  %95 = load i32, ptr %10, align 4, !tbaa !12
  %96 = add i32 %95, 1
  store i32 %96, ptr %10, align 4, !tbaa !12
  br label %76, !llvm.loop !16

97:                                               ; preds = %79
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %98

98:                                               ; preds = %97, %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %99

99:                                               ; preds = %98, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %100

100:                                              ; preds = %99, %36, %29, %22, %17, %13
  %101 = load i32, ptr %3, align 4
  ret i32 %101
}

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

declare i32 @copy_int_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, !11, i64 0}
!10 = !{!"json_value_s", !11, i64 0, !6, i64 8, !7, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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

@.str = external hidden unnamed_addr constant [31 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @constraintRevoluteJoint_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 %.loopexit, 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 %.loopexit, label %7

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

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %1, i64 4
  %11 = tail call i32 @copy_int_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.2, ptr noundef nonnull %10) #2
  %.not28 = icmp eq i32 %11, 0
  br i1 %.not28, label %.loopexit, label %12

12:                                               ; preds = %9
  %13 = tail call ptr @get_const_field_by_name(ptr noundef nonnull %0, ptr noundef nonnull @.str.3) #2
  %14 = load i32, ptr %13, align 8, !tbaa !5
  %.not29 = icmp eq i32 %14, 1
  br i1 %.not29, label %.preheader31, label %.loopexit

.preheader31:                                     ; preds = %12
  %15 = getelementptr inbounds i8, ptr %13, i64 24
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  %17 = load ptr, ptr %15, align 8, !tbaa !11
  %18 = tail call i32 @anon_vector3_from_json(ptr noundef %17, ptr noundef nonnull %16) #2
  %19 = load ptr, ptr %15, align 8, !tbaa !11
  %20 = getelementptr inbounds i8, ptr %19, i64 40
  %21 = getelementptr inbounds i8, ptr %1, i64 20
  %22 = tail call i32 @anon_vector3_from_json(ptr noundef nonnull %20, ptr noundef nonnull %21) #2
  %23 = tail call ptr @get_const_field_by_name(ptr noundef nonnull %0, ptr noundef nonnull @.str.4) #2
  %24 = load i32, ptr %23, align 8, !tbaa !5
  %.not30 = icmp eq i32 %24, 1
  br i1 %.not30, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %.preheader31
  %25 = getelementptr inbounds i8, ptr %23, i64 24
  %26 = getelementptr inbounds i8, ptr %1, i64 32
  %27 = load ptr, ptr %25, align 8, !tbaa !11
  %28 = tail call i32 @anon_vector3_from_json(ptr noundef %27, ptr noundef nonnull %26) #2
  %29 = load ptr, ptr %25, align 8, !tbaa !11
  %30 = getelementptr inbounds i8, ptr %29, i64 40
  %31 = getelementptr inbounds i8, ptr %1, i64 44
  %32 = tail call i32 @anon_vector3_from_json(ptr noundef nonnull %30, ptr noundef nonnull %31) #2
  br label %.loopexit

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

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

declare i32 @copy_int_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 = !{!"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}


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