; LLVM IR from ImperialCollegeLondon/pnflow :: src/pnm/pnextract/medialSurf.ll (Z10makeFriendP10medialBallS0_)

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

%class.medialBall = type { ptr, float, float, float, i16, float, i16, i16, i16, i16, i16, ptr, ptr, ptr }

; 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: mustprogress uwtable
define dso_local void @_Z10makeFriendP10medialBallS0_(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %class.medialBall, ptr %6, i32 0, i32 5
  %8 = load float, ptr %7, align 8, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %class.medialBall, ptr %9, i32 0, i32 5
  %11 = load float, ptr %10, align 8, !tbaa !9
  %12 = fcmp ogt float %8, %11
  br i1 %12, label %13, label %17

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %14, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %15, ptr %3, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %16, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %17

17:                                               ; preds = %13, %2
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %class.medialBall, ptr %18, i32 0, i32 5
  %20 = load float, ptr %19, align 8, !tbaa !9
  %21 = fpext float %20 to double
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %class.medialBall, ptr %22, i32 0, i32 5
  %24 = load float, ptr %23, align 8, !tbaa !9
  %25 = fpext float %24 to double
  %26 = fmul double 1.500000e+00, %25
  %27 = fcmp olt double %21, %26
  br i1 %27, label %28, label %45

28:                                               ; preds = %17
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = call noundef zeroext i1 @_ZNK10medialBall5isNeiEPKS_(ptr noundef nonnull align 8 dereferenceable(64) %29, ptr noundef %30)
  br i1 %31, label %45, label %32

32:                                               ; preds = %28
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = call noundef zeroext i1 @_ZNK10medialBall9inParentsEPS_(ptr noundef nonnull align 8 dereferenceable(64) %33, ptr noundef %34)
  br i1 %35, label %45, label %36

36:                                               ; preds = %32
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = call noundef zeroext i1 @_ZNK10medialBall9inParentsEPS_(ptr noundef nonnull align 8 dereferenceable(64) %37, ptr noundef %38)
  br i1 %39, label %45, label %40

40:                                               ; preds = %36
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN10medialBall6addNeiEPS_(ptr noundef nonnull align 8 dereferenceable(64) %41, ptr noundef %42)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN10medialBall6addNeiEPS_(ptr noundef nonnull align 8 dereferenceable(64) %43, ptr noundef %44)
  br label %45

45:                                               ; preds = %40, %36, %32, %28, %17
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK10medialBall5isNeiEPKS_(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK10medialBall9inParentsEPS_(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10medialBall6addNeiEPS_(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { mustprogress 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 #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++ TBAA"}
!9 = !{!10, !11, i64 24}
!10 = !{!"_ZTS10medialBall", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !12, i64 20, !11, i64 24, !12, i64 28, !12, i64 30, !12, i64 32, !12, i64 34, !12, i64 36, !6, i64 40, !6, i64 48, !6, i64 56}
!11 = !{!"float", !7, i64 0}
!12 = !{!"short", !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"

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10makeFriendP10medialBallS0_(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 24
  %4 = load float, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load float, ptr %5, align 8, !tbaa !5
  %7 = fcmp ogt float %4, %6
  %.017 = select i1 %7, ptr %0, ptr %1
  %.0 = select i1 %7, ptr %1, ptr %0
  %8 = getelementptr inbounds i8, ptr %.0, i64 24
  %9 = load float, ptr %8, align 8, !tbaa !5
  %10 = fpext float %9 to double
  %11 = getelementptr inbounds i8, ptr %.017, i64 24
  %12 = load float, ptr %11, align 8, !tbaa !5
  %13 = fpext float %12 to double
  %14 = fmul double %13, 1.500000e+00
  %15 = fcmp ogt double %14, %10
  br i1 %15, label %16, label %23

16:                                               ; preds = %2
  %17 = tail call noundef zeroext i1 @_ZNK10medialBall5isNeiEPKS_(ptr noundef nonnull align 8 dereferenceable(64) %.0, ptr noundef nonnull %.017)
  br i1 %17, label %23, label %18

18:                                               ; preds = %16
  %19 = tail call noundef zeroext i1 @_ZNK10medialBall9inParentsEPS_(ptr noundef nonnull align 8 dereferenceable(64) %.0, ptr noundef nonnull %.017)
  br i1 %19, label %23, label %20

20:                                               ; preds = %18
  %21 = tail call noundef zeroext i1 @_ZNK10medialBall9inParentsEPS_(ptr noundef nonnull align 8 dereferenceable(64) %.017, ptr noundef nonnull %.0)
  br i1 %21, label %23, label %22

22:                                               ; preds = %20
  tail call void @_ZN10medialBall6addNeiEPS_(ptr noundef nonnull align 8 dereferenceable(64) %.0, ptr noundef nonnull %.017)
  tail call void @_ZN10medialBall6addNeiEPS_(ptr noundef nonnull align 8 dereferenceable(64) %.017, ptr noundef nonnull %.0)
  br label %23

23:                                               ; preds = %22, %20, %18, %16, %2
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK10medialBall5isNeiEPKS_(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK10medialBall9inParentsEPS_(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10medialBall6addNeiEPS_(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef) local_unnamed_addr #0 align 2

attributes #0 = { mustprogress 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 = { mustprogress 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" }

!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, !10, i64 24}
!6 = !{!"_ZTS10medialBall", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !11, i64 20, !10, i64 24, !11, i64 28, !11, i64 30, !11, i64 32, !11, i64 34, !11, i64 36, !7, i64 40, !7, i64 48, !7, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"short", !8, i64 0}


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