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

; 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.data_shape_s = type { i32, i32, %union.anon }
%union.anon = type { %struct.data_shapeCube_s }
%struct.data_shapeCube_s = type { float, float, float }

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @shape_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 i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  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 %90

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

16:                                               ; preds = %12
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = call i32 @add_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 %90

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

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

29:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.data_shape_s, ptr %30, i32 0, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !12
  store i32 %32, ptr %6, align 4, !tbaa !13
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load i32, ptr %6, align 4, !tbaa !13
  %35 = call i32 @add_int_field(ptr noundef %33, ptr noundef @.str.2, i32 noundef %34)
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %38, label %37

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

38:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store ptr null, ptr %8, align 8, !tbaa !5
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.data_shape_s, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 4, !tbaa !12
  switch i32 %41, label %78 [
    i32 7, label %42
    i32 0, label %51
    i32 1, label %60
    i32 4, label %69
  ]

42:                                               ; preds = %38
  store ptr @anon_shapeCapsule_to_json, ptr %8, align 8, !tbaa !5
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.data_shape_s, ptr %45, i32 0, i32 2
  %47 = call i32 @add_object_field(ptr noundef %43, ptr noundef @.str.3, ptr noundef %44, ptr noundef %46)
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %50, label %49

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

50:                                               ; preds = %42
  br label %87

51:                                               ; preds = %38
  store ptr @anon_shapeCube_to_json, ptr %8, align 8, !tbaa !5
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.data_shape_s, ptr %54, i32 0, i32 2
  %56 = call i32 @add_object_field(ptr noundef %52, ptr noundef @.str.4, ptr noundef %53, ptr noundef %55)
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %59, label %58

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

59:                                               ; preds = %51
  br label %87

60:                                               ; preds = %38
  store ptr @anon_shapeCylinder_to_json, ptr %8, align 8, !tbaa !5
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.data_shape_s, ptr %63, i32 0, i32 2
  %65 = call i32 @add_object_field(ptr noundef %61, ptr noundef @.str.5, ptr noundef %62, ptr noundef %64)
  %66 = icmp ne i32 %65, 0
  br i1 %66, label %68, label %67

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

68:                                               ; preds = %60
  br label %87

69:                                               ; preds = %38
  store ptr @anon_shapeSphere_to_json, ptr %8, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.data_shape_s, ptr %72, i32 0, i32 2
  %74 = call i32 @add_object_field(ptr noundef %70, ptr noundef @.str.6, ptr noundef %71, ptr noundef %73)
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %77, label %76

76:                                               ; preds = %69
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %88

77:                                               ; preds = %69
  br label %87

78:                                               ; preds = %38
  store ptr @anon_shapeSphere_to_json, ptr %8, align 8, !tbaa !5
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.data_shape_s, ptr %81, i32 0, i32 2
  %83 = call i32 @add_object_field(ptr noundef %79, ptr noundef @.str.6, ptr noundef %80, ptr noundef %82)
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %86, label %85

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

86:                                               ; preds = %78
  br label %87

87:                                               ; preds = %86, %77, %68, %59, %50
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %88

88:                                               ; preds = %87, %85, %76, %67, %58, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %89

89:                                               ; preds = %88, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %90

90:                                               ; preds = %89, %28, %20, %15, %11
  %91 = load i32, ptr %3, align 4
  ret i32 %91
}

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

declare i32 @add_uint_field(ptr noundef, ptr 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 i32 @add_int_field(ptr noundef, ptr noundef, i32 noundef) #1

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

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

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

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

declare i32 @anon_shapeSphere_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 = !{!"data_shape_s", !11, i64 0, !11, i64 4, !7, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!11, !11, 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"

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1

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

7:                                                ; preds = %5
  %8 = load i32, ptr %1, align 4, !tbaa !5
  %9 = tail call i32 @add_uint_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.1, i32 noundef %8) #2
  %.not26 = icmp eq i32 %9, 0
  br i1 %.not26, label %28, 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
  %.not27 = icmp eq i32 %13, 0
  br i1 %.not27, label %28, label %14

14:                                               ; preds = %10
  %15 = load i32, ptr %11, align 4, !tbaa !10
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  switch i32 %15, label %25 [
    i32 7, label %17
    i32 0, label %19
    i32 1, label %21
    i32 4, label %23
  ]

17:                                               ; preds = %14
  %18 = tail call i32 @add_object_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.3, ptr noundef nonnull @anon_shapeCapsule_to_json, ptr noundef nonnull %16) #2
  %.not31 = icmp eq i32 %18, 0
  br i1 %.not31, label %28, label %27

19:                                               ; preds = %14
  %20 = tail call i32 @add_object_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.4, ptr noundef nonnull @anon_shapeCube_to_json, ptr noundef nonnull %16) #2
  %.not30 = icmp eq i32 %20, 0
  br i1 %.not30, label %28, label %27

21:                                               ; preds = %14
  %22 = tail call i32 @add_object_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.5, ptr noundef nonnull @anon_shapeCylinder_to_json, ptr noundef nonnull %16) #2
  %.not29 = icmp eq i32 %22, 0
  br i1 %.not29, label %28, label %27

23:                                               ; preds = %14
  %24 = tail call i32 @add_object_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.6, ptr noundef nonnull @anon_shapeSphere_to_json, ptr noundef nonnull %16) #2
  %.not28 = icmp eq i32 %24, 0
  br i1 %.not28, label %28, label %27

25:                                               ; preds = %14
  %26 = tail call i32 @add_object_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.6, ptr noundef nonnull @anon_shapeSphere_to_json, ptr noundef nonnull %16) #2
  %.not32 = icmp eq i32 %26, 0
  br i1 %.not32, label %28, label %27

27:                                               ; preds = %25, %23, %21, %19, %17
  br label %28

28:                                               ; preds = %10, %25, %23, %21, %19, %17, %27, %7, %5, %2
  %.2 = phi i32 [ 0, %2 ], [ 0, %5 ], [ 0, %7 ], [ 0, %10 ], [ 1, %27 ], [ 0, %17 ], [ 0, %19 ], [ 0, %21 ], [ 0, %23 ], [ 0, %25 ]
  ret i32 %.2
}

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

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

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

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

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

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

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

declare i32 @anon_shapeSphere_to_json(ptr noundef, ptr noundef) #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 = !{!"data_shape_s", !7, i64 0, !7, i64 4, !8, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}


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