; LLVM IR from gem5/gem5 :: ext/mcpat/cacti/basic_circuit.ll (Z6R_to_wdibbb)

; 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.TechnologyParameter = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, i64, %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::InterconnectType", %"class.TechnologyParameter::InterconnectType", %"class.TechnologyParameter::InterconnectType", %"class.TechnologyParameter::ScalingFactor", %"class.TechnologyParameter::MemoryType", %"class.TechnologyParameter::MemoryType", %"class.TechnologyParameter::MemoryType" }
%"class.TechnologyParameter::DeviceType" = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double }
%"class.TechnologyParameter::InterconnectType" = type { double, double, double, double, double, double, double, double }
%"class.TechnologyParameter::ScalingFactor" = type { double, double, double }
%"class.TechnologyParameter::MemoryType" = type { double, double, double, double, double, double }

@g_tp = external global %class.TechnologyParameter, 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: mustprogress nounwind uwtable
define dso_local noundef double @_Z6R_to_wdibbb(double noundef %0, i32 noundef %1, i1 noundef zeroext %2, i1 noundef zeroext %3, i1 noundef zeroext %4) #1 {
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  %12 = alloca double, align 8
  store double %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  %13 = zext i1 %2 to i8
  store i8 %13, ptr %8, align 1, !tbaa !11
  %14 = zext i1 %3 to i8
  store i8 %14, ptr %9, align 1, !tbaa !11
  %15 = zext i1 %4 to i8
  store i8 %15, ptr %10, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %16 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %17 = trunc i8 %16 to i1
  br i1 %17, label %18, label %22

18:                                               ; preds = %5
  %19 = load i8, ptr %9, align 1, !tbaa !11, !range !13, !noundef !14
  %20 = trunc i8 %19 to i1
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  store ptr getelementptr inbounds (%class.TechnologyParameter, ptr @g_tp, i32 0, i32 46), ptr %11, align 8, !tbaa !15
  br label %39

22:                                               ; preds = %18, %5
  %23 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %24 = trunc i8 %23 to i1
  br i1 %24, label %25, label %29

25:                                               ; preds = %22
  %26 = load i8, ptr %10, align 1, !tbaa !11, !range !13, !noundef !14
  %27 = trunc i8 %26 to i1
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  store ptr getelementptr inbounds (%class.TechnologyParameter, ptr @g_tp, i32 0, i32 47), ptr %11, align 8, !tbaa !15
  br label %38

29:                                               ; preds = %25, %22
  %30 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %31 = trunc i8 %30 to i1
  br i1 %31, label %36, label %32

32:                                               ; preds = %29
  %33 = load i8, ptr %9, align 1, !tbaa !11, !range !13, !noundef !14
  %34 = trunc i8 %33 to i1
  br i1 %34, label %35, label %36

35:                                               ; preds = %32
  store ptr getelementptr inbounds (%class.TechnologyParameter, ptr @g_tp, i32 0, i32 45), ptr %11, align 8, !tbaa !15
  br label %37

36:                                               ; preds = %32, %29
  store ptr getelementptr inbounds (%class.TechnologyParameter, ptr @g_tp, i32 0, i32 48), ptr %11, align 8, !tbaa !15
  br label %37

37:                                               ; preds = %36, %35
  br label %38

38:                                               ; preds = %37, %28
  br label %39

39:                                               ; preds = %38, %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %46

42:                                               ; preds = %39
  %43 = load ptr, ptr %11, align 8, !tbaa !15
  %44 = getelementptr inbounds %"class.TechnologyParameter::DeviceType", ptr %43, i32 0, i32 7
  %45 = load double, ptr %44, align 8, !tbaa !17
  br label %50

46:                                               ; preds = %39
  %47 = load ptr, ptr %11, align 8, !tbaa !15
  %48 = getelementptr inbounds %"class.TechnologyParameter::DeviceType", ptr %47, i32 0, i32 8
  %49 = load double, ptr %48, align 8, !tbaa !19
  br label %50

50:                                               ; preds = %46, %42
  %51 = phi double [ %45, %42 ], [ %49, %46 ]
  store double %51, ptr %12, align 8, !tbaa !5
  %52 = load double, ptr %12, align 8, !tbaa !5
  %53 = load double, ptr %6, align 8, !tbaa !5
  %54 = fdiv double %52, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  ret double %54
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !16, i64 0}
!16 = !{!"any pointer", !7, i64 0}
!17 = !{!18, !6, i64 56}
!18 = !{!"_ZTSN19TechnologyParameter10DeviceTypeE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160}
!19 = !{!18, !6, i64 64}


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

%class.TechnologyParameter = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, i64, %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::InterconnectType", %"class.TechnologyParameter::InterconnectType", %"class.TechnologyParameter::InterconnectType", %"class.TechnologyParameter::ScalingFactor", %"class.TechnologyParameter::MemoryType", %"class.TechnologyParameter::MemoryType", %"class.TechnologyParameter::MemoryType" }
%"class.TechnologyParameter::DeviceType" = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double }
%"class.TechnologyParameter::InterconnectType" = type { double, double, double, double, double, double, double, double }
%"class.TechnologyParameter::ScalingFactor" = type { double, double, double }
%"class.TechnologyParameter::MemoryType" = type { double, double, double, double, double, double }

@g_tp = external local_unnamed_addr global %class.TechnologyParameter, align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef double @_Z6R_to_wdibbb(double noundef %0, i32 noundef %1, i1 noundef zeroext %2, i1 noundef zeroext %3, i1 noundef zeroext %4) local_unnamed_addr #0 {
  %.not11 = xor i1 %3, true
  %brmerge.not = and i1 %2, %3
  br i1 %brmerge.not, label %8, label %6

6:                                                ; preds = %5
  %brmerge14.not = and i1 %2, %4
  br i1 %brmerge14.not, label %8, label %7

7:                                                ; preds = %6
  %brmerge16 = or i1 %.not11, %2
  %spec.select = select i1 %brmerge16, ptr getelementptr inbounds (i8, ptr @g_tp, i64 864), ptr getelementptr inbounds (i8, ptr @g_tp, i64 360)
  br label %8

8:                                                ; preds = %7, %6, %5
  %.0 = phi ptr [ getelementptr inbounds (i8, ptr @g_tp, i64 528), %5 ], [ getelementptr inbounds (i8, ptr @g_tp, i64 696), %6 ], [ %spec.select, %7 ]
  %.not = icmp eq i32 %1, 0
  %.in.v = select i1 %.not, i64 64, i64 56
  %.in = getelementptr inbounds i8, ptr %.0, i64 %.in.v
  %9 = load double, ptr %.in, align 8, !tbaa !5
  %10 = fdiv double %9, %0
  ret double %10
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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