; 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.stack1 = type { ptr, i64, i64, i32, ptr, ptr }
%struct.stack1_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 @s1_new_custom(i64 noundef, ptr noundef, ptr noundef, ptr noundef) #2

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

20:                                               ; preds = %1
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.stack1, ptr %21, i32 0, i32 3
  store i32 7, ptr %22, align 8, !tbaa !15
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %78

23:                                               ; preds = %1
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.stack1, ptr %24, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = getelementptr inbounds %struct.stack1_fval, ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %58

30:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !18
  br label %31

31:                                               ; preds = %54, %30
  %32 = load i64, ptr %6, align 8, !tbaa !18
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.stack1, ptr %33, i32 0, i32 2
  %35 = load i64, ptr %34, align 8, !tbaa !19
  %36 = icmp ult i64 %32, %35
  br i1 %36, label %38, label %37

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

38:                                               ; preds = %31
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.stack1, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !20
  %42 = load i64, ptr %6, align 8, !tbaa !18
  %43 = getelementptr inbounds %struct.struct_s, ptr %41, i64 %42
  call void @llvm.lifetime.start.p0(i64 104, ptr %7) #3
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.stack1, ptr %44, i32 0, i32 4
  %46 = load ptr, ptr %45, align 8, !tbaa !13
  %47 = getelementptr inbounds %struct.stack1_fval, ptr %46, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8, !tbaa !16
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.stack1, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !20
  %52 = load i64, ptr %6, align 8, !tbaa !18
  %53 = getelementptr inbounds %struct.struct_s, ptr %51, i64 %52
  call void %48(ptr dead_on_unwind writable sret(%struct.struct_s) align 8 %7, ptr noundef byval(%struct.struct_s) align 8 %53)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %43, ptr align 8 %7, i64 104, i1 false), !tbaa.struct !21
  call void @llvm.lifetime.end.p0(i64 104, ptr %7) #3
  br label %54

54:                                               ; preds = %38
  %55 = load i64, ptr %6, align 8, !tbaa !18
  %56 = add i64 %55, 1
  store i64 %56, ptr %6, align 8, !tbaa !18
  br label %31, !llvm.loop !24

57:                                               ; preds = %37
  br label %69

58:                                               ; preds = %23
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.stack1, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !20
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.stack1, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !20
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.stack1, ptr %65, i32 0, i32 2
  %67 = load i64, ptr %66, align 8, !tbaa !19
  %68 = mul i64 104, %67
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %61, ptr align 8 %64, i64 %68, i1 false)
  br label %69

69:                                               ; preds = %58, %57
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.stack1, ptr %70, i32 0, i32 2
  %72 = load i64, ptr %71, align 8, !tbaa !19
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.stack1, ptr %73, i32 0, i32 2
  store i64 %72, ptr %74, align 8, !tbaa !19
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.stack1, ptr %75, i32 0, i32 3
  store i32 0, ptr %76, align 8, !tbaa !15
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %77, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %78

78:                                               ; preds = %69, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %79 = load ptr, ptr %2, align 8
  ret ptr %79
}

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


; 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 @s1_new_custom(i64 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @s1_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 32
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = tail call ptr @s1_new_custom(i64 noundef %4, ptr noundef %6, ptr noundef %8, ptr noundef null)
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %34, 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
  %.not23 = icmp eq ptr %13, null
  br i1 %.not23, label %26, label %.preheader

.preheader:                                       ; preds = %10
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = load i64, ptr %14, align 8, !tbaa !16
  %.not25 = icmp eq i64 %15, 0
  br i1 %.not25, label %.loopexit, label %.lr.ph

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

26:                                               ; preds = %10
  %27 = load ptr, ptr %9, align 8, !tbaa !17
  %28 = load ptr, ptr %0, align 8, !tbaa !17
  %29 = getelementptr inbounds i8, ptr %0, i64 16
  %30 = load i64, ptr %29, align 8, !tbaa !16
  %31 = mul i64 %30, 104
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %27, ptr align 8 %28, i64 %31, i1 false)
  %.pre = load i64, ptr %29, align 8, !tbaa !16
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %.preheader, %26
  %32 = phi i64 [ 0, %.preheader ], [ %.pre, %26 ], [ %24, %.lr.ph ]
  %33 = getelementptr inbounds i8, ptr %9, i64 16
  store i64 %32, ptr %33, align 8, !tbaa !16
  br label %34

34:                                               ; preds = %1, %.loopexit
  %.sink = phi i32 [ 0, %.loopexit ], [ 7, %1 ]
  %35 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %.sink, ptr %35, align 8, !tbaa !24
  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 = !{!"stack1", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !7, i64 32, !7, i64 40}
!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 32}
!13 = !{!6, !7, i64 40}
!14 = !{!15, !7, i64 8}
!15 = !{!"stack1_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, !7, i64 0}
!18 = !{i64 0, i64 4, !19, i64 4, i64 4, !19, i64 8, i64 8, !20, i64 16, i64 8, !20, i64 24, i64 80, !21}
!19 = !{!11, !11, i64 0}
!20 = !{!7, !7, i64 0}
!21 = !{!8, !8, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!6, !11, i64 24}


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