; LLVM IR from LeoVen/C-Macro-Collections :: tests (types)

; 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.cmc_alloc_node = type { ptr, ptr, ptr, ptr }
%struct.hashmultimap0 = type { ptr, i64, i64, double, i32, ptr, ptr, ptr }

@cmc_alloc_node_default = external hidden global %struct.cmc_alloc_node, 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 uwtable
define dso_local ptr @hmm0_new_custom(i64 noundef %0, double noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #1 {
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca double, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  store i64 %0, ptr %8, align 8, !tbaa !5
  store double %1, ptr %9, align 8, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !11
  store ptr %3, ptr %11, align 8, !tbaa !11
  store ptr %4, ptr %12, align 8, !tbaa !11
  store ptr %5, ptr %13, align 8, !tbaa !11
  %17 = load ptr, ptr %13, align 8, !tbaa !11
  %18 = load i64, ptr %8, align 8, !tbaa !5
  %19 = icmp eq i64 %18, 0
  br i1 %19, label %23, label %20

20:                                               ; preds = %6
  %21 = load double, ptr %9, align 8, !tbaa !9
  %22 = fcmp ole double %21, 0.000000e+00
  br i1 %22, label %23, label %24

23:                                               ; preds = %20, %6
  store ptr null, ptr %7, align 8
  br label %95

24:                                               ; preds = %20
  %25 = load i64, ptr %8, align 8, !tbaa !5
  %26 = uitofp i64 %25 to double
  %27 = load double, ptr %9, align 8, !tbaa !9
  %28 = fmul double 0x43F0000000000000, %27
  %29 = fcmp oge double %26, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %24
  store ptr null, ptr %7, align 8
  br label %95

31:                                               ; preds = %24
  %32 = load ptr, ptr %10, align 8, !tbaa !11
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %37

34:                                               ; preds = %31
  %35 = load ptr, ptr %11, align 8, !tbaa !11
  %36 = icmp ne ptr %35, null
  br i1 %36, label %38, label %37

37:                                               ; preds = %34, %31
  store ptr null, ptr %7, align 8
  br label %95

38:                                               ; preds = %34
  %39 = load ptr, ptr %12, align 8, !tbaa !11
  %40 = icmp ne ptr %39, null
  br i1 %40, label %42, label %41

41:                                               ; preds = %38
  store ptr @cmc_alloc_node_default, ptr %12, align 8, !tbaa !11
  br label %42

42:                                               ; preds = %41, %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  %43 = load i64, ptr %8, align 8, !tbaa !5
  %44 = uitofp i64 %43 to double
  %45 = load double, ptr %9, align 8, !tbaa !9
  %46 = fdiv double %44, %45
  %47 = fptoui double %46 to i64
  %48 = call i64 @hmm0_impl_calculate_size(i64 noundef %47)
  store i64 %48, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  %49 = load ptr, ptr %12, align 8, !tbaa !11
  %50 = getelementptr inbounds %struct.cmc_alloc_node, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !13
  %52 = call ptr %51(i64 noundef 64)
  store ptr %52, ptr %15, align 8, !tbaa !11
  %53 = load ptr, ptr %15, align 8, !tbaa !11
  %54 = icmp ne ptr %53, null
  br i1 %54, label %56, label %55

55:                                               ; preds = %42
  store ptr null, ptr %7, align 8
  store i32 1, ptr %16, align 4
  br label %94

56:                                               ; preds = %42
  %57 = load ptr, ptr %12, align 8, !tbaa !11
  %58 = getelementptr inbounds %struct.cmc_alloc_node, ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !15
  %60 = load i64, ptr %14, align 8, !tbaa !5
  %61 = call ptr %59(i64 noundef %60, i64 noundef 16)
  %62 = load ptr, ptr %15, align 8, !tbaa !11
  %63 = getelementptr inbounds %struct.hashmultimap0, ptr %62, i32 0, i32 0
  store ptr %61, ptr %63, align 8, !tbaa !16
  %64 = load ptr, ptr %15, align 8, !tbaa !11
  %65 = getelementptr inbounds %struct.hashmultimap0, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !16
  %67 = icmp ne ptr %66, null
  br i1 %67, label %73, label %68

68:                                               ; preds = %56
  %69 = load ptr, ptr %12, align 8, !tbaa !11
  %70 = getelementptr inbounds %struct.cmc_alloc_node, ptr %69, i32 0, i32 3
  %71 = load ptr, ptr %70, align 8, !tbaa !19
  %72 = load ptr, ptr %15, align 8, !tbaa !11
  call void %71(ptr noundef %72)
  store ptr null, ptr %7, align 8
  store i32 1, ptr %16, align 4
  br label %94

73:                                               ; preds = %56
  %74 = load ptr, ptr %15, align 8, !tbaa !11
  %75 = getelementptr inbounds %struct.hashmultimap0, ptr %74, i32 0, i32 2
  store i64 0, ptr %75, align 8, !tbaa !20
  %76 = load i64, ptr %14, align 8, !tbaa !5
  %77 = load ptr, ptr %15, align 8, !tbaa !11
  %78 = getelementptr inbounds %struct.hashmultimap0, ptr %77, i32 0, i32 1
  store i64 %76, ptr %78, align 8, !tbaa !21
  %79 = load double, ptr %9, align 8, !tbaa !9
  %80 = load ptr, ptr %15, align 8, !tbaa !11
  %81 = getelementptr inbounds %struct.hashmultimap0, ptr %80, i32 0, i32 3
  store double %79, ptr %81, align 8, !tbaa !22
  %82 = load ptr, ptr %15, align 8, !tbaa !11
  %83 = getelementptr inbounds %struct.hashmultimap0, ptr %82, i32 0, i32 4
  store i32 0, ptr %83, align 8, !tbaa !23
  %84 = load ptr, ptr %10, align 8, !tbaa !11
  %85 = load ptr, ptr %15, align 8, !tbaa !11
  %86 = getelementptr inbounds %struct.hashmultimap0, ptr %85, i32 0, i32 5
  store ptr %84, ptr %86, align 8, !tbaa !24
  %87 = load ptr, ptr %11, align 8, !tbaa !11
  %88 = load ptr, ptr %15, align 8, !tbaa !11
  %89 = getelementptr inbounds %struct.hashmultimap0, ptr %88, i32 0, i32 6
  store ptr %87, ptr %89, align 8, !tbaa !25
  %90 = load ptr, ptr %12, align 8, !tbaa !11
  %91 = load ptr, ptr %15, align 8, !tbaa !11
  %92 = getelementptr inbounds %struct.hashmultimap0, ptr %91, i32 0, i32 7
  store ptr %90, ptr %92, align 8, !tbaa !26
  %93 = load ptr, ptr %15, align 8, !tbaa !11
  store ptr %93, ptr %7, align 8
  store i32 1, ptr %16, align 4
  br label %94

94:                                               ; preds = %73, %68, %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  br label %95

95:                                               ; preds = %94, %37, %30, %23
  %96 = load ptr, ptr %7, align 8
  ret ptr %96
}

; Function Attrs: nounwind uwtable
declare dso_local i64 @hmm0_impl_calculate_size(i64 noundef) #1

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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"cmc_alloc_node", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!15 = !{!14, !12, i64 8}
!16 = !{!17, !12, i64 0}
!17 = !{!"hashmultimap0", !12, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !18, i64 32, !12, i64 40, !12, i64 48, !12, i64 56}
!18 = !{!"int", !7, i64 0}
!19 = !{!14, !12, i64 24}
!20 = !{!17, !6, i64 16}
!21 = !{!17, !6, i64 8}
!22 = !{!17, !10, i64 24}
!23 = !{!17, !18, i64 32}
!24 = !{!17, !12, i64 40}
!25 = !{!17, !12, i64 48}
!26 = !{!17, !12, i64 56}


; 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.cmc_alloc_node = type { ptr, ptr, ptr, ptr }

@cmc_alloc_node_default = external hidden global %struct.cmc_alloc_node, align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @hmm0_new_custom(i64 noundef %0, double noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr nocapture noundef readnone %5) local_unnamed_addr #0 {
  %7 = icmp eq i64 %0, 0
  %8 = fcmp ole double %1, 0.000000e+00
  %or.cond = or i1 %7, %8
  br i1 %or.cond, label %37, label %9

9:                                                ; preds = %6
  %10 = uitofp i64 %0 to double
  %11 = fmul double %1, 0x43F0000000000000
  %12 = fcmp ugt double %11, %10
  br i1 %12, label %13, label %37

13:                                               ; preds = %9
  %14 = icmp ne ptr %2, null
  %15 = icmp ne ptr %3, null
  %or.cond3 = and i1 %14, %15
  br i1 %or.cond3, label %16, label %37

16:                                               ; preds = %13
  %.not = icmp eq ptr %4, null
  %spec.store.select = select i1 %.not, ptr @cmc_alloc_node_default, ptr %4
  %17 = fdiv double %10, %1
  %18 = fptoui double %17 to i64
  %19 = tail call i64 @hmm0_impl_calculate_size(i64 noundef %18)
  %20 = load ptr, ptr %spec.store.select, align 8, !tbaa !5
  %21 = tail call ptr %20(i64 noundef 64) #1
  %.not40 = icmp eq ptr %21, null
  br i1 %.not40, label %37, label %22

22:                                               ; preds = %16
  %23 = getelementptr inbounds i8, ptr %spec.store.select, i64 8
  %24 = load ptr, ptr %23, align 8, !tbaa !10
  %25 = tail call ptr %24(i64 noundef %19, i64 noundef 16) #1
  store ptr %25, ptr %21, align 8, !tbaa !11
  %.not41 = icmp eq ptr %25, null
  br i1 %.not41, label %26, label %29

26:                                               ; preds = %22
  %27 = getelementptr inbounds i8, ptr %spec.store.select, i64 24
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  tail call void %28(ptr noundef nonnull %21) #1
  br label %37

29:                                               ; preds = %22
  %30 = getelementptr inbounds i8, ptr %21, i64 16
  store i64 0, ptr %30, align 8, !tbaa !17
  %31 = getelementptr inbounds i8, ptr %21, i64 8
  store i64 %19, ptr %31, align 8, !tbaa !18
  %32 = getelementptr inbounds i8, ptr %21, i64 24
  store double %1, ptr %32, align 8, !tbaa !19
  %33 = getelementptr inbounds i8, ptr %21, i64 32
  store i32 0, ptr %33, align 8, !tbaa !20
  %34 = getelementptr inbounds i8, ptr %21, i64 40
  store ptr %2, ptr %34, align 8, !tbaa !21
  %35 = getelementptr inbounds i8, ptr %21, i64 48
  store ptr %3, ptr %35, align 8, !tbaa !22
  %36 = getelementptr inbounds i8, ptr %21, i64 56
  store ptr %spec.store.select, ptr %36, align 8, !tbaa !23
  br label %37

37:                                               ; preds = %26, %29, %16, %13, %9, %6
  %.1 = phi ptr [ null, %6 ], [ null, %9 ], [ null, %13 ], [ %21, %29 ], [ null, %26 ], [ null, %16 ]
  ret ptr %.1
}

; Function Attrs: nounwind uwtable
declare dso_local i64 @hmm0_impl_calculate_size(i64 noundef) 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 = { 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 0}
!6 = !{!"cmc_alloc_node", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!12, !7, i64 0}
!12 = !{!"hashmultimap0", !7, i64 0, !13, i64 8, !13, i64 16, !14, i64 24, !15, i64 32, !7, i64 40, !7, i64 48, !7, i64 56}
!13 = !{!"long", !8, i64 0}
!14 = !{!"double", !8, i64 0}
!15 = !{!"int", !8, i64 0}
!16 = !{!6, !7, i64 24}
!17 = !{!12, !13, i64 16}
!18 = !{!12, !13, i64 8}
!19 = !{!12, !14, i64 24}
!20 = !{!12, !15, i64 32}
!21 = !{!12, !7, i64 40}
!22 = !{!12, !7, i64 48}
!23 = !{!12, !7, i64 56}


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