; LLVM IR from 4LT/galines :: evolver (createEvolver)

; 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.LineDef = type { i32, i32, i32, i32, i32 }
%struct.PointList = type { ptr, i32, i32 }
%struct.Evolver = type { ptr, i32, i32, %struct.Sequence, ptr }
%struct.Sequence = type { i64, ptr }

; Function Attrs: nounwind uwtable
define dso_local ptr @createEvolver(ptr noundef %0, i32 noundef %1, i32 noundef %2, i64 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca %struct.LineDef, align 8
  %14 = alloca %struct.PointList, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i64 %3, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = load i32, ptr %7, align 4, !tbaa !9
  %17 = mul i32 %15, %16
  %18 = zext i32 %17 to i64
  store i64 %18, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %19 = load i64, ptr %9, align 8, !tbaa !11
  %20 = mul i64 %19, 4
  store i64 %20, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %21 = call noalias ptr @malloc(i64 noundef 40) #7
  store ptr %21, ptr %11, align 8, !tbaa !5
  %22 = load i64, ptr %10, align 8, !tbaa !11
  %23 = call noalias ptr @malloc(i64 noundef %22) #7
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.Evolver, ptr %24, i32 0, i32 0
  store ptr %23, ptr %25, align 8, !tbaa !13
  %26 = load i64, ptr %9, align 8, !tbaa !11
  %27 = call noalias ptr @calloc(i64 noundef %26, i64 noundef 4) #8
  %28 = load ptr, ptr %11, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.Evolver, ptr %28, i32 0, i32 4
  store ptr %27, ptr %29, align 8, !tbaa !16
  %30 = load ptr, ptr %11, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Evolver, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load i64, ptr %10, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %32, ptr align 4 %33, i64 %34, i1 false)
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = load ptr, ptr %11, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.Evolver, ptr %36, i32 0, i32 1
  store i32 %35, ptr %37, align 8, !tbaa !17
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.Evolver, ptr %39, i32 0, i32 2
  store i32 %38, ptr %40, align 4, !tbaa !18
  %41 = load i64, ptr %8, align 8, !tbaa !11
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.Evolver, ptr %42, i32 0, i32 3
  %44 = getelementptr inbounds %struct.Sequence, ptr %43, i32 0, i32 0
  store i64 %41, ptr %44, align 8, !tbaa !19
  %45 = load i64, ptr %8, align 8, !tbaa !11
  %46 = mul i64 %45, 20
  %47 = call noalias ptr @malloc(i64 noundef %46) #7
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Evolver, ptr %48, i32 0, i32 3
  %50 = getelementptr inbounds %struct.Sequence, ptr %49, i32 0, i32 1
  store ptr %47, ptr %50, align 8, !tbaa !20
  %51 = call i64 @time(ptr noundef null) #6
  %52 = trunc i64 %51 to i32
  call void @srand(i32 noundef %52) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %85, %4
  %54 = load i32, ptr %12, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = load i64, ptr %8, align 8, !tbaa !11
  %57 = icmp ult i64 %55, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %88

59:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 20, ptr %13) #6
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  call void @randomLine(ptr dead_on_unwind writable sret(%struct.LineDef) align 4 %13, ptr noundef %60)
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #6
  %61 = call { ptr, i64 } @lineToPoints(ptr noundef byval(%struct.LineDef) align 8 %13)
  %62 = getelementptr inbounds { ptr, i64 }, ptr %14, i32 0, i32 0
  %63 = extractvalue { ptr, i64 } %61, 0
  store ptr %63, ptr %62, align 8
  %64 = getelementptr inbounds { ptr, i64 }, ptr %14, i32 0, i32 1
  %65 = extractvalue { ptr, i64 } %61, 1
  store i64 %65, ptr %64, align 8
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.Evolver, ptr %66, i32 0, i32 3
  %68 = getelementptr inbounds %struct.Sequence, ptr %67, i32 0, i32 1
  %69 = load ptr, ptr %68, align 8, !tbaa !20
  %70 = load i32, ptr %12, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds %struct.LineDef, ptr %69, i64 %71
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %72, ptr align 4 %13, i64 20, i1 false), !tbaa.struct !21
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.Evolver, ptr %73, i32 0, i32 4
  %75 = load ptr, ptr %74, align 8, !tbaa !16
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.Evolver, ptr %76, i32 0, i32 1
  %78 = load i32, ptr %77, align 8, !tbaa !17
  %79 = getelementptr inbounds { ptr, i64 }, ptr %14, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8
  %81 = getelementptr inbounds { ptr, i64 }, ptr %14, i32 0, i32 1
  %82 = load i64, ptr %81, align 8
  call void @drawPoints(ptr noundef %75, i32 noundef %78, ptr %80, i64 %82)
  %83 = getelementptr inbounds %struct.PointList, ptr %14, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !22
  call void @free(ptr noundef %84) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 20, ptr %13) #6
  br label %85

85:                                               ; preds = %59
  %86 = load i32, ptr %12, align 4, !tbaa !9
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %12, align 4, !tbaa !9
  br label %53, !llvm.loop !24

88:                                               ; preds = %58
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  ret ptr %89
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #3

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

; Function Attrs: nounwind
declare void @srand(i32 noundef) #5

; Function Attrs: nounwind
declare i64 @time(ptr noundef) #5

; Function Attrs: nounwind uwtable
declare hidden void @randomLine(ptr dead_on_unwind noalias writable sret(%struct.LineDef) align 4, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden { ptr, i64 } @lineToPoints(ptr noundef byval(%struct.LineDef) align 8) #0

; Function Attrs: nounwind uwtable
declare hidden void @drawPoints(ptr noundef, i32 noundef, ptr, i64) #0

; Function Attrs: nounwind
declare void @free(ptr noundef) #5

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind allocsize(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 allocsize(0,1) "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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind "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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind allocsize(0,1) }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"Evolver", !6, i64 0, !10, i64 8, !10, i64 12, !15, i64 16, !6, i64 32}
!15 = !{!"Sequence", !12, i64 0, !6, i64 8}
!16 = !{!14, !6, i64 32}
!17 = !{!14, !10, i64 8}
!18 = !{!14, !10, i64 12}
!19 = !{!14, !12, i64 16}
!20 = !{!14, !6, i64 24}
!21 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 12, i64 4, !9, i64 16, i64 4, !9}
!22 = !{!23, !6, i64 0}
!23 = !{!"PointList", !6, i64 0, !10, i64 8, !10, i64 12}
!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.LineDef = type { i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @createEvolver(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2, i64 noundef %3) local_unnamed_addr #0 {
  %5 = alloca %struct.LineDef, align 8
  %6 = mul i32 %2, %1
  %7 = zext i32 %6 to i64
  %8 = shl nuw nsw i64 %7, 2
  %9 = tail call noalias dereferenceable_or_null(40) ptr @malloc(i64 noundef 40) #7
  %10 = tail call noalias ptr @malloc(i64 noundef %8) #7
  store ptr %10, ptr %9, align 8, !tbaa !5
  %11 = tail call noalias ptr @calloc(i64 noundef %7, i64 noundef 4) #8
  %12 = getelementptr inbounds i8, ptr %9, i64 32
  store ptr %11, ptr %12, align 8, !tbaa !13
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %0, i64 %8, i1 false)
  %13 = getelementptr inbounds i8, ptr %9, i64 8
  store i32 %1, ptr %13, align 8, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %9, i64 12
  store i32 %2, ptr %14, align 4, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %9, i64 16
  store i64 %3, ptr %15, align 8, !tbaa !16
  %16 = mul i64 %3, 20
  %17 = tail call noalias ptr @malloc(i64 noundef %16) #7
  %18 = getelementptr inbounds i8, ptr %9, i64 24
  store ptr %17, ptr %18, align 8, !tbaa !17
  %19 = tail call i64 @time(ptr noundef null) #9
  %20 = trunc i64 %19 to i32
  tail call void @srand(i32 noundef %20) #9
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %4
  ret ptr %9

.lr.ph:                                           ; preds = %4, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %4 ]
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %5) #9
  call void @randomLine(ptr dead_on_unwind nonnull writable sret(%struct.LineDef) align 4 %5, ptr noundef nonnull %9)
  %21 = call { ptr, i64 } @lineToPoints(ptr noundef nonnull byval(%struct.LineDef) align 8 %5)
  %22 = extractvalue { ptr, i64 } %21, 0
  %23 = extractvalue { ptr, i64 } %21, 1
  %24 = load ptr, ptr %18, align 8, !tbaa !17
  %25 = getelementptr inbounds %struct.LineDef, ptr %24, i64 %indvars.iv
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(20) %25, ptr noundef nonnull align 8 dereferenceable(20) %5, i64 20, i1 false), !tbaa.struct !18
  %26 = load ptr, ptr %12, align 8, !tbaa !13
  %27 = load i32, ptr %13, align 8, !tbaa !14
  call void @drawPoints(ptr noundef %26, i32 noundef %27, ptr %22, i64 %23)
  call void @free(ptr noundef %22) #9
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %5) #9
  %indvars.iv.next = add nuw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %3
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !20
}

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind
declare void @srand(i32 noundef) local_unnamed_addr #5

; Function Attrs: nounwind
declare i64 @time(ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden void @randomLine(ptr dead_on_unwind noalias writable sret(%struct.LineDef) align 4, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden { ptr, i64 } @lineToPoints(ptr noundef byval(%struct.LineDef) align 8) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @drawPoints(ptr noundef, i32 noundef, ptr, i64) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #6

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind "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 #6 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind allocsize(0,1) }
attributes #9 = { 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 0}
!6 = !{!"Evolver", !7, i64 0, !10, i64 8, !10, i64 12, !11, i64 16, !7, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"Sequence", !12, i64 0, !7, i64 8}
!12 = !{!"long", !8, i64 0}
!13 = !{!6, !7, i64 32}
!14 = !{!6, !10, i64 8}
!15 = !{!6, !10, i64 12}
!16 = !{!6, !12, i64 16}
!17 = !{!6, !7, i64 24}
!18 = !{i64 0, i64 4, !19, i64 4, i64 4, !19, i64 8, i64 4, !19, i64 12, i64 4, !19, i64 16, i64 4, !19}
!19 = !{!10, !10, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


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