; LLVM IR from marcobambini/gravity :: src/shared (gravity_value)

; 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.gravity_function_t = type { ptr, %struct.gravity_gc_s, ptr, ptr, i16, i16, i16, i16, i32, %union.anon.4 }
%struct.gravity_gc_s = type { i8, i8, ptr, ptr, ptr, ptr }
%union.anon.4 = type { %struct.anon.5 }
%struct.anon.5 = type { %struct.gravity_value_r, %struct.gravity_value_r, %struct.gravity_value_r, i32, ptr, ptr, float, i8 }
%struct.gravity_value_r = type { i64, i64, ptr }

@.str.20 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @gravity_function_dump(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.gravity_function_t, ptr %5, i32 0, i32 3
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %13

9:                                                ; preds = %2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.gravity_function_t, ptr %10, i32 0, i32 3
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  br label %14

13:                                               ; preds = %2
  br label %14

14:                                               ; preds = %13, %9
  %15 = phi ptr [ %12, %9 ], [ @.str.21, %13 ]
  %16 = call i32 (ptr, ...) @printf(ptr noundef @.str.20, ptr noundef %15)
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.gravity_function_t, ptr %17, i32 0, i32 4
  %19 = load i16, ptr %18, align 8, !tbaa !15
  %20 = zext i16 %19 to i32
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.gravity_function_t, ptr %21, i32 0, i32 5
  %23 = load i16, ptr %22, align 2, !tbaa !16
  %24 = zext i16 %23 to i32
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.gravity_function_t, ptr %25, i32 0, i32 6
  %27 = load i16, ptr %26, align 4, !tbaa !17
  %28 = zext i16 %27 to i32
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.gravity_function_t, ptr %29, i32 0, i32 7
  %31 = load i16, ptr %30, align 2, !tbaa !18
  %32 = zext i16 %31 to i32
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.gravity_function_t, ptr %33, i32 0, i32 8
  %35 = load i32, ptr %34, align 8, !tbaa !19
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.gravity_function_t, ptr %36, i32 0, i32 2
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.22, i32 noundef %20, i32 noundef %24, i32 noundef %28, i32 noundef %32, i32 noundef %35, ptr noundef %38)
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.gravity_function_t, ptr %40, i32 0, i32 8
  %42 = load i32, ptr %41, align 8, !tbaa !19
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %100

44:                                               ; preds = %14
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.gravity_function_t, ptr %45, i32 0, i32 9
  %47 = getelementptr inbounds %struct.anon.5, ptr %46, i32 0, i32 0
  %48 = getelementptr inbounds %struct.gravity_value_r, ptr %47, i32 0, i32 0
  %49 = load i64, ptr %48, align 8, !tbaa !21
  %50 = icmp ne i64 %49, 0
  br i1 %50, label %51, label %53

51:                                               ; preds = %44
  %52 = call i32 (ptr, ...) @printf(ptr noundef @.str.23)
  br label %53

53:                                               ; preds = %51, %44
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.gravity_function_t, ptr %55, i32 0, i32 9
  %57 = getelementptr inbounds %struct.anon.5, ptr %56, i32 0, i32 0
  call void @gravity_function_array_dump(ptr noundef %54, ptr noundef byval(%struct.gravity_value_r) align 8 %57)
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.gravity_function_t, ptr %58, i32 0, i32 9
  %60 = getelementptr inbounds %struct.anon.5, ptr %59, i32 0, i32 2
  %61 = getelementptr inbounds %struct.gravity_value_r, ptr %60, i32 0, i32 0
  %62 = load i64, ptr %61, align 8, !tbaa !21
  %63 = icmp ne i64 %62, 0
  br i1 %63, label %64, label %66

64:                                               ; preds = %53
  %65 = call i32 (ptr, ...) @printf(ptr noundef @.str.24)
  br label %66

66:                                               ; preds = %64, %53
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.gravity_function_t, ptr %68, i32 0, i32 9
  %70 = getelementptr inbounds %struct.anon.5, ptr %69, i32 0, i32 2
  call void @gravity_function_array_dump(ptr noundef %67, ptr noundef byval(%struct.gravity_value_r) align 8 %70)
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.gravity_function_t, ptr %71, i32 0, i32 9
  %73 = getelementptr inbounds %struct.anon.5, ptr %72, i32 0, i32 1
  %74 = getelementptr inbounds %struct.gravity_value_r, ptr %73, i32 0, i32 0
  %75 = load i64, ptr %74, align 8, !tbaa !21
  %76 = icmp ne i64 %75, 0
  br i1 %76, label %77, label %79

77:                                               ; preds = %66
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str.25)
  br label %79

79:                                               ; preds = %77, %66
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.gravity_function_t, ptr %81, i32 0, i32 9
  %83 = getelementptr inbounds %struct.anon.5, ptr %82, i32 0, i32 1
  call void @gravity_function_array_dump(ptr noundef %80, ptr noundef byval(%struct.gravity_value_r) align 8 %83)
  %84 = call i32 (ptr, ...) @printf(ptr noundef @.str.26)
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.gravity_function_t, ptr %85, i32 0, i32 9
  %87 = getelementptr inbounds %struct.anon.5, ptr %86, i32 0, i32 4
  %88 = load ptr, ptr %87, align 8, !tbaa !21
  %89 = icmp ne ptr %88, null
  br i1 %89, label %90, label %99

90:                                               ; preds = %79
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = icmp ne ptr %91, null
  br i1 %92, label %93, label %99

