; LLVM IR from aap/pdp6 :: newemu (pdp6)

; 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.PDP6 = type { i32, i32, 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, i64, i64, i8, i64, i64, i64, i32, i32, i32, i32, i32, i32, i64, 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, 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, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, i64, i64, i64, i8, i8, i8, i8, i64, i8, i8, i8, i32, %struct.FD, i64, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, %struct.FD, i32, i64, i64, %struct.FD, i8, i64, i64, i64, i64, i64, i8, i64 }
%struct.FD = type { i32, i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local void @pi_reset(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @handle_pi(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %7 = load i32, ptr %6, align 4, !tbaa !9
  switch i32 %7, label %104 [
    i32 0, label %8
    i32 1, label %17
    i32 5, label %85
  ]

8:                                                ; preds = %3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.PDP6, ptr %9, i32 0, i32 40
  %11 = load i64, ptr %10, align 8, !tbaa !11
  %12 = and i64 %11, 4096
  %13 = icmp ne i64 %12, 0
  br i1 %13, label %14, label %16

14:                                               ; preds = %8
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  call void @pi_reset(ptr noundef %15)
  br label %16

16:                                               ; preds = %14, %8
  br label %104

17:                                               ; preds = %3
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.PDP6, ptr %18, i32 0, i32 40
  %20 = load i64, ptr %19, align 8, !tbaa !11
  %21 = and i64 %20, 2048
  %22 = icmp ne i64 %21, 0
  br i1 %22, label %23, label %30

23:                                               ; preds = %17
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.PDP6, ptr %25, i32 0, i32 40
  %27 = load i64, ptr %26, align 8, !tbaa !11
  %28 = and i64 %27, 127
  %29 = trunc i64 %28 to i8
  call void @pir_set(ptr noundef %24, i8 noundef zeroext %29)
  br label %30

30:                                               ; preds = %23, %17
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.PDP6, ptr %31, i32 0, i32 40
  %33 = load i64, ptr %32, align 8, !tbaa !11
  %34 = and i64 %33, 1024
  %35 = icmp ne i64 %34, 0
  br i1 %35, label %36, label %47

36:                                               ; preds = %30
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.PDP6, ptr %37, i32 0, i32 40
  %39 = load i64, ptr %38, align 8, !tbaa !11
  %40 = and i64 %39, 127
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.PDP6, ptr %41, i32 0, i32 101
  %43 = load i8, ptr %42, align 4, !tbaa !16
  %44 = zext i8 %43 to i64
  %45 = or i64 %44, %40
  %46 = trunc i64 %45 to i8
  store i8 %46, ptr %42, align 4, !tbaa !16
  br label %47

47:                                               ; preds = %36, %30
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.PDP6, ptr %48, i32 0, i32 40
  %50 = load i64, ptr %49, align 8, !tbaa !11
  %51 = and i64 %50, 512
  %52 = icmp ne i64 %51, 0
  br i1 %52, label %53, label %65

53:                                               ; preds = %47
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.PDP6, ptr %54, i32 0, i32 40
  %56 = load i64, ptr %55, align 8, !tbaa !11
  %57 = xor i64 %56, -1
  %58 = and i64 %57, 127
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.PDP6, ptr %59, i32 0, i32 101
  %61 = load i8, ptr %60, align 4, !tbaa !16
  %62 = zext i8 %61 to i64
  %63 = and i64 %62, %58
  %64 = trunc i64 %63 to i8
  store i8 %64, ptr %60, align 4, !tbaa !16
  br label %65

65:                                               ; preds = %53, %47
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.PDP6, ptr %66, i32 0, i32 40
  %68 = load i64, ptr %67, align 8, !tbaa !11
  %69 = and i64 %68, 256
  %70 = icmp ne i64 %69, 0
  br i1 %70, label %71, label %74

71:                                               ; preds = %65
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.PDP6, ptr %72, i32 0, i32 97
  store i8 0, ptr %73, align 8, !tbaa !17
  br label %74

74:                                               ; preds = %71, %65
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.PDP6, ptr %75, i32 0, i32 40
  %77 = load i64, ptr %76, align 8, !tbaa !11
  %78 = and i64 %77, 128
  %79 = icmp ne i64 %78, 0
  br i1 %79, label %80, label %83

80:                                               ; preds = %74
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.PDP6, ptr %81, i32 0, i32 97
  store i8 1, ptr %82, align 8, !tbaa !17
  br label %83

83:                                               ; preds = %80, %74
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  call void @calc_req(ptr noundef %84)
  br label %104

85:                                               ; preds = %3
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.PDP6, ptr %86, i32 0, i32 97
  %88 = load i8, ptr %87, align 8, !tbaa !17, !range !18, !noundef !19
  %89 = trunc i8 %88 to i1
  br i1 %89, label %90, label %95

90:                                               ; preds = %85
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.PDP6, ptr %91, i32 0, i32 40
  %93 = load i64, ptr %92, align 8, !tbaa !11
  %94 = or i64 %93, 128
  store i64 %94, ptr %92, align 8, !tbaa !11
  br label %95

95:                                               ; preds = %90, %85
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.PDP6, ptr %96, i32 0, i32 101
  %98 = load i8, ptr %97, align 4, !tbaa !16
  %99 = zext i8 %98 to i64
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.PDP6, ptr %100, i32 0, i32 40
  %102 = load i64, ptr %101, align 8, !tbaa !11
  %103 = or i64 %102, %99
  store i64 %103, ptr %101, align 8, !tbaa !11
  br label %104

104:                                              ; preds = %95, %83, %16, %3
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @pir_set(ptr noundef, i8 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden void @calc_req(ptr noundef) #0

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, !14, i64 112}
!12 = !{!"PDP6", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !13, i64 16, !13, i64 17, !13, i64 18, !13, i64 19, !13, i64 20, !13, i64 21, !13, i64 22, !13, i64 23, !13, i64 24, !13, i64 25, !13, i64 26, !13, i64 27, !13, i64 28, !13, i64 29, !13, i64 30, !13, i64 31, !13, i64 32, !13, i64 33, !13, i64 34, !13, i64 35, !13, i64 36, !13, i64 37, !13, i64 38, !13, i64 39, !14, i64 40, !14, i64 48, !7, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !14, i64 112, !7, i64 120, !13, i64 121, !13, i64 122, !13, i64 123, !13, i64 124, !13, i64 125, !13, i64 126, !13, i64 127, !13, i64 128, !13, i64 129, !13, i64 130, !13, i64 131, !13, i64 132, !13, i64 133, !13, i64 134, !13, i64 135, !13, i64 136, !13, i64 137, !13, i64 138, !13, i64 139, !13, i64 140, !13, i64 141, !13, i64 142, !13, i64 143, !13, i64 144, !13, i64 145, !13, i64 146, !13, i64 147, !13, i64 148, !13, i64 149, !13, i64 150, !13, i64 151, !13, i64 152, !13, i64 153, !13, i64 154, !13, i64 155, !13, i64 156, !13, i64 157, !13, i64 158, !13, i64 159, !13, i64 160, !13, i64 161, !13, i64 162, !13, i64 163, !13, i64 164, !13, i64 165, !13, i64 166, !13, i64 167, !13, i64 168, !13, i64 169, !13, i64 170, !13, i64 171, !13, i64 172, !13, i64 173, !13, i64 174, !13, i64 175, !13, i64 176, !13, i64 177, !13, i64 178, !13, i64 179, !7, i64 180, !7, i64 181, !7, i64 182, !7, i64 183, !13, i64 184, !13, i64 185, !13, i64 186, !13, i64 187, !13, i64 188, !10, i64 192, !10, i64 196, !10, i64 200, !13, i64 204, !13, i64 205, !13, i64 206, !13, i64 207, !13, i64 208, !13, i64 209, !13, i64 210, !13, i64 211, !13, i64 212, !13, i64 213, !13, i64 214, !13, i64 215, !7, i64 216, !13, i64 217, !13, i64 218, !13, i64 219, !13, i64 220, !13, i64 221, !13, i64 222, !13, i64 223, !13, i64 224, !13, i64 225, !13, i64 226, !13, i64 227, !13, i64 228, !13, i64 229, !7, i64 230, !10, i64 232, !10, i64 236, !14, i64 240, !14, i64 248, !14, i64 256, !13, i64 264, !13, i64 265, !13, i64 266, !7, i64 267, !14, i64 272, !13, i64 280, !13, i64 281, !13, i64 282, !10, i64 284, !15, i64 288, !14, i64 304, !7, i64 312, !13, i64 313, !13, i64 314, !13, i64 315, !7, i64 316, !13, i64 317, !13, i64 318, !7, i64 319, !10, i64 320, !10, i64 324, !15, i64 328, !10, i64 340, !14, i64 344, !14, i64 352, !15, i64 360, !13, i64 372, !14, i64 376, !14, i64 384, !14, i64 392, !14, i64 400, !14, i64 408, !13, i64 416, !14, i64 424}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{!"FD", !10, i64 0, !10, i64 4, !10, i64 8}
!16 = !{!12, !7, i64 180}
!17 = !{!12, !13, i64 176}
!18 = !{i8 0, i8 2}
!19 = !{}


; 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 void @pi_reset(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @handle_pi(ptr noundef %0, ptr nocapture noundef readnone %1, i32 noundef %2) local_unnamed_addr #0 {
  switch i32 %2, label %55 [
    i32 0, label %4
    i32 1, label %9
    i32 5, label %._crit_edge
  ]

4:                                                ; preds = %3
  %5 = getelementptr inbounds i8, ptr %0, i64 112
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = and i64 %6, 4096
  %.not24 = icmp eq i64 %7, 0
  br i1 %.not24, label %55, label %8

8:                                                ; preds = %4
  tail call void @pi_reset(ptr noundef nonnull %0)
  br label %55

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %0, i64 112
  %11 = load i64, ptr %10, align 8, !tbaa !5
  %12 = and i64 %11, 2048
  %.not = icmp eq i64 %12, 0
  br i1 %.not, label %16, label %13

13:                                               ; preds = %9
  %14 = trunc i64 %11 to i8
  %15 = and i8 %14, 127
  tail call void @pir_set(ptr noundef nonnull %0, i8 noundef zeroext %15)
  %.pre25 = load i64, ptr %10, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %13, %9
  %17 = phi i64 [ %.pre25, %13 ], [ %11, %9 ]
  %18 = and i64 %17, 1024
  %.not20 = icmp eq i64 %18, 0
  br i1 %.not20, label %25, label %19

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %0, i64 180
  %21 = load i8, ptr %20, align 4, !tbaa !13
  %22 = trunc i64 %17 to i8
  %23 = and i8 %22, 127
  %24 = or i8 %21, %23
  store i8 %24, ptr %20, align 4, !tbaa !13
  br label %25

25:                                               ; preds = %19, %16
  %26 = and i64 %17, 512
  %.not21 = icmp eq i64 %26, 0
  br i1 %.not21, label %34, label %27

27:                                               ; preds = %25
  %28 = getelementptr inbounds i8, ptr %0, i64 180
  %29 = load i8, ptr %28, align 4, !tbaa !13
  %30 = trunc i64 %17 to i8
  %31 = and i8 %30, 127
  %32 = xor i8 %31, 127
  %33 = and i8 %29, %32
  store i8 %33, ptr %28, align 4, !tbaa !13
  br label %34

34:                                               ; preds = %27, %25
  %35 = and i64 %17, 256
  %.not22 = icmp eq i64 %35, 0
  br i1 %.not22, label %38, label %36

36:                                               ; preds = %34
  %37 = getelementptr inbounds i8, ptr %0, i64 176
  store i8 0, ptr %37, align 8, !tbaa !14
  br label %38

38:                                               ; preds = %36, %34
  %39 = and i64 %17, 128
  %.not23 = icmp eq i64 %39, 0
  br i1 %.not23, label %42, label %40

40:                                               ; preds = %38
  %41 = getelementptr inbounds i8, ptr %0, i64 176
  store i8 1, ptr %41, align 8, !tbaa !14
  br label %42

42:                                               ; preds = %40, %38
  tail call void @calc_req(ptr noundef nonnull %0)
  br label %55

._crit_edge:                                      ; preds = %3
  %43 = getelementptr inbounds i8, ptr %0, i64 176
  %44 = load i8, ptr %43, align 8, !tbaa !14, !range !15, !noundef !16
  %45 = trunc nuw i8 %44 to i1
  %46 = getelementptr inbounds i8, ptr %0, i64 112
  %47 = load i64, ptr %46, align 8, !tbaa !5
  %48 = or i64 %47, 128
  %49 = select i1 %45, i64 %48, i64 %47
  %50 = getelementptr inbounds i8, ptr %0, i64 180
  %51 = load i8, ptr %50, align 4, !tbaa !13
  %52 = zext i8 %51 to i64
  %53 = getelementptr inbounds i8, ptr %0, i64 112
  %54 = or i64 %49, %52
  store i64 %54, ptr %53, align 8, !tbaa !5
  br label %55

55:                                               ; preds = %4, %8, %._crit_edge, %42, %3
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @pir_set(ptr noundef, i8 noundef zeroext) local_unnamed_addr #0

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

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, !11, i64 112}
!6 = !{!"PDP6", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 17, !10, i64 18, !10, i64 19, !10, i64 20, !10, i64 21, !10, i64 22, !10, i64 23, !10, i64 24, !10, i64 25, !10, i64 26, !10, i64 27, !10, i64 28, !10, i64 29, !10, i64 30, !10, i64 31, !10, i64 32, !10, i64 33, !10, i64 34, !10, i64 35, !10, i64 36, !10, i64 37, !10, i64 38, !10, i64 39, !11, i64 40, !11, i64 48, !8, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !7, i64 88, !7, i64 92, !7, i64 96, !7, i64 100, !7, i64 104, !7, i64 108, !11, i64 112, !8, i64 120, !10, i64 121, !10, i64 122, !10, i64 123, !10, i64 124, !10, i64 125, !10, i64 126, !10, i64 127, !10, i64 128, !10, i64 129, !10, i64 130, !10, i64 131, !10, i64 132, !10, i64 133, !10, i64 134, !10, i64 135, !10, i64 136, !10, i64 137, !10, i64 138, !10, i64 139, !10, i64 140, !10, i64 141, !10, i64 142, !10, i64 143, !10, i64 144, !10, i64 145, !10, i64 146, !10, i64 147, !10, i64 148, !10, i64 149, !10, i64 150, !10, i64 151, !10, i64 152, !10, i64 153, !10, i64 154, !10, i64 155, !10, i64 156, !10, i64 157, !10, i64 158, !10, i64 159, !10, i64 160, !10, i64 161, !10, i64 162, !10, i64 163, !10, i64 164, !10, i64 165, !10, i64 166, !10, i64 167, !10, i64 168, !10, i64 169, !10, i64 170, !10, i64 171, !10, i64 172, !10, i64 173, !10, i64 174, !10, i64 175, !10, i64 176, !10, i64 177, !10, i64 178, !10, i64 179, !8, i64 180, !8, i64 181, !8, i64 182, !8, i64 183, !10, i64 184, !10, i64 185, !10, i64 186, !10, i64 187, !10, i64 188, !7, i64 192, !7, i64 196, !7, i64 200, !10, i64 204, !10, i64 205, !10, i64 206, !10, i64 207, !10, i64 208, !10, i64 209, !10, i64 210, !10, i64 211, !10, i64 212, !10, i64 213, !10, i64 214, !10, i64 215, !8, i64 216, !10, i64 217, !10, i64 218, !10, i64 219, !10, i64 220, !10, i64 221, !10, i64 222, !10, i64 223, !10, i64 224, !10, i64 225, !10, i64 226, !10, i64 227, !10, i64 228, !10, i64 229, !8, i64 230, !7, i64 232, !7, i64 236, !11, i64 240, !11, i64 248, !11, i64 256, !10, i64 264, !10, i64 265, !10, i64 266, !8, i64 267, !11, i64 272, !10, i64 280, !10, i64 281, !10, i64 282, !7, i64 284, !12, i64 288, !11, i64 304, !8, i64 312, !10, i64 313, !10, i64 314, !10, i64 315, !8, i64 316, !10, i64 317, !10, i64 318, !8, i64 319, !7, i64 320, !7, i64 324, !12, i64 328, !7, i64 340, !11, i64 344, !11, i64 352, !12, i64 360, !10, i64 372, !11, i64 376, !11, i64 384, !11, i64 392, !11, i64 400, !11, i64 408, !10, i64 416, !11, i64 424}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!"long long", !8, i64 0}
!12 = !{!"FD", !7, i64 0, !7, i64 4, !7, i64 8}
!13 = !{!6, !8, i64 180}
!14 = !{!6, !10, i64 176}
!15 = !{i8 0, i8 2}
!16 = !{}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass