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

; 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 }
%struct.XUartPsFormat = type { i32, i32, i32, i8 }

@Xil_AssertStatus = external global i32, align 4
@.str = external hidden unnamed_addr constant [171 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

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

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

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

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

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

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

12:                                               ; preds = %2
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 651)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !9
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %94

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

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

17:                                               ; preds = %13
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 652)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !9
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %94

18:                                               ; preds = %16
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.XUartPs, ptr %19, i32 0, i32 2
  %21 = load i32, ptr %20, align 4, !tbaa !11
  %22 = icmp eq i32 %21, 286331153
  br i1 %22, label %23, label %24

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

24:                                               ; preds = %18
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 653)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !9
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %94

25:                                               ; preds = %23
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.XUartPsFormat, ptr %26, i32 0, i32 1
  %28 = load i32, ptr %27, align 4, !tbaa !16
  %29 = icmp ugt i32 %28, 3
  br i1 %29, label %41, label %30

30:                                               ; preds = %25
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.XUartPsFormat, ptr %31, i32 0, i32 3
  %33 = load i8, ptr %32, align 4, !tbaa !18
  %34 = zext i8 %33 to i32
  %35 = icmp sgt i32 %34, 2
  br i1 %35, label %41, label %36

36:                                               ; preds = %30
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.XUartPsFormat, ptr %37, i32 0, i32 2
  %39 = load i32, ptr %38, align 4, !tbaa !19
  %40 = icmp ugt i32 %39, 4
  br i1 %40, label %41, label %42

41:                                               ; preds = %36, %30, %25
  store i32 15, ptr %6, align 4, !tbaa !9
  br label %92

42:                                               ; preds = %36
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.XUartPsFormat, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %45, align 4, !tbaa !20
  %47 = call i32 @XUartPs_SetBaudRate(ptr noundef %43, i32 noundef %46)
  store i32 %47, ptr %6, align 4, !tbaa !9
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %51

50:                                               ; preds = %42
  br label %91

51:                                               ; preds = %42
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.XUartPs, ptr %52, i32 0, i32 0
  %54 = getelementptr inbounds %struct.XUartPs_Config, ptr %53, i32 0, i32 1
  %55 = load i32, ptr %54, align 4, !tbaa !21
  %56 = add i32 %55, 4
  %57 = zext i32 %56 to i64
  %58 = call i32 @Xil_In32(i64 noundef %57)
  store i32 %58, ptr %7, align 4, !tbaa !9
  %59 = load i32, ptr %7, align 4, !tbaa !9
  %60 = and i32 %59, -7
  store i32 %60, ptr %7, align 4, !tbaa !9
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.XUartPsFormat, ptr %61, i32 0, i32 1
  %63 = load i32, ptr %62, align 4, !tbaa !16
  %64 = shl i32 %63, 1
  %65 = load i32, ptr %7, align 4, !tbaa !9
  %66 = or i32 %65, %64
  store i32 %66, ptr %7, align 4, !tbaa !9
  %67 = load i32, ptr %7, align 4, !tbaa !9
  %68 = and i32 %67, -161
  store i32 %68, ptr %7, align 4, !tbaa !9
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.XUartPsFormat, ptr %69, i32 0, i32 3
  %71 = load i8, ptr %70, align 4, !tbaa !18
  %72 = zext i8 %71 to i32
  %73 = shl i32 %72, 6
  %74 = load i32, ptr %7, align 4, !tbaa !9
  %75 = or i32 %74, %73
  store i32 %75, ptr %7, align 4, !tbaa !9
  %76 = load i32, ptr %7, align 4, !tbaa !9
  %77 = and i32 %76, -57
  store i32 %77, ptr %7, align 4, !tbaa !9
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.XUartPsFormat, ptr %78, i32 0, i32 2
  %80 = load i32, ptr %79, align 4, !tbaa !19
  %81 = shl i32 %80, 3
  %82 = load i32, ptr %7, align 4, !tbaa !9
  %83 = or i32 %82, %81
  store i32 %83, ptr %7, align 4, !tbaa !9
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.XUartPs, ptr %84, i32 0, i32 0
  %86 = getelementptr inbounds %struct.XUartPs_Config, ptr %85, i32 0, i32 1
  %87 = load i32, ptr %86, align 4, !tbaa !21
  %88 = add i32 %87, 4
  %89 = zext i32 %88 to i64
  %90 = load i32, ptr %7, align 4, !tbaa !9
  call void @Xil_Out32(i64 noundef %89, i32 noundef %90)
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %91

91:                                               ; preds = %51, %50
  br label %92

92:                                               ; preds = %91, %41
  %93 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %93, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %94

94:                                               ; preds = %92, %24, %17, %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %95 = load i32, ptr %3, align 4
  ret i32 %95
}

declare i32 @XUartPs_SetBaudRate(ptr noundef, i32 noundef) #1

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 = { 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 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 = !{!17, !10, i64 4}
!17 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12}
!18 = !{!17, !7, i64 12}
!19 = !{!17, !10, i64 8}
!20 = !{!17, !10, i64 0}
!21 = !{!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 [171 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 i32 @XUartPs_SetDataFormat(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %4, label %3

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

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

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

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

10:                                               ; preds = %5
  %11 = getelementptr inbounds i8, ptr %1, i64 4
  %12 = load i32, ptr %11, align 4, !tbaa !15
  %13 = icmp ugt i32 %12, 3
  br i1 %13, label %46, label %15

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

15:                                               ; preds = %10
  %16 = getelementptr inbounds i8, ptr %1, i64 12
  %17 = load i8, ptr %16, align 4, !tbaa !17
  %18 = icmp ugt i8 %17, 2
  br i1 %18, label %46, label %19

19:                                               ; preds = %15
  %20 = getelementptr inbounds i8, ptr %1, i64 8
  %21 = load i32, ptr %20, align 4, !tbaa !18
  %22 = icmp ugt i32 %21, 4
  br i1 %22, label %46, label %23

23:                                               ; preds = %19
  %24 = load i32, ptr %1, align 4, !tbaa !19
  %25 = tail call i32 @XUartPs_SetBaudRate(ptr noundef nonnull %0, i32 noundef %24) #3
  %.not27 = icmp eq i32 %25, 0
  br i1 %.not27, label %26, label %46

26:                                               ; preds = %23
  %27 = getelementptr inbounds i8, ptr %0, i64 4
  %28 = load i32, ptr %27, align 4, !tbaa !20
  %29 = add i32 %28, 4
  %30 = zext i32 %29 to i64
  %31 = tail call i32 @Xil_In32(i64 noundef %30)
  %32 = and i32 %31, -191
  %33 = load i32, ptr %11, align 4, !tbaa !15
  %34 = shl i32 %33, 1
  %.masked = and i32 %34, -186
  %35 = or i32 %.masked, %32
  %36 = load i8, ptr %16, align 4, !tbaa !17
  %37 = zext i8 %36 to i32
  %38 = shl nuw nsw i32 %37, 6
  %39 = or i32 %35, %38
  %40 = load i32, ptr %20, align 4, !tbaa !18
  %41 = shl i32 %40, 3
  %42 = or i32 %39, %41
  %43 = load i32, ptr %27, align 4, !tbaa !20
  %44 = add i32 %43, 4
  %45 = zext i32 %44 to i64
  tail call void @Xil_Out32(i64 noundef %45, i32 noundef %42)
  br label %46

46:                                               ; preds = %23, %26, %19, %15, %10, %14, %9, %4
  %.0 = phi i32 [ 0, %14 ], [ 0, %9 ], [ 0, %4 ], [ %25, %23 ], [ 0, %26 ], [ 15, %19 ], [ 15, %15 ], [ 15, %10 ]
  ret i32 %.0
}

declare i32 @XUartPs_SetBaudRate(ptr noundef, i32 noundef) local_unnamed_addr #0

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 = !{!16, !6, i64 4}
!16 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !7, i64 12}
!17 = !{!16, !7, i64 12}
!18 = !{!16, !6, i64 8}
!19 = !{!16, !6, i64 0}
!20 = !{!10, !6, i64 4}


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