; 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: 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 @shape_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 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 %88

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

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

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 = 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 %88

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

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

33:                                               ; preds = %28
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.data_shape_s, ptr %35, i32 0, i32 1
  store i32 %34, ptr %36, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store ptr null, ptr %8, align 8, !tbaa !5
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.data_shape_s, ptr %37, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !11
  switch i32 %39, label %76 [
    i32 7, label %40
    i32 0, label %49
    i32 1, label %58
    i32 4, label %67
  ]

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

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

48:                                               ; preds = %40
  br label %85

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

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

57:                                               ; preds = %49
  br label %85

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

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

66:                                               ; preds = %58
  br label %85

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

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

75:                                               ; preds = %67
  br label %85

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

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

84:                                               ; preds = %76
  br label %85

85:                                               ; preds = %84, %75, %66, %57, %48
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %86

86:                                               ; preds = %85, %83, %74, %65, %56, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %87

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

88:                                               ; preds = %87, %27, %20, %15, %11
  %89 = load i32, ptr %3, align 4
  ret i32 %89
}

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

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

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

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

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

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

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

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


; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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 range(i32 0, 2) i32 @shape_from_json(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  %4 = icmp eq ptr %0, null
  %5 = icmp eq ptr %1, null
  %or.cond = or i1 %4, %5
  br i1 %or.cond, label %28, label %6

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

8:                                                ; preds = %6
  %9 = tail call i32 @copy_uint_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.1, ptr noundef nonnull %1) #3
  %.not25 = icmp eq i32 %9, 0
  br i1 %.not25, label %28, label %10

10:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %11 = call i32 @copy_int_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.2, ptr noundef nonnull %3) #3
  %.not26 = icmp eq i32 %11, 0
  br i1 %.not26, label %27, label %12

12:                                               ; preds = %10
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 %13, ptr %14, align 4, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  switch i32 %13, label %24 [
    i32 7, label %16
    i32 0, label %18
    i32 1, label %20
    i32 4, label %22
  ]

16:                                               ; preds = %12
  %17 = call i32 @copy_object_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.3, ptr noundef nonnull @anon_shapeCapsule_from_json, ptr noundef nonnull %15) #3
  %.not30 = icmp eq i32 %17, 0
  br i1 %.not30, label %27, label %26

18:                                               ; preds = %12
  %19 = call i32 @copy_object_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.4, ptr noundef nonnull @anon_shapeCube_from_json, ptr noundef nonnull %15) #3
  %.not29 = icmp eq i32 %19, 0
  br i1 %.not29, label %27, label %26

20:                                               ; preds = %12
  %21 = call i32 @copy_object_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.5, ptr noundef nonnull @anon_shapeCylinder_from_json, ptr noundef nonnull %15) #3
  %.not28 = icmp eq i32 %21, 0
  br i1 %.not28, label %27, label %26

22:                                               ; preds = %12
  %23 = call i32 @copy_object_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.6, ptr noundef nonnull @anon_shapeSphere_from_json, ptr noundef nonnull %15) #3
  %.not27 = icmp eq i32 %23, 0
  br i1 %.not27, label %27, label %26

24:                                               ; preds = %12
  %25 = call i32 @copy_object_field(ptr noundef nonnull %0, ptr noundef nonnull @.str.6, ptr noundef nonnull @anon_shapeSphere_from_json, ptr noundef nonnull %15) #3
  %.not31 = icmp eq i32 %25, 0
  br i1 %.not31, label %27, label %26

26:                                               ; preds = %24, %22, %20, %18, %16
  br label %27

27:                                               ; preds = %26, %16, %18, %20, %22, %24, %10
  %.1 = phi i32 [ 0, %10 ], [ 1, %26 ], [ 0, %16 ], [ 0, %18 ], [ 0, %20 ], [ 0, %22 ], [ 0, %24 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %28

28:                                               ; preds = %8, %6, %2, %27
  %.2 = phi i32 [ %.1, %27 ], [ 0, %2 ], [ 0, %6 ], [ 0, %8 ]
  ret i32 %.2
}

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

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

declare i32 @copy_int_field(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare i32 @copy_object_field(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

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

attributes #0 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 4}
!10 = !{!"data_shape_s", !6, i64 0, !6, i64 4, !7, i64 8}


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