; LLVM IR from InductiveComputerScience/infracore :: examples/screen-keyboard-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, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  %11 = alloca ptr, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca i8, align 1
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  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 8, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  call void @ScreenSpecs(ptr noundef %18, ptr noundef %5, ptr noundef %6, ptr noundef %7)
  %19 = load double, ptr %5, align 8, !tbaa !9
  %20 = fmul double 4.000000e+00, %19
  %21 = load double, ptr %6, align 8, !tbaa !9
  %22 = fmul double %20, %21
  %23 = fptoui double %22 to i64
  %24 = call noalias ptr @malloc(i64 noundef %23) #7
  store ptr %24, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = load double, ptr %5, align 8, !tbaa !9
  %27 = fmul double 4.000000e+00, %26
  %28 = load double, ptr %6, align 8, !tbaa !9
  %29 = fmul double %27, %28
  %30 = fptoui double %29 to i64
  call void @llvm.memset.p0.i64(ptr align 4 %25, i8 0, i64 %30, i1 false)
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  call void @GetKeyboardSpecs(ptr noundef %31, ptr noundef %12, ptr noundef %13, ptr noundef %14)
  %32 = load double, ptr %14, align 8, !tbaa !9
  %33 = fmul double %32, 8.000000e+00
  %34 = fptoui double %33 to i64
  %35 = call noalias ptr @malloc(i64 noundef %34) #7
  store ptr %35, ptr %9, align 8, !tbaa !5
  %36 = load double, ptr %14, align 8, !tbaa !9
  %37 = fmul double %36, 1.000000e+00
  %38 = fptoui double %37 to i64
  %39 = call noalias ptr @malloc(i64 noundef %38) #7
  store ptr %39, ptr %11, align 8, !tbaa !5
  store i8 0, ptr %15, align 1, !tbaa !11
  store i32 0, ptr %16, align 4, !tbaa !13
  br label %40

40:                                               ; preds = %92, %2
  %41 = load i8, ptr %15, align 1, !tbaa !11, !range !15, !noundef !16
  %42 = trunc i8 %41 to i1
  %43 = xor i1 %42, true
  br i1 %43, label %44, label %95

44:                                               ; preds = %40
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  call void @GetKeyboardState(ptr noundef %45, ptr noundef %46, ptr noundef %47, ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  store i32 0, ptr %17, align 4, !tbaa !13
  br label %48

48:                                               ; preds = %70, %44
  %49 = load i32, ptr %17, align 4, !tbaa !13
  %50 = sitofp i32 %49 to double
  %51 = load double, ptr %10, align 8, !tbaa !9
  %52 = fcmp olt double %50, %51
  br i1 %52, label %54, label %53

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

54:                                               ; preds = %48
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = load i32, ptr %17, align 4, !tbaa !13
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds double, ptr %55, i64 %57
  %59 = load double, ptr %58, align 8, !tbaa !9
  %60 = fcmp oeq double %59, -4.300000e+01
  br i1 %60, label %61, label %69

61:                                               ; preds = %54
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = load i32, ptr %17, align 4, !tbaa !13
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i8, ptr %62, i64 %64
  %66 = load i8, ptr %65, align 1, !tbaa !11, !range !15, !noundef !16
  %67 = trunc i8 %66 to i1
  br i1 %67, label %68, label %69

68:                                               ; preds = %61
  store i8 1, ptr %15, align 1, !tbaa !11
  br label %69

69:                                               ; preds = %68, %61, %54
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %17, align 4, !tbaa !13
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %17, align 4, !tbaa !13
  br label %48, !llvm.loop !17

73:                                               ; preds = %53
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = load double, ptr %5, align 8, !tbaa !9
  %76 = fptosi double %75 to i32
  %77 = load i32, ptr %16, align 4, !tbaa !13
  %78 = mul nsw i32 %77, 7
  %79 = sitofp i32 %78 to double
  %80 = load double, ptr %5, align 8, !tbaa !9
  %81 = call double @fmod(double noundef %79, double noundef %80) #6
  %82 = fptosi double %81 to i32
  %83 = load i32, ptr %16, align 4, !tbaa !13
  %84 = mul nsw i32 %83, 11
  %85 = sitofp i32 %84 to double
  %86 = load double, ptr %6, align 8, !tbaa !9
  %87 = call double @fmod(double noundef %85, double noundef %86) #6
  %88 = fptosi double %87 to i32
  call void @DrawPixel(ptr noundef %74, i32 noundef %76, i32 noundef %82, i32 noundef %88, i32 noundef 255, i32 noundef 255, i32 noundef 255)
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  call void @Display(ptr noundef %89, ptr noundef %90)
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  call void @Synchronize(ptr noundef %91)
  br label %92

92:                                               ; preds = %73
  %93 = load i32, ptr %16, align 4, !tbaa !13
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %16, align 4, !tbaa !13
  br label %40, !llvm.loop !19

95:                                               ; preds = %40
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  call void @free(ptr noundef %96) #6
  %97 = load ptr, ptr %11, align 8, !tbaa !5
  call void @free(ptr noundef %97) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  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
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, 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
  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

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

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

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

; 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: nounwind
declare void @free(ptr noundef) #5

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 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #7
  call void @ScreenSpecs(ptr noundef %0, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5) #7
  %10 = load double, ptr %3, align 8, !tbaa !5
  %11 = fmul double %10, 4.000000e+00
  %12 = load double, ptr %4, align 8, !tbaa !5
  %13 = fmul double %11, %12
  %14 = fptoui double %13 to i64
  %calloc = call ptr @calloc(i64 1, i64 %14)
  call void @GetKeyboardSpecs(ptr noundef %1, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %9) #7
  %15 = load double, ptr %9, align 8, !tbaa !5
  %16 = fmul double %15, 8.000000e+00
  %17 = fptoui double %16 to i64
  %18 = call noalias ptr @malloc(i64 noundef %17) #8
  %19 = fptoui double %15 to i64
  %20 = call noalias ptr @malloc(i64 noundef %19) #8
  br label %21

21:                                               ; preds = %2, %._crit_edge
  %.02126 = phi i32 [ 0, %2 ], [ %35, %._crit_edge ]
  call void @GetKeyboardState(ptr noundef %1, ptr noundef %18, ptr noundef %20, ptr noundef nonnull %6) #7
  %22 = load double, ptr %6, align 8, !tbaa !5
  %23 = fcmp ogt double %22, 0.000000e+00
  br i1 %23, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %43, %21
  %.1.lcssa = phi i1 [ false, %21 ], [ %.2, %43 ]
  %24 = load double, ptr %3, align 8, !tbaa !5
  %25 = fptosi double %24 to i32
  %26 = mul nuw nsw i32 %.02126, 7
  %27 = uitofp nneg i32 %26 to double
  %28 = call double @fmod(double noundef %27, double noundef %24) #7
  %29 = fptosi double %28 to i32
  %30 = mul nuw nsw i32 %.02126, 11
  %31 = uitofp nneg i32 %30 to double
  %32 = load double, ptr %4, align 8, !tbaa !5
  %33 = call double @fmod(double noundef %31, double noundef %32) #7
  %34 = fptosi double %33 to i32
  call void @DrawPixel(ptr noundef %calloc, i32 noundef %25, i32 noundef %29, i32 noundef %34, i32 noundef 255, i32 noundef 255, i32 noundef 255)
  call void @Display(ptr noundef %0, ptr noundef %calloc) #7
  call void @Synchronize(ptr noundef %0) #7
  %35 = add nuw nsw i32 %.02126, 1
  br i1 %.1.lcssa, label %47, label %21, !llvm.loop !9

.lr.ph:                                           ; preds = %21, %43
  %indvars.iv = phi i64 [ %indvars.iv.next, %43 ], [ 0, %21 ]
  %.123 = phi i1 [ %.2, %43 ], [ false, %21 ]
  %36 = getelementptr inbounds double, ptr %18, i64 %indvars.iv
  %37 = load double, ptr %36, align 8, !tbaa !5
  %38 = fcmp oeq double %37, -4.300000e+01
  br i1 %38, label %39, label %43

39:                                               ; preds = %.lr.ph
  %40 = getelementptr inbounds i8, ptr %20, i64 %indvars.iv
  %41 = load i8, ptr %40, align 1, !tbaa !11, !range !13, !noundef !14
  %42 = trunc nuw i8 %41 to i1
  %spec.select = select i1 %42, i1 true, i1 %.123
  br label %43

43:                                               ; preds = %39, %.lr.ph
  %.2 = phi i1 [ %.123, %.lr.ph ], [ %spec.select, %39 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %44 = trunc nuw nsw i64 %indvars.iv.next to i32
  %45 = uitofp nneg i32 %44 to double
  %46 = fcmp ogt double %22, %45
  br i1 %46, label %.lr.ph, label %._crit_edge, !llvm.loop !15

47:                                               ; preds = %._crit_edge
  call void @free(ptr noundef %18) #7
  call void @free(ptr noundef %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  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 allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

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

declare void @GetKeyboardState(ptr noundef, ptr noundef, ptr noundef, 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: mustprogress nofree nounwind willreturn memory(write)
declare double @fmod(double noundef, double noundef) local_unnamed_addr #4

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

declare void @Synchronize(ptr noundef) local_unnamed_addr #2

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

; 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 #6

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


; Effective O3 passes: AggressiveInstCombinePass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass