; 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.struct_s = type { i32, i32, ptr, ptr, [10 x double] }
%struct.deque1 = type { ptr, i64, i64, i64, i64, i32, ptr, ptr }
%struct.deque1_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
declare dso_local ptr @d1_new_custom(i64 noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @d1_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 i64, align 8
  %8 = alloca %struct.struct_s, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.deque1, ptr %11, i32 0, i32 1
  %13 = load i64, ptr %12, align 8, !tbaa !9
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.deque1, ptr %14, i32 0, i32 6
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.deque1, ptr %17, i32 0, i32 7
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = call ptr @d1_new_custom(i64 noundef %13, ptr noundef %16, ptr noundef %19, ptr noundef null)
  store ptr %20, ptr %4, align 8, !tbaa !5
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %26, label %23

23:                                               ; preds = %1
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.deque1, ptr %24, i32 0, i32 5
  store i32 7, ptr %25, align 8, !tbaa !15
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %118

26:                                               ; preds = %1
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.deque1, ptr %27, i32 0, i32 6
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = getelementptr inbounds %struct.deque1_fval, ptr %29, i32 0, i32 1
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %70

33:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.deque1, ptr %34, i32 0, i32 3
  %36 = load i64, ptr %35, align 8, !tbaa !18
  store i64 %36, ptr %6, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 0, ptr %7, align 8, !tbaa !19
  br label %37

37:                                               ; preds = %66, %33
  %38 = load i64, ptr %7, align 8, !tbaa !19
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.deque1, ptr %39, i32 0, i32 2
  %41 = load i64, ptr %40, align 8, !tbaa !20
  %42 = icmp ult i64 %38, %41
  br i1 %42, label %44, label %43

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

44:                                               ; preds = %37
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.deque1, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !21
  %48 = load i64, ptr %7, align 8, !tbaa !19
  %49 = getelementptr inbounds %struct.struct_s, ptr %47, i64 %48
  call void @llvm.lifetime.start.p0(i64 104, ptr %8) #3
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.deque1, ptr %50, i32 0, i32 6
  %52 = load ptr, ptr %51, align 8, !tbaa !13
  %53 = getelementptr inbounds %struct.deque1_fval, ptr %52, i32 0, i32 1
  %54 = load ptr, ptr %53, align 8, !tbaa !16
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.deque1, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !21
  %58 = load i64, ptr %6, align 8, !tbaa !19
  %59 = getelementptr inbounds %struct.struct_s, ptr %57, i64 %58
  call void %54(ptr dead_on_unwind writable sret(%struct.struct_s) align 8 %8, ptr noundef byval(%struct.struct_s) align 8 %59)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %49, ptr align 8 %8, i64 104, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 104, ptr %8) #3
  %60 = load i64, ptr %6, align 8, !tbaa !19
  %61 = add i64 %60, 1
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.deque1, ptr %62, i32 0, i32 1
  %64 = load i64, ptr %63, align 8, !tbaa !9
  %65 = urem i64 %61, %64
  store i64 %65, ptr %6, align 8, !tbaa !19
  br label %66

66:                                               ; preds = %44
  %67 = load i64, ptr %7, align 8, !tbaa !19
  %68 = add i64 %67, 1
  store i64 %68, ptr %7, align 8, !tbaa !19
  br label %37, !llvm.loop !25

69:                                               ; preds = %43
  br label %102

70:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.deque1, ptr %71, i32 0, i32 3
  %73 = load i64, ptr %72, align 8, !tbaa !18
  store i64 %73, ptr %9, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i64 0, ptr %10, align 8, !tbaa !19
  br label %74

74:                                               ; preds = %98, %70
  %75 = load i64, ptr %10, align 8, !tbaa !19
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.deque1, ptr %76, i32 0, i32 2
  %78 = load i64, ptr %77, align 8, !tbaa !20
  %79 = icmp ult i64 %75, %78
  br i1 %79, label %81, label %80

80:                                               ; preds = %74
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %101

81:                                               ; preds = %74
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.deque1, ptr %82, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !21
  %85 = load i64, ptr %10, align 8, !tbaa !19
  %86 = getelementptr inbounds %struct.struct_s, ptr %84, i64 %85
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.deque1, ptr %87, i32 0, i32 0
  %89 = load ptr, ptr %88, align 8, !tbaa !21
  %90 = load i64, ptr %9, align 8, !tbaa !19
  %91 = getelementptr inbounds %struct.struct_s, ptr %89, i64 %90
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %86, ptr align 8 %91, i64 104, i1 false), !tbaa.struct !22
  %92 = load i64, ptr %9, align 8, !tbaa !19
  %93 = add i64 %92, 1
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.deque1, ptr %94, i32 0, i32 1
  %96 = load i64, ptr %95, align 8, !tbaa !9
  %97 = urem i64 %93, %96
  store i64 %97, ptr %9, align 8, !tbaa !19
  br label %98

98:                                               ; preds = %81
  %99 = load i64, ptr %10, align 8, !tbaa !19
  %100 = add i64 %99, 1
  store i64 %100, ptr %10, align 8, !tbaa !19
  br label %74, !llvm.loop !27

101:                                              ; preds = %80
  br label %102

102:                                              ; preds = %101, %69
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.deque1, ptr %103, i32 0, i32 2
  %105 = load i64, ptr %104, align 8, !tbaa !20
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.deque1, ptr %106, i32 0, i32 2
  store i64 %105, ptr %107, align 8, !tbaa !20
  %108 = load ptr, ptr %4, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.deque1, ptr %108, i32 0, i32 3
  store i64 0, ptr %109, align 8, !tbaa !18
  %110 = load ptr, ptr %3, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.deque1, ptr %110, i32 0, i32 2
  %112 = load i64, ptr %111, align 8, !tbaa !20
  %113 = load ptr, ptr %4, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.deque1, ptr %113, i32 0, i32 4
  store i64 %112, ptr %114, align 8, !tbaa !28
  %115 = load ptr, ptr %3, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.deque1, ptr %115, i32 0, i32 5
  store i32 0, ptr %116, align 8, !tbaa !15
  %117 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %117, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %118

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

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 = !{!"deque1", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !12, i64 40, !6, i64 48, !6, i64 56}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, i64 48}
!14 = !{!10, !6, i64 56}
!15 = !{!10, !12, i64 40}
!16 = !{!17, !6, i64 8}
!17 = !{!"deque1_fval", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!18 = !{!10, !11, i64 24}
!19 = !{!11, !11, i64 0}
!20 = !{!10, !11, i64 16}
!21 = !{!10, !6, i64 0}
!22 = !{i64 0, i64 4, !23, i64 4, i64 4, !23, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 80, !24}
!23 = !{!12, !12, i64 0}
!24 = !{!7, !7, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = distinct !{!27, !26}
!28 = !{!10, !11, 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; 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) #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @d1_copy_of(ptr nocapture noundef %0) local_unnamed_addr #2 {
  %2 = alloca %struct.struct_s, align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = tail call ptr @d1_new_custom(i64 noundef %4, ptr noundef %6, ptr noundef %8, ptr noundef null)
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %51, label %10

10:                                               ; preds = %1
  %11 = load ptr, ptr %5, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %.not39 = icmp eq ptr %13, null
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = load i64, ptr %14, align 8, !tbaa !16
  %.not47 = icmp eq i64 %15, 0
  br i1 %.not39, label %32, label %16

16:                                               ; preds = %10
  br i1 %.not47, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %16
  %17 = getelementptr inbounds i8, ptr %0, i64 24
  %18 = load i64, ptr %17, align 8, !tbaa !17
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.03542 = phi i64 [ %29, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %.03641 = phi i64 [ %28, %.lr.ph ], [ %18, %.lr.ph.preheader ]
  %19 = load ptr, ptr %9, align 8, !tbaa !18
  %20 = getelementptr inbounds %struct.struct_s, ptr %19, i64 %.03542
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %2) #3
  %21 = load ptr, ptr %5, align 8, !tbaa !12
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = load ptr, ptr %0, align 8, !tbaa !18
  %25 = getelementptr inbounds %struct.struct_s, ptr %24, i64 %.03641
  call void %23(ptr dead_on_unwind nonnull writable sret(%struct.struct_s) align 8 %2, ptr noundef byval(%struct.struct_s) align 8 %25) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %20, ptr noundef nonnull align 8 dereferenceable(104) %2, i64 104, i1 false), !tbaa.struct !19
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %2) #3
  %26 = add i64 %.03641, 1
  %27 = load i64, ptr %3, align 8, !tbaa !5
  %28 = urem i64 %26, %27
  %29 = add nuw i64 %.03542, 1
  %30 = load i64, ptr %14, align 8, !tbaa !16
  %31 = icmp ult i64 %29, %30
  br i1 %31, label %.lr.ph, label %.loopexit, !llvm.loop !23

32:                                               ; preds = %10
  br i1 %.not47, label %.loopexit, label %.lr.ph45.preheader

.lr.ph45.preheader:                               ; preds = %32
  %33 = getelementptr inbounds i8, ptr %0, i64 24
  %34 = load i64, ptr %33, align 8, !tbaa !17
  br label %.lr.ph45

.lr.ph45:                                         ; preds = %.lr.ph45.preheader, %.lr.ph45
  %.044 = phi i64 [ %42, %.lr.ph45 ], [ 0, %.lr.ph45.preheader ]
  %.03443 = phi i64 [ %41, %.lr.ph45 ], [ %34, %.lr.ph45.preheader ]
  %35 = load ptr, ptr %9, align 8, !tbaa !18
  %36 = getelementptr inbounds %struct.struct_s, ptr %35, i64 %.044
  %37 = load ptr, ptr %0, align 8, !tbaa !18
  %38 = getelementptr inbounds %struct.struct_s, ptr %37, i64 %.03443
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %36, ptr noundef nonnull align 8 dereferenceable(104) %38, i64 104, i1 false), !tbaa.struct !19
  %39 = add i64 %.03443, 1
  %40 = load i64, ptr %3, align 8, !tbaa !5
  %41 = urem i64 %39, %40
  %42 = add nuw i64 %.044, 1
  %43 = load i64, ptr %14, align 8, !tbaa !16
  %44 = icmp ult i64 %42, %43
  br i1 %44, label %.lr.ph45, label %.loopexit, !llvm.loop !25

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph45, %16, %32
  %45 = phi i64 [ 0, %16 ], [ 0, %32 ], [ %43, %.lr.ph45 ], [ %30, %.lr.ph ]
  %46 = getelementptr inbounds i8, ptr %0, i64 16
  %47 = getelementptr inbounds i8, ptr %9, i64 16
  store i64 %45, ptr %47, align 8, !tbaa !16
  %48 = getelementptr inbounds i8, ptr %9, i64 24
  store i64 0, ptr %48, align 8, !tbaa !17
  %49 = load i64, ptr %46, align 8, !tbaa !16
  %50 = getelementptr inbounds i8, ptr %9, i64 32
  store i64 %49, ptr %50, align 8, !tbaa !26
  br label %51

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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, !10, i64 8}
!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, !7, i64 48}
!13 = !{!6, !7, i64 56}
!14 = !{!15, !7, i64 8}
!15 = !{!"deque1_fval", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!16 = !{!6, !10, i64 16}
!17 = !{!6, !10, i64 24}
!18 = !{!6, !7, i64 0}
!19 = !{i64 0, i64 4, !20, i64 4, i64 4, !20, i64 8, i64 8, !21, i64 16, i64 8, !21, i64 24, i64 80, !22}
!20 = !{!11, !11, i64 0}
!21 = !{!7, !7, i64 0}
!22 = !{!8, !8, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}
!26 = !{!6, !10, i64 32}
!27 = !{!6, !11, i64 40}


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