; LLVM IR from aap/pdp6 :: emu (apr)

; 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.Apr = type { %struct.Device, %struct.IOBus, %struct.Membus, i32, %struct.AprState, %struct.AprState, i32, i64, i64, i32, i32, i32, i8, i16, i16, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, ptr, ptr, i32, i8, [20 x %struct.TPulse], ptr, ptr }
%struct.Device = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.IOBus = type { i64, i64, i64, i64, i64, i64, i32, [128 x %struct.Busdev] }
%struct.Busdev = type { ptr, ptr, i8 }
%struct.Membus = type { i64, i64, i64, i64, i64, i64, ptr, [16 x ptr] }
%struct.AprState = type { i64, i64, i64 }
%struct.TPulse = type { ptr, ptr, i32 }

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

; 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 i32 @get_pi_req(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.Apr, ptr %6, i32 0, i32 50
  %8 = load i8, ptr %7, align 4, !tbaa !9
  %9 = icmp ne i8 %8, 0
  br i1 %9, label %10, label %39

10:                                               ; preds = %1
  store i32 64, ptr %4, align 4, !tbaa !18
  br label %11

11:                                               ; preds = %35, %10
  %12 = load i32, ptr %4, align 4, !tbaa !18
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %38

14:                                               ; preds = %11
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.Apr, ptr %15, i32 0, i32 48
  %17 = load i8, ptr %16, align 2, !tbaa !19
  %18 = zext i8 %17 to i32
  %19 = load i32, ptr %4, align 4, !tbaa !18
  %20 = and i32 %18, %19
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %14
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %40

23:                                               ; preds = %14
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.Apr, ptr %24, i32 0, i32 47
  %26 = load i8, ptr %25, align 1, !tbaa !20
  %27 = zext i8 %26 to i32
  %28 = load i32, ptr %4, align 4, !tbaa !18
  %29 = and i32 %27, %28
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %33

31:                                               ; preds = %23
  %32 = load i32, ptr %4, align 4, !tbaa !18
  store i32 %32, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %40

33:                                               ; preds = %23
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %4, align 4, !tbaa !18
  %37 = ashr i32 %36, 1
  store i32 %37, ptr %4, align 4, !tbaa !18
  br label %11, !llvm.loop !21

38:                                               ; preds = %11
  br label %39

39:                                               ; preds = %38, %1
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %40

40:                                               ; preds = %39, %31, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %41 = load i32, ptr %2, align 4
  ret i32 %41
}

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 = { 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, !7, i64 3516}
!10 = !{!"Apr", !11, i64 0, !12, i64 64, !15, i64 3192, !14, i64 3376, !16, i64 3384, !16, i64 3408, !14, i64 3432, !13, i64 3440, !13, i64 3448, !14, i64 3456, !14, i64 3460, !14, i64 3464, !7, i64 3468, !17, i64 3470, !17, i64 3472, !7, i64 3474, !7, i64 3475, !7, i64 3476, !7, i64 3477, !7, i64 3478, !7, i64 3479, !7, i64 3480, !7, i64 3481, !7, i64 3482, !7, i64 3483, !7, i64 3484, !7, i64 3485, !7, i64 3486, !7, i64 3487, !7, i64 3488, !7, i64 3489, !7, i64 3490, !7, i64 3491, !7, i64 3492, !7, i64 3493, !7, i64 3494, !7, i64 3495, !7, i64 3496, !7, i64 3497, !7, i64 3498, !7, i64 3499, !7, i64 3500, !7, i64 3501, !7, i64 3502, !14, i64 3504, !14, i64 3508, !7, i64 3512, !7, i64 3513, !7, i64 3514, !7, i64 3515, !7, i64 3516, !7, i64 3517, !7, i64 3518, !7, i64 3519, !7, i64 3520, !7, i64 3521, !7, i64 3522, !7, i64 3523, !7, i64 3524, !7, i64 3525, !7, i64 3526, !7, i64 3527, !7, i64 3528, !7, i64 3529, !7, i64 3530, !7, i64 3531, !7, i64 3532, !7, i64 3533, !7, i64 3534, !7, i64 3535, !7, i64 3536, !7, i64 3537, !7, i64 3538, !7, i64 3539, !7, i64 3540, !7, i64 3541, !7, i64 3542, !7, i64 3543, !7, i64 3544, !7, i64 3545, !7, i64 3546, !7, i64 3547, !7, i64 3548, !7, i64 3549, !7, i64 3550, !7, i64 3551, !14, i64 3552, !7, i64 3556, !7, i64 3557, !7, i64 3558, !7, i64 3559, !7, i64 3560, !7, i64 3561, !7, i64 3562, !7, i64 3563, !7, i64 3564, !7, i64 3565, !7, i64 3566, !7, i64 3567, !7, i64 3568, !7, i64 3569, !7, i64 3570, !7, i64 3571, !7, i64 3572, !7, i64 3573, !7, i64 3574, !7, i64 3575, !7, i64 3576, !7, i64 3577, !7, i64 3578, !7, i64 3579, !7, i64 3580, !7, i64 3581, !7, i64 3582, !7, i64 3583, !7, i64 3584, !7, i64 3585, !7, i64 3586, !7, i64 3587, !7, i64 3588, !7, i64 3589, !7, i64 3590, !7, i64 3591, !7, i64 3592, !7, i64 3593, !7, i64 3594, !7, i64 3595, !7, i64 3596, !7, i64 3597, !7, i64 3598, !7, i64 3599, !7, i64 3600, !7, i64 3601, !7, i64 3602, !7, i64 3603, !7, i64 3604, !7, i64 3605, !7, i64 3606, !7, i64 3607, !7, i64 3608, !7, i64 3609, !7, i64 3610, !7, i64 3611, !7, i64 3612, !7, i64 3613, !7, i64 3614, !14, i64 3616, !14, i64 3620, !14, i64 3624, !7, i64 3628, !7, i64 3629, !7, i64 3630, !7, i64 3631, !7, i64 3632, !7, i64 3633, !7, i64 3634, !7, i64 3635, !7, i64 3636, !7, i64 3637, !7, i64 3638, !7, i64 3639, !7, i64 3640, !7, i64 3641, !7, i64 3642, !14, i64 3644, !7, i64 3648, !7, i64 3649, !7, i64 3650, !7, i64 3651, !7, i64 3652, !7, i64 3653, !7, i64 3654, !7, i64 3655, !7, i64 3656, !7, i64 3657, !7, i64 3658, !6, i64 3664, !6, i64 3672, !14, i64 3680, !7, i64 3684, !7, i64 3688, !6, i64 4168, !6, i64 4176}
!11 = !{!"Device", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!12 = !{!"IOBus", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !14, i64 48, !7, i64 56}
!13 = !{!"long", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"Membus", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !6, i64 48, !7, i64 56}
!16 = !{!"AprState", !13, i64 0, !13, i64 8, !13, i64 16}
!17 = !{!"short", !7, i64 0}
!18 = !{!14, !14, i64 0}
!19 = !{!10, !7, i64 3514}
!20 = !{!10, !7, i64 3513}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @get_pi_req(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 3516
  %3 = load i8, ptr %2, align 4, !tbaa !5
  %.not = icmp eq i8 %3, 0
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 3514
  %5 = load i8, ptr %4, align 2, !tbaa !17
  %6 = zext i8 %5 to i32
  %7 = and i32 %6, 64
  %.not10 = icmp eq i32 %7, 0
  br i1 %.not10, label %8, label %.loopexit

8:                                                ; preds = %.preheader
  %9 = getelementptr inbounds i8, ptr %0, i64 3513
  %10 = load i8, ptr %9, align 1, !tbaa !18
  %11 = zext i8 %10 to i32
  %12 = and i32 %11, 64
  %.not11 = icmp eq i32 %12, 0
  br i1 %.not11, label %13, label %.loopexit

13:                                               ; preds = %8
  %14 = and i32 %6, 32
  %.not10.1 = icmp eq i32 %14, 0
  br i1 %.not10.1, label %15, label %.loopexit

15:                                               ; preds = %13
  %16 = and i32 %11, 32
  %.not11.1 = icmp eq i32 %16, 0
  br i1 %.not11.1, label %17, label %.loopexit

17:                                               ; preds = %15
  %18 = and i32 %6, 16
  %.not10.2 = icmp eq i32 %18, 0
  br i1 %.not10.2, label %19, label %.loopexit

19:                                               ; preds = %17
  %20 = and i32 %11, 16
  %.not11.2 = icmp eq i32 %20, 0
  br i1 %.not11.2, label %21, label %.loopexit

21:                                               ; preds = %19
  %22 = and i32 %6, 8
  %.not10.3 = icmp eq i32 %22, 0
  br i1 %.not10.3, label %23, label %.loopexit

23:                                               ; preds = %21
  %24 = and i32 %11, 8
  %.not11.3 = icmp eq i32 %24, 0
  br i1 %.not11.3, label %25, label %.loopexit

25:                                               ; preds = %23
  %26 = and i32 %6, 4
  %.not10.4 = icmp eq i32 %26, 0
  br i1 %.not10.4, label %27, label %.loopexit

27:                                               ; preds = %25
  %28 = and i32 %11, 4
  %.not11.4 = icmp eq i32 %28, 0
  br i1 %.not11.4, label %29, label %.loopexit

29:                                               ; preds = %27
  %30 = and i32 %6, 2
  %.not10.5 = icmp eq i32 %30, 0
  br i1 %.not10.5, label %31, label %.loopexit

31:                                               ; preds = %29
  %32 = and i32 %11, 2
  %.not11.5 = icmp eq i32 %32, 0
  br i1 %.not11.5, label %33, label %.loopexit

33:                                               ; preds = %31
  %34 = and i32 %6, 1
  %.not10.6 = icmp eq i32 %34, 0
  %35 = and i32 %11, 1
  %spec.select = select i1 %.not10.6, i32 %35, i32 0
  br label %.loopexit

.loopexit:                                        ; preds = %33, %8, %.preheader, %13, %15, %17, %19, %21, %23, %25, %27, %29, %31, %1
  %.08 = phi i32 [ 0, %1 ], [ 0, %.preheader ], [ 64, %8 ], [ 0, %13 ], [ 32, %15 ], [ 0, %17 ], [ 16, %19 ], [ 0, %21 ], [ 8, %23 ], [ 0, %25 ], [ 4, %27 ], [ 0, %29 ], [ 2, %31 ], [ %spec.select, %33 ]
  ret i32 %.08
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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, !9, i64 3516}
!6 = !{!"Apr", !7, i64 0, !11, i64 64, !14, i64 3192, !13, i64 3376, !15, i64 3384, !15, i64 3408, !13, i64 3432, !12, i64 3440, !12, i64 3448, !13, i64 3456, !13, i64 3460, !13, i64 3464, !9, i64 3468, !16, i64 3470, !16, i64 3472, !9, i64 3474, !9, i64 3475, !9, i64 3476, !9, i64 3477, !9, i64 3478, !9, i64 3479, !9, i64 3480, !9, i64 3481, !9, i64 3482, !9, i64 3483, !9, i64 3484, !9, i64 3485, !9, i64 3486, !9, i64 3487, !9, i64 3488, !9, i64 3489, !9, i64 3490, !9, i64 3491, !9, i64 3492, !9, i64 3493, !9, i64 3494, !9, i64 3495, !9, i64 3496, !9, i64 3497, !9, i64 3498, !9, i64 3499, !9, i64 3500, !9, i64 3501, !9, i64 3502, !13, i64 3504, !13, i64 3508, !9, i64 3512, !9, i64 3513, !9, i64 3514, !9, i64 3515, !9, i64 3516, !9, i64 3517, !9, i64 3518, !9, i64 3519, !9, i64 3520, !9, i64 3521, !9, i64 3522, !9, i64 3523, !9, i64 3524, !9, i64 3525, !9, i64 3526, !9, i64 3527, !9, i64 3528, !9, i64 3529, !9, i64 3530, !9, i64 3531, !9, i64 3532, !9, i64 3533, !9, i64 3534, !9, i64 3535, !9, i64 3536, !9, i64 3537, !9, i64 3538, !9, i64 3539, !9, i64 3540, !9, i64 3541, !9, i64 3542, !9, i64 3543, !9, i64 3544, !9, i64 3545, !9, i64 3546, !9, i64 3547, !9, i64 3548, !9, i64 3549, !9, i64 3550, !9, i64 3551, !13, i64 3552, !9, i64 3556, !9, i64 3557, !9, i64 3558, !9, i64 3559, !9, i64 3560, !9, i64 3561, !9, i64 3562, !9, i64 3563, !9, i64 3564, !9, i64 3565, !9, i64 3566, !9, i64 3567, !9, i64 3568, !9, i64 3569, !9, i64 3570, !9, i64 3571, !9, i64 3572, !9, i64 3573, !9, i64 3574, !9, i64 3575, !9, i64 3576, !9, i64 3577, !9, i64 3578, !9, i64 3579, !9, i64 3580, !9, i64 3581, !9, i64 3582, !9, i64 3583, !9, i64 3584, !9, i64 3585, !9, i64 3586, !9, i64 3587, !9, i64 3588, !9, i64 3589, !9, i64 3590, !9, i64 3591, !9, i64 3592, !9, i64 3593, !9, i64 3594, !9, i64 3595, !9, i64 3596, !9, i64 3597, !9, i64 3598, !9, i64 3599, !9, i64 3600, !9, i64 3601, !9, i64 3602, !9, i64 3603, !9, i64 3604, !9, i64 3605, !9, i64 3606, !9, i64 3607, !9, i64 3608, !9, i64 3609, !9, i64 3610, !9, i64 3611, !9, i64 3612, !9, i64 3613, !9, i64 3614, !13, i64 3616, !13, i64 3620, !13, i64 3624, !9, i64 3628, !9, i64 3629, !9, i64 3630, !9, i64 3631, !9, i64 3632, !9, i64 3633, !9, i64 3634, !9, i64 3635, !9, i64 3636, !9, i64 3637, !9, i64 3638, !9, i64 3639, !9, i64 3640, !9, i64 3641, !9, i64 3642, !13, i64 3644, !9, i64 3648, !9, i64 3649, !9, i64 3650, !9, i64 3651, !9, i64 3652, !9, i64 3653, !9, i64 3654, !9, i64 3655, !9, i64 3656, !9, i64 3657, !9, i64 3658, !8, i64 3664, !8, i64 3672, !13, i64 3680, !9, i64 3684, !9, i64 3688, !8, i64 4168, !8, i64 4176}
!7 = !{!"Device", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"IOBus", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !13, i64 48, !9, i64 56}
!12 = !{!"long", !9, i64 0}
!13 = !{!"int", !9, i64 0}
!14 = !{!"Membus", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !8, i64 48, !9, i64 56}
!15 = !{!"AprState", !12, i64 0, !12, i64 8, !12, i64 16}
!16 = !{!"short", !9, i64 0}
!17 = !{!6, !9, i64 3514}
!18 = !{!6, !9, i64 3513}


; Effective O3 passes: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass