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

; 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_MC = type { i32, i32, i32, [21 x i32], i32, i32, i32 }
%struct._AT91S_WDTC = type { 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 }
%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_AIC = type { [32 x i32], [32 x i32], i32, i32, i32, i32, i32, i32, [2 x i32], i32, i32, i32, i32, i32, i32, i32, [1 x i32], i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @low_level_hw_init() #0 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  store ptr inttoptr (i64 4294964224 to ptr), ptr %2, align 8, !tbaa !5
  store ptr inttoptr (i64 4294966272 to ptr), ptr %1, align 8, !tbaa !5
  store ptr inttoptr (i64 4294963200 to ptr), ptr %3, align 8, !tbaa !5
  store volatile i32 3145984, ptr getelementptr inbounds (%struct._AT91S_MC, ptr inttoptr (i64 4294967040 to ptr), i32 0, i32 4), align 4, !tbaa !9
  store volatile i32 32768, ptr getelementptr inbounds (%struct._AT91S_WDTC, ptr inttoptr (i64 4294966592 to ptr), i32 0, i32 1), align 4, !tbaa !12
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct._AT91S_PMC, ptr %4, i32 0, i32 8
  store volatile i32 1537, ptr %5, align 4, !tbaa !14
  br label %6

6:                                                ; preds = %12, %0
  %7 = load ptr, ptr %1, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct._AT91S_PMC, ptr %7, i32 0, i32 18
  %9 = load volatile i32, ptr %8, align 4, !tbaa !16
  %10 = and i32 %9, 1
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %6
  br label %6, !llvm.loop !17

13:                                               ; preds = %6
  %14 = load ptr, ptr %1, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._AT91S_PMC, ptr %14, i32 0, i32 11
  store volatile i32 400390, ptr %15, align 4, !tbaa !19
  br label %16

16:                                               ; preds = %22, %13
  %17 = load ptr, ptr %1, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._AT91S_PMC, ptr %17, i32 0, i32 18
  %19 = load volatile i32, ptr %18, align 4, !tbaa !16
  %20 = and i32 %19, 4
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %16
  br label %16, !llvm.loop !20

23:                                               ; preds = %16
  br label %24

24:                                               ; preds = %30, %23
  %25 = load ptr, ptr %1, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._AT91S_PMC, ptr %25, i32 0, i32 18
  %27 = load volatile i32, ptr %26, align 4, !tbaa !16
  %28 = and i32 %27, 8
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %24
  br label %24, !llvm.loop !21

31:                                               ; preds = %24
  %32 = load ptr, ptr %1, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._AT91S_PMC, ptr %32, i32 0, i32 12
  store volatile i32 4, ptr %33, align 4, !tbaa !22
  br label %34

34:                                               ; preds = %40, %31
  %35 = load ptr, ptr %1, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._AT91S_PMC, ptr %35, i32 0, i32 18
  %37 = load volatile i32, ptr %36, align 4, !tbaa !16
  %38 = and i32 %37, 8
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %34
  br label %34, !llvm.loop !23

41:                                               ; preds = %34
  %42 = load ptr, ptr %1, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._AT91S_PMC, ptr %42, i32 0, i32 12
  %44 = load volatile i32, ptr %43, align 4, !tbaa !22
  %45 = or i32 %44, 3
  store volatile i32 %45, ptr %43, align 4, !tbaa !22
  br label %46

46:                                               ; preds = %52, %41
  %47 = load ptr, ptr %1, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct._AT91S_PMC, ptr %47, i32 0, i32 18
  %49 = load volatile i32, ptr %48, align 4, !tbaa !16
  %50 = and i32 %49, 8
  %51 = icmp eq i32 %50, 0
  br i1 %51, label %52, label %53

52:                                               ; preds = %46
  br label %46, !llvm.loop !24

53:                                               ; preds = %46
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._AT91S_PIO, ptr %54, i32 0, i32 0
  store volatile i32 536870912, ptr %55, align 4, !tbaa !25
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._AT91S_PIO, ptr %56, i32 0, i32 24
  store volatile i32 536870912, ptr %57, align 4, !tbaa !27
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._AT91S_PIO, ptr %58, i32 0, i32 1
  store volatile i32 536870912, ptr %59, align 4, !tbaa !28
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._AT91S_PIO, ptr %60, i32 0, i32 28
  store volatile i32 536870912, ptr %61, align 4, !tbaa !29
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._AT91S_AIC, ptr %62, i32 0, i32 0
  %64 = getelementptr inbounds [32 x i32], ptr %63, i64 0, i64 0
  store volatile i32 0, ptr %64, align 4, !tbaa !30
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._AT91S_AIC, ptr %65, i32 0, i32 9
  store volatile i32 1, ptr %66, align 4, !tbaa !31
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #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, !11, i64 96}
!10 = !{!"_AT91S_MC", !11, i64 0, !11, i64 4, !11, i64 8, !7, i64 12, !11, i64 96, !11, i64 100, !11, i64 104}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 4}
!13 = !{!"_AT91S_WDTC", !11, i64 0, !11, i64 4, !11, i64 8}
!14 = !{!15, !11, i64 32}
!15 = !{!"_AT91S_PMC", !11, i64 0, !11, i64 4, !11, i64 8, !7, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !7, i64 28, !11, i64 32, !11, i64 36, !7, i64 40, !11, i64 44, !11, i64 48, !7, i64 52, !7, i64 64, !7, i64 80, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108}
!16 = !{!15, !11, i64 104}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!15, !11, i64 44}
!20 = distinct !{!20, !18}
!21 = distinct !{!21, !18}
!22 = !{!15, !11, i64 48}
!23 = distinct !{!23, !18}
!24 = distinct !{!24, !18}
!25 = !{!26, !11, i64 0}
!26 = !{!"_AT91S_PIO", !11, i64 0, !11, i64 4, !11, i64 8, !7, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !7, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !7, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !7, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !7, i64 108, !11, i64 112, !11, i64 116, !11, i64 120, !7, i64 124, !11, i64 160, !11, i64 164, !11, i64 168}
!27 = !{!26, !11, i64 96}
!28 = !{!26, !11, i64 4}
!29 = !{!26, !11, i64 112}
!30 = !{!11, !11, i64 0}
!31 = !{!32, !11, i64 288}
!32 = !{!"_AT91S_AIC", !7, i64 0, !7, i64 128, !11, i64 256, !11, i64 260, !11, i64 264, !11, i64 268, !11, i64 272, !11, i64 276, !7, i64 280, !11, i64 288, !11, i64 292, !11, i64 296, !11, i64 300, !11, i64 304, !11, i64 308, !11, i64 312, !7, i64 316, !11, i64 320, !11, i64 324, !11, i64 328}


