; 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.hashmap0 = 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 @hm0_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 %26, 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 %26, label %23

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

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

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

33:                                               ; preds = %27
  store ptr null, ptr %7, align 8
  br label %98

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

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

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

41:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  %42 = load i64, ptr %8, align 8, !tbaa !5
  %43 = uitofp i64 %42 to double
  %44 = load double, ptr %9, align 8, !tbaa !9
  %45 = fdiv double %43, %44
  %46 = fptoui double %45 to i64
  %47 = call i64 @hm0_impl_calculate_size(i64 noundef %46)
  store i64 %47, ptr %14, align 8, !tbaa !5
  %48 = load ptr, ptr %12, align 8, !tbaa !11
  %49 = icmp ne ptr %48, null
  br i1 %49, label %51, label %50

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

51:                                               ; preds = %50, %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  %52 = load ptr, ptr %12, align 8, !tbaa !11
  %53 = getelementptr inbounds %struct.cmc_alloc_node, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !13
  %55 = call ptr %54(i64 noundef 64)
  store ptr %55, ptr %15, align 8, !tbaa !11
  %56 = load ptr, ptr %15, align 8, !tbaa !11
  %57 = icmp ne ptr %56, null
  br i1 %57, label %59, label %58

58:                                               ; preds = %51
  store ptr null, ptr %7, align 8
  store i32 1, ptr %16, align 4
  br label %97

59:                                               ; preds = %51
  %60 = load ptr, ptr %12, align 8, !tbaa !11
  %61 = getelementptr inbounds %struct.cmc_alloc_node, ptr %60, i32 0, i32 1
  %62 = load ptr, ptr %61, align 8, !tbaa !15
  %63 = load i64, ptr %14, align 8, !tbaa !5
  %64 = call ptr %62(i64 noundef %63, i64 noundef 32)
  %65 = load ptr, ptr %15, align 8, !tbaa !11
  %66 = getelementptr inbounds %struct.hashmap0, ptr %65, i32 0, i32 0
  store ptr %64, ptr %66, align 8, !tbaa !16
  %67 = load ptr, ptr %15, align 8, !tbaa !11
  %68 = getelementptr inbounds %struct.hashmap0, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !16
  %70 = icmp ne ptr %69, null
  br i1 %70, label %76, label %71

71:                                               ; preds = %59
  %72 = load ptr, ptr %12, align 8, !tbaa !11
  %73 = getelementptr inbounds %struct.cmc_alloc_node, ptr %72, i32 0, i32 3
  %74 = load ptr, ptr %73, align 8, !tbaa !19
  %75 = load ptr, ptr %15, align 8, !tbaa !11
  call void %74(ptr noundef %75)
  store ptr null, ptr %7, align 8
  store i32 1, ptr %16, align 4
  br label %97

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

97:                                               ; preds = %76, %71, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  br label %98

98:                                               ; preds = %97, %40, %33, %26
  %99 = load ptr, ptr %7, align 8
  ret ptr %99
}

; Function Attrs: nounwind uwtable
declare hidden i64 @hm0_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 = !{!"hashmap0", !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 @hm0_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
  %9 = fcmp oge double %1, 1.000000e+00
  %or.cond3 = or i1 %9, %or.cond
  br i1 %or.cond3, label %38, label %10

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

14:                                               ; preds = %10
  %15 = icmp ne ptr %2, null
  %16 = icmp ne ptr %3, null
  %or.cond5 = and i1 %15, %16
  br i1 %or.cond5, label %17, label %38

17:                                               ; preds = %14
  %18 = fdiv double %11, %1
  %19 = fptoui double %18 to i64
  %20 = tail call i64 @hm0_impl_calculate_size(i64 noundef %19)
  %.not = icmp eq ptr %4, null
  %spec.store.select = select i1 %.not, ptr @cmc_alloc_node_default, ptr %4
  %21 = load ptr, ptr %spec.store.select, align 8, !tbaa !5
  %22 = tail call ptr %21(i64 noundef 64) #1
  %.not43 = icmp eq ptr %22, null
  br i1 %.not43, label %38, label %23

23:                                               ; preds = %17
  %24 = getelementptr inbounds i8, ptr %spec.store.select, i64 8
  %25 = load ptr, ptr %24, align 8, !tbaa !10
  %26 = tail call ptr %25(i64 noundef %20, i64 noundef 32) #1
  store ptr %26, ptr %22, align 8, !tbaa !11
  %.not44 = icmp eq ptr %26, null
  br i1 %.not44, label %27, label %30

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

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

38:                                               ; preds = %27, %30, %17, %14, %10, %6
  %.1 = phi ptr [ null, %6 ], [ null, %10 ], [ null, %14 ], [ %22, %30 ], [ null, %27 ], [ null, %17 ]
  ret ptr %.1
}

; Function Attrs: nounwind uwtable
declare hidden i64 @hm0_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 = !{!"hashmap0", !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,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass