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

@dot = external dso_local global ptr, align 8
@lastdot = external dso_local global %struct.Value, align 8
@reldot = external dso_local global %struct.Value, align 8
@absdot = external dso_local global %struct.Value, align 8
@.str.55 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 @resetdot() #1 {
  %1 = alloca %struct.Value, align 8
  %2 = alloca %struct.Value, align 8
  %3 = call i64 @sixbit(ptr noundef @.str.55)
  %4 = call ptr @getsym(i64 noundef %3)
  store ptr %4, ptr @dot, align 8, !tbaa !5
  %5 = load ptr, ptr @dot, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.Sym, ptr %5, i32 0, i32 1
  store i32 25, ptr %6, align 8, !tbaa !9
  %7 = getelementptr inbounds %struct.Value, ptr %1, i32 0, i32 0
  store i64 0, ptr %7, align 8, !tbaa !13
  %8 = getelementptr inbounds %struct.Value, ptr %1, i32 0, i32 1
  store i32 0, ptr %8, align 8, !tbaa !15
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 @absdot, ptr align 8 %1, i64 16, i1 false), !tbaa.struct !16
  %9 = getelementptr inbounds %struct.Value, ptr %2, i32 0, i32 0
  store i64 0, ptr %9, align 8, !tbaa !13
  %10 = getelementptr inbounds %struct.Value, ptr %2, i32 0, i32 1
  store i32 1, ptr %10, align 8, !tbaa !15
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 @reldot, ptr align 8 %2, i64 16, i1 false), !tbaa.struct !16
  %11 = load ptr, ptr @dot, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.Sym, ptr %11, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 @reldot, i64 16, i1 false), !tbaa.struct !16
  %13 = load ptr, ptr @dot, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.Sym, ptr %13, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 @lastdot, ptr align 8 %14, i64 16, i1 false), !tbaa.struct !16
  store i64 68719476735, ptr @lastdot, align 8, !tbaa !13
  ret void
}

attributes #0 = { nocallback nofree 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" }

!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, !12, i64 8}
!10 = !{!"Sym", !11, i64 0, !12, i64 8, !7, i64 16, !6, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !11, i64 0}
!14 = !{!"Value", !11, i64 0, !12, i64 8}
!15 = !{!14, !12, i64 8}
!16 = !{i64 0, i64 8, !17, i64 8, i64 4, !18}
!17 = !{!11, !11, i64 0}
!18 = !{!12, !12, 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"

%struct.Value = type { i64, i32 }

@dot = external dso_local local_unnamed_addr global ptr, align 8
@lastdot = external dso_local local_unnamed_addr global %struct.Value, align 8
@reldot = external dso_local local_unnamed_addr global %struct.Value, align 8
@absdot = external dso_local local_unnamed_addr global %struct.Value, align 8
@.str.55 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

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

declare i64 @sixbit(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @resetdot() local_unnamed_addr #1 {
  %1 = tail call i64 @sixbit(ptr noundef nonnull @.str.55) #3
  %2 = tail call ptr @getsym(i64 noundef %1)
  store ptr %2, ptr @dot, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 8
  store i32 25, ptr %3, align 8, !tbaa !9
  store i64 0, ptr @absdot, align 8, !tbaa !13
  store i32 0, ptr getelementptr inbounds (i8, ptr @absdot, i64 8), align 8, !tbaa !14
  store i64 0, ptr @reldot, align 8, !tbaa !13
  store i32 1, ptr getelementptr inbounds (i8, ptr @reldot, i64 8), align 8, !tbaa !14
  %4 = getelementptr inbounds i8, ptr %2, i64 16
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(16) @reldot, i64 16, i1 false), !tbaa.struct !15
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) @lastdot, ptr noundef nonnull align 8 dereferenceable(16) @reldot, i64 16, i1 false)
  store i64 68719476735, ptr @lastdot, align 8, !tbaa !16
  ret void
}

attributes #0 = { mustprogress nocallback nofree 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, !12, i64 8}
!10 = !{!"Sym", !11, i64 0, !12, i64 8, !7, i64 16, !6, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!12, !12, i64 0}
!15 = !{i64 0, i64 8, !13, i64 8, i64 4, !14}
!16 = !{!17, !11, i64 0}
!17 = !{!"Value", !11, i64 0, !12, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,TailCallElimPass