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

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @ih0_resize(ptr noundef %0, i64 noundef %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.intervalheap0, ptr %7, i32 0, i32 1
  %9 = load i64, ptr %8, align 8, !tbaa !11
  %10 = load i64, ptr %5, align 8, !tbaa !9
  %11 = icmp eq i64 %9, %10
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  br label %74

13:                                               ; preds = %2
  %14 = load i64, ptr %5, align 8, !tbaa !9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.intervalheap0, ptr %15, i32 0, i32 3
  %17 = load i64, ptr %16, align 8, !tbaa !14
  %18 = icmp ult i64 %14, %17
  br i1 %18, label %19, label %22

19:                                               ; preds = %13
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.intervalheap0, ptr %20, i32 0, i32 4
  store i32 4, ptr %21, align 8, !tbaa !15
  store i1 false, ptr %3, align 1
  br label %77

22:                                               ; preds = %13
  %23 = load i64, ptr %5, align 8, !tbaa !9
  %24 = icmp eq i64 %23, -1
  br i1 %24, label %25, label %28

25:                                               ; preds = %22
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.intervalheap0, ptr %26, i32 0, i32 4
  store i32 7, ptr %27, align 8, !tbaa !15
  store i1 false, ptr %3, align 1
  br label %77

28:                                               ; preds = %22
  %29 = load i64, ptr %5, align 8, !tbaa !9
  %30 = urem i64 %29, 2
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = add i64 %31, %30
  store i64 %32, ptr %5, align 8, !tbaa !9
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.intervalheap0, ptr %33, i32 0, i32 6
  %35 = load ptr, ptr %34, align 8, !tbaa !16
  %36 = getelementptr inbounds %struct.cmc_alloc_node, ptr %35, i32 0, i32 2
  %37 = load ptr, ptr %36, align 8, !tbaa !17
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.intervalheap0, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !19
  %41 = load i64, ptr %5, align 8, !tbaa !9
  %42 = mul i64 16, %41
  %43 = call ptr %37(ptr noundef %40, i64 noundef %42)
  store ptr %43, ptr %6, align 8, !tbaa !5
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %49, label %46

46:                                               ; preds = %28
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.intervalheap0, ptr %47, i32 0, i32 4
  store i32 1, ptr %48, align 8, !tbaa !15
  store i1 false, ptr %3, align 1
  br label %77

49:                                               ; preds = %28
  %50 = load i64, ptr %5, align 8, !tbaa !9
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.intervalheap0, ptr %51, i32 0, i32 1
  %53 = load i64, ptr %52, align 8, !tbaa !11
  %54 = icmp ugt i64 %50, %53
  br i1 %54, label %55, label %67

55:                                               ; preds = %49
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.intervalheap0, ptr %57, i32 0, i32 1
  %59 = load i64, ptr %58, align 8, !tbaa !11
  %60 = getelementptr inbounds [2 x ptr], ptr %56, i64 %59
  %61 = load i64, ptr %5, align 8, !tbaa !9
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.intervalheap0, ptr %62, i32 0, i32 1
  %64 = load i64, ptr %63, align 8, !tbaa !11
  %65 = sub i64 %61, %64
  %66 = mul i64 16, %65
  call void @llvm.memset.p0.i64(ptr align 8 %60, i8 0, i64 %66, i1 false)
  br label %67

67:                                               ; preds = %55, %49
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.intervalheap0, ptr %69, i32 0, i32 0
  store ptr %68, ptr %70, align 8, !tbaa !19
  %71 = load i64, ptr %5, align 8, !tbaa !9
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.intervalheap0, ptr %72, i32 0, i32 1
  store i64 %71, ptr %73, align 8, !tbaa !11
  br label %74

74:                                               ; preds = %67, %12
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.intervalheap0, ptr %75, i32 0, i32 4
  store i32 0, ptr %76, align 8, !tbaa !15
  store i1 true, ptr %3, align 1
  br label %77

77:                                               ; preds = %74, %46, %25, %19
  %78 = load i1, ptr %3, align 1
  ret i1 %78
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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" }

!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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"intervalheap0", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !13, i64 32, !6, i64 40, !6, i64 48}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !10, i64 24}
!15 = !{!12, !13, i64 32}
!16 = !{!12, !6, i64 48}
!17 = !{!18, !6, i64 16}
!18 = !{!"cmc_alloc_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!19 = !{!12, !6, i64 0}


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

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

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @ih0_resize(ptr nocapture noundef %0, i64 noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = icmp eq i64 %4, %1
  br i1 %5, label %30, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load i64, ptr %7, align 8, !tbaa !12
  %9 = icmp ugt i64 %8, %1
  br i1 %9, label %30, label %10

10:                                               ; preds = %6
  %11 = icmp eq i64 %1, -1
  br i1 %11, label %30, label %12

12:                                               ; preds = %10
  %13 = and i64 %1, 1
  %14 = add nuw i64 %13, %1
  %15 = getelementptr inbounds i8, ptr %0, i64 48
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  %19 = load ptr, ptr %0, align 8, !tbaa !16
  %20 = shl i64 %14, 4
  %21 = tail call ptr %18(ptr noundef %19, i64 noundef %20) #2
  %.not = icmp eq ptr %21, null
  br i1 %.not, label %30, label %22

22:                                               ; preds = %12
  %23 = load i64, ptr %3, align 8, !tbaa !5
  %24 = icmp ugt i64 %14, %23
  br i1 %24, label %25, label %29

25:                                               ; preds = %22
  %26 = getelementptr inbounds [2 x ptr], ptr %21, i64 %23
  %27 = sub i64 %14, %23
  %28 = shl i64 %27, 4
  tail call void @llvm.memset.p0.i64(ptr nonnull align 8 %26, i8 0, i64 %28, i1 false)
  br label %29

29:                                               ; preds = %25, %22
  store ptr %21, ptr %0, align 8, !tbaa !16
  store i64 %14, ptr %3, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %29, %2, %12, %10, %6
  %.sink = phi i32 [ 4, %6 ], [ 7, %10 ], [ 1, %12 ], [ 0, %2 ], [ 0, %29 ]
  %.0 = phi i1 [ false, %6 ], [ false, %10 ], [ false, %12 ], [ true, %2 ], [ true, %29 ]
  %31 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 %.sink, ptr %31, align 8, !tbaa !17
  ret i1 %.0
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"intervalheap0", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !11, 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 = !{!"int", !8, i64 0}
!12 = !{!6, !10, i64 24}
!13 = !{!6, !7, i64 48}
!14 = !{!15, !7, i64 16}
!15 = !{!"cmc_alloc_node", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!16 = !{!6, !7, i64 0}
!17 = !{!6, !11, i64 32}


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