; 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
declare hidden void @dash_cp0(ptr noundef) #0

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

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

15:                                               ; preds = %3
  store i64 0, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %72

16:                                               ; preds = %3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Dc136, ptr %17, i32 0, i32 3
  %19 = load i32, ptr %18, align 4, !tbaa !11
  switch i32 %19, label %67 [
    i32 1, label %20
    i32 2, label %20
    i32 3, label %49
    i32 4, label %49
    i32 5, label %62
    i32 6, label %62
  ]

20:                                               ; preds = %16, %16
  %21 = load i32, ptr %7, align 4, !tbaa !9
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %35

23:                                               ; preds = %20
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.Dc136, ptr %24, i32 0, i32 6
  %26 = load i64, ptr %25, align 8, !tbaa !15
  %27 = and i64 %26, 63
  store i64 %27, ptr %8, align 8, !tbaa !16
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.Dc136, ptr %28, i32 0, i32 6
  %30 = load i64, ptr %29, align 8, !tbaa !15
  %31 = lshr i64 %30, 6
  %32 = and i64 %31, 68719476735
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.Dc136, ptr %33, i32 0, i32 6
  store i64 %32, ptr %34, align 8, !tbaa !15
  br label %48

35:                                               ; preds = %20
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.Dc136, ptr %36, i32 0, i32 6
  %38 = load i64, ptr %37, align 8, !tbaa !15
  %39 = lshr i64 %38, 30
  %40 = and i64 %39, 63
  store i64 %40, ptr %8, align 8, !tbaa !16
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.Dc136, ptr %41, i32 0, i32 6
  %43 = load i64, ptr %42, align 8, !tbaa !15
  %44 = shl i64 %43, 6
  %45 = and i64 %44, 68719476735
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.Dc136, ptr %46, i32 0, i32 6
  store i64 %45, ptr %47, align 8, !tbaa !15
  br label %48

48:                                               ; preds = %35, %23
  br label %68

49:                                               ; preds = %16, %16
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.Dc136, ptr %50, i32 0, i32 6
  %52 = load i64, ptr %51, align 8, !tbaa !15
  %53 = lshr i64 %52, 30
  %54 = and i64 %53, 63
  store i64 %54, ptr %8, align 8, !tbaa !16
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.Dc136, ptr %55, i32 0, i32 6
  %57 = load i64, ptr %56, align 8, !tbaa !15
  %58 = shl i64 %57, 6
  %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
  store i64 %59, ptr %61, align 8, !tbaa !15
  br label %68

62:                                               ; preds = %16, %16
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.Dc136, ptr %63, i32 0, i32 6
  %65 = load i64, ptr %64, align 8, !tbaa !15
  %66 = and i64 %65, 68719476735
  store i64 %66, ptr %8, align 8, !tbaa !16
  br label %68

67:                                               ; preds = %16
  store i64 0, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %72

68:                                               ; preds = %62, %49, %48
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  call void @dash_cp0(ptr noundef %69)
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  call void @recalc_dc_req(ptr noundef %70)
  %71 = load i64, ptr %8, align 8, !tbaa !16
  store i64 %71, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %72

72:                                               ; preds = %68, %67, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %73 = load i64, ptr %4, align 8
  ret i64 %73
}

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 76}
!12 = !{!"Dc136", !13, i64 0, !6, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !7, i64 88, !14, i64 152, !14, i64 160, !10, i64 168, !10, i64 172, !10, i64 176, !10, i64 180, !10, i64 184, !10, i64 188, !10, i64 192}
!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 = !{!"long", !7, i64 0}
!15 = !{!12, !14, i64 152}
!16 = !{!14, !14, i64 0}


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

; Function Attrs: nounwind uwtable
define dso_local range(i64 0, 68719476736) i64 @dctk(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 76
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %.not = icmp eq i32 %5, %1
  br i1 %.not, label %6, label %31

6:                                                ; preds = %3
  switch i32 %1, label %31 [
    i32 1, label %7
    i32 2, label %7
    i32 3, label %19
    i32 4, label %19
    i32 5, label %26
    i32 6, label %26
  ]

7:                                                ; preds = %6, %6
  %.not19 = icmp eq i32 %2, 0
  %8 = getelementptr inbounds i8, ptr %0, i64 152
  %9 = load i64, ptr %8, align 8, !tbaa !13
  br i1 %.not19, label %14, label %10

10:                                               ; preds = %7
  %11 = and i64 %9, 63
  %12 = lshr i64 %9, 6
  %13 = and i64 %12, 68719476735
  store i64 %13, ptr %8, align 8, !tbaa !13
  br label %30

14:                                               ; preds = %7
  %15 = lshr i64 %9, 30
  %16 = and i64 %15, 63
  %17 = shl i64 %9, 6
  %18 = and i64 %17, 68719476672
  store i64 %18, ptr %8, align 8, !tbaa !13
  br label %30

19:                                               ; preds = %6, %6
  %20 = getelementptr inbounds i8, ptr %0, i64 152
  %21 = load i64, ptr %20, align 8, !tbaa !13
  %22 = lshr i64 %21, 30
  %23 = and i64 %22, 63
  %24 = shl i64 %21, 6
  %25 = and i64 %24, 68719476672
  store i64 %25, ptr %20, align 8, !tbaa !13
  br label %30

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

30:                                               ; preds = %10, %14, %26, %19
  %.0 = phi i64 [ %29, %26 ], [ %23, %19 ], [ %11, %10 ], [ %16, %14 ]
  tail call void @dash_cp0(ptr noundef nonnull %0)
  tail call void @recalc_dc_req(ptr noundef nonnull %0)
  br label %31

31:                                               ; preds = %6, %3, %30
  %.017 = phi i64 [ %.0, %30 ], [ 0, %3 ], [ 0, %6 ]
  ret i64 %.017
}

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,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass