; 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.queue1 = type { ptr, i64, i64, i64, i64, i32, ptr, ptr }
%struct.cmc_alloc_node = type { ptr, ptr, ptr, ptr }
%struct.struct_s = type { i32, i32, ptr, ptr, [10 x double] }

; 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
define dso_local zeroext i1 @q1_resize(ptr noundef %0, i64 noundef %1) #2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.queue1, ptr %9, i32 0, i32 1
  %11 = load i64, ptr %10, align 8, !tbaa !11
  %12 = load i64, ptr %5, align 8, !tbaa !9
  %13 = icmp eq i64 %11, %12
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  br label %89

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

21:                                               ; preds = %15
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.queue1, ptr %22, i32 0, i32 5
  store i32 4, ptr %23, align 8, !tbaa !15
  store i1 false, ptr %3, align 1
  br label %92

24:                                               ; preds = %15
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.queue1, ptr %25, i32 0, i32 7
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  %28 = getelementptr inbounds %struct.cmc_alloc_node, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !17
  %30 = load i64, ptr %5, align 8, !tbaa !9
  %31 = mul i64 104, %30
  %32 = call ptr %29(i64 noundef %31)
  store ptr %32, ptr %6, align 8, !tbaa !5
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %38, label %35

35:                                               ; preds = %24
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.queue1, ptr %36, i32 0, i32 5
  store i32 1, ptr %37, align 8, !tbaa !15
  store i1 false, ptr %3, align 1
  br label %92

38:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.queue1, ptr %39, i32 0, i32 3
  %41 = load i64, ptr %40, align 8, !tbaa !19
  store i64 %41, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %64, %38
  %43 = load i64, ptr %8, align 8, !tbaa !9
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.queue1, ptr %44, i32 0, i32 2
  %46 = load i64, ptr %45, align 8, !tbaa !14
  %47 = icmp ult i64 %43, %46
  br i1 %47, label %49, label %48

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

49:                                               ; preds = %42
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = load i64, ptr %8, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct.struct_s, ptr %50, i64 %51
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.queue1, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !20
  %56 = load i64, ptr %7, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.struct_s, ptr %55, i64 %56
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %52, ptr align 8 %57, i64 104, i1 false), !tbaa.struct !21
  %58 = load i64, ptr %7, align 8, !tbaa !9
  %59 = add i64 %58, 1
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.queue1, ptr %60, i32 0, i32 1
  %62 = load i64, ptr %61, align 8, !tbaa !11
  %63 = urem i64 %59, %62
  store i64 %63, ptr %7, align 8, !tbaa !9
  br label %64

64:                                               ; preds = %49
  %65 = load i64, ptr %8, align 8, !tbaa !9
  %66 = add i64 %65, 1
  store i64 %66, ptr %8, align 8, !tbaa !9
  br label %42, !llvm.loop !24

67:                                               ; preds = %48
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.queue1, ptr %68, i32 0, i32 7
  %70 = load ptr, ptr %69, align 8, !tbaa !16
  %71 = getelementptr inbounds %struct.cmc_alloc_node, ptr %70, i32 0, i32 3
  %72 = load ptr, ptr %71, align 8, !tbaa !26
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.queue1, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !20
  call void %72(ptr noundef %75)
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.queue1, ptr %77, i32 0, i32 0
  store ptr %76, ptr %78, align 8, !tbaa !20
  %79 = load i64, ptr %5, align 8, !tbaa !9
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.queue1, ptr %80, i32 0, i32 1
  store i64 %79, ptr %81, align 8, !tbaa !11
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.queue1, ptr %82, i32 0, i32 3
  store i64 0, ptr %83, align 8, !tbaa !19
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.queue1, ptr %84, i32 0, i32 2
  %86 = load i64, ptr %85, align 8, !tbaa !14
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.queue1, ptr %87, i32 0, i32 4
  store i64 %86, ptr %88, align 8, !tbaa !27
  br label %89

89:                                               ; preds = %67, %14
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.queue1, ptr %90, i32 0, i32 5
  store i32 0, ptr %91, align 8, !tbaa !15
  store i1 true, ptr %3, align 1
  br label %92