93:                                               ; preds = %90
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.gravity_function_t, ptr %95, i32 0, i32 9
  %97 = getelementptr inbounds %struct.anon.5, ptr %96, i32 0, i32 4
  %98 = load ptr, ptr %97, align 8, !tbaa !21
  call void %94(ptr noundef %98)
  br label %99

99:                                               ; preds = %93, %90, %79
  br label %100

100:                                              ; preds = %99, %14
  %101 = call i32 (ptr, ...) @printf(ptr noundef @.str.27)
  ret void
}

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare hidden void @gravity_function_array_dump(ptr noundef, ptr noundef byval(%struct.gravity_value_r) align 8) #0

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

!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, !6, i64 56}
!10 = !{!"", !6, i64 0, !11, i64 8, !6, i64 48, !6, i64 56, !13, i64 64, !13, i64 66, !13, i64 68, !13, i64 70, !14, i64 72, !7, i64 80}
!11 = !{!"gravity_gc_s", !12, i64 0, !12, i64 1, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!10, !13, i64 64}
!16 = !{!10, !13, i64 66}
!17 = !{!10, !13, i64 68}
!18 = !{!10, !13, i64 70}
!19 = !{!10, !14, i64 72}
!20 = !{!10, !6, i64 48}
!21 = !{!7, !7, 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"

%struct.gravity_value_r = type { i64, i64, ptr }

@.str.20 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @gravity_function_dump(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 56
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  %spec.select = select i1 %.not, ptr @.str.21, ptr %4
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, ptr noundef nonnull %spec.select)
  %6 = getelementptr inbounds i8, ptr %0, i64 64
  %7 = load i16, ptr %6, align 8, !tbaa !14
  %8 = zext i16 %7 to i32
  %9 = getelementptr inbounds i8, ptr %0, i64 66
  %10 = load i16, ptr %9, align 2, !tbaa !15
  %11 = zext i16 %10 to i32
  %12 = getelementptr inbounds i8, ptr %0, i64 68
  %13 = load i16, ptr %12, align 4, !tbaa !16
  %14 = zext i16 %13 to i32
  %15 = getelementptr inbounds i8, ptr %0, i64 70
  %16 = load i16, ptr %15, align 2, !tbaa !17
  %17 = zext i16 %16 to i32
  %18 = getelementptr inbounds i8, ptr %0, i64 72
  %19 = load i32, ptr %18, align 8, !tbaa !18
  %20 = getelementptr inbounds i8, ptr %0, i64 48
  %21 = load ptr, ptr %20, align 8, !tbaa !19
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.22, i32 noundef %8, i32 noundef %11, i32 noundef %14, i32 noundef %17, i32 noundef %19, ptr noundef %21)
  %23 = load i32, ptr %18, align 8, !tbaa !18
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %47

25:                                               ; preds = %2
  %26 = getelementptr inbounds i8, ptr %0, i64 80
  %27 = load i64, ptr %26, align 8, !tbaa !20
  %.not25 = icmp eq i64 %27, 0
  br i1 %.not25, label %30, label %28

28:                                               ; preds = %25
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.23)
  br label %30

30:                                               ; preds = %28, %25
  tail call void @gravity_function_array_dump(ptr noundef nonnull %0, ptr noundef nonnull byval(%struct.gravity_value_r) align 8 %26)
  %31 = getelementptr inbounds i8, ptr %0, i64 128
  %32 = load i64, ptr %31, align 8, !tbaa !20
  %.not26 = icmp eq i64 %32, 0
  br i1 %.not26, label %35, label %33

33:                                               ; preds = %30
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.24)
  br label %35

35:                                               ; preds = %33, %30
  tail call void @gravity_function_array_dump(ptr noundef nonnull %0, ptr noundef nonnull byval(%struct.gravity_value_r) align 8 %31)
  %36 = getelementptr inbounds i8, ptr %0, i64 104
  %37 = load i64, ptr %36, align 8, !tbaa !20
  %.not27 = icmp eq i64 %37, 0
  br i1 %.not27, label %40, label %38

38:                                               ; preds = %35
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.25)
  br label %40

40:                                               ; preds = %38, %35
  tail call void @gravity_function_array_dump(ptr noundef nonnull %0, ptr noundef nonnull byval(%struct.gravity_value_r) align 8 %36)
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.26)
  %42 = getelementptr inbounds i8, ptr %0, i64 160
  %43 = load ptr, ptr %42, align 8, !tbaa !20
  %44 = icmp ne ptr %43, null
  %45 = icmp ne ptr %1, null
  %or.cond = and i1 %45, %44
  br i1 %or.cond, label %46, label %47

46:                                               ; preds = %40
  tail call void %1(ptr noundef nonnull %43) #2
  br label %47

47:                                               ; preds = %40, %46, %2
  %48 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.27)
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @gravity_function_array_dump(ptr noundef, ptr noundef byval(%struct.gravity_value_r) align 8) local_unnamed_addr #0

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 = { nofree nounwind "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 56}
!6 = !{!"", !7, i64 0, !10, i64 8, !7, i64 48, !7, i64 56, !12, i64 64, !12, i64 66, !12, i64 68, !12, i64 70, !13, i64 72, !8, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"gravity_gc_s", !11, i64 0, !11, i64 1, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = !{!6, !12, i64 64}
!15 = !{!6, !12, i64 66}
!16 = !{!6, !12, i64 68}
!17 = !{!6, !12, i64 70}
!18 = !{!6, !13, i64 72}
!19 = !{!6, !7, i64 48}
!20 = !{!8, !8, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass