; LLVM IR from embeddednirvana/A-Rudimentary-RTOS-for-Satellite-Control :: device (usart)

; 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._AT91S_PIO = type { i32, i32, i32, [1 x i32], i32, i32, i32, [1 x i32], i32, i32, i32, [1 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [1 x i32], i32, i32, i32, [1 x i32], i32, i32, i32, [9 x i32], i32, i32, i32 }
%struct._AT91S_USART = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [5 x i32], i32, i32, [1 x i32], i32, [44 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct._AT91S_PMC = type { i32, i32, i32, [1 x i32], i32, i32, i32, [1 x i32], i32, i32, [1 x i32], i32, i32, [3 x i32], [4 x i32], [4 x i32], i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @usart_init_normal_async(ptr noundef %0) #0 section ".text.fastcode" {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = icmp eq ptr %5, inttoptr (i64 4294705152 to ptr)
  br i1 %6, label %7, label %8

7:                                                ; preds = %1
  store i32 31, ptr %3, align 4, !tbaa !9
  store i32 6, ptr %4, align 4, !tbaa !9
  br label %9

8:                                                ; preds = %1
  store i32 992, ptr %3, align 4, !tbaa !9
  store i32 7, ptr %4, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %8, %7
  %10 = load i32, ptr %3, align 4, !tbaa !9
  %11 = load volatile i32, ptr getelementptr inbounds (%struct._AT91S_PIO, ptr inttoptr (i64 4294964224 to ptr), i32 0, i32 1), align 4, !tbaa !11
  %12 = or i32 %11, %10
  store volatile i32 %12, ptr getelementptr inbounds (%struct._AT91S_PIO, ptr inttoptr (i64 4294964224 to ptr), i32 0, i32 1), align 4, !tbaa !11
  %13 = load i32, ptr %3, align 4, !tbaa !9
  %14 = load volatile i32, ptr getelementptr inbounds (%struct._AT91S_PIO, ptr inttoptr (i64 4294964224 to ptr), i32 0, i32 28), align 4, !tbaa !13
  %15 = or i32 %14, %13
  store volatile i32 %15, ptr getelementptr inbounds (%struct._AT91S_PIO, ptr inttoptr (i64 4294964224 to ptr), i32 0, i32 28), align 4, !tbaa !13
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._AT91S_USART, ptr %16, i32 0, i32 0
  store volatile i32 172, ptr %17, align 4, !tbaa !14
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._AT91S_USART, ptr %18, i32 0, i32 1
  store volatile i32 526528, ptr %19, align 4, !tbaa !16
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._AT91S_USART, ptr %20, i32 0, i32 8
  store volatile i32 624, ptr %21, align 4, !tbaa !17
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._AT91S_USART, ptr %22, i32 0, i32 2
  store volatile i32 0, ptr %23, align 4, !tbaa !18
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = shl i32 1, %24
  store volatile i32 %25, ptr getelementptr inbounds (%struct._AT91S_PMC, ptr inttoptr (i64 4294966272 to ptr), i32 0, i32 4), align 4, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

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

; 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 = { 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 4}
!12 = !{!"_AT91S_PIO", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !7, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !7, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !7, i64 108, !10, i64 112, !10, i64 116, !10, i64 120, !7, i64 124, !10, i64 160, !10, i64 164, !10, i64 168}
!13 = !{!12, !10, i64 112}
!14 = !{!15, !10, i64 0}
!15 = !{!"_AT91S_USART", !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, !7, i64 44, !10, i64 64, !10, i64 68, !7, i64 72, !10, i64 76, !7, i64 80, !10, i64 256, !10, i64 260, !10, i64 264, !10, i64 268, !10, i64 272, !10, i64 276, !10, i64 280, !10, i64 284, !10, i64 288, !10, i64 292}
!16 = !{!15, !10, i64 4}
!17 = !{!15, !10, i64 32}
!18 = !{!15, !10, i64 8}
!19 = !{!20, !10, i64 16}
!20 = !{!"_AT91S_PMC", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 28, !10, i64 32, !10, i64 36, !7, i64 40, !10, i64 44, !10, i64 48, !7, i64 52, !7, i64 64, !7, i64 80, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108}


; 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: nofree norecurse nounwind uwtable
define dso_local void @usart_init_normal_async(ptr noundef %0) local_unnamed_addr #0 section ".text.fastcode" {
  %2 = icmp eq ptr %0, inttoptr (i64 4294705152 to ptr)
  %. = select i1 %2, i32 31, i32 992
  %3 = load volatile i32, ptr inttoptr (i64 4294964228 to ptr), align 4, !tbaa !5
  %4 = or i32 %3, %.
  store volatile i32 %4, ptr inttoptr (i64 4294964228 to ptr), align 4, !tbaa !5
  %5 = load volatile i32, ptr inttoptr (i64 4294964336 to ptr), align 16, !tbaa !10
  %6 = or i32 %5, %.
  store volatile i32 %6, ptr inttoptr (i64 4294964336 to ptr), align 16, !tbaa !10
  store volatile i32 172, ptr %0, align 4, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %0, i64 4
  store volatile i32 526528, ptr %7, align 4, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  store volatile i32 624, ptr %8, align 4, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  store volatile i32 0, ptr %9, align 4, !tbaa !15
  %10 = select i1 %2, i32 64, i32 128
  store volatile i32 %10, ptr inttoptr (i64 4294966288 to ptr), align 16, !tbaa !16
  ret void
}

attributes #0 = { nofree norecurse 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, !7, i64 4}
!6 = !{!"_AT91S_PIO", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !8, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !8, i64 44, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !7, i64 88, !8, i64 92, !7, i64 96, !7, i64 100, !7, i64 104, !8, i64 108, !7, i64 112, !7, i64 116, !7, i64 120, !8, i64 124, !7, i64 160, !7, i64 164, !7, i64 168}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 112}
!11 = !{!12, !7, i64 0}
!12 = !{!"_AT91S_USART", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !8, i64 44, !7, i64 64, !7, i64 68, !8, i64 72, !7, i64 76, !8, i64 80, !7, i64 256, !7, i64 260, !7, i64 264, !7, i64 268, !7, i64 272, !7, i64 276, !7, i64 280, !7, i64 284, !7, i64 288, !7, i64 292}
!13 = !{!12, !7, i64 4}
!14 = !{!12, !7, i64 32}
!15 = !{!12, !7, i64 8}
!16 = !{!17, !7, i64 16}
!17 = !{!"_AT91S_PMC", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !8, i64 28, !7, i64 32, !7, i64 36, !8, i64 40, !7, i64 44, !7, i64 48, !8, i64 52, !8, i64 64, !8, i64 80, !7, i64 96, !7, i64 100, !7, i64 104, !7, i64 108}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass