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

; 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.XEmacPs_Instance = type { %struct.XEmacPs_Config, i32, i32, i32, %struct.XEmacPs_BdRing, %struct.XEmacPs_BdRing, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32 }
%struct.XEmacPs_Config = type { i16, i64, i8, i8, i8, i8, i8, i8, i8 }
%struct.XEmacPs_BdRing = type { i64, i64, i64, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32 }

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @Xil_Out32(i64 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @XEmacPs_SetQueuePtr(ptr noundef %0, i64 noundef %1, i8 noundef zeroext %2, i16 noundef zeroext %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i8, align 1
  %8 = alloca i16, align 2
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store i8 %2, ptr %7, align 1, !tbaa !11
  store i16 %3, ptr %8, align 2, !tbaa !12
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %4
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !14
  br label %13

12:                                               ; preds = %4
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 449)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !14
  br label %62

13:                                               ; preds = %11
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.XEmacPs_Instance, ptr %14, i32 0, i32 2
  %16 = load i32, ptr %15, align 4, !tbaa !16
  %17 = icmp eq i32 %16, 286331153
  br i1 %17, label %18, label %19

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

19:                                               ; preds = %13
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 450)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !14
  br label %62

20:                                               ; preds = %18
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.XEmacPs_Instance, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 8, !tbaa !20
  %24 = icmp eq i32 %23, 572662306
  br i1 %24, label %25, label %26

25:                                               ; preds = %20
  br label %62

26:                                               ; preds = %20
  %27 = load i8, ptr %7, align 1, !tbaa !11
  %28 = zext i8 %27 to i32
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %53

30:                                               ; preds = %26
  %31 = load i16, ptr %8, align 2, !tbaa !12
  %32 = zext i16 %31 to i32
  %33 = icmp eq i32 %32, 1
  br i1 %33, label %34, label %43

34:                                               ; preds = %30
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.XEmacPs_Instance, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.XEmacPs_Config, ptr %36, i32 0, i32 1
  %38 = load i64, ptr %37, align 8, !tbaa !21
  %39 = add i64 %38, 28
  %40 = load i64, ptr %6, align 8, !tbaa !9
  %41 = and i64 %40, 4294967295
  %42 = trunc i64 %41 to i32
  call void @Xil_Out32(i64 noundef %39, i32 noundef %42)
  br label %52

43:                                               ; preds = %30
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.XEmacPs_Instance, ptr %44, i32 0, i32 0
  %46 = getelementptr inbounds %struct.XEmacPs_Config, ptr %45, i32 0, i32 1
  %47 = load i64, ptr %46, align 8, !tbaa !21
  %48 = add i64 %47, 24
  %49 = load i64, ptr %6, align 8, !tbaa !9
  %50 = and i64 %49, 4294967295
  %51 = trunc i64 %50 to i32
  call void @Xil_Out32(i64 noundef %48, i32 noundef %51)
  br label %52

52:                                               ; preds = %43, %34
  br label %62

53:                                               ; preds = %26
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.XEmacPs_Instance, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds %struct.XEmacPs_Config, ptr %55, i32 0, i32 1
  %57 = load i64, ptr %56, align 8, !tbaa !21
  %58 = add i64 %57, 1088
  %59 = load i64, ptr %6, align 8, !tbaa !9
  %60 = and i64 %59, 4294967295
  %61 = trunc i64 %60 to i32
  call void @Xil_Out32(i64 noundef %58, i32 noundef %61)
  br label %62

62:                                               ; preds = %53, %52, %25, %19, %12
  ret void
}

attributes #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 = { inlinehint 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 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !15, i64 28}
!17 = !{!"XEmacPs_Instance", !18, i64 0, !15, i64 24, !15, i64 28, !15, i64 32, !19, i64 40, !19, i64 152, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !15, i64 312, !15, i64 316, !15, i64 320, !15, i64 324, !15, i64 328}
!18 = !{!"", !13, i64 0, !10, i64 8, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19, !7, i64 20, !7, i64 21, !7, i64 22}
!19 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !15, i64 24, !15, i64 28, !15, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !15, i64 88, !15, i64 92, !15, i64 96, !15, i64 100, !15, i64 104}
!20 = !{!17, !15, i64 24}
!21 = !{!17, !10, i64 8}


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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @Xil_Out32(i64 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @XEmacPs_SetQueuePtr(ptr noundef readonly %0, i64 noundef %1, i8 noundef zeroext %2, i16 noundef zeroext %3) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %9, label %5

5:                                                ; preds = %4
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 28
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = icmp eq i32 %7, 286331153
  br i1 %8, label %10, label %14

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

10:                                               ; preds = %5
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = load i32, ptr %11, align 8, !tbaa !16
  %13 = icmp eq i32 %12, 572662306
  br i1 %13, label %30, label %15

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

15:                                               ; preds = %10
  %16 = icmp eq i8 %2, 0
  %17 = trunc i64 %1 to i32
  br i1 %16, label %18, label %26

18:                                               ; preds = %15
  %19 = icmp eq i16 %3, 1
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  %21 = load i64, ptr %20, align 8, !tbaa !17
  br i1 %19, label %22, label %24

22:                                               ; preds = %18
  %23 = add i64 %21, 28
  tail call void @Xil_Out32(i64 noundef %23, i32 noundef %17)
  br label %30

24:                                               ; preds = %18
  %25 = add i64 %21, 24
  tail call void @Xil_Out32(i64 noundef %25, i32 noundef %17)
  br label %30

26:                                               ; preds = %15
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  %28 = load i64, ptr %27, align 8, !tbaa !17
  %29 = add i64 %28, 1088
  tail call void @Xil_Out32(i64 noundef %29, i32 noundef %17)
  br label %30

30:                                               ; preds = %22, %24, %10, %26, %14, %9
  ret void
}

attributes #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 = { inlinehint 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 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 28}
!10 = !{!"XEmacPs_Instance", !11, i64 0, !6, i64 24, !6, i64 28, !6, i64 32, !14, i64 40, !14, i64 152, !15, i64 264, !15, i64 272, !15, i64 280, !15, i64 288, !15, i64 296, !15, i64 304, !6, i64 312, !6, i64 316, !6, i64 320, !6, i64 324, !6, i64 328}
!11 = !{!"", !12, i64 0, !13, i64 8, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19, !7, i64 20, !7, i64 21, !7, i64 22}
!12 = !{!"short", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"", !13, i64 0, !13, i64 8, !13, i64 16, !6, i64 24, !6, i64 28, !6, i64 32, !15, i64 40, !15, i64 48, !15, i64 56, !15, i64 64, !15, i64 72, !15, i64 80, !6, i64 88, !6, i64 92, !6, i64 96, !6, i64 100, !6, i64 104}
!15 = !{!"any pointer", !7, i64 0}
!16 = !{!10, !6, i64 24}
!17 = !{!10, !13, i64 8}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass