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

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

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

17:                                               ; preds = %3
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !10
  br label %19

18:                                               ; preds = %3
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 71)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !10
  store i64 0, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %124

19:                                               ; preds = %17
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !10
  br label %24

23:                                               ; preds = %19
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 72)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !10
  store i64 0, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %124

24:                                               ; preds = %22
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.XEmacPs_Instance, ptr %25, i32 0, i32 2
  %27 = load i32, ptr %26, align 4, !tbaa !12
  %28 = icmp eq i32 %27, 286331153
  br i1 %28, label %29, label %30

29:                                               ; preds = %24
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !10
  br label %31

30:                                               ; preds = %24
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 73)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !10
  store i64 0, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %124

31:                                               ; preds = %29
  %32 = load i8, ptr %10, align 1, !tbaa !9
  %33 = zext i8 %32 to i32
  %34 = icmp sle i32 %33, 4
  br i1 %34, label %35, label %40

35:                                               ; preds = %31
  %36 = load i8, ptr %10, align 1, !tbaa !9
  %37 = zext i8 %36 to i32
  %38 = icmp ugt i32 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %35
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !10
  br label %41

40:                                               ; preds = %35, %31
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 74)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !10
  store i64 0, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %124

41:                                               ; preds = %39
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.XEmacPs_Instance, ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 8, !tbaa !18
  %45 = icmp eq i32 %44, 572662306
  br i1 %45, label %46, label %47

46:                                               ; preds = %41
  store i64 5, ptr %11, align 8, !tbaa !19
  br label %122

47:                                               ; preds = %41
  %48 = load i8, ptr %10, align 1, !tbaa !9
  %49 = add i8 %48, -1
  store i8 %49, ptr %10, align 1, !tbaa !9
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = load i8, ptr %50, align 1, !tbaa !9
  %52 = zext i8 %51 to i32
  store i32 %52, ptr %8, align 4, !tbaa !10
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds i8, ptr %53, i64 1
  %55 = load i8, ptr %54, align 1, !tbaa !9
  %56 = zext i8 %55 to i32
  %57 = shl i32 %56, 8
  %58 = load i32, ptr %8, align 4, !tbaa !10
  %59 = or i32 %58, %57
  store i32 %59, ptr %8, align 4, !tbaa !10
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %60, i64 2
  %62 = load i8, ptr %61, align 1, !tbaa !9
  %63 = zext i8 %62 to i32
  %64 = shl i32 %63, 16
  %65 = load i32, ptr %8, align 4, !tbaa !10
  %66 = or i32 %65, %64
  store i32 %66, ptr %8, align 4, !tbaa !10
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %67, i64 3
  %69 = load i8, ptr %68, align 1, !tbaa !9
  %70 = zext i8 %69 to i32
  %71 = shl i32 %70, 24
  %72 = load i32, ptr %8, align 4, !tbaa !10
  %73 = or i32 %72, %71
  store i32 %73, ptr %8, align 4, !tbaa !10
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.XEmacPs_Instance, ptr %74, i32 0, i32 0
  %76 = getelementptr inbounds %struct.XEmacPs_Config, ptr %75, i32 0, i32 1
  %77 = load i64, ptr %76, align 8, !tbaa !20
  %78 = load i8, ptr %10, align 1, !tbaa !9
  %79 = zext i8 %78 to i32
  %80 = mul i32 %79, 8
  %81 = add i32 136, %80
  %82 = zext i32 %81 to i64
  %83 = add i64 %77, %82
  %84 = load i32, ptr %8, align 4, !tbaa !10
  call void @Xil_Out32(i64 noundef %83, i32 noundef %84)
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.XEmacPs_Instance, ptr %85, i32 0, i32 0
  %87 = getelementptr inbounds %struct.XEmacPs_Config, ptr %86, i32 0, i32 1
  %88 = load i64, ptr %87, align 8, !tbaa !20
  %89 = load i8, ptr %10, align 1, !tbaa !9
  %90 = zext i8 %89 to i32
  %91 = mul i32 %90, 8
  %92 = add i32 140, %91
  %93 = zext i32 %92 to i64
  %94 = add i64 %88, %93
  %95 = call i32 @Xil_In32(i64 noundef %94)
  store i32 %95, ptr %8, align 4, !tbaa !10
  %96 = load i32, ptr %8, align 4, !tbaa !10
  %97 = and i32 %96, -65536
  store i32 %97, ptr %8, align 4, !tbaa !10
  %98 = load ptr, ptr %9, align 8, !tbaa !5
  %99 = getelementptr inbounds i8, ptr %98, i64 4
  %100 = load i8, ptr %99, align 1, !tbaa !9
  %101 = zext i8 %100 to i32
  %102 = load i32, ptr %8, align 4, !tbaa !10
  %103 = or i32 %102, %101
  store i32 %103, ptr %8, align 4, !tbaa !10
  %104 = load ptr, ptr %9, align 8, !tbaa !5
  %105 = getelementptr inbounds i8, ptr %104, i64 5
  %106 = load i8, ptr %105, align 1, !tbaa !9
  %107 = zext i8 %106 to i32
  %108 = shl i32 %107, 8
  %109 = load i32, ptr %8, align 4, !tbaa !10
  %110 = or i32 %109, %108
  store i32 %110, ptr %8, align 4, !tbaa !10
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.XEmacPs_Instance, ptr %111, i32 0, i32 0
  %113 = getelementptr inbounds %struct.XEmacPs_Config, ptr %112, i32 0, i32 1
  %114 = load i64, ptr %113, align 8, !tbaa !20
  %115 = load i8, ptr %10, align 1, !tbaa !9
  %116 = zext i8 %115 to i32
  %117 = mul i32 %116, 8
  %118 = add i32 140, %117
  %119 = zext i32 %118 to i64
  %120 = add i64 %114, %119
  %121 = load i32, ptr %8, align 4, !tbaa !10
  call void @Xil_Out32(i64 noundef %120, i32 noundef %121)
  store i64 0, ptr %11, align 8, !tbaa !19
  br label %122

122:                                              ; preds = %47, %46
  %123 = load i64, ptr %11, align 8, !tbaa !19
  store i64 %123, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %124

124:                                              ; preds = %122, %40, %30, %23, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %125 = load i64, ptr %4, align 8
  ret i64 %125
}

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

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

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

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

; 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 = { "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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 28}
!13 = !{!"XEmacPs_Instance", !14, i64 0, !11, i64 24, !11, i64 28, !11, i64 32, !17, i64 40, !17, i64 152, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !11, i64 312, !11, i64 316, !11, i64 320, !11, i64 324, !11, i64 328}
!14 = !{!"", !15, i64 0, !16, i64 8, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19, !7, i64 20, !7, i64 21, !7, i64 22}
!15 = !{!"short", !7, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!"", !16, i64 0, !16, i64 8, !16, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104}
!18 = !{!13, !11, i64 24}
!19 = !{!16, !16, i64 0}
!20 = !{!13, !16, 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 [173 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i64 0, 6) i64 @XEmacPs_SetMacAddress(ptr noundef readonly %0, ptr noundef readonly %1, i8 noundef zeroext %2) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %5, label %4

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

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

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 28
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = icmp eq i32 %8, 286331153
  br i1 %9, label %11, label %13

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

11:                                               ; preds = %6
  %12 = add i8 %2, -1
  %or.cond = icmp ult i8 %12, 4
  br i1 %or.cond, label %14, label %18

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

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %0, i64 24
  %16 = load i32, ptr %15, align 8, !tbaa !16
  %17 = icmp eq i32 %16, 572662306
  br i1 %17, label %45, label %19

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

19:                                               ; preds = %14
  %20 = load i32, ptr %1, align 1
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %22 = load i64, ptr %21, align 8, !tbaa !17
  %23 = shl nuw nsw i8 %12, 3
  %24 = zext nneg i8 %23 to i32
  %25 = add nuw nsw i32 %24, 136
  %26 = zext nneg i32 %25 to i64
  %27 = add i64 %22, %26
  tail call void @Xil_Out32(i64 noundef %27, i32 noundef %20)
  %28 = load i64, ptr %21, align 8, !tbaa !17
  %29 = add nuw nsw i32 %24, 140
  %30 = zext nneg i32 %29 to i64
  %31 = add i64 %28, %30
  %32 = tail call i32 @Xil_In32(i64 noundef %31)
  %33 = and i32 %32, -65536
  %34 = getelementptr inbounds i8, ptr %1, i64 4
  %35 = load i8, ptr %34, align 1, !tbaa !18
  %36 = zext i8 %35 to i32
  %37 = or disjoint i32 %33, %36
  %38 = getelementptr inbounds i8, ptr %1, i64 5
  %39 = load i8, ptr %38, align 1, !tbaa !18
  %40 = zext i8 %39 to i32
  %41 = shl nuw nsw i32 %40, 8
  %42 = or disjoint i32 %41, %37
  %43 = load i64, ptr %21, align 8, !tbaa !17
  %44 = add i64 %43, %30
  tail call void @Xil_Out32(i64 noundef %44, i32 noundef %42)
  br label %45

45:                                               ; preds = %19, %14, %18, %13, %10, %5
  %.032 = phi i64 [ 0, %18 ], [ 0, %13 ], [ 0, %10 ], [ 0, %5 ], [ 0, %19 ], [ 5, %14 ]
  ret i64 %.032
}

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

; 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 i32 @Xil_In32(i64 noundef) local_unnamed_addr #2

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 = { "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 = !{!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}
!18 = !{!7, !7, i64 0}


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