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

; 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.Dc136 = type { %struct.Device, ptr, i32, i32, i32, [8 x ptr], i64, i64, i32, i32, i32, i32, i32, i32, i32 }
%struct.Device = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @dcgv(ptr noundef %0, i32 noundef %1, i64 noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i64 %2, ptr %7, align 8, !tbaa !11
  store i32 %3, ptr %8, align 4, !tbaa !9
  %9 = load i32, ptr %6, align 4, !tbaa !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.Dc136, ptr %10, i32 0, i32 3
  %12 = load i32, ptr %11, align 4, !tbaa !13
  %13 = icmp ne i32 %9, %12
  br i1 %13, label %14, label %15

14:                                               ; preds = %4
  br label %68

15:                                               ; preds = %4
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.Dc136, ptr %16, i32 0, i32 3
  %18 = load i32, ptr %17, align 4, !tbaa !13
  switch i32 %18, label %64 [
    i32 1, label %19
    i32 2, label %19
    i32 3, label %46
    i32 4, label %46
    i32 5, label %57
    i32 6, label %57
  ]

19:                                               ; preds = %15, %15
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %34

22:                                               ; preds = %19
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.Dc136, ptr %23, i32 0, i32 6
  %25 = load i64, ptr %24, align 8, !tbaa !16
  %26 = lshr i64 %25, 6
  %27 = load i64, ptr %7, align 8, !tbaa !11
  %28 = and i64 %27, 63
  %29 = shl i64 %28, 30
  %30 = or i64 %26, %29
  %31 = and i64 %30, 68719476735
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Dc136, ptr %32, i32 0, i32 6
  store i64 %31, ptr %33, align 8, !tbaa !16
  br label %45

34:                                               ; preds = %19
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.Dc136, ptr %35, i32 0, i32 6
  %37 = load i64, ptr %36, align 8, !tbaa !16
  %38 = shl i64 %37, 6
  %39 = load i64, ptr %7, align 8, !tbaa !11
  %40 = and i64 %39, 63
  %41 = or i64 %38, %40
  %42 = and i64 %41, 68719476735
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.Dc136, ptr %43, i32 0, i32 6
  store i64 %42, ptr %44, align 8, !tbaa !16
  br label %45

45:                                               ; preds = %34, %22
  br label %65

46:                                               ; preds = %15, %15
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.Dc136, ptr %47, i32 0, i32 6
  %49 = load i64, ptr %48, align 8, !tbaa !16
  %50 = shl i64 %49, 6
  %51 = load i64, ptr %7, align 8, !tbaa !11
  %52 = and i64 %51, 63
  %53 = or i64 %50, %52
  %54 = and i64 %53, 68719476735
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.Dc136, ptr %55, i32 0, i32 6
  store i64 %54, ptr %56, align 8, !tbaa !16
  br label %65

57:                                               ; preds = %15, %15
  %58 = load i64, ptr %7, align 8, !tbaa !11
  %59 = and i64 %58, 68719476735
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.Dc136, ptr %60, i32 0, i32 6
  %62 = load i64, ptr %61, align 8, !tbaa !16
  %63 = or i64 %62, %59
  store i64 %63, ptr %61, align 8, !tbaa !16
  br label %65

64:                                               ; preds = %15
  br label %68

65:                                               ; preds = %57, %46, %45
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  call void @dash_cp0(ptr noundef %66)
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  call void @recalc_dc_req(ptr noundef %67)
  br label %68

68:                                               ; preds = %65, %64, %14
  ret void
}

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

; Function Attrs: nounwind uwtable
declare hidden void @recalc_dc_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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 76}
!14 = !{!"Dc136", !15, i64 0, !6, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !7, i64 88, !12, i64 152, !12, i64 160, !10, i64 168, !10, i64 172, !10, i64 176, !10, i64 180, !10, i64 184, !10, i64 188, !10, i64 192}
!15 = !{!"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}
!16 = !{!14, !12, i64 152}


; 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
define dso_local void @dcgv(ptr noundef %0, i32 noundef %1, i64 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 76
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not = icmp eq i32 %6, %1
  br i1 %.not, label %7, label %32

7:                                                ; preds = %4
  switch i32 %1, label %32 [
    i32 1, label %8
    i32 2, label %8
    i32 3, label %20
    i32 4, label %20
    i32 5, label %26
    i32 6, label %26
  ]

8:                                                ; preds = %7, %7
  %.not16 = icmp eq i32 %3, 0
  %9 = getelementptr inbounds i8, ptr %0, i64 152
  %10 = load i64, ptr %9, align 8, !tbaa !13
  br i1 %.not16, label %16, label %11

11:                                               ; preds = %8
  %12 = lshr i64 %10, 6
  %13 = shl i64 %2, 30
  %14 = or i64 %12, %13
  %15 = and i64 %14, 68719476735
  store i64 %15, ptr %9, align 8, !tbaa !13
  br label %31

16:                                               ; preds = %8
  %17 = shl i64 %10, 6
  %18 = and i64 %2, 63
  %.masked17 = and i64 %17, 68719476672
  %19 = or disjoint i64 %.masked17, %18
  store i64 %19, ptr %9, align 8, !tbaa !13
  br label %31

20:                                               ; preds = %7, %7
  %21 = getelementptr inbounds i8, ptr %0, i64 152
  %22 = load i64, ptr %21, align 8, !tbaa !13
  %23 = shl i64 %22, 6
  %24 = and i64 %2, 63
  %.masked = and i64 %23, 68719476672
  %25 = or disjoint i64 %.masked, %24
  store i64 %25, ptr %21, align 8, !tbaa !13
  br label %31

26:                                               ; preds = %7, %7
  %27 = and i64 %2, 68719476735
  %28 = getelementptr inbounds i8, ptr %0, i64 152
  %29 = load i64, ptr %28, align 8, !tbaa !13
  %30 = or i64 %29, %27
  store i64 %30, ptr %28, align 8, !tbaa !13
  br label %31

31:                                               ; preds = %11, %16, %26, %20
  tail call void @dash_cp0(ptr noundef nonnull %0)
  tail call void @recalc_dc_req(ptr noundef nonnull %0)
  br label %32

32:                                               ; preds = %7, %4, %31
  ret void
}

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

; Function Attrs: nounwind uwtable
declare hidden void @recalc_dc_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 76}
!6 = !{!"Dc136", !7, i64 0, !8, i64 64, !11, i64 72, !11, i64 76, !11, i64 80, !9, i64 88, !12, i64 152, !12, i64 160, !11, i64 168, !11, i64 172, !11, i64 176, !11, i64 180, !11, i64 184, !11, i64 188, !11, i64 192}
!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 = !{!"int", !9, i64 0}
!12 = !{!"long", !9, i64 0}
!13 = !{!6, !12, i64 152}


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