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

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

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

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

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

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

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

19:                                               ; preds = %5
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !9
  br label %21

20:                                               ; preds = %5
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 244)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !9
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %95

21:                                               ; preds = %19
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %91, %21
  %23 = load i32, ptr %14, align 4, !tbaa !9
  %24 = load i32, ptr %8, align 4, !tbaa !9
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %26, label %94

26:                                               ; preds = %22
  %27 = load i32, ptr %10, align 4, !tbaa !9
  switch i32 %27, label %36 [
    i32 1, label %28
    i32 2, label %32
  ]

28:                                               ; preds = %26
  %29 = load ptr, ptr %12, align 8, !tbaa !5
  %30 = ptrtoint ptr %29 to i64
  %31 = load i32, ptr %9, align 4, !tbaa !9
  call void @Xil_Out32(i64 noundef %30, i32 noundef %31)
  br label %40

32:                                               ; preds = %26
  %33 = load ptr, ptr %12, align 8, !tbaa !5
  %34 = ptrtoint ptr %33 to i64
  %35 = load i32, ptr %9, align 4, !tbaa !9
  call void @Xil_Out32BE(i64 noundef %34, i32 noundef %35)
  br label %40

36:                                               ; preds = %26
  %37 = load ptr, ptr %12, align 8, !tbaa !5
  %38 = ptrtoint ptr %37 to i64
  %39 = load i32, ptr %9, align 4, !tbaa !9
  call void @Xil_Out32(i64 noundef %38, i32 noundef %39)
  br label %40

40:                                               ; preds = %36, %32, %28
  %41 = load ptr, ptr %12, align 8, !tbaa !5
  %42 = ptrtoint ptr %41 to i64
  %43 = call i32 @Xil_In32(i64 noundef %42)
  store i32 %43, ptr %13, align 4, !tbaa !9
  %44 = load i32, ptr %10, align 4, !tbaa !9
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %52

46:                                               ; preds = %40
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %52

49:                                               ; preds = %46
  %50 = load i32, ptr %13, align 4, !tbaa !9
  %51 = call i32 @Swap32(i32 noundef %50)
  store i32 %51, ptr %13, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %49, %46, %40
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = load i32, ptr %13, align 4, !tbaa !9
  %55 = icmp ne i32 %53, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %52
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %95

57:                                               ; preds = %52
  %58 = load ptr, ptr %12, align 8, !tbaa !5
  %59 = ptrtoint ptr %58 to i64
  %60 = load i32, ptr %9, align 4, !tbaa !9
  call void @Xil_Out32(i64 noundef %59, i32 noundef %60)
  %61 = load i32, ptr %10, align 4, !tbaa !9
  switch i32 %61, label %70 [
    i32 1, label %62
    i32 2, label %66
  ]

62:                                               ; preds = %57
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = ptrtoint ptr %63 to i64
  %65 = call i32 @Xil_In32(i64 noundef %64)
  store i32 %65, ptr %13, align 4, !tbaa !9
  br label %74

66:                                               ; preds = %57
  %67 = load ptr, ptr %12, align 8, !tbaa !5
  %68 = ptrtoint ptr %67 to i64
  %69 = call i32 @Xil_In32BE(i64 noundef %68)
  store i32 %69, ptr %13, align 4, !tbaa !9
  br label %74

70:                                               ; preds = %57
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = ptrtoint ptr %71 to i64
  %73 = call i32 @Xil_In32(i64 noundef %72)
  store i32 %73, ptr %13, align 4, !tbaa !9
  br label %74

74:                                               ; preds = %70, %66, %62
  %75 = load i32, ptr %10, align 4, !tbaa !9
  %76 = icmp ne i32 %75, 0
  br i1 %76, label %77, label %83

77:                                               ; preds = %74
  %78 = load i32, ptr %11, align 4, !tbaa !9
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %83

80:                                               ; preds = %77
  %81 = load i32, ptr %13, align 4, !tbaa !9
  %82 = call i32 @Swap32(i32 noundef %81)
  store i32 %82, ptr %13, align 4, !tbaa !9
  br label %83

83:                                               ; preds = %80, %77, %74
  %84 = load i32, ptr %9, align 4, !tbaa !9
  %85 = load i32, ptr %13, align 4, !tbaa !9
  %86 = icmp ne i32 %84, %85
  br i1 %86, label %87, label %88

87:                                               ; preds = %83
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %95

88:                                               ; preds = %83
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = getelementptr inbounds i32, ptr %89, i64 4
  store ptr %90, ptr %12, align 8, !tbaa !5
  br label %91

91:                                               ; preds = %88
  %92 = load i32, ptr %14, align 4, !tbaa !9
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %14, align 4, !tbaa !9
  br label %22, !llvm.loop !11

94:                                               ; preds = %22
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %95

95:                                               ; preds = %94, %87, %56, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %96 = load i32, ptr %6, align 4
  ret i32 %96
}

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @Swap32(i32 noundef) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { 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 #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 = distinct !{!11, !12}
!12 = !{!"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"

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

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

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

6:                                                ; preds = %5
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !5
  %7 = icmp sgt i32 %1, 0
  br i1 %7, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %6
  %8 = icmp ne i32 %3, 0
  %9 = icmp ne i32 %4, 0
  %or.cond = and i1 %8, %9
  br i1 %or.cond, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %26
  %.041.us = phi i32 [ %28, %26 ], [ 0, %.lr.ph ]
  %.03440.us = phi ptr [ %27, %26 ], [ %0, %.lr.ph ]
  %10 = ptrtoint ptr %.03440.us to i64
  switch i32 %3, label %13 [
    i32 1, label %12
    i32 2, label %11
  ]

11:                                               ; preds = %.lr.ph.split.us
  tail call void @Xil_Out32BE(i64 noundef %10, i32 noundef %2)
  br label %14

12:                                               ; preds = %.lr.ph.split.us
  tail call void @Xil_Out32(i64 noundef %10, i32 noundef %2)
  br label %14

13:                                               ; preds = %.lr.ph.split.us
  tail call void @Xil_Out32(i64 noundef %10, i32 noundef %2)
  br label %14

14:                                               ; preds = %13, %12, %11
  %15 = tail call i32 @Xil_In32(i64 noundef %10)
  %16 = tail call i32 @Swap32(i32 noundef %15)
  %.not38.us = icmp eq i32 %16, %2
  br i1 %.not38.us, label %17, label %.loopexit

17:                                               ; preds = %14
  tail call void @Xil_Out32(i64 noundef %10, i32 noundef %2)
  switch i32 %3, label %22 [
    i32 1, label %20
    i32 2, label %18
  ]

18:                                               ; preds = %17
  %19 = tail call i32 @Xil_In32BE(i64 noundef %10)
  br label %24

20:                                               ; preds = %17
  %21 = tail call i32 @Xil_In32(i64 noundef %10)
  br label %24

22:                                               ; preds = %17
  %23 = tail call i32 @Xil_In32(i64 noundef %10)
  br label %24

24:                                               ; preds = %22, %20, %18
  %.1.us = phi i32 [ %23, %22 ], [ %19, %18 ], [ %21, %20 ]
  %25 = tail call i32 @Swap32(i32 noundef %.1.us)
  %.not39.us = icmp eq i32 %25, %2
  br i1 %.not39.us, label %26, label %.loopexit

26:                                               ; preds = %24
  %27 = getelementptr inbounds i8, ptr %.03440.us, i64 16
  %28 = add nuw nsw i32 %.041.us, 1
  %exitcond79.not = icmp eq i32 %28, %1
  br i1 %exitcond79.not, label %.loopexit, label %.lr.ph.split.us, !llvm.loop !9

.lr.ph.split:                                     ; preds = %.lr.ph
  switch i32 %3, label %.lr.ph.split.split [
    i32 1, label %.lr.ph.split.split.us
    i32 2, label %.lr.ph.split.split.us59
  ]

.lr.ph.split.split.us:                            ; preds = %.lr.ph.split, %33
  %.041.us48 = phi i32 [ %35, %33 ], [ 0, %.lr.ph.split ]
  %.03440.us49 = phi ptr [ %34, %33 ], [ %0, %.lr.ph.split ]
  %29 = ptrtoint ptr %.03440.us49 to i64
  tail call void @Xil_Out32(i64 noundef %29, i32 noundef %2)
  %30 = tail call i32 @Xil_In32(i64 noundef %29)
  %.not38.us50 = icmp eq i32 %30, %2
  br i1 %.not38.us50, label %31, label %.loopexit

31:                                               ; preds = %.lr.ph.split.split.us
  tail call void @Xil_Out32(i64 noundef %29, i32 noundef %2)
  %32 = tail call i32 @Xil_In32(i64 noundef %29)
  %.not39.us52 = icmp eq i32 %32, %2
  br i1 %.not39.us52, label %33, label %.loopexit

33:                                               ; preds = %31
  %34 = getelementptr inbounds i8, ptr %.03440.us49, i64 16
  %35 = add nuw nsw i32 %.041.us48, 1
  %exitcond77.not = icmp eq i32 %35, %1
  br i1 %exitcond77.not, label %.loopexit, label %.lr.ph.split.split.us, !llvm.loop !9

.lr.ph.split.split.us59:                          ; preds = %.lr.ph.split, %40
  %.041.us60 = phi i32 [ %42, %40 ], [ 0, %.lr.ph.split ]
  %.03440.us61 = phi ptr [ %41, %40 ], [ %0, %.lr.ph.split ]
  %36 = ptrtoint ptr %.03440.us61 to i64
  tail call void @Xil_Out32BE(i64 noundef %36, i32 noundef %2)
  %37 = tail call i32 @Xil_In32(i64 noundef %36)
  %.not38.us62 = icmp eq i32 %37, %2
  br i1 %.not38.us62, label %38, label %.loopexit

38:                                               ; preds = %.lr.ph.split.split.us59
  tail call void @Xil_Out32(i64 noundef %36, i32 noundef %2)
  %39 = tail call i32 @Xil_In32BE(i64 noundef %36)
  %.not39.us64 = icmp eq i32 %39, %2
  br i1 %.not39.us64, label %40, label %.loopexit

40:                                               ; preds = %38
  %41 = getelementptr inbounds i8, ptr %.03440.us61, i64 16
  %42 = add nuw nsw i32 %.041.us60, 1
  %exitcond.not = icmp eq i32 %42, %1
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph.split.split.us59, !llvm.loop !9

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

.lr.ph.split.split:                               ; preds = %.lr.ph.split, %54
  %.041 = phi i32 [ %56, %54 ], [ 0, %.lr.ph.split ]
  %.03440 = phi ptr [ %55, %54 ], [ %0, %.lr.ph.split ]
  %44 = ptrtoint ptr %.03440 to i64
  tail call void @Xil_Out32(i64 noundef %44, i32 noundef %2)
  %45 = tail call i32 @Xil_In32(i64 noundef %44)
  %.not38 = icmp eq i32 %45, %2
  br i1 %.not38, label %46, label %.loopexit

46:                                               ; preds = %.lr.ph.split.split
  tail call void @Xil_Out32(i64 noundef %44, i32 noundef %2)
  switch i32 %3, label %51 [
    i32 1, label %47
    i32 2, label %49
  ]

47:                                               ; preds = %46
  %48 = tail call i32 @Xil_In32(i64 noundef %44)
  br label %53

49:                                               ; preds = %46
  %50 = tail call i32 @Xil_In32BE(i64 noundef %44)
  br label %53

51:                                               ; preds = %46
  %52 = tail call i32 @Xil_In32(i64 noundef %44)
  br label %53

53:                                               ; preds = %51, %49, %47
  %.1 = phi i32 [ %52, %51 ], [ %50, %49 ], [ %48, %47 ]
  %.not39 = icmp eq i32 %.1, %2
  br i1 %.not39, label %54, label %.loopexit

54:                                               ; preds = %53
  %55 = getelementptr inbounds i8, ptr %.03440, i64 16
  %56 = add nuw nsw i32 %.041, 1
  %exitcond78.not = icmp eq i32 %56, %1
  br i1 %exitcond78.not, label %.loopexit, label %.lr.ph.split.split, !llvm.loop !9

.loopexit:                                        ; preds = %.lr.ph.split.split.us59, %38, %40, %.lr.ph.split.split.us, %31, %33, %.lr.ph.split.split, %53, %54, %14, %24, %26, %6, %43
  %.035 = phi i32 [ 0, %43 ], [ 0, %6 ], [ -1, %14 ], [ -1, %24 ], [ 0, %26 ], [ -1, %.lr.ph.split.split ], [ -1, %53 ], [ 0, %54 ], [ -1, %.lr.ph.split.split.us ], [ -1, %31 ], [ 0, %33 ], [ -1, %.lr.ph.split.split.us59 ], [ -1, %38 ], [ 0, %40 ]
  ret i32 %.035
}

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

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @Xil_In32BE(i64 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 = { 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 = { 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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass