; LLVM IR from ImperialCollegeLondon/pnflow :: src/pnm/pnflow/polygon/cornerApex.ll (ZN10CornerApex14initCornerApexEdddddb)

; 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.Apex = type { ptr, i8, double, double, ptr, i32, double, double, double, double, i8, i8, i8, i8, %"struct.std::pair" }
%"struct.std::pair" = type { i32, double }
%class.CornerApex = type { %class.Apex, ptr, double, double, double, ptr }

@_ZN4Apex2PIE = external dso_local global double, align 8

; 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
declare double @cos(double noundef) #1

; Function Attrs: nounwind
declare double @sin(double noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK9ElemModel6elemanEv(ptr noundef nonnull align 8 dereferenceable(152)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4Elem12isTrappedOilEv(ptr noundef nonnull align 8 dereferenceable(408)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNK4Apex10trappingCLEv(ptr noundef nonnull align 8 dereferenceable(104)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10CornerApex14initCornerApexEdddddb(ptr noundef nonnull align 8 dereferenceable(144) %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, i1 noundef zeroext %6) #4 align 2 {
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca i8, align 1
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store double %1, ptr %9, align 8, !tbaa !9
  store double %2, ptr %10, align 8, !tbaa !9
  store double %3, ptr %11, align 8, !tbaa !9
  store double %4, ptr %12, align 8, !tbaa !9
  store double %5, ptr %13, align 8, !tbaa !9
  %17 = zext i1 %6 to i8
  store i8 %17, ptr %14, align 1, !tbaa !11
  %18 = load ptr, ptr %8, align 8
  %19 = getelementptr inbounds %class.Apex, ptr %18, i32 0, i32 12
  %20 = load i8, ptr %19, align 2, !tbaa !13, !range !17, !noundef !18
  %21 = trunc i8 %20 to i1
  br i1 %21, label %22, label %39

22:                                               ; preds = %7
  %23 = getelementptr inbounds %class.Apex, ptr %18, i32 0, i32 14
  %24 = getelementptr inbounds %"struct.std::pair", ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !19
  %26 = icmp sgt i32 %25, -1
  br i1 %26, label %39, label %27

27:                                               ; preds = %22
  %28 = getelementptr inbounds %class.CornerApex, ptr %18, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !20
  %30 = call noundef ptr @_ZNK9ElemModel6elemanEv(ptr noundef nonnull align 8 dereferenceable(152) %29)
  %31 = call noundef zeroext i1 @_ZNK4Elem12isTrappedOilEv(ptr noundef nonnull align 8 dereferenceable(408) %30)
  br i1 %31, label %39, label %32

32:                                               ; preds = %27
  %33 = getelementptr inbounds %class.CornerApex, ptr %18, i32 0, i32 5
  %34 = load ptr, ptr %33, align 8, !tbaa !22
  %35 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK4Apex10trappingCLEv(ptr noundef nonnull align 8 dereferenceable(104) %34)
  %36 = getelementptr inbounds %"struct.std::pair", ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !23
  %38 = icmp sgt i32 %37, -1
  br i1 %38, label %39, label %40

39:                                               ; preds = %32, %27, %22, %7
  br label %78

40:                                               ; preds = %32
  %41 = getelementptr inbounds %class.Apex, ptr %18, i32 0, i32 13
  store i8 1, ptr %41, align 1, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %42 = load double, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %43 = load double, ptr %10, align 8, !tbaa !9
  %44 = load double, ptr %12, align 8, !tbaa !9
  %45 = fadd double %43, %44
  store double %45, ptr %16, align 8, !tbaa !9
  %46 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @_ZN4Apex2PIE, ptr noundef nonnull align 8 dereferenceable(8) %16)
  %47 = load double, ptr %46, align 8, !tbaa !9
  %48 = call double @cos(double noundef %47) #5
  %49 = fmul double %42, %48
  %50 = getelementptr inbounds %class.CornerApex, ptr %18, i32 0, i32 2
  %51 = load double, ptr %50, align 8, !tbaa !25
  %52 = load double, ptr %12, align 8, !tbaa !9
  %53 = call double @sin(double noundef %52) #5
  %54 = fmul double %51, %53
  %55 = fdiv double %49, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  store double %55, ptr %15, align 8, !tbaa !9
  %56 = getelementptr inbounds %class.Apex, ptr %18, i32 0, i32 7
  %57 = load double, ptr %56, align 8, !tbaa !26
  %58 = load double, ptr %15, align 8, !tbaa !9
  %59 = fcmp olt double %57, %58
  br i1 %59, label %60, label %63

60:                                               ; preds = %40
  %61 = load double, ptr %15, align 8, !tbaa !9
  %62 = getelementptr inbounds %class.Apex, ptr %18, i32 0, i32 7
  store double %61, ptr %62, align 8, !tbaa !26
  br label %63

63:                                               ; preds = %60, %40
  %64 = load double, ptr %13, align 8, !tbaa !9
  %65 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @_ZN4Apex2PIE, ptr noundef nonnull align 8 dereferenceable(8) %11)
  %66 = load double, ptr %65, align 8, !tbaa !9
  %67 = load double, ptr %12, align 8, !tbaa !9
  %68 = fadd double %66, %67
  %69 = call double @cos(double noundef %68) #5
  %70 = fmul double %64, %69
  %71 = getelementptr inbounds %class.CornerApex, ptr %18, i32 0, i32 2
  %72 = load double, ptr %71, align 8, !tbaa !25
  %73 = load double, ptr %12, align 8, !tbaa !9
  %74 = call double @sin(double noundef %73) #5
  %75 = fmul double %72, %74
  %76 = fdiv double %70, %75
  %77 = getelementptr inbounds %class.Apex, ptr %18, i32 0, i32 6
  store double %76, ptr %77, align 8, !tbaa !27
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  br label %78

78:                                               ; preds = %63, %39
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { inlinehint 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 = { 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 #4 = { 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 #5 = { 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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !12, i64 82}
!14 = !{!"_ZTS4Apex", !12, i64 8, !10, i64 16, !10, i64 24, !6, i64 32, !15, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !12, i64 80, !12, i64 81, !12, i64 82, !12, i64 83, !16, i64 88}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTSSt4pairIidE", !15, i64 0, !10, i64 8}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!14, !15, i64 88}
!20 = !{!21, !6, i64 104}
!21 = !{!"_ZTS10CornerApex", !14, i64 0, !6, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !6, i64 136}
!22 = !{!21, !6, i64 136}
!23 = !{!16, !15, i64 0}
!24 = !{!14, !12, i64 83}
!25 = !{!21, !10, i64 112}
!26 = !{!14, !10, i64 56}
!27 = !{!14, !10, i64 48}


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

@_ZN4Apex2PIE = external dso_local global double, align 8

; 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: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK9ElemModel6elemanEv(ptr noundef nonnull align 8 dereferenceable(152)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4Elem12isTrappedOilEv(ptr noundef nonnull align 8 dereferenceable(408)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNK4Apex10trappingCLEv(ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN10CornerApex14initCornerApexEdddddb(ptr nocapture noundef nonnull align 8 dereferenceable(144) %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, i1 noundef zeroext %6) local_unnamed_addr #3 align 2 {
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  store double %3, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 82
  %11 = load i8, ptr %10, align 2, !tbaa !9, !range !15, !noundef !16
  %12 = trunc nuw i8 %11 to i1
  %13 = getelementptr inbounds i8, ptr %0, i64 88
  %14 = load i32, ptr %13, align 8
  %15 = icmp slt i32 %14, 0
  %or.cond.not = select i1 %12, i1 %15, i1 false
  br i1 %or.cond.not, label %16, label %54

16:                                               ; preds = %7
  %17 = getelementptr inbounds i8, ptr %0, i64 104
  %18 = load ptr, ptr %17, align 8, !tbaa !17
  %19 = tail call noundef ptr @_ZNK9ElemModel6elemanEv(ptr noundef nonnull align 8 dereferenceable(152) %18)
  %20 = tail call noundef zeroext i1 @_ZNK4Elem12isTrappedOilEv(ptr noundef nonnull align 8 dereferenceable(408) %19)
  br i1 %20, label %54, label %21

21:                                               ; preds = %16
  %22 = getelementptr inbounds i8, ptr %0, i64 136
  %23 = load ptr, ptr %22, align 8, !tbaa !19
  %24 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK4Apex10trappingCLEv(ptr noundef nonnull align 8 dereferenceable(104) %23)
  %25 = load i32, ptr %24, align 8, !tbaa !20
  %26 = icmp sgt i32 %25, -1
  br i1 %26, label %54, label %27

27:                                               ; preds = %21
  %28 = getelementptr inbounds i8, ptr %0, i64 83
  store i8 1, ptr %28, align 1, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #4
  %29 = fadd double %2, %4
  store double %29, ptr %9, align 8, !tbaa !5
  %30 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @_ZN4Apex2PIE, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = call double @cos(double noundef %31) #4
  %33 = fmul double %32, %5
  %34 = getelementptr inbounds i8, ptr %0, i64 112
  %35 = load double, ptr %34, align 8, !tbaa !22
  %36 = call double @sin(double noundef %4) #4
  %37 = fmul double %35, %36
  %38 = fdiv double %33, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #4
  %39 = getelementptr inbounds i8, ptr %0, i64 56
  %40 = load double, ptr %39, align 8, !tbaa !23
  %41 = fcmp olt double %40, %38
  br i1 %41, label %42, label %43

42:                                               ; preds = %27
  store double %38, ptr %39, align 8, !tbaa !23
  br label %43

43:                                               ; preds = %42, %27
  %44 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @_ZN4Apex2PIE, ptr noundef nonnull align 8 dereferenceable(8) %8)
  %45 = load double, ptr %44, align 8, !tbaa !5
  %46 = fadd double %45, %4
  %47 = call double @cos(double noundef %46) #4
  %48 = fmul double %47, %5
  %49 = load double, ptr %34, align 8, !tbaa !22
  %50 = call double @sin(double noundef %4) #4
  %51 = fmul double %49, %50
  %52 = fdiv double %48, %51
  %53 = getelementptr inbounds i8, ptr %0, i64 48
  store double %52, ptr %53, align 8, !tbaa !24
  br label %54

54:                                               ; preds = %7, %16, %21, %43
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write) "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 = { inlinehint 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 = { 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 #4 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 82}
!10 = !{!"_ZTS4Apex", !11, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !13, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !11, i64 80, !11, i64 81, !11, i64 82, !11, i64 83, !14, i64 88}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSSt4pairIidE", !13, i64 0, !6, i64 8}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !12, i64 104}
!18 = !{!"_ZTS10CornerApex", !10, i64 0, !12, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !12, i64 136}
!19 = !{!18, !12, i64 136}
!20 = !{!14, !13, i64 0}
!21 = !{!10, !11, i64 83}
!22 = !{!18, !6, i64 112}
!23 = !{!10, !6, i64 56}
!24 = !{!10, !6, i64 48}


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