92:                                               ; preds = %89, %35, %21
  %93 = load i1, ptr %3, align 1
  ret i1 %93
}

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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"queue1", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !13, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !13, i64 40}
!16 = !{!12, !6, i64 56}
!17 = !{!18, !6, i64 0}
!18 = !{!"cmc_alloc_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!19 = !{!12, !10, i64 24}
!20 = !{!12, !6, i64 0}
!21 = !{i64 0, i64 4, !22, i64 4, i64 4, !22, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 80, !23}
!22 = !{!13, !13, i64 0}
!23 = !{!7, !7, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!18, !6, i64 24}
!27 = !{!12, !10, i64 32}


; 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.struct_s = type { i32, i32, ptr, ptr, [10 x double] }

; 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
define dso_local noundef zeroext i1 @q1_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 %35, label %6

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

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %0, i64 56
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %14 = mul i64 %1, 104
  %15 = tail call ptr %13(i64 noundef %14) #2
  %.not = icmp eq ptr %15, null
  br i1 %.not, label %35, label %16

16:                                               ; preds = %10
  %17 = getelementptr inbounds i8, ptr %0, i64 24
  %18 = load i64, ptr %7, align 8, !tbaa !12
  %.not35 = icmp eq i64 %18, 0
  br i1 %.not35, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %16
  %19 = load i64, ptr %17, align 8, !tbaa !16
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %16
  %20 = load ptr, ptr %11, align 8, !tbaa !13
  %21 = getelementptr inbounds i8, ptr %20, i64 24
  %22 = load ptr, ptr %21, align 8, !tbaa !17
  %23 = load ptr, ptr %0, align 8, !tbaa !18
  tail call void %22(ptr noundef %23) #2
  store ptr %15, ptr %0, align 8, !tbaa !18
  store i64 %1, ptr %3, align 8, !tbaa !5
  store i64 0, ptr %17, align 8, !tbaa !16
  %24 = load i64, ptr %7, align 8, !tbaa !12
  %25 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %24, ptr %25, align 8, !tbaa !19
  br label %35

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.034 = phi i64 [ %32, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %.02933 = phi i64 [ %31, %.lr.ph ], [ %19, %.lr.ph.preheader ]
  %26 = getelementptr inbounds %struct.struct_s, ptr %15, i64 %.034
  %27 = load ptr, ptr %0, align 8, !tbaa !18
  %28 = getelementptr inbounds %struct.struct_s, ptr %27, i64 %.02933
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %26, ptr noundef nonnull align 8 dereferenceable(104) %28, i64 104, i1 false), !tbaa.struct !20
  %29 = add i64 %.02933, 1
  %30 = load i64, ptr %3, align 8, !tbaa !5
  %31 = urem i64 %29, %30
  %32 = add nuw i64 %.034, 1
  %33 = load i64, ptr %7, align 8, !tbaa !12
  %34 = icmp ult i64 %32, %33
  br i1 %34, label %.lr.ph, label %._crit_edge, !llvm.loop !24

35:                                               ; preds = %._crit_edge, %2, %10, %6
  %.sink = phi i32 [ 4, %6 ], [ 1, %10 ], [ 0, %2 ], [ 0, %._crit_edge ]
  %.030 = phi i1 [ false, %6 ], [ false, %10 ], [ true, %2 ], [ true, %._crit_edge ]
  %36 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 %.sink, ptr %36, align 8, !tbaa !26
  ret i1 %.030
}

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 = !{!"queue1", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !11, i64 40, !7, i64 48, !7, i64 56}
!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 16}
!13 = !{!6, !7, i64 56}
!14 = !{!15, !7, i64 0}
!15 = !{!"cmc_alloc_node", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!16 = !{!6, !10, i64 24}
!17 = !{!15, !7, i64 24}
!18 = !{!6, !7, i64 0}
!19 = !{!6, !10, i64 32}
!20 = !{i64 0, i64 4, !21, i64 4, i64 4, !21, i64 8, i64 8, !22, i64 16, i64 8, !22, i64 24, i64 80, !23}
!21 = !{!11, !11, i64 0}
!22 = !{!7, !7, i64 0}
!23 = !{!8, !8, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!6, !11, i64 40}


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