; LLVM IR from microsoft/vOW4SIKE_on_HW :: SIKE_vOW_hw-sw/ref_c_riscv/SIKE_cryptanalysis/util (util)

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

@__const.irqCallback.data = external hidden unnamed_addr constant [6 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: nounwind uwtable
declare hidden void @uart_write(ptr noundef, i32 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @irqCallback() #1 {
  %1 = alloca [6 x i8], align 1
  %2 = load volatile i32, ptr inttoptr (i64 4026662928 to ptr), align 4, !tbaa !5
  %3 = and i32 %2, 1
  %4 = icmp ne i32 %3, 0
  br i1 %4, label %5, label %6

5:                                                ; preds = %0
  store volatile i32 1, ptr inttoptr (i64 4026662928 to ptr), align 4, !tbaa !5
  br label %25

6:                                                ; preds = %0
  call void @llvm.lifetime.start.p0(i64 6, ptr %1) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %1, ptr align 1 @__const.irqCallback.data, i64 6, i1 false)
  %7 = getelementptr inbounds [6 x i8], ptr %1, i64 0, i64 0
  %8 = load i8, ptr %7, align 1, !tbaa !10
  %9 = sext i8 %8 to i32
  call void @uart_write(ptr noundef inttoptr (i64 4026597376 to ptr), i32 noundef %9)
  %10 = getelementptr inbounds [6 x i8], ptr %1, i64 0, i64 1
  %11 = load i8, ptr %10, align 1, !tbaa !10
  %12 = sext i8 %11 to i32
  call void @uart_write(ptr noundef inttoptr (i64 4026597376 to ptr), i32 noundef %12)
  %13 = getelementptr inbounds [6 x i8], ptr %1, i64 0, i64 2
  %14 = load i8, ptr %13, align 1, !tbaa !10
  %15 = sext i8 %14 to i32
  call void @uart_write(ptr noundef inttoptr (i64 4026597376 to ptr), i32 noundef %15)
  %16 = getelementptr inbounds [6 x i8], ptr %1, i64 0, i64 3
  %17 = load i8, ptr %16, align 1, !tbaa !10
  %18 = sext i8 %17 to i32
  call void @uart_write(ptr noundef inttoptr (i64 4026597376 to ptr), i32 noundef %18)
  %19 = getelementptr inbounds [6 x i8], ptr %1, i64 0, i64 4
  %20 = load i8, ptr %19, align 1, !tbaa !10
  %21 = sext i8 %20 to i32
  call void @uart_write(ptr noundef inttoptr (i64 4026597376 to ptr), i32 noundef %21)
  %22 = getelementptr inbounds [6 x i8], ptr %1, i64 0, i64 5
  %23 = load i8, ptr %22, align 1, !tbaa !10
  %24 = sext i8 %23 to i32
  call void @uart_write(ptr noundef inttoptr (i64 4026597376 to ptr), i32 noundef %24)
  call void @llvm.lifetime.end.p0(i64 6, ptr %1) #3
  br label %25

25:                                               ; preds = %6, %5
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, 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"

@__const.irqCallback.data = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
declare hidden void @uart_write(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @irqCallback() local_unnamed_addr #0 {
  %1 = load volatile i32, ptr inttoptr (i64 4026662928 to ptr), align 16, !tbaa !5
  %2 = and i32 %1, 1
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %4, label %3

3:                                                ; preds = %0
  store volatile i32 1, ptr inttoptr (i64 4026662928 to ptr), align 16, !tbaa !5
  br label %11

4:                                                ; preds = %0
  %.sroa.0.0.copyload = load i8, ptr @__const.irqCallback.data, align 1
  %.sroa.4.0.copyload = load i8, ptr getelementptr inbounds (i8, ptr @__const.irqCallback.data, i64 1), align 1
  %.sroa.5.0.copyload = load i8, ptr getelementptr inbounds (i8, ptr @__const.irqCallback.data, i64 2), align 1
  %.sroa.6.0.copyload = load i8, ptr getelementptr inbounds (i8, ptr @__const.irqCallback.data, i64 3), align 1
  %.sroa.7.0.copyload = load i8, ptr getelementptr inbounds (i8, ptr @__const.irqCallback.data, i64 4), align 1
  %.sroa.8.0.copyload = load i8, ptr getelementptr inbounds (i8, ptr @__const.irqCallback.data, i64 5), align 1
  %5 = sext i8 %.sroa.0.0.copyload to i32
  tail call void @uart_write(ptr noundef nonnull inttoptr (i64 4026597376 to ptr), i32 noundef %5)
  %6 = sext i8 %.sroa.4.0.copyload to i32
  tail call void @uart_write(ptr noundef nonnull inttoptr (i64 4026597376 to ptr), i32 noundef %6)
  %7 = sext i8 %.sroa.5.0.copyload to i32
  tail call void @uart_write(ptr noundef nonnull inttoptr (i64 4026597376 to ptr), i32 noundef %7)
  %8 = sext i8 %.sroa.6.0.copyload to i32
  tail call void @uart_write(ptr noundef nonnull inttoptr (i64 4026597376 to ptr), i32 noundef %8)
  %9 = sext i8 %.sroa.7.0.copyload to i32
  tail call void @uart_write(ptr noundef nonnull inttoptr (i64 4026597376 to ptr), i32 noundef %9)
  %10 = sext i8 %.sroa.8.0.copyload to i32
  tail call void @uart_write(ptr noundef nonnull inttoptr (i64 4026597376 to ptr), i32 noundef %10)
  br label %11

11:                                               ; preds = %4, %3
  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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass