; LLVM IR from aap/pdp6 :: tools (as6)

; 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.Ps = type { ptr, ptr }
%struct.Op = type { ptr, i32, i64 }
%struct.Sym = type { i64, i32, %union.anon, ptr }
%union.anon = type { %struct.Value }
%struct.Value = type { i64, i32 }

@pslist = external dso_local global [21 x %struct.Ps], align 16
@oplist = external dso_local global [376 x %struct.Op], align 16

; 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
declare dso_local ptr @getsym(i64 noundef) #1

declare i64 @sixbit(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @initsymtab() #1 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store ptr @oplist, ptr %1, align 8, !tbaa !5
  br label %4

4:                                                ; preds = %31, %0
  %5 = load ptr, ptr %1, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.Op, ptr %5, i32 0, i32 0
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds i8, ptr %7, i64 0
  %9 = load i8, ptr %8, align 1, !tbaa !13
  %10 = icmp ne i8 %9, 0
  br i1 %10, label %11, label %34

11:                                               ; preds = %4
  %12 = load ptr, ptr %1, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.Op, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = call i64 @sixbit(ptr noundef %14)
  %16 = call ptr @getsym(i64 noundef %15)
  store ptr %16, ptr %3, align 8, !tbaa !5
  %17 = load ptr, ptr %1, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Op, ptr %17, i32 0, i32 1
  %19 = load i32, ptr %18, align 8, !tbaa !14
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Sym, ptr %20, i32 0, i32 1
  store i32 %19, ptr %21, align 8, !tbaa !15
  %22 = load ptr, ptr %1, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.Op, ptr %22, i32 0, i32 2
  %24 = load i64, ptr %23, align 8, !tbaa !17
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Sym, ptr %25, i32 0, i32 2
  %27 = getelementptr inbounds %struct.Value, ptr %26, i32 0, i32 0
  store i64 %24, ptr %27, align 8, !tbaa !13
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.Sym, ptr %28, i32 0, i32 2
  %30 = getelementptr inbounds %struct.Value, ptr %29, i32 0, i32 1
  store i32 0, ptr %30, align 8, !tbaa !13
  br label %31

31:                                               ; preds = %11
  %32 = load ptr, ptr %1, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Op, ptr %32, i32 1
  store ptr %33, ptr %1, align 8, !tbaa !5
  br label %4, !llvm.loop !18

34:                                               ; preds = %4
  store ptr @pslist, ptr %2, align 8, !tbaa !5
  br label %35

35:                                               ; preds = %55, %34
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.Ps, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  %39 = getelementptr inbounds i8, ptr %38, i64 0
  %40 = load i8, ptr %39, align 1, !tbaa !13
  %41 = icmp ne i8 %40, 0
  br i1 %41, label %42, label %58

42:                                               ; preds = %35
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.Ps, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !20
  %46 = call i64 @sixbit(ptr noundef %45)
  %47 = call ptr @getsym(i64 noundef %46)
  store ptr %47, ptr %3, align 8, !tbaa !5
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Sym, ptr %48, i32 0, i32 1
  store i32 66, ptr %49, align 8, !tbaa !15
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.Ps, ptr %50, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !22
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.Sym, ptr %53, i32 0, i32 2
  store ptr %52, ptr %54, align 8, !tbaa !13
  br label %55

55:                                               ; preds = %42
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.Ps, ptr %56, i32 1
  store ptr %57, ptr %2, align 8, !tbaa !5
  br label %35, !llvm.loop !23

58:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  ret void
}

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 = { "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 #3 = { 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, !6, i64 0}
!10 = !{!"Op", !6, i64 0, !11, i64 8, !12, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!10, !11, i64 8}
!15 = !{!16, !11, i64 8}
!16 = !{!"Sym", !12, i64 0, !11, i64 8, !7, i64 16, !6, i64 32}
!17 = !{!10, !12, i64 16}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!21, !6, i64 0}
!21 = !{!"Ps", !6, i64 0, !6, i64 8}
!22 = !{!21, !6, i64 8}
!23 = distinct !{!23, !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"

%struct.Ps = type { ptr, ptr }
%struct.Op = type { ptr, i32, i64 }

@pslist = external dso_local local_unnamed_addr global [21 x %struct.Ps], align 16
@oplist = external dso_local local_unnamed_addr global [376 x %struct.Op], align 16

; Function Attrs: nounwind uwtable
declare dso_local ptr @getsym(i64 noundef) local_unnamed_addr #0

declare i64 @sixbit(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @initsymtab() local_unnamed_addr #0 {
  %1 = load ptr, ptr @oplist, align 16, !tbaa !5
  %2 = load i8, ptr %1, align 1, !tbaa !12
  %.not16 = icmp eq i8 %2, 0
  br i1 %.not16, label %.preheader, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph, %0
  %3 = load ptr, ptr @pslist, align 16, !tbaa !13
  %4 = load i8, ptr %3, align 1, !tbaa !12
  %.not1518 = icmp eq i8 %4, 0
  br i1 %.not1518, label %._crit_edge, label %.lr.ph20

.lr.ph:                                           ; preds = %0, %.lr.ph
  %5 = phi ptr [ %16, %.lr.ph ], [ %1, %0 ]
  %.01417 = phi ptr [ %15, %.lr.ph ], [ @oplist, %0 ]
  %6 = tail call i64 @sixbit(ptr noundef nonnull %5) #2
  %7 = tail call ptr @getsym(i64 noundef %6)
  %8 = getelementptr inbounds i8, ptr %.01417, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !15
  %10 = getelementptr inbounds i8, ptr %7, i64 8
  store i32 %9, ptr %10, align 8, !tbaa !16
  %11 = getelementptr inbounds i8, ptr %.01417, i64 16
  %12 = load i64, ptr %11, align 8, !tbaa !18
  %13 = getelementptr inbounds i8, ptr %7, i64 16
  store i64 %12, ptr %13, align 8, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %7, i64 24
  store i32 0, ptr %14, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %.01417, i64 24
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = load i8, ptr %16, align 1, !tbaa !12
  %.not = icmp eq i8 %17, 0
  br i1 %.not, label %.preheader, label %.lr.ph, !llvm.loop !19

.lr.ph20:                                         ; preds = %.preheader, %.lr.ph20
  %18 = phi ptr [ %26, %.lr.ph20 ], [ %3, %.preheader ]
  %.019 = phi ptr [ %25, %.lr.ph20 ], [ @pslist, %.preheader ]
  %19 = tail call i64 @sixbit(ptr noundef nonnull %18) #2
  %20 = tail call ptr @getsym(i64 noundef %19)
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  store i32 66, ptr %21, align 8, !tbaa !16
  %22 = getelementptr inbounds i8, ptr %.019, i64 8
  %23 = load ptr, ptr %22, align 8, !tbaa !21
  %24 = getelementptr inbounds i8, ptr %20, i64 16
  store ptr %23, ptr %24, align 8, !tbaa !12
  %25 = getelementptr inbounds i8, ptr %.019, i64 16
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = load i8, ptr %26, align 1, !tbaa !12
  %.not15 = icmp eq i8 %27, 0
  br i1 %.not15, label %._crit_edge, label %.lr.ph20, !llvm.loop !22

._crit_edge:                                      ; preds = %.lr.ph20, %.preheader
  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" }
attributes #1 = { "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, !7, i64 0}
!6 = !{!"Op", !7, i64 0, !10, i64 8, !11, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!8, !8, i64 0}
!13 = !{!14, !7, i64 0}
!14 = !{!"Ps", !7, i64 0, !7, i64 8}
!15 = !{!6, !10, i64 8}
!16 = !{!17, !10, i64 8}
!17 = !{!"Sym", !11, i64 0, !10, i64 8, !8, i64 16, !7, i64 32}
!18 = !{!6, !11, i64 16}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!14, !7, i64 8}
!22 = distinct !{!22, !20}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass