; 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: nounwind uwtable
declare dso_local i32 @get_pi_req(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @set_pir(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load i32, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.Apr, ptr %6, i32 0, i32 47
  %8 = load i8, ptr %7, align 1, !tbaa !11
  %9 = zext i8 %8 to i32
  %10 = or i32 %9, %5
  %11 = trunc i32 %10 to i8
  store i8 %11, ptr %7, align 1, !tbaa !11
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.Apr, ptr %12, i32 0, i32 48
  %14 = load i8, ptr %13, align 2, !tbaa !19
  %15 = zext i8 %14 to i32
  %16 = xor i32 %15, -1
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Apr, ptr %17, i32 0, i32 47
  %19 = load i8, ptr %18, align 1, !tbaa !11
  %20 = zext i8 %19 to i32
  %21 = and i32 %20, %16
  %22 = trunc i32 %21 to i8
  store i8 %22, ptr %18, align 1, !tbaa !11
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = call i32 @get_pi_req(ptr noundef %23)
  %25 = trunc i32 %24 to i8
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.Apr, ptr %26, i32 0, i32 49
  store i8 %25, ptr %27, align 1, !tbaa !20
  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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !7, i64 3513}
!12 = !{!"Apr", !13, i64 0, !14, i64 64, !16, i64 3192, !10, i64 3376, !17, i64 3384, !17, i64 3408, !10, i64 3432, !15, i64 3440, !15, i64 3448, !10, i64 3456, !10, i64 3460, !10, i64 3464, !7, i64 3468, !18, i64 3470, !18, 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, !10, i64 3504, !10, 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, !10, 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, !10, i64 3616, !10, i64 3620, !10, 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, !10, 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, !10, i64 3680, !7, i64 3684, !7, i64 3688, !6, i64 4168, !6, i64 4176}
!13 = !{!"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}
!14 = !{!"IOBus", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !10, i64 48, !7, i64 56}
!15 = !{!"long", !7, i64 0}
!16 = !{!"Membus", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !6, i64 48, !7, i64 56}
!17 = !{!"AprState", !15, i64 0, !15, i64 8, !15, i64 16}
!18 = !{!"short", !7, i64 0}
!19 = !{!12, !7, i64 3514}
!20 = !{!12, !7, i64 3515}


; 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: nounwind uwtable
declare dso_local i32 @get_pi_req(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @set_pir(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 3513
  %4 = load i8, ptr %3, align 1, !tbaa !5
  %5 = trunc i32 %1 to i8
  %6 = or i8 %4, %5
  %7 = getelementptr inbounds i8, ptr %0, i64 3514
  %8 = load i8, ptr %7, align 2, !tbaa !17
  %9 = xor i8 %8, -1
  %10 = and i8 %6, %9
  store i8 %10, ptr %3, align 1, !tbaa !5
  %11 = tail call i32 @get_pi_req(ptr noundef %0)
  %12 = trunc i32 %11 to i8
  %13 = getelementptr inbounds i8, ptr %0, i64 3515
  store i8 %12, ptr %13, align 1, !tbaa !18
  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, !9, i64 3513}
!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 3515}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,ReassociatePass,SROAPass,TailCallElimPass