; 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.deque1 = 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 @d1_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.deque1, ptr %9, i32 0, i32 5
  store i32 0, ptr %10, align 8, !tbaa !11
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.deque1, ptr %11, i32 0, i32 1
  %13 = load i64, ptr %12, align 8, !tbaa !14
  %14 = load i64, ptr %5, align 8, !tbaa !9
  %15 = icmp eq i64 %13, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %2
  br label %91

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

23:                                               ; preds = %17
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.deque1, ptr %24, i32 0, i32 5
  store i32 4, ptr %25, align 8, !tbaa !11
  store i1 false, ptr %3, align 1
  br label %92

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

37:                                               ; preds = %26
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.deque1, ptr %38, i32 0, i32 5
  store i32 1, ptr %39, align 8, !tbaa !11
  store i1 false, ptr %3, align 1
  br label %92

40:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.deque1, ptr %41, i32 0, i32 3
  %43 = load i64, ptr %42, align 8, !tbaa !19
  store i64 %43, 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 %44

44:                                               ; preds = %66, %40
  %45 = load i64, ptr %8, align 8, !tbaa !9
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.deque1, ptr %46, i32 0, i32 2
  %48 = load i64, ptr %47, align 8, !tbaa !15
  %49 = icmp ult i64 %45, %48
  br i1 %49, label %51, label %50

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

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

66:                                               ; preds = %51
  %67 = load i64, ptr %8, align 8, !tbaa !9
  %68 = add i64 %67, 1
  store i64 %68, ptr %8, align 8, !tbaa !9
  br label %44, !llvm.loop !24

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

91:                                               ; preds = %69, %16
  store i1 true, ptr %3, align 1
  br label %92

92:                                               ; preds = %91, %37, %23
  %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, !13, i64 40}
!12 = !{!"deque1", !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 8}
!15 = !{!12, !10, i64 16}
!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 @d1_resize(ptr nocapture noundef %0, i64 noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 0, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i64, ptr %4, align 8, !tbaa !12
  %6 = icmp eq i64 %5, %1
  br i1 %6, label %38, label %7

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

11:                                               ; preds = %7
  store i32 4, ptr %3, align 8, !tbaa !5
  br label %38

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

18:                                               ; preds = %12
  store i32 1, ptr %3, align 8, !tbaa !5
  br label %38

19:                                               ; preds = %12
  %20 = getelementptr inbounds i8, ptr %0, i64 24
  %21 = load i64, ptr %8, align 8, !tbaa !13
  %.not35 = icmp eq i64 %21, 0
  br i1 %.not35, label %._crit_edge, label %.lr.ph.preheader

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

._crit_edge:                                      ; preds = %.lr.ph, %19
  %23 = load ptr, ptr %13, align 8, !tbaa !14
  %24 = getelementptr inbounds i8, ptr %23, i64 24
  %25 = load ptr, ptr %24, align 8, !tbaa !18
  %26 = load ptr, ptr %0, align 8, !tbaa !19
  tail call void %25(ptr noundef %26) #2
  store ptr %17, ptr %0, align 8, !tbaa !19
  store i64 %1, ptr %4, align 8, !tbaa !12
  store i64 0, ptr %20, align 8, !tbaa !17
  %27 = load i64, ptr %8, align 8, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %27, ptr %28, align 8, !tbaa !20
  br label %38

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.034 = phi i64 [ %35, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %.02933 = phi i64 [ %34, %.lr.ph ], [ %22, %.lr.ph.preheader ]
  %29 = getelementptr inbounds %struct.struct_s, ptr %17, i64 %.034
  %30 = load ptr, ptr %0, align 8, !tbaa !19
  %31 = getelementptr inbounds %struct.struct_s, ptr %30, i64 %.02933
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %29, ptr noundef nonnull align 8 dereferenceable(104) %31, i64 104, i1 false), !tbaa.struct !21
  %32 = add i64 %.02933, 1
  %33 = load i64, ptr %4, align 8, !tbaa !12
  %34 = urem i64 %32, %33
  %35 = add nuw i64 %.034, 1
  %36 = load i64, ptr %8, align 8, !tbaa !13
  %37 = icmp ult i64 %35, %36
  br i1 %37, label %.lr.ph, label %._crit_edge, !llvm.loop !25

38:                                               ; preds = %._crit_edge, %2, %18, %11
  %.030 = phi i1 [ false, %11 ], [ false, %18 ], [ true, %2 ], [ true, %._crit_edge ]
  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, !11, i64 40}
!6 = !{!"deque1", !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 8}
!13 = !{!6, !10, i64 16}
!14 = !{!6, !7, i64 56}
!15 = !{!16, !7, i64 0}
!16 = !{!"cmc_alloc_node", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!17 = !{!6, !10, i64 24}
!18 = !{!16, !7, i64 24}
!19 = !{!6, !7, i64 0}
!20 = !{!6, !10, i64 32}
!21 = !{i64 0, i64 4, !22, i64 4, i64 4, !22, i64 8, i64 8, !23, i64 16, i64 8, !23, i64 24, i64 80, !24}
!22 = !{!11, !11, i64 0}
!23 = !{!7, !7, i64 0}
!24 = !{!8, !8, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


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