; LLVM IR from pandax381/microps :: platform/linux (intr)

; 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.__sigset_t = type { [16 x i64] }
%struct.irq_entry = type { ptr, i32, ptr, i32, [16 x i8], ptr }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.intr_request_irq = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [46 x i8], align 1
@irq_vec = external dso_local global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@sigmask = external dso_local global %struct.__sigset_t, align 8
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @intr_request_irq(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store i32 %0, ptr %7, align 4, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !9
  %14 = load ptr, ptr @stderr, align 8, !tbaa !9
  %15 = load i32, ptr %7, align 4, !tbaa !5
  %16 = load ptr, ptr %8, align 8, !tbaa !9
  %17 = load i32, ptr %9, align 4, !tbaa !5
  %18 = load ptr, ptr %10, align 8, !tbaa !9
  %19 = load ptr, ptr %11, align 8, !tbaa !9
  %20 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %14, i32 noundef 68, ptr noundef @.str, i32 noundef 28, ptr noundef @__func__.intr_request_irq, ptr noundef @.str.1, i32 noundef %15, ptr noundef %16, i32 noundef %17, ptr noundef %18, ptr noundef %19)
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %21 = load ptr, ptr @irq_vec, align 8, !tbaa !9
  store ptr %21, ptr %12, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %46, %5
  %23 = load ptr, ptr %12, align 8, !tbaa !9
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %50

25:                                               ; preds = %22
  %26 = load ptr, ptr %12, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.irq_entry, ptr %26, i32 0, i32 1
  %28 = load i32, ptr %27, align 8, !tbaa !11
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = icmp eq i32 %28, %29
  br i1 %30, label %31, label %45

31:                                               ; preds = %25
  %32 = load ptr, ptr %12, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.irq_entry, ptr %32, i32 0, i32 3
  %34 = load i32, ptr %33, align 8, !tbaa !13
  %35 = xor i32 %34, 1
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %41, label %37

37:                                               ; preds = %31
  %38 = load i32, ptr %9, align 4, !tbaa !5
  %39 = xor i32 %38, 1
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %44

41:                                               ; preds = %37, %31
  %42 = load ptr, ptr @stderr, align 8, !tbaa !9
  %43 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %42, i32 noundef 69, ptr noundef @.str, i32 noundef 33, ptr noundef @__func__.intr_request_irq, ptr noundef @.str.2)
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %85

44:                                               ; preds = %37
  br label %45

45:                                               ; preds = %44, %25
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %12, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.irq_entry, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !14
  store ptr %49, ptr %12, align 8, !tbaa !9
  br label %22, !llvm.loop !15

50:                                               ; preds = %22
  %51 = call ptr @memory_alloc(i64 noundef 56)
  store ptr %51, ptr %12, align 8, !tbaa !9
  %52 = load ptr, ptr %12, align 8, !tbaa !9
  %53 = icmp ne ptr %52, null
  br i1 %53, label %57, label %54

54:                                               ; preds = %50
  %55 = load ptr, ptr @stderr, align 8, !tbaa !9
  %56 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %55, i32 noundef 69, ptr noundef @.str, i32 noundef 40, ptr noundef @__func__.intr_request_irq, ptr noundef @.str.3)
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %85

57:                                               ; preds = %50
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = load ptr, ptr %12, align 8, !tbaa !9
  %60 = getelementptr inbounds %struct.irq_entry, ptr %59, i32 0, i32 1
  store i32 %58, ptr %60, align 8, !tbaa !11
  %61 = load ptr, ptr %8, align 8, !tbaa !9
  %62 = load ptr, ptr %12, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.irq_entry, ptr %62, i32 0, i32 2
  store ptr %61, ptr %63, align 8, !tbaa !17
  %64 = load i32, ptr %9, align 4, !tbaa !5
  %65 = load ptr, ptr %12, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct.irq_entry, ptr %65, i32 0, i32 3
  store i32 %64, ptr %66, align 8, !tbaa !13
  %67 = load ptr, ptr %12, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.irq_entry, ptr %67, i32 0, i32 4
  %69 = getelementptr inbounds [16 x i8], ptr %68, i64 0, i64 0
  %70 = load ptr, ptr %10, align 8, !tbaa !9
  %71 = call ptr @strncpy(ptr noundef %69, ptr noundef %70, i64 noundef 15) #5
  %72 = load ptr, ptr %11, align 8, !tbaa !9
  %73 = load ptr, ptr %12, align 8, !tbaa !9
  %74 = getelementptr inbounds %struct.irq_entry, ptr %73, i32 0, i32 5
  store ptr %72, ptr %74, align 8, !tbaa !18
  %75 = load ptr, ptr @irq_vec, align 8, !tbaa !9
  %76 = load ptr, ptr %12, align 8, !tbaa !9
  %77 = getelementptr inbounds %struct.irq_entry, ptr %76, i32 0, i32 0
  store ptr %75, ptr %77, align 8, !tbaa !14
  %78 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %78, ptr @irq_vec, align 8, !tbaa !9
  %79 = load i32, ptr %7, align 4, !tbaa !5
  %80 = call i32 @sigaddset(ptr noundef @sigmask, i32 noundef %79) #5
  %81 = load ptr, ptr @stderr, align 8, !tbaa !9
  %82 = load i32, ptr %7, align 4, !tbaa !5
  %83 = load ptr, ptr %10, align 8, !tbaa !9
  %84 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %81, i32 noundef 68, ptr noundef @.str, i32 noundef 51, ptr noundef @__func__.intr_request_irq, ptr noundef @.str.4, i32 noundef %82, ptr noundef %83)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %85

85:                                               ; preds = %57, %54, %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  %86 = load i32, ptr %6, align 4
  ret i32 %86
}

declare i32 @lprintf(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #1

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

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

; Function Attrs: nounwind
declare ptr @strncpy(ptr noundef, ptr noundef, i64 noundef) #4

; Function Attrs: nounwind
declare i32 @sigaddset(ptr noundef, i32 noundef) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 #5 = { 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 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"irq_entry", !10, i64 0, !6, i64 8, !10, i64 16, !6, i64 24, !7, i64 28, !10, i64 48}
!13 = !{!12, !6, i64 24}
!14 = !{!12, !10, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!12, !10, i64 16}
!18 = !{!12, !10, i64 48}


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

%struct.__sigset_t = type { [16 x i64] }

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.intr_request_irq = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [46 x i8], align 1
@irq_vec = external dso_local local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@sigmask = external dso_local global %struct.__sigset_t, align 8
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @intr_request_irq(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = load ptr, ptr @stderr, align 8, !tbaa !5
  %7 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %6, i32 noundef 68, ptr noundef nonnull @.str, i32 noundef 28, ptr noundef nonnull @__func__.intr_request_irq, ptr noundef nonnull @.str.1, i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #5
  %.032 = load ptr, ptr @irq_vec, align 8, !tbaa !5
  %.not33 = icmp eq ptr %.032, null
  br i1 %.not33, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5
  %.not31 = icmp eq i32 %2, 1
  br i1 %.not31, label %.lr.ph.split, label %.lr.ph.split.us

.lr.ph.split.us:                                  ; preds = %.lr.ph, %11
  %.034.us = phi ptr [ %.0.us, %11 ], [ %.032, %.lr.ph ]
  %8 = getelementptr inbounds i8, ptr %.034.us, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = icmp eq i32 %9, %0
  br i1 %10, label %.split.us, label %11

11:                                               ; preds = %.lr.ph.split.us
  %.0.us = load ptr, ptr %.034.us, align 8, !tbaa !5
  %.not.us = icmp eq ptr %.0.us, null
  br i1 %.not.us, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !12

.lr.ph.split:                                     ; preds = %.lr.ph, %20
  %.034 = phi ptr [ %.0, %20 ], [ %.032, %.lr.ph ]
  %12 = getelementptr inbounds i8, ptr %.034, i64 8
  %13 = load i32, ptr %12, align 8, !tbaa !9
  %14 = icmp eq i32 %13, %0
  br i1 %14, label %15, label %20

15:                                               ; preds = %.lr.ph.split
  %16 = getelementptr inbounds i8, ptr %.034, i64 24
  %17 = load i32, ptr %16, align 8, !tbaa !14
  %.not30 = icmp eq i32 %17, 1
  br i1 %.not30, label %20, label %.split.us

.split.us:                                        ; preds = %.lr.ph.split.us, %15
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %18, i32 noundef 69, ptr noundef nonnull @.str, i32 noundef 33, ptr noundef nonnull @__func__.intr_request_irq, ptr noundef nonnull @.str.2) #5
  br label %36

20:                                               ; preds = %15, %.lr.ph.split
  %.0 = load ptr, ptr %.034, align 8, !tbaa !5
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %._crit_edge, label %.lr.ph.split, !llvm.loop !12

._crit_edge:                                      ; preds = %11, %20, %5
  %21 = tail call ptr @memory_alloc(i64 noundef 56)
  %.not29 = icmp eq ptr %21, null
  br i1 %.not29, label %22, label %25

22:                                               ; preds = %._crit_edge
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %23, i32 noundef 69, ptr noundef nonnull @.str, i32 noundef 40, ptr noundef nonnull @__func__.intr_request_irq, ptr noundef nonnull @.str.3) #5
  br label %36

25:                                               ; preds = %._crit_edge
  %26 = getelementptr inbounds i8, ptr %21, i64 8
  store i32 %0, ptr %26, align 8, !tbaa !9
  %27 = getelementptr inbounds i8, ptr %21, i64 16
  store ptr %1, ptr %27, align 8, !tbaa !15
  %28 = getelementptr inbounds i8, ptr %21, i64 24
  store i32 %2, ptr %28, align 8, !tbaa !14
  %29 = getelementptr inbounds i8, ptr %21, i64 28
  %30 = tail call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %29, ptr noundef nonnull dereferenceable(1) %3, i64 noundef 15) #5
  %31 = getelementptr inbounds i8, ptr %21, i64 48
  store ptr %4, ptr %31, align 8, !tbaa !16
  %32 = load ptr, ptr @irq_vec, align 8, !tbaa !5
  store ptr %32, ptr %21, align 8, !tbaa !17
  store ptr %21, ptr @irq_vec, align 8, !tbaa !5
  %33 = tail call i32 @sigaddset(ptr noundef nonnull @sigmask, i32 noundef %0) #5
  %34 = load ptr, ptr @stderr, align 8, !tbaa !5
  %35 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %34, i32 noundef 68, ptr noundef nonnull @.str, i32 noundef 51, ptr noundef nonnull @__func__.intr_request_irq, ptr noundef nonnull @.str.4, i32 noundef %0, ptr noundef %3) #5
  br label %36

36:                                               ; preds = %25, %22, %.split.us
  %.027 = phi i32 [ -1, %.split.us ], [ 0, %25 ], [ -1, %22 ]
  ret i32 %.027
}

declare i32 @lprintf(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @memory_alloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strncpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly, i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @sigaddset(ptr noundef, i32 noundef) local_unnamed_addr #4

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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 "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 #5 = { 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, !11, i64 8}
!10 = !{!"irq_entry", !6, i64 0, !11, i64 8, !6, i64 16, !11, i64 24, !7, i64 28, !6, i64 48}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !11, i64 24}
!15 = !{!10, !6, i64 16}
!16 = !{!10, !6, i64 48}
!17 = !{!10, !6, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass