; LLVM IR from lfarcaro/ARINC653_ARMV7A_AM335X :: Hardware (hsi2c)

; 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 void @I2CWakeUpDisable(i32 noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp eq i32 1, %7
  br i1 %8, label %9, label %18

9:                                                ; preds = %3
  %10 = load i32, ptr %5, align 4, !tbaa !5
  %11 = xor i32 %10, -1
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = add i32 %12, 52
  %14 = zext i32 %13 to i64
  %15 = inttoptr i64 %14 to ptr
  %16 = load volatile i32, ptr %15, align 4, !tbaa !5
  %17 = and i32 %16, %11
  store volatile i32 %17, ptr %15, align 4, !tbaa !5
  br label %44

18:                                               ; preds = %3
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = icmp eq i32 2, %19
  br i1 %20, label %21, label %30

21:                                               ; preds = %18
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = xor i32 %22, -1
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = add i32 %24, 72
  %26 = zext i32 %25 to i64
  %27 = inttoptr i64 %26 to ptr
  %28 = load volatile i32, ptr %27, align 4, !tbaa !5
  %29 = and i32 %28, %23
  store volatile i32 %29, ptr %27, align 4, !tbaa !5
  br label %43

30:                                               ; preds = %18
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = icmp eq i32 3, %31
  br i1 %32, label %33, label %42

33:                                               ; preds = %30
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = xor i32 %34, -1
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = add i32 %36, 76
  %38 = zext i32 %37 to i64
  %39 = inttoptr i64 %38 to ptr
  %40 = load volatile i32, ptr %39, align 4, !tbaa !5
  %41 = and i32 %40, %35
  store volatile i32 %41, ptr %39, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %33, %30
  br label %43

43:                                               ; preds = %42, %21
  br label %44

44:                                               ; preds = %43, %9
  ret void
}

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

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


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

@switch.table.I2CWakeUpDisable = private unnamed_addr constant [3 x i32] [i32 52, i32 72, i32 76], align 4

; Function Attrs: nofree norecurse nounwind uwtable
define dso_local void @I2CWakeUpDisable(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %switch.tableidx = add i32 %2, -1
  %4 = icmp ult i32 %switch.tableidx, 3
  br i1 %4, label %switch.lookup, label %12

switch.lookup:                                    ; preds = %3
  %5 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [3 x i32], ptr @switch.table.I2CWakeUpDisable, i64 0, i64 %5
  %switch.load = load i32, ptr %switch.gep, align 4
  %6 = xor i32 %1, -1
  %7 = add i32 %switch.load, %0
  %8 = zext i32 %7 to i64
  %9 = inttoptr i64 %8 to ptr
  %10 = load volatile i32, ptr %9, align 4, !tbaa !5
  %11 = and i32 %10, %6
  store volatile i32 %11, ptr %9, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %3, %switch.lookup
  ret void
}

attributes #0 = { nofree norecurse 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" }

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


; Effective O3 passes: GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass