; LLVM IR from lfarcaro/ARINC653_ARMV7A_Z7000 :: ARINC653_ARMV7A_Z7000.sw/ARINC653_ARMV7A_Z7000_bsp/ps7_cortexa9_0/libsrc/uartps_v3 (InterruptHandler)

; 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.XUartPs = type { %struct.XUartPs_Config, i32, i32, i32, %struct.XUartPsBuffer, %struct.XUartPsBuffer, ptr, ptr, i32, i8 }
%struct.XUartPs_Config = type { i16, i32, i32, i32 }
%struct.XUartPsBuffer = type { ptr, i32, i32 }

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @XUartPs_InterruptHandler(ptr noundef %0) #3 {
  %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) #4
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = icmp ne ptr %5, null
  br i1 %6, label %7, label %8

7:                                                ; preds = %1
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !9
  br label %9

8:                                                ; preds = %1
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 185)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !9
  store i32 1, ptr %4, align 4
  br label %72

9:                                                ; preds = %7
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.XUartPs, ptr %10, i32 0, i32 2
  %12 = load i32, ptr %11, align 4, !tbaa !11
  %13 = icmp eq i32 %12, 286331153
  br i1 %13, label %14, label %15

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

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

16:                                               ; preds = %14
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.XUartPs, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %struct.XUartPs_Config, ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !16
  %21 = add i32 %20, 16
  %22 = zext i32 %21 to i64
  %23 = call i32 @Xil_In32(i64 noundef %22)
  store i32 %23, ptr %3, align 4, !tbaa !9
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.XUartPs, ptr %24, i32 0, i32 0
  %26 = getelementptr inbounds %struct.XUartPs_Config, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !16
  %28 = add i32 %27, 20
  %29 = zext i32 %28 to i64
  %30 = call i32 @Xil_In32(i64 noundef %29)
  %31 = load i32, ptr %3, align 4, !tbaa !9
  %32 = and i32 %31, %30
  store i32 %32, ptr %3, align 4, !tbaa !9
  %33 = load i32, ptr %3, align 4, !tbaa !9
  %34 = and i32 %33, 7
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %16
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  call void @ReceiveDataHandler(ptr noundef %37)
  br label %38

38:                                               ; preds = %36, %16
  %39 = load i32, ptr %3, align 4, !tbaa !9
  %40 = and i32 %39, 24
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %45

42:                                               ; preds = %38
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = load i32, ptr %3, align 4, !tbaa !9
  call void @SendDataHandler(ptr noundef %43, i32 noundef %44)
  br label %45

45:                                               ; preds = %42, %38
  %46 = load i32, ptr %3, align 4, !tbaa !9
  %47 = and i32 %46, 8416
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %52

49:                                               ; preds = %45
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = load i32, ptr %3, align 4, !tbaa !9
  call void @ReceiveErrorHandler(ptr noundef %50, i32 noundef %51)
  br label %52

52:                                               ; preds = %49, %45
  %53 = load i32, ptr %3, align 4, !tbaa !9
  %54 = and i32 %53, 256
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %58

56:                                               ; preds = %52
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  call void @ReceiveTimeoutHandler(ptr noundef %57)
  br label %58

58:                                               ; preds = %56, %52
  %59 = load i32, ptr %3, align 4, !tbaa !9
  %60 = and i32 %59, 512
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %64

62:                                               ; preds = %58
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  call void @ModemHandler(ptr noundef %63)
  br label %64

64:                                               ; preds = %62, %58
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.XUartPs, ptr %65, i32 0, i32 0
  %67 = getelementptr inbounds %struct.XUartPs_Config, ptr %66, i32 0, i32 1
  %68 = load i32, ptr %67, align 4, !tbaa !16
  %69 = add i32 %68, 20
  %70 = zext i32 %69 to i64
  %71 = load i32, ptr %3, align 4, !tbaa !9
  call void @Xil_Out32(i64 noundef %70, i32 noundef %71)
  store i32 0, ptr %4, align 4
  br label %72

72:                                               ; preds = %64, %15, %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  %73 = load i32, ptr %4, align 4
  switch i32 %73, label %75 [
    i32 0, label %74
    i32 1, label %74
  ]

74:                                               ; preds = %72, %72
  ret void

75:                                               ; preds = %72
  unreachable
}

; Function Attrs: nounwind uwtable
declare hidden void @ReceiveDataHandler(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @SendDataHandler(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @ReceiveErrorHandler(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @ReceiveTimeoutHandler(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @ModemHandler(ptr noundef) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 20}
!12 = !{!"", !13, i64 0, !10, i64 16, !10, i64 20, !10, i64 24, !15, i64 32, !15, i64 48, !6, i64 64, !6, i64 72, !10, i64 80, !7, i64 84}
!13 = !{!"", !14, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!14 = !{!"short", !7, i64 0}
!15 = !{!"", !6, i64 0, !10, i64 8, !10, i64 12}
!16 = !{!12, !10, i64 4}


; 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 [168 x i8], align 1

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

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

; 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 @XUartPs_InterruptHandler(ptr noundef %0) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %6, label %2

2:                                                ; preds = %1
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 20
  %4 = load i32, ptr %3, align 4, !tbaa !9
  %5 = icmp eq i32 %4, 286331153
  br i1 %5, label %7, label %19

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

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !15
  %10 = add i32 %9, 16
  %11 = zext i32 %10 to i64
  %12 = tail call i32 @Xil_In32(i64 noundef %11)
  %13 = load i32, ptr %8, align 4, !tbaa !15
  %14 = add i32 %13, 20
  %15 = zext i32 %14 to i64
  %16 = tail call i32 @Xil_In32(i64 noundef %15)
  %17 = and i32 %16, %12
  %18 = and i32 %17, 7
  %.not18 = icmp eq i32 %18, 0
  br i1 %.not18, label %21, label %20

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

20:                                               ; preds = %7
  tail call void @ReceiveDataHandler(ptr noundef nonnull %0)
  br label %21

21:                                               ; preds = %20, %7
  %22 = and i32 %17, 24
  %.not19 = icmp eq i32 %22, 0
  br i1 %.not19, label %24, label %23

23:                                               ; preds = %21
  tail call void @SendDataHandler(ptr noundef nonnull %0, i32 noundef %17)
  br label %24

24:                                               ; preds = %23, %21
  %25 = and i32 %17, 8416
  %.not20 = icmp eq i32 %25, 0
  br i1 %.not20, label %27, label %26

26:                                               ; preds = %24
  tail call void @ReceiveErrorHandler(ptr noundef nonnull %0, i32 noundef %17)
  br label %27

27:                                               ; preds = %26, %24
  %28 = and i32 %17, 256
  %.not21 = icmp eq i32 %28, 0
  br i1 %.not21, label %30, label %29

29:                                               ; preds = %27
  tail call void @ReceiveTimeoutHandler(ptr noundef nonnull %0)
  br label %30

30:                                               ; preds = %29, %27
  %31 = and i32 %17, 512
  %.not22 = icmp eq i32 %31, 0
  br i1 %.not22, label %33, label %32

32:                                               ; preds = %30
  tail call void @ModemHandler(ptr noundef nonnull %0)
  br label %33

33:                                               ; preds = %32, %30
  %34 = load i32, ptr %8, align 4, !tbaa !15
  %35 = add i32 %34, 20
  %36 = zext i32 %35 to i64
  tail call void @Xil_Out32(i64 noundef %36, i32 noundef %17)
  br label %37

37:                                               ; preds = %33, %19, %6
  ret void
}

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

; Function Attrs: nounwind uwtable
declare hidden void @SendDataHandler(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @ReceiveErrorHandler(ptr noundef, i32 noundef) local_unnamed_addr #2

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

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

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 20}
!10 = !{!"", !11, i64 0, !6, i64 16, !6, i64 20, !6, i64 24, !13, i64 32, !13, i64 48, !14, i64 64, !14, i64 72, !6, i64 80, !7, i64 84}
!11 = !{!"", !12, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!12 = !{!"short", !7, i64 0}
!13 = !{!"", !14, i64 0, !6, i64 8, !6, i64 12}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!10, !6, i64 4}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass