; 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.hashmultiset0 = type { ptr, i64, i64, i64, double, i32, 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 @hms0_new_custom(i64 noundef %0, double noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca double, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store i64 %0, ptr %7, align 8, !tbaa !5
  store double %1, ptr %8, align 8, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !11
  store ptr %3, ptr %10, align 8, !tbaa !11
  store ptr %4, ptr %11, align 8, !tbaa !11
  %15 = load ptr, ptr %11, align 8, !tbaa !11
  %16 = load i64, ptr %7, align 8, !tbaa !5
  %17 = icmp eq i64 %16, 0
  br i1 %17, label %24, label %18

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

21:                                               ; preds = %18
  %22 = load double, ptr %8, align 8, !tbaa !9
  %23 = fcmp oge double %22, 1.000000e+00
  br i1 %23, label %24, label %25

24:                                               ; preds = %21, %18, %5
  store ptr null, ptr %6, align 8
  br label %92

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

31:                                               ; preds = %25
  store ptr null, ptr %6, align 8
  br label %92

32:                                               ; preds = %25
  %33 = load ptr, ptr %9, align 8, !tbaa !11
  %34 = icmp ne ptr %33, null
  br i1 %34, label %36, label %35

35:                                               ; preds = %32
  store ptr null, ptr %6, align 8
  br label %92

36:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %37 = load i64, ptr %7, align 8, !tbaa !5
  %38 = uitofp i64 %37 to double
  %39 = load double, ptr %8, align 8, !tbaa !9
  %40 = fdiv double %38, %39
  %41 = fptoui double %40 to i64
  %42 = call i64 @hms0_impl_calculate_size(i64 noundef %41)
  store i64 %42, ptr %12, align 8, !tbaa !5
  %43 = load ptr, ptr %10, align 8, !tbaa !11
  %44 = icmp ne ptr %43, null
  br i1 %44, label %46, label %45

45:                                               ; preds = %36
  store ptr @cmc_alloc_node_default, ptr %10, align 8, !tbaa !11
  br label %46

46:                                               ; preds = %45, %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %47 = load ptr, ptr %10, align 8, !tbaa !11
  %48 = getelementptr inbounds %struct.cmc_alloc_node, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  %50 = call ptr %49(i64 noundef 64)
  store ptr %50, ptr %13, align 8, !tbaa !11
  %51 = load ptr, ptr %13, align 8, !tbaa !11
  %52 = icmp ne ptr %51, null
  br i1 %52, label %54, label %53

53:                                               ; preds = %46
  store ptr null, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %91

54:                                               ; preds = %46
  %55 = load ptr, ptr %10, align 8, !tbaa !11
  %56 = getelementptr inbounds %struct.cmc_alloc_node, ptr %55, i32 0, i32 1
  %57 = load ptr, ptr %56, align 8, !tbaa !15
  %58 = load i64, ptr %12, align 8, !tbaa !5
  %59 = call ptr %57(i64 noundef %58, i64 noundef 32)
  %60 = load ptr, ptr %13, align 8, !tbaa !11
  %61 = getelementptr inbounds %struct.hashmultiset0, ptr %60, i32 0, i32 0
  store ptr %59, ptr %61, align 8, !tbaa !16
  %62 = load ptr, ptr %13, align 8, !tbaa !11
  %63 = getelementptr inbounds %struct.hashmultiset0, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !16
  %65 = icmp ne ptr %64, null
  br i1 %65, label %71, label %66

66:                                               ; preds = %54
  %67 = load ptr, ptr %10, align 8, !tbaa !11
  %68 = getelementptr inbounds %struct.cmc_alloc_node, ptr %67, i32 0, i32 3
  %69 = load ptr, ptr %68, align 8, !tbaa !19
  %70 = load ptr, ptr %13, align 8, !tbaa !11
  call void %69(ptr noundef %70)
  store ptr null, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %91

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

91:                                               ; preds = %71, %66, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  br label %92

92:                                               ; preds = %91, %35, %31, %24
  %93 = load ptr, ptr %6, align 8
  ret ptr %93
}

; Function Attrs: nounwind uwtable
declare hidden i64 @hms0_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 = !{!"hashmultiset0", !12, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !18, 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 24}
!22 = !{!17, !6, i64 8}
!23 = !{!17, !10, i64 32}
!24 = !{!17, !18, 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 @hms0_new_custom(i64 noundef %0, double noundef %1, ptr noundef %2, ptr noundef %3, ptr nocapture noundef readnone %4) local_unnamed_addr #0 {
  %6 = icmp eq i64 %0, 0
  %7 = fcmp ole double %1, 0.000000e+00
  %or.cond = or i1 %6, %7
  %8 = fcmp oge double %1, 1.000000e+00
  %or.cond3 = or i1 %8, %or.cond
  br i1 %or.cond3, label %33, label %9

9:                                                ; preds = %5
  %10 = uitofp i64 %0 to double
  %11 = fmul double %1, 0x43F0000000000000
  %12 = fcmp ole double %11, %10
  %.not = icmp eq ptr %2, null
  %or.cond41 = or i1 %12, %.not
  br i1 %or.cond41, label %33, label %13

13:                                               ; preds = %9
  %14 = fdiv double %10, %1
  %15 = fptoui double %14 to i64
  %16 = tail call i64 @hms0_impl_calculate_size(i64 noundef %15)
  %.not38 = icmp eq ptr %3, null
  %spec.store.select = select i1 %.not38, ptr @cmc_alloc_node_default, ptr %3
  %17 = load ptr, ptr %spec.store.select, align 8, !tbaa !5
  %18 = tail call ptr %17(i64 noundef 64) #2
  %.not39 = icmp eq ptr %18, null
  br i1 %.not39, label %33, label %19

19:                                               ; preds = %13
  %20 = getelementptr inbounds i8, ptr %spec.store.select, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !10
  %22 = tail call ptr %21(i64 noundef %16, i64 noundef 32) #2
  store ptr %22, ptr %18, align 8, !tbaa !11
  %.not40 = icmp eq ptr %22, null
  br i1 %.not40, label %23, label %26

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %spec.store.select, i64 24
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  tail call void %25(ptr noundef nonnull %18) #2
  br label %33

26:                                               ; preds = %19
  %27 = getelementptr inbounds i8, ptr %18, i64 16
  %28 = getelementptr inbounds i8, ptr %18, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %27, i8 0, i64 16, i1 false)
  store i64 %16, ptr %28, align 8, !tbaa !17
  %29 = getelementptr inbounds i8, ptr %18, i64 32
  store double %1, ptr %29, align 8, !tbaa !18
  %30 = getelementptr inbounds i8, ptr %18, i64 40
  store i32 0, ptr %30, align 8, !tbaa !19
  %31 = getelementptr inbounds i8, ptr %18, i64 48
  store ptr %2, ptr %31, align 8, !tbaa !20
  %32 = getelementptr inbounds i8, ptr %18, i64 56
  store ptr %spec.store.select, ptr %32, align 8, !tbaa !21
  br label %33

33:                                               ; preds = %23, %26, %13, %9, %5
  %.1 = phi ptr [ null, %5 ], [ null, %9 ], [ %18, %26 ], [ null, %23 ], [ null, %13 ]
  ret ptr %.1
}

; Function Attrs: nounwind uwtable
declare hidden i64 @hms0_impl_calculate_size(i64 noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 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 = !{!"hashmultiset0", !7, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !14, i64 32, !15, 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 8}
!18 = !{!12, !14, i64 32}
!19 = !{!12, !15, i64 40}
!20 = !{!12, !7, i64 48}
!21 = !{!12, !7, i64 56}


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