; LLVM IR from FrancesoM/Bisc8FX :: sdk_projects/bisc8_platform/ps7_cortexa9_0/standalone_domain/bsp/ps7_cortexa9_0_ (CfgInitialize)

; 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.XScuGic = type { ptr, i32, i32 }
%struct.XScuGic_Config = type { i16, i32, i32, [95 x %struct.XScuGic_VectorTableEntry] }
%struct.XScuGic_VectorTableEntry = type { ptr, ptr }

@Xil_AssertStatus = external global i32, align 4
@.str = external hidden unnamed_addr constant [164 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @XScuGic_CfgInitialize(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %10 = load i32, ptr %7, align 4, !tbaa !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !9
  br label %15

14:                                               ; preds = %3
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 381)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !9
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %74

15:                                               ; preds = %13
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !9
  br label %20

19:                                               ; preds = %15
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 382)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !9
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %74

20:                                               ; preds = %18
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.XScuGic, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 8, !tbaa !11
  %24 = icmp ne i32 %23, 286331153
  br i1 %24, label %25, label %73

25:                                               ; preds = %20
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.XScuGic, ptr %26, i32 0, i32 1
  store i32 0, ptr %27, align 8, !tbaa !11
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.XScuGic, ptr %29, i32 0, i32 0
  store ptr %28, ptr %30, align 8, !tbaa !13
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %64, %25
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = icmp ult i32 %32, 95
  br i1 %33, label %34, label %67

34:                                               ; preds = %31
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.XScuGic, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !13
  %38 = getelementptr inbounds %struct.XScuGic_Config, ptr %37, i32 0, i32 3
  %39 = load i32, ptr %8, align 4, !tbaa !9
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds [95 x %struct.XScuGic_VectorTableEntry], ptr %38, i64 0, i64 %40
  %42 = getelementptr inbounds %struct.XScuGic_VectorTableEntry, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !14
  %44 = icmp eq ptr %43, null
  br i1 %44, label %45, label %54

45:                                               ; preds = %34
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.XScuGic, ptr %46, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !13
  %49 = getelementptr inbounds %struct.XScuGic_Config, ptr %48, i32 0, i32 3
  %50 = load i32, ptr %8, align 4, !tbaa !9
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds [95 x %struct.XScuGic_VectorTableEntry], ptr %49, i64 0, i64 %51
  %53 = getelementptr inbounds %struct.XScuGic_VectorTableEntry, ptr %52, i32 0, i32 0
  store ptr @StubHandler, ptr %53, align 8, !tbaa !14
  br label %54

54:                                               ; preds = %45, %34
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.XScuGic, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !13
  %59 = getelementptr inbounds %struct.XScuGic_Config, ptr %58, i32 0, i32 3
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds [95 x %struct.XScuGic_VectorTableEntry], ptr %59, i64 0, i64 %61
  %63 = getelementptr inbounds %struct.XScuGic_VectorTableEntry, ptr %62, i32 0, i32 1
  store ptr %55, ptr %63, align 8, !tbaa !16
  br label %64

64:                                               ; preds = %54
  %65 = load i32, ptr %8, align 4, !tbaa !9
  %66 = add i32 %65, 1
  store i32 %66, ptr %8, align 4, !tbaa !9
  br label %31, !llvm.loop !17

67:                                               ; preds = %31
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  call void @XScuGic_Stop(ptr noundef %68)
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  call void @DistributorInit(ptr noundef %69)
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  call void @CPUInitialize(ptr noundef %70)
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.XScuGic, ptr %71, i32 0, i32 1
  store i32 286331153, ptr %72, align 8, !tbaa !11
  br label %73

73:                                               ; preds = %67, %20
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %74

74:                                               ; preds = %73, %19, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %75 = load i32, ptr %4, align 4
  ret i32 %75
}

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

declare void @Xil_Assert(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @StubHandler(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @XScuGic_Stop(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @DistributorInit(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @CPUInitialize(ptr noundef) #0

; 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 = { "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 = !{!"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 8}
!12 = !{!"", !6, i64 0, !10, i64 8, !10, i64 12}
!13 = !{!12, !6, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"", !6, i64 0, !6, i64 8}
!16 = !{!15, !6, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; 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.XScuGic_VectorTableEntry = type { ptr, ptr }

@Xil_AssertStatus = external local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [164 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @XScuGic_CfgInitialize(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %5, label %4

4:                                                ; preds = %3
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !5
  %.not23 = icmp eq ptr %1, null
  br i1 %.not23, label %9, label %6

5:                                                ; preds = %3
  tail call void @Xil_Assert(ptr noundef nonnull @.str, i32 noundef 381) #2
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !5
  br label %27

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load i32, ptr %7, align 8, !tbaa !9
  %.not24 = icmp eq i32 %8, 286331153
  br i1 %.not24, label %27, label %10

9:                                                ; preds = %4
  tail call void @Xil_Assert(ptr noundef nonnull @.str, i32 noundef 382) #2
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !5
  br label %27

10:                                               ; preds = %6
  store i32 0, ptr %7, align 8, !tbaa !9
  store ptr %1, ptr %0, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %1, i64 16
  br label %12

12:                                               ; preds = %24, %10
  %indvars.iv = phi i64 [ 0, %10 ], [ %indvars.iv.next.1, %24 ]
  %13 = getelementptr inbounds [95 x %struct.XScuGic_VectorTableEntry], ptr %11, i64 0, i64 %indvars.iv
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %12
  store ptr @StubHandler, ptr %13, align 8, !tbaa !13
  br label %17

17:                                               ; preds = %16, %12
  %18 = getelementptr inbounds [95 x %struct.XScuGic_VectorTableEntry], ptr %11, i64 0, i64 %indvars.iv, i32 1
  store ptr %0, ptr %18, align 8, !tbaa !15
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, 94
  br i1 %exitcond.not, label %26, label %19, !llvm.loop !16

19:                                               ; preds = %17
  %20 = getelementptr inbounds [95 x %struct.XScuGic_VectorTableEntry], ptr %11, i64 0, i64 %indvars.iv.next
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %19
  store ptr @StubHandler, ptr %20, align 8, !tbaa !13
  br label %24

24:                                               ; preds = %23, %19
  %25 = getelementptr inbounds [95 x %struct.XScuGic_VectorTableEntry], ptr %11, i64 0, i64 %indvars.iv.next, i32 1
  store ptr %0, ptr %25, align 8, !tbaa !15
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  br label %12

26:                                               ; preds = %17
  tail call void @XScuGic_Stop(ptr noundef nonnull %0)
  tail call void @DistributorInit(ptr noundef nonnull %0)
  tail call void @CPUInitialize(ptr noundef nonnull %0)
  store i32 286331153, ptr %7, align 8, !tbaa !9
  br label %27

27:                                               ; preds = %6, %26, %9, %5
  ret i32 0
}

declare void @Xil_Assert(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @StubHandler(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @XScuGic_Stop(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @DistributorInit(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @CPUInitialize(ptr 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" }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"", !11, i64 0, !6, i64 8, !6, i64 12}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!14, !11, i64 0}
!14 = !{!"", !11, i64 0, !11, i64 8}
!15 = !{!14, !11, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass