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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @Xil_EndianSwap32(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i16, align 2
  %4 = alloca i16, align 2
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 2, ptr %4) #2
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %6 = and i32 %5, 65535
  %7 = trunc i32 %6 to i16
  store i16 %7, ptr %3, align 2, !tbaa !9
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = and i32 %8, -65536
  %10 = lshr i32 %9, 16
  %11 = trunc i32 %10 to i16
  store i16 %11, ptr %4, align 2, !tbaa !9
  %12 = load i16, ptr %3, align 2, !tbaa !9
  %13 = zext i16 %12 to i32
  %14 = and i32 %13, 65280
  %15 = lshr i32 %14, 8
  %16 = load i16, ptr %3, align 2, !tbaa !9
  %17 = zext i16 %16 to i32
  %18 = and i32 %17, 255
  %19 = shl i32 %18, 8
  %20 = or i32 %15, %19
  %21 = trunc i32 %20 to i16
  store i16 %21, ptr %3, align 2, !tbaa !9
  %22 = load i16, ptr %4, align 2, !tbaa !9
  %23 = zext i16 %22 to i32
  %24 = and i32 %23, 65280
  %25 = lshr i32 %24, 8
  %26 = load i16, ptr %4, align 2, !tbaa !9
  %27 = zext i16 %26 to i32
  %28 = and i32 %27, 255
  %29 = shl i32 %28, 8
  %30 = or i32 %25, %29
  %31 = trunc i32 %30 to i16
  store i16 %31, ptr %4, align 2, !tbaa !9
  %32 = load i16, ptr %3, align 2, !tbaa !9
  %33 = zext i16 %32 to i32
  %34 = shl i32 %33, 16
  %35 = load i16, ptr %4, align 2, !tbaa !9
  %36 = zext i16 %35 to i32
  %37 = or i32 %34, %36
  call void @llvm.lifetime.end.p0(i64 2, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 2, ptr %3) #2
  ret i32 %37
}

; 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef i32 @Xil_EndianSwap32(i32 noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @llvm.bswap.i32(i32 %0)
  ret i32 %2
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.bswap.i32(i32) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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 speculatable willreturn memory(none) }

!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)"}


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