; 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 @low_level_hw_init() local_unnamed_addr #0 {
  store volatile i32 3145984, ptr inttoptr (i64 4294967136 to ptr), align 32, !tbaa !5
  store volatile i32 32768, ptr inttoptr (i64 4294966596 to ptr), align 4, !tbaa !10
  store volatile i32 1537, ptr inttoptr (i64 4294966304 to ptr), align 32, !tbaa !12
  br label %1

1:                                                ; preds = %1, %0
  %2 = load volatile i32, ptr inttoptr (i64 4294966376 to ptr), align 8, !tbaa !14
  %3 = and i32 %2, 1
  %4 = icmp eq i32 %3, 0
  br i1 %4, label %1, label %5, !llvm.loop !15

5:                                                ; preds = %1
  store volatile i32 400390, ptr inttoptr (i64 4294966316 to ptr), align 4, !tbaa !17
  br label %6

6:                                                ; preds = %6, %5
  %7 = load volatile i32, ptr inttoptr (i64 4294966376 to ptr), align 8, !tbaa !14
  %8 = and i32 %7, 4
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %6, label %.preheader, !llvm.loop !18

.preheader:                                       ; preds = %6, %.preheader
  %10 = load volatile i32, ptr inttoptr (i64 4294966376 to ptr), align 8, !tbaa !14
  %11 = and i32 %10, 8
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %.preheader, label %13, !llvm.loop !19

13:                                               ; preds = %.preheader
  store volatile i32 4, ptr inttoptr (i64 4294966320 to ptr), align 16, !tbaa !20
  br label %14

14:                                               ; preds = %14, %13
  %15 = load volatile i32, ptr inttoptr (i64 4294966376 to ptr), align 8, !tbaa !14
  %16 = and i32 %15, 8
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %14, label %18, !llvm.loop !21

18:                                               ; preds = %14
  %19 = load volatile i32, ptr inttoptr (i64 4294966320 to ptr), align 16, !tbaa !20
  %20 = or i32 %19, 3
  store volatile i32 %20, ptr inttoptr (i64 4294966320 to ptr), align 16, !tbaa !20
  br label %21

21:                                               ; preds = %21, %18
  %22 = load volatile i32, ptr inttoptr (i64 4294966376 to ptr), align 8, !tbaa !14
  %23 = and i32 %22, 8
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %21, label %25, !llvm.loop !22

25:                                               ; preds = %21
  store volatile i32 536870912, ptr inttoptr (i64 4294964224 to ptr), align 1024, !tbaa !23
  store volatile i32 536870912, ptr inttoptr (i64 4294964320 to ptr), align 32, !tbaa !25
  store volatile i32 536870912, ptr inttoptr (i64 4294964228 to ptr), align 4, !tbaa !26
  store volatile i32 536870912, ptr inttoptr (i64 4294964336 to ptr), align 16, !tbaa !27
  store volatile i32 0, ptr inttoptr (i64 4294963200 to ptr), align 4096, !tbaa !28
  store volatile i32 1, ptr inttoptr (i64 4294963488 to ptr), align 32, !tbaa !29
  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 96}
!6 = !{!"_AT91S_MC", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 12, !7, i64 96, !7, i64 100, !7, i64 104}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 4}
!11 = !{!"_AT91S_WDTC", !7, i64 0, !7, i64 4, !7, i64 8}
!12 = !{!13, !7, i64 32}
!13 = !{!"_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}
!14 = !{!13, !7, i64 104}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!13, !7, i64 44}
!18 = distinct !{!18, !16}
!19 = distinct !{!19, !16}
!20 = !{!13, !7, i64 48}
!21 = distinct !{!21, !16}
!22 = distinct !{!22, !16}
!23 = !{!24, !7, i64 0}
!24 = !{!"_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}
!25 = !{!24, !7, i64 96}
!26 = !{!24, !7, i64 4}
!27 = !{!24, !7, i64 112}
!28 = !{!7, !7, i64 0}
!29 = !{!30, !7, i64 288}
!30 = !{!"_AT91S_AIC", !8, i64 0, !8, i64 128, !7, i64 256, !7, i64 260, !7, i64 264, !7, i64 268, !7, i64 272, !7, i64 276, !8, i64 280, !7, i64 288, !7, i64 292, !7, i64 296, !7, i64 300, !7, i64 304, !7, i64 308, !7, i64 312, !8, i64 316, !7, i64 320, !7, i64 324, !7, i64 328}


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