; LLVM IR from InductiveComputerScience/infracore :: examples/screen-demo1 (program)

; 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"

; Function Attrs: nounwind uwtable
declare dso_local void @DrawPixel(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @Program(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  call void @ScreenSpecs(ptr noundef %8, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  %9 = load double, ptr %3, align 8, !tbaa !9
  %10 = fmul double 4.000000e+00, %9
  %11 = load double, ptr %4, align 8, !tbaa !9
  %12 = fmul double %10, %11
  %13 = fptoui double %12 to i64
  %14 = call noalias ptr @malloc(i64 noundef %13) #7
  store ptr %14, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = load double, ptr %3, align 8, !tbaa !9
  %17 = fmul double 4.000000e+00, %16
  %18 = load double, ptr %4, align 8, !tbaa !9
  %19 = fmul double %17, %18
  %20 = fptoui double %19 to i64
  call void @llvm.memset.p0.i64(ptr align 4 %15, i8 0, i64 %20, i1 false)
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %43, %1
  %22 = load i32, ptr %7, align 4, !tbaa !11
  %23 = icmp slt i32 %22, 300
  br i1 %23, label %24, label %46

24:                                               ; preds = %21
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load double, ptr %3, align 8, !tbaa !9
  %27 = fptosi double %26 to i32
  %28 = load i32, ptr %7, align 4, !tbaa !11
  %29 = mul nsw i32 %28, 7
  %30 = sitofp i32 %29 to double
  %31 = load double, ptr %3, align 8, !tbaa !9
  %32 = call double @fmod(double noundef %30, double noundef %31) #6
  %33 = fptosi double %32 to i32
  %34 = load i32, ptr %7, align 4, !tbaa !11
  %35 = mul nsw i32 %34, 11
  %36 = sitofp i32 %35 to double
  %37 = load double, ptr %4, align 8, !tbaa !9
  %38 = call double @fmod(double noundef %36, double noundef %37) #6
  %39 = fptosi double %38 to i32
  call void @DrawPixel(ptr noundef %25, i32 noundef %27, i32 noundef %33, i32 noundef %39, i32 noundef 255, i32 noundef 255, i32 noundef 255)
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  call void @Display(ptr noundef %40, ptr noundef %41)
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  call void @Synchronize(ptr noundef %42)
  br label %43

43:                                               ; preds = %24
  %44 = load i32, ptr %7, align 4, !tbaa !11
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %7, align 4, !tbaa !11
  br label %21, !llvm.loop !13

46:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  ret void
}

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

declare void @ScreenSpecs(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: nounwind
declare double @fmod(double noundef, double noundef) #5

declare void @Display(ptr noundef, ptr noundef) #2

declare void @Synchronize(ptr noundef) #2

; 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 = { "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) "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: write) }
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) }

!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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

; Function Attrs: nounwind uwtable
declare dso_local void @DrawPixel(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @Program(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  call void @ScreenSpecs(ptr noundef %0, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4) #5
  %5 = load double, ptr %2, align 8, !tbaa !5
  %6 = fmul double %5, 4.000000e+00
  %7 = load double, ptr %3, align 8, !tbaa !5
  %8 = fmul double %6, %7
  %9 = fptoui double %8 to i64
  %calloc = call ptr @calloc(i64 1, i64 %9)
  br label %10

10:                                               ; preds = %1, %10
  %.09 = phi i32 [ 0, %1 ], [ %22, %10 ]
  %11 = load double, ptr %2, align 8, !tbaa !5
  %12 = fptosi double %11 to i32
  %13 = mul nuw nsw i32 %.09, 7
  %14 = uitofp nneg i32 %13 to double
  %15 = call double @fmod(double noundef %14, double noundef %11) #5
  %16 = fptosi double %15 to i32
  %17 = mul nuw nsw i32 %.09, 11
  %18 = uitofp nneg i32 %17 to double
  %19 = load double, ptr %3, align 8, !tbaa !5
  %20 = call double @fmod(double noundef %18, double noundef %19) #5
  %21 = fptosi double %20 to i32
  call void @DrawPixel(ptr noundef %calloc, i32 noundef %12, i32 noundef %16, i32 noundef %21, i32 noundef 255, i32 noundef 255, i32 noundef 255)
  call void @Display(ptr noundef %0, ptr noundef %calloc) #5
  call void @Synchronize(ptr noundef %0) #5
  %22 = add nuw nsw i32 %.09, 1
  %exitcond.not = icmp eq i32 %22, 300
  br i1 %exitcond.not, label %23, label %10, !llvm.loop !9

23:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  ret void
}

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

declare void @ScreenSpecs(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @fmod(double noundef, double noundef) local_unnamed_addr #3

declare void @Display(ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @Synchronize(ptr noundef) local_unnamed_addr #2

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

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

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 = { "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 memory(write) "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 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #5 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass