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

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @hs0_new_custom(i64 noundef, double noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @hs0_copy_of(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.hashset0, ptr %9, i32 0, i32 1
  %11 = load i64, ptr %10, align 8, !tbaa !9
  %12 = uitofp i64 %11 to double
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.hashset0, ptr %13, i32 0, i32 3
  %15 = load double, ptr %14, align 8, !tbaa !14
  %16 = fmul double %12, %15
  %17 = fptoui double %16 to i64
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.hashset0, ptr %18, i32 0, i32 3
  %20 = load double, ptr %19, align 8, !tbaa !14
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.hashset0, ptr %21, i32 0, i32 5
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.hashset0, ptr %24, i32 0, i32 6
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  %27 = call ptr @hs0_new_custom(i64 noundef %17, double noundef %20, ptr noundef %23, ptr noundef %26, ptr noundef null)
  store ptr %27, ptr %4, align 8, !tbaa !5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %33, label %30

30:                                               ; preds = %1
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.hashset0, ptr %31, i32 0, i32 4
  store i32 7, ptr %32, align 8, !tbaa !17
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %119

33:                                               ; preds = %1
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.hashset0, ptr %34, i32 0, i32 5
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = getelementptr inbounds %struct.hashset0_fval, ptr %36, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !18
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %99

40:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !20
  br label %41

41:                                               ; preds = %95, %40
  %42 = load i64, ptr %6, align 8, !tbaa !20
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.hashset0, ptr %43, i32 0, i32 1
  %45 = load i64, ptr %44, align 8, !tbaa !9
  %46 = icmp ult i64 %42, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %41
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %98

48:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.hashset0, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !21
  %52 = load i64, ptr %6, align 8, !tbaa !20
  %53 = getelementptr inbounds %struct.hashset0_entry, ptr %51, i64 %52
  store ptr %53, ptr %7, align 8, !tbaa !5
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.hashset0_entry, ptr %54, i32 0, i32 2
  %56 = load i32, ptr %55, align 8, !tbaa !22
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %94

58:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.hashset0, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !21
  %62 = load i64, ptr %6, align 8, !tbaa !20
  %63 = getelementptr inbounds %struct.hashset0_entry, ptr %61, i64 %62
  store ptr %63, ptr %8, align 8, !tbaa !5
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.hashset0_entry, ptr %64, i32 0, i32 2
  %66 = load i32, ptr %65, align 8, !tbaa !22
  %67 = icmp eq i32 %66, -1
  br i1 %67, label %68, label %71

68:                                               ; preds = %58
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.hashset0_entry, ptr %69, i32 0, i32 2
  store i32 -1, ptr %70, align 8, !tbaa !22
  br label %93

71:                                               ; preds = %58
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.hashset0_entry, ptr %72, i32 0, i32 2
  %74 = load i32, ptr %73, align 8, !tbaa !22
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.hashset0_entry, ptr %75, i32 0, i32 2
  store i32 %74, ptr %76, align 8, !tbaa !22
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.hashset0_entry, ptr %77, i32 0, i32 1
  %79 = load i64, ptr %78, align 8, !tbaa !24
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.hashset0_entry, ptr %80, i32 0, i32 1
  store i64 %79, ptr %81, align 8, !tbaa !24
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.hashset0, ptr %82, i32 0, i32 5
  %84 = load ptr, ptr %83, align 8, !tbaa !15
  %85 = getelementptr inbounds %struct.hashset0_fval, ptr %84, i32 0, i32 1
  %86 = load ptr, ptr %85, align 8, !tbaa !18
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.hashset0_entry, ptr %87, i32 0, i32 0
  %89 = load ptr, ptr %88, align 8, !tbaa !25
  %90 = call ptr %86(ptr noundef %89)
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.hashset0_entry, ptr %91, i32 0, i32 0
  store ptr %90, ptr %92, align 8, !tbaa !25
  br label %93

93:                                               ; preds = %71, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %94

94:                                               ; preds = %93, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %95

95:                                               ; preds = %94
  %96 = load i64, ptr %6, align 8, !tbaa !20
  %97 = add i64 %96, 1
  store i64 %97, ptr %6, align 8, !tbaa !20
  br label %41, !llvm.loop !26

98:                                               ; preds = %47
  br label %110

99:                                               ; preds = %33
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.hashset0, ptr %100, i32 0, i32 0
  %102 = load ptr, ptr %101, align 8, !tbaa !21
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.hashset0, ptr %103, i32 0, i32 0
  %105 = load ptr, ptr %104, align 8, !tbaa !21
  %106 = load ptr, ptr %3, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.hashset0, ptr %106, i32 0, i32 1
  %108 = load i64, ptr %107, align 8, !tbaa !9
  %109 = mul i64 24, %108
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %102, ptr align 8 %105, i64 %109, i1 false)
  br label %110

110:                                              ; preds = %99, %98
  %111 = load ptr, ptr %3, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.hashset0, ptr %111, i32 0, i32 2
  %113 = load i64, ptr %112, align 8, !tbaa !28
  %114 = load ptr, ptr %4, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.hashset0, ptr %114, i32 0, i32 2
  store i64 %113, ptr %115, align 8, !tbaa !28
  %116 = load ptr, ptr %3, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.hashset0, ptr %116, i32 0, i32 4
  store i32 0, ptr %117, align 8, !tbaa !17
  %118 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %118, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %119

119:                                              ; preds = %110, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %120 = load ptr, ptr %2, align 8
  ret ptr %120
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"hashset0", !6, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !13, i64 32, !6, i64 40, !6, i64 48}
!11 = !{!"long", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!10, !12, i64 24}
!15 = !{!10, !6, i64 40}
!16 = !{!10, !6, i64 48}
!17 = !{!10, !13, i64 32}
!18 = !{!19, !6, i64 8}
!19 = !{!"hashset0_fval", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!20 = !{!11, !11, i64 0}
!21 = !{!10, !6, i64 0}
!22 = !{!23, !13, i64 16}
!23 = !{!"hashset0_entry", !6, i64 0, !11, i64 8, !13, i64 16}
!24 = !{!23, !11, i64 8}
!25 = !{!23, !6, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!10, !11, i64 16}


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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @hs0_new_custom(i64 noundef, double noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @hs0_copy_of(ptr nocapture noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %4 = uitofp i64 %3 to double
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load double, ptr %5, align 8, !tbaa !13
  %7 = fmul double %6, %4
  %8 = fptoui double %7 to i64
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %0, i64 48
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %13 = tail call ptr @hs0_new_custom(i64 noundef %8, double noundef %6, ptr noundef %10, ptr noundef %12, ptr noundef null)
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %51, label %14

14:                                               ; preds = %1
  %15 = load ptr, ptr %9, align 8, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !16
  %.not35 = icmp eq ptr %17, null
  br i1 %.not35, label %43, label %.preheader

.preheader:                                       ; preds = %14
  %18 = load i64, ptr %2, align 8, !tbaa !5
  %.not38 = icmp eq i64 %18, 0
  br i1 %.not38, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %39
  %19 = phi i64 [ %40, %39 ], [ %18, %.preheader ]
  %.03237 = phi i64 [ %41, %39 ], [ 0, %.preheader ]
  %20 = load ptr, ptr %0, align 8, !tbaa !18
  %21 = getelementptr inbounds %struct.hashset0_entry, ptr %20, i64 %.03237
  %22 = getelementptr inbounds i8, ptr %21, i64 16
  %23 = load i32, ptr %22, align 8, !tbaa !19
  %.not36 = icmp eq i32 %23, 0
  br i1 %.not36, label %39, label %24

24:                                               ; preds = %.lr.ph
  %25 = load ptr, ptr %13, align 8, !tbaa !18
  %26 = getelementptr inbounds %struct.hashset0_entry, ptr %25, i64 %.03237
  %27 = icmp eq i32 %23, -1
  %28 = getelementptr inbounds i8, ptr %26, i64 16
  br i1 %27, label %29, label %30

29:                                               ; preds = %24
  store i32 -1, ptr %28, align 8, !tbaa !19
  br label %39

30:                                               ; preds = %24
  store i32 %23, ptr %28, align 8, !tbaa !19
  %31 = getelementptr inbounds i8, ptr %21, i64 8
  %32 = load i64, ptr %31, align 8, !tbaa !21
  %33 = getelementptr inbounds i8, ptr %26, i64 8
  store i64 %32, ptr %33, align 8, !tbaa !21
  %34 = load ptr, ptr %9, align 8, !tbaa !14
  %35 = getelementptr inbounds i8, ptr %34, i64 8
  %36 = load ptr, ptr %35, align 8, !tbaa !16
  %37 = load ptr, ptr %21, align 8, !tbaa !22
  %38 = tail call ptr %36(ptr noundef %37) #2
  store ptr %38, ptr %26, align 8, !tbaa !22
  %.pre = load i64, ptr %2, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %29, %30, %.lr.ph
  %40 = phi i64 [ %19, %29 ], [ %.pre, %30 ], [ %19, %.lr.ph ]
  %41 = add nuw i64 %.03237, 1
  %42 = icmp ult i64 %41, %40
  br i1 %42, label %.lr.ph, label %.loopexit, !llvm.loop !23

43:                                               ; preds = %14
  %44 = load ptr, ptr %13, align 8, !tbaa !18
  %45 = load ptr, ptr %0, align 8, !tbaa !18
  %46 = load i64, ptr %2, align 8, !tbaa !5
  %47 = mul i64 %46, 24
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %44, ptr align 8 %45, i64 %47, i1 false)
  br label %.loopexit

.loopexit:                                        ; preds = %39, %.preheader, %43
  %48 = getelementptr inbounds i8, ptr %0, i64 16
  %49 = load i64, ptr %48, align 8, !tbaa !25
  %50 = getelementptr inbounds i8, ptr %13, i64 16
  store i64 %49, ptr %50, align 8, !tbaa !25
  br label %51

51:                                               ; preds = %1, %.loopexit
  %.sink = phi i32 [ 0, %.loopexit ], [ 7, %1 ]
  %52 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 %.sink, ptr %52, align 8, !tbaa !26
  ret ptr %13
}

attributes #0 = { mustprogress nocallback nofree 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, !10, i64 8}
!6 = !{!"hashset0", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !12, i64 32, !7, i64 40, !7, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!6, !11, i64 24}
!14 = !{!6, !7, i64 40}
!15 = !{!6, !7, i64 48}
!16 = !{!17, !7, i64 8}
!17 = !{!"hashset0_fval", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!18 = !{!6, !7, i64 0}
!19 = !{!20, !12, i64 16}
!20 = !{!"hashset0_entry", !7, i64 0, !10, i64 8, !12, i64 16}
!21 = !{!20, !10, i64 8}
!22 = !{!20, !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!6, !10, i64 16}
!26 = !{!6, !12, i64 32}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass