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

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

@item = external dso_local global [262144 x i64], align 16
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @left(i64 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @right(i64 noundef) #0

; 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

; Function Attrs: nounwind uwtable
define dso_local void @dumpitem() #0 {
  %1 = alloca i64, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %6 = load i64, ptr @item, align 16, !tbaa !5
  %7 = call i32 @left(i64 noundef %6)
  store i32 %7, ptr %2, align 4, !tbaa !9
  %8 = load i64, ptr @item, align 16, !tbaa !5
  %9 = call i32 @right(i64 noundef %8)
  store i32 %9, ptr %3, align 4, !tbaa !9
  %10 = load i32, ptr %2, align 4, !tbaa !9
  %11 = load i32, ptr %3, align 4, !tbaa !9
  %12 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %10, i32 noundef %11)
  store i32 1, ptr %4, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %59, %0
  %14 = load i32, ptr %3, align 4, !tbaa !9
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %60

16:                                               ; preds = %13
  %17 = load i32, ptr %4, align 4, !tbaa !9
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %4, align 4, !tbaa !9
  %19 = sext i32 %17 to i64
  %20 = getelementptr inbounds [262144 x i64], ptr @item, i64 0, i64 %19
  %21 = load i64, ptr %20, align 8, !tbaa !5
  store i64 %21, ptr %1, align 8, !tbaa !5
  store i32 18, ptr %5, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %31, %16
  %23 = load i32, ptr %3, align 4, !tbaa !9
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %29

25:                                               ; preds = %22
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = add nsw i32 %26, -1
  store i32 %27, ptr %5, align 4, !tbaa !9
  %28 = icmp ne i32 %26, 0
  br label %29

29:                                               ; preds = %25, %22
  %30 = phi i1 [ false, %22 ], [ %28, %25 ]
  br i1 %30, label %31, label %59

31:                                               ; preds = %29
  %32 = load i32, ptr %4, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [262144 x i64], ptr @item, i64 0, i64 %33
  %35 = load i64, ptr %34, align 8, !tbaa !5
  %36 = call i32 @left(i64 noundef %35)
  %37 = load i64, ptr %1, align 8, !tbaa !5
  %38 = and i64 %37, 34359738368
  %39 = icmp ne i64 %38, 0
  %40 = zext i1 %39 to i64
  %41 = select i1 %39, i32 39, i32 32
  %42 = load i32, ptr %4, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [262144 x i64], ptr @item, i64 0, i64 %43
  %45 = load i64, ptr %44, align 8, !tbaa !5
  %46 = call i32 @right(i64 noundef %45)
  %47 = load i64, ptr %1, align 8, !tbaa !5
  %48 = and i64 %47, 17179869184
  %49 = icmp ne i64 %48, 0
  %50 = zext i1 %49 to i64
  %51 = select i1 %49, i32 39, i32 32
  %52 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %36, i32 noundef %41, i32 noundef %46, i32 noundef %51)
  %53 = load i64, ptr %1, align 8, !tbaa !5
  %54 = shl i64 %53, 2
  store i64 %54, ptr %1, align 8, !tbaa !5
  %55 = load i32, ptr %4, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %4, align 4, !tbaa !9
  %57 = load i32, ptr %3, align 4, !tbaa !9
  %58 = add nsw i32 %57, -1
  store i32 %58, ptr %3, align 4, !tbaa !9
  br label %22, !llvm.loop !11

59:                                               ; preds = %29
  br label %13, !llvm.loop !13

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

declare i32 @printf(ptr noundef, ...) #2

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 = { "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 = !{!"long", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@item = external dso_local local_unnamed_addr global [262144 x i64], align 16
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @dumpitem() local_unnamed_addr #0 {
  %1 = load i64, ptr @item, align 16, !tbaa !5
  %2 = tail call i32 @left(i64 noundef %1)
  %3 = load i64, ptr @item, align 16, !tbaa !5
  %4 = tail call i32 @right(i64 noundef %3)
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %2, i32 noundef %4)
  %.not26 = icmp eq i32 %4, 0
  br i1 %.not26, label %.critedge._crit_edge, label %.lr.ph

.critedge.loopexit:                               ; preds = %11
  %6 = trunc nsw i64 %indvars.iv.next to i32
  br i1 %.not17, label %.critedge._crit_edge, label %.lr.ph, !llvm.loop !9

.lr.ph:                                           ; preds = %0, %.critedge.loopexit
  %.01328 = phi i32 [ %6, %.critedge.loopexit ], [ 1, %0 ]
  %.01427 = phi i32 [ %24, %.critedge.loopexit ], [ %4, %0 ]
  %7 = sext i32 %.01328 to i64
  %8 = getelementptr inbounds [262144 x i64], ptr @item, i64 0, i64 %7
  %9 = load i64, ptr %8, align 8, !tbaa !5
  %.121 = add i32 %.01328, 1
  %10 = sext i32 %.121 to i64
  br label %11

11:                                               ; preds = %.lr.ph, %11
  %indvars.iv = phi i64 [ %10, %.lr.ph ], [ %indvars.iv.next, %11 ]
  %.024 = phi i32 [ 18, %.lr.ph ], [ %12, %11 ]
  %.11523 = phi i32 [ %.01427, %.lr.ph ], [ %24, %11 ]
  %.01622 = phi i64 [ %9, %.lr.ph ], [ %23, %11 ]
  %12 = add nsw i32 %.024, -1
  %13 = getelementptr inbounds [262144 x i64], ptr @item, i64 0, i64 %indvars.iv
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %15 = tail call i32 @left(i64 noundef %14)
  %16 = and i64 %.01622, 34359738368
  %.not19 = icmp eq i64 %16, 0
  %17 = select i1 %.not19, i32 32, i32 39
  %18 = load i64, ptr %13, align 8, !tbaa !5
  %19 = tail call i32 @right(i64 noundef %18)
  %20 = and i64 %.01622, 17179869184
  %.not20 = icmp eq i64 %20, 0
  %21 = select i1 %.not20, i32 32, i32 39
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %15, i32 noundef %17, i32 noundef %19, i32 noundef %21)
  %23 = shl i64 %.01622, 2
  %24 = add nsw i32 %.11523, -1
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %.not17 = icmp eq i32 %24, 0
  %.not18 = icmp eq i32 %12, 0
  %or.cond = select i1 %.not17, i1 true, i1 %.not18
  br i1 %or.cond, label %.critedge.loopexit, label %11, !llvm.loop !11

.critedge._crit_edge:                             ; preds = %.critedge.loopexit, %0
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { nofree nounwind "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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass