; LLVM IR from aap/pdp6 :: fe6 (cmd)

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

@.str = external hidden unnamed_addr constant [9 x i8], align 1
@stdout = external global ptr, align 8
@started = external global i32, align 4
@.str.2 = external hidden unnamed_addr constant [22 x i8], align 1

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

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

declare i32 @right(i64 noundef) #1

declare i32 @fflush(ptr noundef) #1

declare void @cpu_setpc(i32 noundef) #1

declare i32 @left(i64 noundef) #1

declare void @deposit(i32 noundef, i64 noundef) #1

; 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 @loadsblk(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  br label %8

8:                                                ; preds = %17, %1
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = call i64 @readwits(ptr noundef %9)
  store i64 %10, ptr %4, align 8, !tbaa !9
  %11 = load i64, ptr %4, align 8, !tbaa !9
  %12 = icmp ne i64 %11, -1
  br i1 %12, label %13, label %18

13:                                               ; preds = %8
  %14 = load i64, ptr %4, align 8, !tbaa !9
  %15 = icmp eq i64 %14, 23085449217
  br i1 %15, label %16, label %17

16:                                               ; preds = %13
  br label %19

17:                                               ; preds = %13
  br label %8, !llvm.loop !11

18:                                               ; preds = %8
  br label %90

19:                                               ; preds = %16
  br label %20

20:                                               ; preds = %71, %19
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = call i64 @readwits(ptr noundef %21)
  store i64 %22, ptr %4, align 8, !tbaa !9
  %23 = load i64, ptr %4, align 8, !tbaa !9
  %24 = icmp ne i64 %23, -1
  br i1 %24, label %25, label %72

25:                                               ; preds = %20
  %26 = load i64, ptr %4, align 8, !tbaa !9
  %27 = and i64 %26, 34359738368
  %28 = icmp eq i64 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %25
  br label %73

30:                                               ; preds = %25
  %31 = load i64, ptr %4, align 8, !tbaa !9
  store i64 %31, ptr %3, align 8, !tbaa !9
  %32 = load i64, ptr %3, align 8, !tbaa !9
  store i64 %32, ptr %5, align 8, !tbaa !9
  %33 = load i64, ptr %3, align 8, !tbaa !9
  %34 = call i32 @right(i64 noundef %33)
  %35 = icmp ne i32 %34, 0
  %36 = zext i1 %35 to i32
  store i32 %36, ptr %6, align 4, !tbaa !13
  br label %37

37:                                               ; preds = %62, %30
  %38 = load i64, ptr %3, align 8, !tbaa !9
  %39 = call i32 @left(i64 noundef %38)
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %65

41:                                               ; preds = %37
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = call i64 @readwits(ptr noundef %42)
  store i64 %43, ptr %4, align 8, !tbaa !9
  %44 = load i64, ptr %4, align 8, !tbaa !9
  %45 = icmp eq i64 %44, -1
  br i1 %45, label %46, label %47

46:                                               ; preds = %41
  br label %90

47:                                               ; preds = %41
  %48 = load i64, ptr %5, align 8, !tbaa !9
  %49 = shl i64 %48, 1
  %50 = load i64, ptr %5, align 8, !tbaa !9
  %51 = lshr i64 %50, 35
  %52 = or i64 %49, %51
  %53 = load i64, ptr %4, align 8, !tbaa !9
  %54 = add i64 %52, %53
  %55 = and i64 %54, 68719476735
  store i64 %55, ptr %5, align 8, !tbaa !9
  %56 = load i32, ptr %6, align 4, !tbaa !13
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %62

58:                                               ; preds = %47
  %59 = load i64, ptr %3, align 8, !tbaa !9
  %60 = call i32 @right(i64 noundef %59)
  %61 = load i64, ptr %4, align 8, !tbaa !9
  call void @deposit(i32 noundef %60, i64 noundef %61)
  br label %62

62:                                               ; preds = %58, %47
  %63 = load i64, ptr %3, align 8, !tbaa !9
  %64 = add i64 %63, 262145
  store i64 %64, ptr %3, align 8, !tbaa !9
  br label %37, !llvm.loop !15

65:                                               ; preds = %37
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = call i64 @readwits(ptr noundef %66)
  %68 = load i64, ptr %5, align 8, !tbaa !9
  %69 = icmp ne i64 %67, %68
  br i1 %69, label %70, label %71

70:                                               ; preds = %65
  br label %90

71:                                               ; preds = %65
  br label %20, !llvm.loop !16

72:                                               ; preds = %20
  br label %90

73:                                               ; preds = %29
  %74 = load i64, ptr %4, align 8, !tbaa !9
  %75 = call i32 @left(i64 noundef %74)
  %76 = icmp ne i32 %75, 108544
  br i1 %76, label %77, label %82

77:                                               ; preds = %73
  %78 = load i64, ptr %4, align 8, !tbaa !9
  %79 = call i32 @left(i64 noundef %78)
  %80 = icmp ne i32 %79, 88064
  br i1 %80, label %81, label %82

81:                                               ; preds = %77
  br label %90

82:                                               ; preds = %77, %73
  %83 = load i64, ptr %4, align 8, !tbaa !9
  %84 = call i32 @right(i64 noundef %83)
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %84)
  %86 = load ptr, ptr @stdout, align 8, !tbaa !5
  %87 = call i32 @fflush(ptr noundef %86)
  %88 = load i64, ptr %4, align 8, !tbaa !9
  %89 = call i32 @right(i64 noundef %88)
  call void @cpu_setpc(i32 noundef %89)
  store i32 1, ptr @started, align 4, !tbaa !13
  store i32 1, ptr %7, align 4
  br label %94

90:                                               ; preds = %81, %72, %70, %46, %18
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %92 = load ptr, ptr @stdout, align 8, !tbaa !5
  %93 = call i32 @fflush(ptr noundef %92)
  store i32 0, ptr %7, align 4
  br label %94

94:                                               ; preds = %90, %82
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %95 = load i32, ptr %7, align 4
  switch i32 %95, label %97 [
    i32 0, label %96
    i32 1, label %96
  ]

96:                                               ; preds = %94, %94
  ret void

97:                                               ; preds = %94
  unreachable
}

declare i64 @readwits(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !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"

@.str = external hidden unnamed_addr constant [9 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@started = external local_unnamed_addr global i32, align 4
@.str.2 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

declare i32 @right(i64 noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #0

declare void @cpu_setpc(i32 noundef) local_unnamed_addr #1

declare i32 @left(i64 noundef) local_unnamed_addr #1

declare void @deposit(i32 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @loadsblk(ptr noundef %0) local_unnamed_addr #2 {
  br label %2

2:                                                ; preds = %2, %1
  %3 = tail call i64 @readwits(ptr noundef %0) #3
  switch i64 %3, label %2 [
    i64 -1, label %.loopexit
    i64 23085449217, label %.preheader
  ]

.preheader:                                       ; preds = %2, %._crit_edge
  %4 = tail call i64 @readwits(ptr noundef %0) #3
  %.not28 = icmp eq i64 %4, -1
  br i1 %.not28, label %.loopexit, label %5

5:                                                ; preds = %.preheader
  %6 = and i64 %4, 34359738368
  %7 = icmp eq i64 %6, 0
  br i1 %7, label %33, label %8

8:                                                ; preds = %5
  %9 = tail call i32 @right(i64 noundef %4) #3
  %10 = tail call i32 @left(i64 noundef %4) #3
  %.not3039 = icmp eq i32 %10, 0
  br i1 %.not3039, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %8
  %.fr = freeze i32 %9
  %.not29 = icmp eq i32 %.fr, 0
  br i1 %.not29, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %13
  %.041.us = phi i64 [ %19, %13 ], [ %4, %.lr.ph ]
  %.02440.us = phi i64 [ %18, %13 ], [ %4, %.lr.ph ]
  %11 = tail call i64 @readwits(ptr noundef %0) #3
  %12 = icmp eq i64 %11, -1
  br i1 %12, label %.loopexit, label %13

13:                                               ; preds = %.lr.ph.split.us
  %14 = shl i64 %.02440.us, 1
  %15 = lshr i64 %.02440.us, 35
  %16 = or i64 %14, %15
  %17 = add i64 %11, %16
  %18 = and i64 %17, 68719476735
  %19 = add i64 %.041.us, 262145
  %20 = tail call i32 @left(i64 noundef %19) #3
  %.not30.us = icmp eq i32 %20, 0
  br i1 %.not30.us, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !5

.lr.ph.split:                                     ; preds = %.lr.ph, %23
  %.041 = phi i64 [ %30, %23 ], [ %4, %.lr.ph ]
  %.02440 = phi i64 [ %28, %23 ], [ %4, %.lr.ph ]
  %21 = tail call i64 @readwits(ptr noundef %0) #3
  %22 = icmp eq i64 %21, -1
  br i1 %22, label %.loopexit, label %23

23:                                               ; preds = %.lr.ph.split
  %24 = shl i64 %.02440, 1
  %25 = lshr i64 %.02440, 35
  %26 = or i64 %24, %25
  %27 = add i64 %21, %26
  %28 = and i64 %27, 68719476735
  %29 = tail call i32 @right(i64 noundef %.041) #3
  tail call void @deposit(i32 noundef %29, i64 noundef %21) #3
  %30 = add i64 %.041, 262145
  %31 = tail call i32 @left(i64 noundef %30) #3
  %.not30 = icmp eq i32 %31, 0
  br i1 %.not30, label %._crit_edge, label %.lr.ph.split, !llvm.loop !5

._crit_edge:                                      ; preds = %23, %13, %8
  %.024.lcssa = phi i64 [ %4, %8 ], [ %18, %13 ], [ %28, %23 ]
  %32 = tail call i64 @readwits(ptr noundef %0) #3
  %.not31 = icmp eq i64 %32, %.024.lcssa
  br i1 %.not31, label %.preheader, label %.loopexit, !llvm.loop !7

33:                                               ; preds = %5
  %34 = tail call i32 @left(i64 noundef %4) #3
  %.not32 = icmp eq i32 %34, 108544
  br i1 %.not32, label %37, label %35

35:                                               ; preds = %33
  %36 = tail call i32 @left(i64 noundef %4) #3
  %.not33 = icmp eq i32 %36, 88064
  br i1 %.not33, label %37, label %.loopexit

37:                                               ; preds = %35, %33
  %38 = tail call i32 @right(i64 noundef %4) #3
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %38)
  %40 = load ptr, ptr @stdout, align 8, !tbaa !8
  %41 = tail call i32 @fflush(ptr noundef %40)
  %42 = tail call i32 @right(i64 noundef %4) #3
  tail call void @cpu_setpc(i32 noundef %42) #3
  store i32 1, ptr @started, align 4, !tbaa !12
  br label %46

.loopexit:                                        ; preds = %2, %.preheader, %._crit_edge, %.lr.ph.split, %.lr.ph.split.us, %35
  %43 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %44 = load ptr, ptr @stdout, align 8, !tbaa !8
  %45 = tail call i32 @fflush(ptr noundef %44)
  br label %46

46:                                               ; preds = %.loopexit, %37
  ret void
}

declare i64 @readwits(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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" }
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 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !10, i64 0}


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