; LLVM IR from smwikipedia/EmbeddedAndRTOSSamples :: C2.6 (vid)

; 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.DisplayContext = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@gDisplayContext = external dso_local global %struct.DisplayContext, align 4
@fb = external dso_local global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @fbuf_init() #0 {
  %1 = alloca i32, align 4
  store ptr inttoptr (i64 2097152 to ptr), ptr @fb, align 8, !tbaa !5
  call void (...) @InitializeFontContext12x16()
  store volatile i32 11436, ptr inttoptr (i64 268435484 to ptr), align 4, !tbaa !9
  store volatile i32 320054468, ptr inttoptr (i64 269615104 to ptr), align 4, !tbaa !9
  store volatile i32 84276983, ptr inttoptr (i64 269615108 to ptr), align 4, !tbaa !9
  store volatile i32 119478272, ptr inttoptr (i64 269615112 to ptr), align 4, !tbaa !9
  store i32 800, ptr @gDisplayContext, align 4, !tbaa !11
  store i32 600, ptr getelementptr inbounds (%struct.DisplayContext, ptr @gDisplayContext, i32 0, i32 1), align 4, !tbaa !13
  store i32 1, ptr getelementptr inbounds (%struct.DisplayContext, ptr @gDisplayContext, i32 0, i32 11), align 4, !tbaa !14
  store i32 1, ptr getelementptr inbounds (%struct.DisplayContext, ptr @gDisplayContext, i32 0, i32 12), align 4, !tbaa !15
  %2 = load i32, ptr @gDisplayContext, align 4, !tbaa !11
  %3 = load i32, ptr getelementptr inbounds (%struct.DisplayContext, ptr @gDisplayContext, i32 0, i32 5), align 4, !tbaa !16
  %4 = load i32, ptr getelementptr inbounds (%struct.DisplayContext, ptr @gDisplayContext, i32 0, i32 8), align 4, !tbaa !17
  %5 = add i32 %3, %4
  %6 = udiv i32 %2, %5
  store i32 %6, ptr getelementptr inbounds (%struct.DisplayContext, ptr @gDisplayContext, i32 0, i32 14), align 4, !tbaa !18
  %7 = load i32, ptr getelementptr inbounds (%struct.DisplayContext, ptr @gDisplayContext, i32 0, i32 1), align 4, !tbaa !13
  %8 = load i32, ptr getelementptr inbounds (%struct.DisplayContext, ptr @gDisplayContext, i32 0, i32 6), align 4, !tbaa !19
  %9 = load i32, ptr getelementptr inbounds (%struct.DisplayContext, ptr @gDisplayContext, i32 0, i32 7), align 4, !tbaa !20
  %10 = add i32 %8, %9
  %11 = udiv i32 %7, %10
  store i32 %11, ptr getelementptr inbounds (%struct.DisplayContext, ptr @gDisplayContext, i32 0, i32 13), align 4, !tbaa !21
  store volatile i32 2097152, ptr inttoptr (i64 269615120 to ptr), align 4, !tbaa !9
  store volatile i32 2091, ptr inttoptr (i64 269615128 to ptr), align 4, !tbaa !9
  %12 = load i32, ptr %1, align 4
  ret i32 %12
}

declare void @InitializeFontContext12x16(...) #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 = { "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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 44}
!15 = !{!12, !10, i64 48}
!16 = !{!12, !10, i64 20}
!17 = !{!12, !10, i64 32}
!18 = !{!12, !10, i64 56}
!19 = !{!12, !10, i64 24}
!20 = !{!12, !10, i64 28}
!21 = !{!12, !10, i64 52}


; 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.DisplayContext = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@gDisplayContext = external dso_local local_unnamed_addr global %struct.DisplayContext, align 4
@fb = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @fbuf_init() local_unnamed_addr #0 {
  store ptr inttoptr (i64 2097152 to ptr), ptr @fb, align 8, !tbaa !5
  tail call void (...) @InitializeFontContext12x16() #2
  store volatile i32 11436, ptr inttoptr (i64 268435484 to ptr), align 4, !tbaa !9
  store volatile i32 320054468, ptr inttoptr (i64 269615104 to ptr), align 131072, !tbaa !9
  store volatile i32 84276983, ptr inttoptr (i64 269615108 to ptr), align 4, !tbaa !9
  store volatile i32 119478272, ptr inttoptr (i64 269615112 to ptr), align 8, !tbaa !9
  store i32 800, ptr @gDisplayContext, align 4, !tbaa !11
  store i32 600, ptr getelementptr inbounds (i8, ptr @gDisplayContext, i64 4), align 4, !tbaa !13
  store i32 1, ptr getelementptr inbounds (i8, ptr @gDisplayContext, i64 44), align 4, !tbaa !14
  store i32 1, ptr getelementptr inbounds (i8, ptr @gDisplayContext, i64 48), align 4, !tbaa !15
  %1 = load i32, ptr getelementptr inbounds (i8, ptr @gDisplayContext, i64 20), align 4, !tbaa !16
  %2 = load i32, ptr getelementptr inbounds (i8, ptr @gDisplayContext, i64 32), align 4, !tbaa !17
  %3 = add i32 %2, %1
  %4 = udiv i32 800, %3
  store i32 %4, ptr getelementptr inbounds (i8, ptr @gDisplayContext, i64 56), align 4, !tbaa !18
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @gDisplayContext, i64 24), align 4, !tbaa !19
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @gDisplayContext, i64 28), align 4, !tbaa !20
  %7 = add i32 %6, %5
  %8 = udiv i32 600, %7
  store i32 %8, ptr getelementptr inbounds (i8, ptr @gDisplayContext, i64 52), align 4, !tbaa !21
  store volatile i32 2097152, ptr inttoptr (i64 269615120 to ptr), align 16, !tbaa !9
  store volatile i32 2091, ptr inttoptr (i64 269615128 to ptr), align 8, !tbaa !9
  ret i32 undef
}

declare void @InitializeFontContext12x16(...) local_unnamed_addr #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 = { "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 = !{!"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, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 44}
!15 = !{!12, !10, i64 48}
!16 = !{!12, !10, i64 20}
!17 = !{!12, !10, i64 32}
!18 = !{!12, !10, i64 56}
!19 = !{!12, !10, i64 24}
!20 = !{!12, !10, i64 28}
!21 = !{!12, !10, i64 52}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InstCombinePass,ReassociatePass,SROAPass,TailCallElimPass