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

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

; 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
define dso_local void @readf(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  store i8 0, ptr %9, align 1, !tbaa !9
  store i64 0, ptr %10, align 8, !tbaa !10
  store i32 0, ptr %7, align 4, !tbaa !12
  br label %11

11:                                               ; preds = %38, %3
  %12 = load i32, ptr %7, align 4, !tbaa !12
  %13 = icmp slt i32 %12, 6
  br i1 %13, label %14, label %41

14:                                               ; preds = %11
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i32 1
  store ptr %17, ptr %15, align 8, !tbaa !5
  %18 = load i8, ptr %16, align 1, !tbaa !9
  store i8 %18, ptr %8, align 1, !tbaa !9
  %19 = load i8, ptr %9, align 1, !tbaa !9
  %20 = zext i8 %19 to i32
  %21 = shl i32 %20, 1
  %22 = load i8, ptr %8, align 1, !tbaa !9
  %23 = zext i8 %22 to i32
  %24 = and i32 %23, 8
  %25 = icmp ne i32 %24, 0
  %26 = xor i1 %25, true
  %27 = xor i1 %26, true
  %28 = zext i1 %27 to i32
  %29 = or i32 %21, %28
  %30 = trunc i32 %29 to i8
  store i8 %30, ptr %9, align 1, !tbaa !9
  %31 = load i64, ptr %10, align 8, !tbaa !10
  %32 = shl i64 %31, 3
  %33 = load i8, ptr %8, align 1, !tbaa !9
  %34 = zext i8 %33 to i32
  %35 = and i32 %34, 7
  %36 = sext i32 %35 to i64
  %37 = or i64 %32, %36
  store i64 %37, ptr %10, align 8, !tbaa !10
  br label %38

38:                                               ; preds = %14
  %39 = load i32, ptr %7, align 4, !tbaa !12
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %7, align 4, !tbaa !12
  br label %11, !llvm.loop !14

41:                                               ; preds = %11
  %42 = load i8, ptr %9, align 1, !tbaa !9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  store i8 %42, ptr %43, align 1, !tbaa !9
  %44 = load i64, ptr %10, align 8, !tbaa !10
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  store i64 %44, ptr %45, align 8, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  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 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @readf(ptr nocapture noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %.promoted = load ptr, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %.promoted, i64 1
  store ptr %4, ptr %0, align 8, !tbaa !5
  %5 = load i8, ptr %.promoted, align 1, !tbaa !9
  %6 = getelementptr inbounds i8, ptr %.promoted, i64 2
  store ptr %6, ptr %0, align 8, !tbaa !5
  %7 = load i8, ptr %4, align 1, !tbaa !9
  %8 = shl i8 %5, 3
  %9 = and i8 %8, 56
  %10 = and i8 %7, 7
  %11 = or disjoint i8 %9, %10
  %12 = zext nneg i8 %11 to i64
  %13 = getelementptr inbounds i8, ptr %.promoted, i64 3
  store ptr %13, ptr %0, align 8, !tbaa !5
  %14 = load i8, ptr %6, align 1, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %.promoted, i64 4
  store ptr %15, ptr %0, align 8, !tbaa !5
  %16 = load i8, ptr %13, align 1, !tbaa !9
  %17 = lshr i8 %7, 1
  %18 = and i8 %17, 4
  %.mask = and i8 %5, 8
  %19 = or disjoint i8 %.mask, %18
  %20 = lshr i8 %14, 2
  %21 = and i8 %20, 2
  %22 = or disjoint i8 %19, %21
  %23 = lshr i8 %16, 3
  %.lobit.3 = and i8 %23, 1
  %24 = or disjoint i8 %.lobit.3, %22
  %25 = shl nuw nsw i64 %12, 6
  %26 = shl i8 %14, 3
  %27 = and i8 %26, 56
  %28 = zext nneg i8 %27 to i64
  %29 = or disjoint i64 %25, %28
  %30 = and i8 %16, 7
  %31 = zext nneg i8 %30 to i64
  %32 = or disjoint i64 %29, %31
  %33 = getelementptr inbounds i8, ptr %.promoted, i64 5
  store ptr %33, ptr %0, align 8, !tbaa !5
  %34 = load i8, ptr %15, align 1, !tbaa !9
  %35 = getelementptr inbounds i8, ptr %.promoted, i64 6
  store ptr %35, ptr %0, align 8, !tbaa !5
  %36 = load i8, ptr %33, align 1, !tbaa !9
  %37 = shl nuw nsw i8 %24, 2
  %38 = lshr i8 %34, 2
  %39 = and i8 %38, 2
  %40 = or disjoint i8 %37, %39
  %41 = lshr i8 %36, 3
  %.lobit.5 = and i8 %41, 1
  %42 = or disjoint i8 %.lobit.5, %40
  %43 = shl nuw nsw i64 %32, 6
  %44 = shl i8 %34, 3
  %45 = and i8 %44, 56
  %46 = zext nneg i8 %45 to i64
  %47 = or disjoint i64 %43, %46
  %48 = and i8 %36, 7
  %49 = zext nneg i8 %48 to i64
  %50 = or disjoint i64 %47, %49
  store i8 %42, ptr %1, align 1, !tbaa !9
  store i64 %50, ptr %2, align 8, !tbaa !10
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass