; LLVM IR from alekras/ao.rtos.cpp :: Porting/ARM-Raspberry_Pi/display-start.ll (Z21putChar2VRAM_originalciiii)

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

@baseAddress = external dso_local global ptr, align 8
@_ZL11fontSet8x16 = external hidden global <{ [16 x i8], [16 x i8], <{ i8, i8, i8, i8, i8, i8, i8, [9 x i8] }>, [16 x i8], [16 x i8], [16 x i8], [16 x i8], <{ i8, i8, i8, i8, i8, i8, i8, [9 x i8] }>, [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], <{ i8, i8, i8, i8, i8, i8, i8, [9 x i8] }>, [16 x i8], <{ i8, i8, i8, i8, [12 x i8] }>, [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8] }>, 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: mustprogress nounwind uwtable
define dso_local void @_Z21putChar2VRAM_originalciiii(i8 noundef signext %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i8, align 1
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store i8 %0, ptr %6, align 1, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !8
  store i32 %2, ptr %8, align 4, !tbaa !8
  store i32 %3, ptr %9, align 4, !tbaa !8
  store i32 %4, ptr %10, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %17 = load i8, ptr %6, align 1, !tbaa !5
  %18 = sext i8 %17 to i32
  %19 = sub nsw i32 %18, 32
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [97 x [16 x i8]], ptr @_ZL11fontSet8x16, i64 0, i64 %20
  %22 = getelementptr inbounds [16 x i8], ptr %21, i64 0, i64 0
  store ptr %22, ptr %11, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %23 = load ptr, ptr @baseAddress, align 8, !tbaa !10
  store ptr %23, ptr %13, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #2
  %24 = load i32, ptr %8, align 4, !tbaa !8
  %25 = mul nsw i32 %24, 1280
  %26 = mul nsw i32 %25, 16
  %27 = load i32, ptr %7, align 4, !tbaa !8
  %28 = mul nsw i32 %27, 16
  %29 = add nsw i32 %26, %28
  %30 = load ptr, ptr %13, align 8, !tbaa !10
  %31 = sext i32 %29 to i64
  %32 = getelementptr inbounds i32, ptr %30, i64 %31
  store ptr %32, ptr %13, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  store i32 0, ptr %15, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #2
  store i32 0, ptr %16, align 4, !tbaa !8
  br label %33

33:                                               ; preds = %71, %5
  %34 = load i32, ptr %15, align 4, !tbaa !8
  %35 = icmp slt i32 %34, 16
  br i1 %35, label %37, label %36

36:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  br label %76

37:                                               ; preds = %33
  store i8 1, ptr %14, align 1, !tbaa !5
  %38 = load ptr, ptr %13, align 8, !tbaa !10
  %39 = load i32, ptr %16, align 4, !tbaa !8
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i32, ptr %38, i64 %40
  store ptr %41, ptr %12, align 8, !tbaa !10
  br label %42

42:                                               ; preds = %61, %37
  %43 = load i8, ptr %14, align 1, !tbaa !5
  %44 = zext i8 %43 to i32
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %70

46:                                               ; preds = %42
  %47 = load ptr, ptr %11, align 8, !tbaa !10
  %48 = load i32, ptr %15, align 4, !tbaa !8
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i8, ptr %47, i64 %49
  %51 = load i8, ptr %50, align 1, !tbaa !5
  %52 = zext i8 %51 to i32
  %53 = load i8, ptr %14, align 1, !tbaa !5
  %54 = zext i8 %53 to i32
  %55 = and i32 %52, %54
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %57, label %59

57:                                               ; preds = %46
  %58 = load i32, ptr %9, align 4, !tbaa !8
  br label %61

59:                                               ; preds = %46
  %60 = load i32, ptr %10, align 4, !tbaa !8
  br label %61

61:                                               ; preds = %59, %57
  %62 = phi i32 [ %58, %57 ], [ %60, %59 ]
  %63 = or i32 %62, -16777216
  %64 = load ptr, ptr %12, align 8, !tbaa !10
  %65 = getelementptr inbounds i32, ptr %64, i32 1
  store ptr %65, ptr %12, align 8, !tbaa !10
  store i32 %63, ptr %64, align 4, !tbaa !8
  %66 = load i8, ptr %14, align 1, !tbaa !5
  %67 = zext i8 %66 to i32
  %68 = shl i32 %67, 1
  %69 = trunc i32 %68 to i8
  store i8 %69, ptr %14, align 1, !tbaa !5
  br label %42, !llvm.loop !12

70:                                               ; preds = %42
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %15, align 4, !tbaa !8
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %15, align 4, !tbaa !8
  %74 = load i32, ptr %16, align 4, !tbaa !8
  %75 = add nsw i32 %74, 1280
  store i32 %75, ptr %16, align 4, !tbaa !8
  br label %33, !llvm.loop !14

76:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #2 = { 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++ 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"

@baseAddress = external dso_local local_unnamed_addr global ptr, align 8
@_ZL11fontSet8x16 = external hidden local_unnamed_addr global <{ [16 x i8], [16 x i8], <{ i8, i8, i8, i8, i8, i8, i8, [9 x i8] }>, [16 x i8], [16 x i8], [16 x i8], [16 x i8], <{ i8, i8, i8, i8, i8, i8, i8, [9 x i8] }>, [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], <{ i8, i8, i8, i8, i8, i8, i8, [9 x i8] }>, [16 x i8], <{ i8, i8, i8, i8, [12 x i8] }>, [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8] }>, align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(readwrite, argmem: write, inaccessiblemem: none) uwtable
define dso_local void @_Z21putChar2VRAM_originalciiii(i8 noundef signext %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = sext i8 %0 to i64
  %7 = add nsw i64 %6, -32
  %8 = getelementptr inbounds [97 x [16 x i8]], ptr @_ZL11fontSet8x16, i64 0, i64 %7
  %9 = load ptr, ptr @baseAddress, align 8, !tbaa !5
  %10 = mul i32 %2, 20480
  %11 = shl nsw i32 %1, 4
  %12 = add nsw i32 %10, %11
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds i32, ptr %9, i64 %13
  br label %16

15:                                               ; preds = %16
  ret void

16:                                               ; preds = %5, %16
  %indvars.iv25 = phi i64 [ 0, %5 ], [ %indvars.iv.next26, %16 ]
  %indvars.iv = phi i64 [ 0, %5 ], [ %indvars.iv.next, %16 ]
  %17 = getelementptr inbounds i32, ptr %14, i64 %indvars.iv
  %18 = getelementptr inbounds i8, ptr %8, i64 %indvars.iv25
  %19 = load i8, ptr %18, align 1, !tbaa !9
  %20 = and i8 %19, 1
  %.not20 = icmp eq i8 %20, 0
  %21 = select i1 %.not20, i32 %4, i32 %3
  %22 = or i32 %21, -16777216
  %23 = getelementptr inbounds i8, ptr %17, i64 4
  store i32 %22, ptr %17, align 4, !tbaa !10
  %24 = load i8, ptr %18, align 1, !tbaa !9
  %25 = and i8 %24, 2
  %.not20.1 = icmp eq i8 %25, 0
  %26 = select i1 %.not20.1, i32 %4, i32 %3
  %27 = or i32 %26, -16777216
  %28 = getelementptr inbounds i8, ptr %17, i64 8
  store i32 %27, ptr %23, align 4, !tbaa !10
  %29 = load i8, ptr %18, align 1, !tbaa !9
  %30 = and i8 %29, 4
  %.not20.2 = icmp eq i8 %30, 0
  %31 = select i1 %.not20.2, i32 %4, i32 %3
  %32 = or i32 %31, -16777216
  %33 = getelementptr inbounds i8, ptr %17, i64 12
  store i32 %32, ptr %28, align 4, !tbaa !10
  %34 = load i8, ptr %18, align 1, !tbaa !9
  %35 = and i8 %34, 8
  %.not20.3 = icmp eq i8 %35, 0
  %36 = select i1 %.not20.3, i32 %4, i32 %3
  %37 = or i32 %36, -16777216
  %38 = getelementptr inbounds i8, ptr %17, i64 16
  store i32 %37, ptr %33, align 4, !tbaa !10
  %39 = load i8, ptr %18, align 1, !tbaa !9
  %40 = and i8 %39, 16
  %.not20.4 = icmp eq i8 %40, 0
  %41 = select i1 %.not20.4, i32 %4, i32 %3
  %42 = or i32 %41, -16777216
  %43 = getelementptr inbounds i8, ptr %17, i64 20
  store i32 %42, ptr %38, align 4, !tbaa !10
  %44 = load i8, ptr %18, align 1, !tbaa !9
  %45 = and i8 %44, 32
  %.not20.5 = icmp eq i8 %45, 0
  %46 = select i1 %.not20.5, i32 %4, i32 %3
  %47 = or i32 %46, -16777216
  %48 = getelementptr inbounds i8, ptr %17, i64 24
  store i32 %47, ptr %43, align 4, !tbaa !10
  %49 = load i8, ptr %18, align 1, !tbaa !9
  %50 = and i8 %49, 64
  %.not20.6 = icmp eq i8 %50, 0
  %51 = select i1 %.not20.6, i32 %4, i32 %3
  %52 = or i32 %51, -16777216
  %53 = getelementptr inbounds i8, ptr %17, i64 28
  store i32 %52, ptr %48, align 4, !tbaa !10
  %54 = load i8, ptr %18, align 1, !tbaa !9
  %.not20.730 = icmp slt i8 %54, 0
  %55 = select i1 %.not20.730, i32 %3, i32 %4
  %56 = or i32 %55, -16777216
  store i32 %56, ptr %53, align 4, !tbaa !10
  %indvars.iv.next26 = add nuw nsw i64 %indvars.iv25, 1
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1280
  %exitcond.not = icmp eq i64 %indvars.iv.next26, 16
  br i1 %exitcond.not, label %15, label %16, !llvm.loop !12
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(readwrite, argmem: write, inaccessiblemem: none) 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass