; 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 }
%struct.intervalheap0_fval = type { ptr, ptr, ptr, ptr, ptr, ptr }

; 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 ptr @ih0_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
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.intervalheap0, ptr %7, i32 0, i32 6
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds %struct.cmc_alloc_node, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %12 = call ptr %11(i64 noundef 56)
  store ptr %12, ptr %4, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %18, label %15

15:                                               ; preds = %1
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.intervalheap0, ptr %16, i32 0, i32 4
  store i32 1, ptr %17, align 8, !tbaa !15
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %133

18:                                               ; preds = %1
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %19, ptr align 8 %20, i64 56, i1 false)
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.intervalheap0, ptr %21, i32 0, i32 6
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.cmc_alloc_node, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !13
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.intervalheap0, ptr %26, i32 0, i32 1
  %28 = load i64, ptr %27, align 8, !tbaa !16
  %29 = mul i64 16, %28
  %30 = call ptr %25(i64 noundef %29)
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.intervalheap0, ptr %31, i32 0, i32 0
  store ptr %30, ptr %32, align 8, !tbaa !17
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.intervalheap0, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !17
  %36 = icmp ne ptr %35, null
  br i1 %36, label %46, label %37

37:                                               ; preds = %18
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.intervalheap0, ptr %38, i32 0, i32 6
  %40 = load ptr, ptr %39, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.cmc_alloc_node, ptr %40, i32 0, i32 3
  %42 = load ptr, ptr %41, align 8, !tbaa !18
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  call void %42(ptr noundef %43)
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.intervalheap0, ptr %44, i32 0, i32 4
  store i32 1, ptr %45, align 8, !tbaa !15
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %133

46:                                               ; preds = %18
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.intervalheap0, ptr %47, i32 0, i32 5
  %49 = load ptr, ptr %48, align 8, !tbaa !19
  %50 = getelementptr inbounds %struct.intervalheap0_fval, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !20
  %52 = icmp ne ptr %51, null
  br i1 %52, label %53, label %91

53:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !22
  br label %54

54:                                               ; preds = %87, %53
  %55 = load i64, ptr %6, align 8, !tbaa !22
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.intervalheap0, ptr %56, i32 0, i32 3
  %58 = load i64, ptr %57, align 8, !tbaa !23
  %59 = icmp ult i64 %55, %58
  br i1 %59, label %61, label %60

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

61:                                               ; preds = %54
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.intervalheap0, ptr %62, i32 0, i32 5
  %64 = load ptr, ptr %63, align 8, !tbaa !19
  %65 = getelementptr inbounds %struct.intervalheap0_fval, ptr %64, i32 0, i32 1
  %66 = load ptr, ptr %65, align 8, !tbaa !20
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.intervalheap0, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !17
  %70 = load i64, ptr %6, align 8, !tbaa !22
  %71 = udiv i64 %70, 2
  %72 = getelementptr inbounds [2 x ptr], ptr %69, i64 %71
  %73 = load i64, ptr %6, align 8, !tbaa !22
  %74 = urem i64 %73, 2
  %75 = getelementptr inbounds [2 x ptr], ptr %72, i64 0, i64 %74
  %76 = load ptr, ptr %75, align 8, !tbaa !5
  %77 = call ptr %66(ptr noundef %76)
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.intervalheap0, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !17
  %81 = load i64, ptr %6, align 8, !tbaa !22
  %82 = udiv i64 %81, 2
  %83 = getelementptr inbounds [2 x ptr], ptr %80, i64 %82
  %84 = load i64, ptr %6, align 8, !tbaa !22
  %85 = urem i64 %84, 2
  %86 = getelementptr inbounds [2 x ptr], ptr %83, i64 0, i64 %85
  store ptr %77, ptr %86, align 8, !tbaa !5
  br label %87

87:                                               ; preds = %61
  %88 = load i64, ptr %6, align 8, !tbaa !22
  %89 = add i64 %88, 1
  store i64 %89, ptr %6, align 8, !tbaa !22
  br label %54, !llvm.loop !24

90:                                               ; preds = %60
  br label %102

91:                                               ; preds = %46
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.intervalheap0, ptr %92, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !17
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.intervalheap0, ptr %95, i32 0, i32 0
  %97 = load ptr, ptr %96, align 8, !tbaa !17
  %98 = load ptr, ptr %3, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.intervalheap0, ptr %98, i32 0, i32 1
  %100 = load i64, ptr %99, align 8, !tbaa !16
  %101 = mul i64 16, %100
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %94, ptr align 8 %97, i64 %101, i1 false)
  br label %102

102:                                              ; preds = %91, %90
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.intervalheap0, ptr %103, i32 0, i32 1
  %105 = load i64, ptr %104, align 8, !tbaa !16
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.intervalheap0, ptr %106, i32 0, i32 1
  store i64 %105, ptr %107, align 8, !tbaa !16
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.intervalheap0, ptr %108, i32 0, i32 2
  %110 = load i64, ptr %109, align 8, !tbaa !26
  %111 = load ptr, ptr %4, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.intervalheap0, ptr %111, i32 0, i32 2
  store i64 %110, ptr %112, align 8, !tbaa !26
  %113 = load ptr, ptr %3, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.intervalheap0, ptr %113, i32 0, i32 3
  %115 = load i64, ptr %114, align 8, !tbaa !23
  %116 = load ptr, ptr %4, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.intervalheap0, ptr %116, i32 0, i32 3
  store i64 %115, ptr %117, align 8, !tbaa !23
  %118 = load ptr, ptr %4, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.intervalheap0, ptr %118, i32 0, i32 4
  store i32 0, ptr %119, align 8, !tbaa !15
  %120 = load ptr, ptr %3, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.intervalheap0, ptr %120, i32 0, i32 5
  %122 = load ptr, ptr %121, align 8, !tbaa !19
  %123 = load ptr, ptr %4, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.intervalheap0, ptr %123, i32 0, i32 5
  store ptr %122, ptr %124, align 8, !tbaa !19
  %125 = load ptr, ptr %3, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.intervalheap0, ptr %125, i32 0, i32 6
  %127 = load ptr, ptr %126, align 8, !tbaa !9
  %128 = load ptr, ptr %4, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.intervalheap0, ptr %128, i32 0, i32 6
  store ptr %127, ptr %129, align 8, !tbaa !9
  %130 = load ptr, ptr %3, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.intervalheap0, ptr %130, i32 0, i32 4
  store i32 0, ptr %131, align 8, !tbaa !15
  %132 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %132, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %133

133:                                              ; preds = %102, %37, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %134 = load ptr, ptr %2, align 8
  ret ptr %134
}

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

; 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 ptr @ih0_copy_of(ptr nocapture noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 48
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !12
  %5 = tail call ptr %4(i64 noundef 56) #2
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %49, label %6

6:                                                ; preds = %1
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %5, ptr noundef nonnull align 8 dereferenceable(56) %0, i64 56, i1 false)
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load i64, ptr %9, align 8, !tbaa !14
  %11 = shl i64 %10, 4
  %12 = tail call ptr %8(i64 noundef %11) #2
  store ptr %12, ptr %5, align 8, !tbaa !15
  %.not42 = icmp eq ptr %12, null
  br i1 %.not42, label %13, label %17

13:                                               ; preds = %6
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 24
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  tail call void %16(ptr noundef nonnull %5) #2
  br label %49

17:                                               ; preds = %6
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  %19 = load ptr, ptr %18, align 8, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  %.not43 = icmp eq ptr %21, null
  br i1 %.not43, label %38, label %.preheader

.preheader:                                       ; preds = %17
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  %23 = load i64, ptr %22, align 8, !tbaa !20
  %.not45 = icmp eq i64 %23, 0
  br i1 %.not45, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.044 = phi i64 [ %35, %.lr.ph ], [ 0, %.preheader ]
  %24 = load ptr, ptr %18, align 8, !tbaa !17
  %25 = getelementptr inbounds i8, ptr %24, i64 8
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %27 = load ptr, ptr %0, align 8, !tbaa !15
  %28 = lshr i64 %.044, 1
  %29 = and i64 %.044, 1
  %30 = getelementptr inbounds [2 x ptr], ptr %27, i64 %28, i64 %29
  %31 = load ptr, ptr %30, align 8, !tbaa !21
  %32 = tail call ptr %26(ptr noundef %31) #2
  %33 = load ptr, ptr %5, align 8, !tbaa !15
  %34 = getelementptr inbounds [2 x ptr], ptr %33, i64 %28, i64 %29
  store ptr %32, ptr %34, align 8, !tbaa !21
  %35 = add nuw i64 %.044, 1
  %36 = load i64, ptr %22, align 8, !tbaa !20
  %37 = icmp ult i64 %35, %36
  br i1 %37, label %.lr.ph, label %.loopexit, !llvm.loop !22

38:                                               ; preds = %17
  %39 = load ptr, ptr %0, align 8, !tbaa !15
  %40 = load i64, ptr %9, align 8, !tbaa !14
  %41 = shl i64 %40, 4
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %12, ptr align 8 %39, i64 %41, i1 false)
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 24
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !20
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %.preheader, %38
  %42 = phi i64 [ 0, %.preheader ], [ %.pre, %38 ], [ %36, %.lr.ph ]
  %43 = getelementptr inbounds i8, ptr %5, i64 8
  %44 = load <2 x i64>, ptr %9, align 8, !tbaa !24
  store <2 x i64> %44, ptr %43, align 8, !tbaa !24
  %45 = getelementptr inbounds i8, ptr %5, i64 24
  store i64 %42, ptr %45, align 8, !tbaa !20
  %46 = getelementptr inbounds i8, ptr %5, i64 32
  store i32 0, ptr %46, align 8, !tbaa !25
  %47 = getelementptr inbounds i8, ptr %5, i64 40
  %48 = load <2 x ptr>, ptr %18, align 8, !tbaa !21
  store <2 x ptr> %48, ptr %47, align 8, !tbaa !21
  br label %49

49:                                               ; preds = %1, %.loopexit, %13
  %.sink = phi i32 [ 0, %.loopexit ], [ 1, %13 ], [ 1, %1 ]
  %.039 = phi ptr [ %5, %.loopexit ], [ null, %13 ], [ null, %1 ]
  %50 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 %.sink, ptr %50, align 8, !tbaa !25
  ret ptr %.039
}

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


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