; LLVM IR from rociodellasala/TP3_SO :: Kernel (video_driver)

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

@font = external dso_local global <{ [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], <{ i8, i8, i8, i8, i8, [8 x i8] }>, [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], <{ i8, i8, [11 x i8] }>, [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [43 x [13 x i8]] }>, align 16
@__const.draw_charColor.mask = external hidden unnamed_addr constant [8 x i32], align 16

; 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
define dso_local void @draw_charColor(i8 noundef zeroext %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #2 {
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca [8 x i32], align 16
  %12 = alloca ptr, align 8
  store i8 %0, ptr %5, align 1, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !8
  store i32 %2, ptr %7, align 4, !tbaa !8
  store i32 %3, ptr %8, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %11, ptr align 16 @__const.draw_charColor.mask, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %13 = load i8, ptr %5, align 1, !tbaa !5
  %14 = zext i8 %13 to i32
  %15 = sub nsw i32 %14, 32
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [200 x [13 x i8]], ptr @font, i64 0, i64 %16
  %18 = getelementptr inbounds [13 x i8], ptr %17, i64 0, i64 0
  store ptr %18, ptr %12, align 8, !tbaa !10
  store i32 0, ptr %10, align 4, !tbaa !8
  br label %19

19:                                               ; preds = %54, %4
  %20 = load i32, ptr %10, align 4, !tbaa !8
  %21 = icmp slt i32 %20, 13
  br i1 %21, label %22, label %57

22:                                               ; preds = %19
  store i32 0, ptr %9, align 4, !tbaa !8
  br label %23

23:                                               ; preds = %50, %22
  %24 = load i32, ptr %9, align 4, !tbaa !8
  %25 = icmp slt i32 %24, 8
  br i1 %25, label %26, label %53

26:                                               ; preds = %23
  %27 = load ptr, ptr %12, align 8, !tbaa !10
  %28 = load i32, ptr %10, align 4, !tbaa !8
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i8, ptr %27, i64 %29
  %31 = load i8, ptr %30, align 1, !tbaa !5
  %32 = zext i8 %31 to i32
  %33 = load i32, ptr %9, align 4, !tbaa !8
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [8 x i32], ptr %11, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !8
  %37 = and i32 %32, %36
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %49

39:                                               ; preds = %26
  %40 = load i32, ptr %6, align 4, !tbaa !8
  %41 = add nsw i32 %40, 8
  %42 = load i32, ptr %9, align 4, !tbaa !8
  %43 = sub nsw i32 %41, %42
  %44 = load i32, ptr %7, align 4, !tbaa !8
  %45 = add nsw i32 %44, 13
  %46 = load i32, ptr %10, align 4, !tbaa !8
  %47 = sub nsw i32 %45, %46
  %48 = load i32, ptr %8, align 4, !tbaa !8
  call void @draw_pixelColor(i32 noundef %43, i32 noundef %47, i32 noundef %48)
  br label %49

49:                                               ; preds = %39, %26
  br label %50

50:                                               ; preds = %49
  %51 = load i32, ptr %9, align 4, !tbaa !8
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %9, align 4, !tbaa !8
  br label %23, !llvm.loop !12

53:                                               ; preds = %23
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %10, align 4, !tbaa !8
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %10, align 4, !tbaa !8
  br label %19, !llvm.loop !14

57:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @draw_pixelColor(i32 noundef, i32 noundef, i32 noundef) #2

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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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

@font = external dso_local local_unnamed_addr global <{ [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], <{ i8, i8, i8, i8, i8, [8 x i8] }>, [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], <{ i8, i8, [11 x i8] }>, [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [13 x i8], [43 x [13 x i8]] }>, align 16
@__const.draw_charColor.mask = external hidden unnamed_addr constant [8 x i32], align 16

; Function Attrs: nounwind uwtable
define dso_local void @draw_charColor(i8 noundef zeroext %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = zext i8 %0 to i64
  %6 = add nsw i64 %5, -32
  %7 = getelementptr inbounds [200 x [13 x i8]], ptr @font, i64 0, i64 %6
  %8 = add nsw i32 %1, 8
  %9 = add nsw i32 %2, 13
  %.pre = load i32, ptr @__const.draw_charColor.mask, align 16, !tbaa !5
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @__const.draw_charColor.mask, i64 4), align 4
  %11 = add nsw i32 %1, 7
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @__const.draw_charColor.mask, i64 8), align 8
  %13 = add nsw i32 %1, 6
  %14 = load i32, ptr getelementptr inbounds (i8, ptr @__const.draw_charColor.mask, i64 12), align 4
  %15 = add nsw i32 %1, 5
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @__const.draw_charColor.mask, i64 16), align 16
  %17 = add nsw i32 %1, 4
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @__const.draw_charColor.mask, i64 20), align 4
  %19 = add nsw i32 %1, 3
  %20 = load i32, ptr getelementptr inbounds (i8, ptr @__const.draw_charColor.mask, i64 24), align 8
  %21 = add nsw i32 %1, 2
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @__const.draw_charColor.mask, i64 28), align 4
  %23 = add nsw i32 %1, 1
  br label %.preheader

.preheader:                                       ; preds = %4, %52
  %indvars.iv = phi i64 [ 0, %4 ], [ %indvars.iv.next, %52 ]
  %24 = getelementptr inbounds i8, ptr %7, i64 %indvars.iv
  %25 = trunc nuw nsw i64 %indvars.iv to i32
  %26 = sub i32 %9, %25
  %27 = load i8, ptr %24, align 1, !tbaa !9
  %28 = zext i8 %27 to i32
  %29 = and i32 %.pre, %28
  %.not = icmp eq i32 %29, 0
  br i1 %.not, label %31, label %30

30:                                               ; preds = %.preheader
  tail call void @draw_pixelColor(i32 noundef %8, i32 noundef %26, i32 noundef %3)
  %.pre17 = load i8, ptr %24, align 1, !tbaa !9
  %.pre24 = zext i8 %.pre17 to i32
  br label %31

31:                                               ; preds = %.preheader, %30
  %.pre-phi = phi i32 [ %28, %.preheader ], [ %.pre24, %30 ]
  %32 = and i32 %10, %.pre-phi
  %.not.1 = icmp eq i32 %32, 0
  br i1 %.not.1, label %34, label %33

33:                                               ; preds = %31
  tail call void @draw_pixelColor(i32 noundef %11, i32 noundef %26, i32 noundef %3)
  %.pre18 = load i8, ptr %24, align 1, !tbaa !9
  %.pre25 = zext i8 %.pre18 to i32
  br label %34

34:                                               ; preds = %33, %31
  %.pre-phi26 = phi i32 [ %.pre25, %33 ], [ %.pre-phi, %31 ]
  %35 = and i32 %12, %.pre-phi26
  %.not.2 = icmp eq i32 %35, 0
  br i1 %.not.2, label %37, label %36

36:                                               ; preds = %34
  tail call void @draw_pixelColor(i32 noundef %13, i32 noundef %26, i32 noundef %3)
  %.pre19 = load i8, ptr %24, align 1, !tbaa !9
  %.pre27 = zext i8 %.pre19 to i32
  br label %37

37:                                               ; preds = %36, %34
  %.pre-phi28 = phi i32 [ %.pre27, %36 ], [ %.pre-phi26, %34 ]
  %38 = and i32 %14, %.pre-phi28
  %.not.3 = icmp eq i32 %38, 0
  br i1 %.not.3, label %40, label %39

39:                                               ; preds = %37
  tail call void @draw_pixelColor(i32 noundef %15, i32 noundef %26, i32 noundef %3)
  %.pre20 = load i8, ptr %24, align 1, !tbaa !9
  %.pre29 = zext i8 %.pre20 to i32
  br label %40

40:                                               ; preds = %39, %37
  %.pre-phi30 = phi i32 [ %.pre29, %39 ], [ %.pre-phi28, %37 ]
  %41 = and i32 %16, %.pre-phi30
  %.not.4 = icmp eq i32 %41, 0
  br i1 %.not.4, label %43, label %42

42:                                               ; preds = %40
  tail call void @draw_pixelColor(i32 noundef %17, i32 noundef %26, i32 noundef %3)
  %.pre21 = load i8, ptr %24, align 1, !tbaa !9
  %.pre31 = zext i8 %.pre21 to i32
  br label %43

43:                                               ; preds = %42, %40
  %.pre-phi32 = phi i32 [ %.pre31, %42 ], [ %.pre-phi30, %40 ]
  %44 = and i32 %18, %.pre-phi32
  %.not.5 = icmp eq i32 %44, 0
  br i1 %.not.5, label %46, label %45

45:                                               ; preds = %43
  tail call void @draw_pixelColor(i32 noundef %19, i32 noundef %26, i32 noundef %3)
  %.pre22 = load i8, ptr %24, align 1, !tbaa !9
  %.pre33 = zext i8 %.pre22 to i32
  br label %46

46:                                               ; preds = %45, %43
  %.pre-phi34 = phi i32 [ %.pre33, %45 ], [ %.pre-phi32, %43 ]
  %47 = and i32 %20, %.pre-phi34
  %.not.6 = icmp eq i32 %47, 0
  br i1 %.not.6, label %49, label %48

48:                                               ; preds = %46
  tail call void @draw_pixelColor(i32 noundef %21, i32 noundef %26, i32 noundef %3)
  %.pre23 = load i8, ptr %24, align 1, !tbaa !9
  %.pre35 = zext i8 %.pre23 to i32
  br label %49

49:                                               ; preds = %48, %46
  %.pre-phi36 = phi i32 [ %.pre35, %48 ], [ %.pre-phi34, %46 ]
  %50 = and i32 %22, %.pre-phi36
  %.not.7 = icmp eq i32 %50, 0
  br i1 %.not.7, label %52, label %51

51:                                               ; preds = %49
  tail call void @draw_pixelColor(i32 noundef %23, i32 noundef %26, i32 noundef %3)
  br label %52

52:                                               ; preds = %51, %49
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 13
  br i1 %exitcond.not, label %53, label %.preheader, !llvm.loop !10

53:                                               ; preds = %52
  ret void
}

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

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

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass