; 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: nounwind uwtable
define dso_local i32 @constraintRevoluteJoint_to_json(ptr noundef %0, ptr noundef %1) #0 {
  %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 %112

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 %112

18:                                               ; preds = %14
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = call i32 @add_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 %112

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 = load i32, ptr %26, align 4, !tbaa !9
  %28 = call i32 @add_int_field(ptr noundef %24, ptr noundef @.str.1, i32 noundef %27)
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %31, label %30

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

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

38:                                               ; preds = %31
  store i32 0, ptr %3, align 4
  br label %112

39:                                               ; preds = %31
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = call i32 @add_dynamic_object_array_field(ptr noundef %40, ptr noundef @.str.3, i32 noundef 2, i32 noundef 2)
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  store i32 0, ptr %3, align 4
  br label %112

44:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = call ptr @get_field_by_name(ptr noundef %45, ptr noundef @.str.3)
  store ptr %46, ptr %6, align 8, !tbaa !5
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.json_value_s, ptr %47, i32 0, i32 0
  %49 = load i32, ptr %48, align 8, !tbaa !13
  %50 = icmp ne i32 %49, 1
  br i1 %50, label %51, label %52

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

52:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !15
  br label %53

53:                                               ; preds = %71, %52
  %54 = load i32, ptr %8, align 4, !tbaa !15
  %55 = icmp ult i32 %54, 2
  br i1 %55, label %57, label %56

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

57:                                               ; preds = %53
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.json_value_s, ptr %58, i32 0, i32 2
  %60 = getelementptr inbounds %struct.json_array_s, ptr %59, i32 0, i32 2
  %61 = load ptr, ptr %60, align 8, !tbaa !16
  %62 = load i32, ptr %8, align 4, !tbaa !15
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds %struct.json_value_s, ptr %61, i64 %63
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.constraintRevoluteJoint, ptr %65, i32 0, i32 2
  %67 = load i32, ptr %8, align 4, !tbaa !15
  %68 = zext i32 %67 to i64
  %69 = getelementptr inbounds [2 x %struct.vector3], ptr %66, i64 0, i64 %68
  %70 = call i32 @anon_vector3_to_json(ptr noundef %64, ptr noundef %69)
  br label %71

71:                                               ; preds = %57
  %72 = load i32, ptr %8, align 4, !tbaa !15
  %73 = add i32 %72, 1
  store i32 %73, ptr %8, align 4, !tbaa !15
  br label %53, !llvm.loop !17

74:                                               ; preds = %56
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = call i32 @add_dynamic_object_array_field(ptr noundef %75, ptr noundef @.str.4, i32 noundef 2, i32 noundef 2)
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %79, label %78

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

79:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = call ptr @get_field_by_name(ptr noundef %80, ptr noundef @.str.4)
  store ptr %81, ptr %9, align 8, !tbaa !5
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.json_value_s, ptr %82, i32 0, i32 0
  %84 = load i32, ptr %83, align 8, !tbaa !13
  %85 = icmp ne i32 %84, 1
  br i1 %85, label %86, label %87

86:                                               ; preds = %79
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %110

87:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !15
  br label %88

88:                                               ; preds = %106, %87
  %89 = load i32, ptr %10, align 4, !tbaa !15
  %90 = icmp ult i32 %89, 2
  br i1 %90, label %92, label %91

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

92:                                               ; preds = %88
  %93 = load ptr, ptr %9, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.json_value_s, ptr %93, i32 0, i32 2
  %95 = getelementptr inbounds %struct.json_array_s, ptr %94, i32 0, i32 2
  %96 = load ptr, ptr %95, align 8, !tbaa !16
  %97 = load i32, ptr %10, align 4, !tbaa !15
  %98 = zext i32 %97 to i64
  %99 = getelementptr inbounds %struct.json_value_s, ptr %96, i64 %98
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.constraintRevoluteJoint, ptr %100, i32 0, i32 3
  %102 = load i32, ptr %10, align 4, !tbaa !15
  %103 = zext i32 %102 to i64
  %104 = getelementptr inbounds [2 x %struct.vector3], ptr %101, i64 0, i64 %103
  %105 = call i32 @anon_vector3_to_json(ptr noundef %99, ptr noundef %104)
  br label %106

106:                                              ; preds = %92
  %107 = load i32, ptr %10, align 4, !tbaa !15
  %108 = add i32 %107, 1
  store i32 %108, ptr %10, align 4, !tbaa !15
  br label %88, !llvm.loop !19

109:                                              ; preds = %91
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %110

110:                                              ; preds = %109, %86
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %111

111:                                              ; preds = %110, %78, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %112

112:                                              ; preds = %111, %43, %38, %30, %22, %17, %13
  %113 = load i32, ptr %3, align 4
  ret i32 %113
}

declare i32 @add_typename(ptr noundef, ptr noundef) #1

declare i32 @add_int_field(ptr noundef, ptr noundef, i32 noundef) #1

declare i32 @add_dynamic_object_array_field(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #1

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

declare ptr @get_field_by_name(ptr noundef, ptr noundef) #1

declare i32 @anon_vector3_to_json(ptr noundef, ptr noundef) #1

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

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 = { nocallback nofree nosync 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, !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 = !{!"constraintRevoluteJoint", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!14, !11, i64 0}
!14 = !{!"json_value_s", !11, i64 0, !6, i64 8, !7, i64 16}
!15 = !{!11, !11, i64 0}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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_to_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 @add_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 = load i32, ptr %1, align 4, !tbaa !5
  %9 = tail call i32 @add_int_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.1, i32 noundef %8) #2
  %.not29 = icmp eq i32 %9, 0
  br i1 %.not29, label %.loopexit, label %10

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %1, i64 4
  %12 = load i32, ptr %11, align 4, !tbaa !10
  %13 = tail call i32 @add_int_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.2, i32 noundef %12) #2
  %.not30 = icmp eq i32 %13, 0
  br i1 %.not30, label %.loopexit, label %14

14:                                               ; preds = %10
  %15 = tail call i32 @add_dynamic_object_array_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.3, i32 noundef 2, i32 noundef 2) #2
  %.not31 = icmp eq i32 %15, 0
  br i1 %.not31, label %.loopexit, label %16

16:                                               ; preds = %14
  %17 = tail call ptr @get_field_by_name(ptr noundef nonnull %0, ptr noundef nonnull @.str.3) #2
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %.not32 = icmp eq i32 %18, 1
  br i1 %.not32, label %.preheader35, label %.loopexit

.preheader35:                                     ; preds = %16
  %19 = getelementptr inbounds i8, ptr %17, i64 24
  %20 = getelementptr inbounds i8, ptr %1, i64 8
  %21 = load ptr, ptr %19, align 8, !tbaa !14
  %22 = tail call i32 @anon_vector3_to_json(ptr noundef %21, ptr noundef nonnull %20) #2
  %23 = load ptr, ptr %19, align 8, !tbaa !14
  %24 = getelementptr inbounds i8, ptr %23, i64 40
  %25 = getelementptr inbounds i8, ptr %1, i64 20
  %26 = tail call i32 @anon_vector3_to_json(ptr noundef nonnull %24, ptr noundef nonnull %25) #2
  %27 = tail call i32 @add_dynamic_object_array_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.4, i32 noundef 2, i32 noundef 2) #2
  %.not33 = icmp eq i32 %27, 0
  br i1 %.not33, label %.loopexit, label %28

28:                                               ; preds = %.preheader35
  %29 = tail call ptr @get_field_by_name(ptr noundef nonnull %0, ptr noundef nonnull @.str.4) #2
  %30 = load i32, ptr %29, align 8, !tbaa !11
  %.not34 = icmp eq i32 %30, 1
  br i1 %.not34, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %28
  %31 = getelementptr inbounds i8, ptr %29, i64 24
  %32 = getelementptr inbounds i8, ptr %1, i64 32
  %33 = load ptr, ptr %31, align 8, !tbaa !14
  %34 = tail call i32 @anon_vector3_to_json(ptr noundef %33, ptr noundef nonnull %32) #2
  %35 = load ptr, ptr %31, align 8, !tbaa !14
  %36 = getelementptr inbounds i8, ptr %35, i64 40
  %37 = getelementptr inbounds i8, ptr %1, i64 44
  %38 = tail call i32 @anon_vector3_to_json(ptr noundef nonnull %36, ptr noundef nonnull %37) #2
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %16, %.preheader35, %28, %14, %10, %7, %5, %2
  %.2 = phi i32 [ 0, %2 ], [ 0, %5 ], [ 0, %7 ], [ 0, %10 ], [ 0, %14 ], [ 0, %16 ], [ 0, %.preheader35 ], [ 0, %28 ], [ 1, %.preheader ]
  ret i32 %.2
}

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

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

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

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

declare i32 @anon_vector3_to_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 = !{!"constraintRevoluteJoint", !7, i64 0, !7, i64 4, !8, i64 8, !8, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!12, !7, i64 0}
!12 = !{!"json_value_s", !7, i64 0, !13, i64 8, !8, i64 16}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!8, !8, i64 0}


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