; 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.1 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @loadsav(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = 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
  br label %6

6:                                                ; preds = %41, %1
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = call i64 @readwbak(ptr noundef %7)
  store i64 %8, ptr %4, align 8, !tbaa !9
  %9 = load i64, ptr %4, align 8, !tbaa !9
  %10 = icmp ne i64 %9, -1
  br i1 %10, label %11, label %42

11:                                               ; preds = %6
  %12 = load i64, ptr %4, align 8, !tbaa !9
  %13 = lshr i64 %12, 27
  %14 = icmp eq i64 %13, 172
  br i1 %14, label %15, label %23

15:                                               ; preds = %11
  %16 = load i64, ptr %4, align 8, !tbaa !9
  %17 = call i32 @right(i64 noundef %16)
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %17)
  %19 = load ptr, ptr @stdout, align 8, !tbaa !5
  %20 = call i32 @fflush(ptr noundef %19)
  %21 = load i64, ptr %4, align 8, !tbaa !9
  %22 = call i32 @right(i64 noundef %21)
  call void @cpu_setpc(i32 noundef %22)
  store i32 1, ptr @started, align 4, !tbaa !11
  store i32 1, ptr %5, align 4
  br label %47

23:                                               ; preds = %11
  %24 = load i64, ptr %4, align 8, !tbaa !9
  store i64 %24, ptr %3, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %37, %23
  %26 = load i64, ptr %3, align 8, !tbaa !9
  %27 = call i32 @left(i64 noundef %26)
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %41

29:                                               ; preds = %25
  %30 = load i64, ptr %3, align 8, !tbaa !9
  %31 = add i64 %30, 262145
  store i64 %31, ptr %3, align 8, !tbaa !9
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = call i64 @readwbak(ptr noundef %32)
  store i64 %33, ptr %4, align 8, !tbaa !9
  %34 = load i64, ptr %4, align 8, !tbaa !9
  %35 = icmp eq i64 %34, -1
  br i1 %35, label %36, label %37

36:                                               ; preds = %29
  br label %43

37:                                               ; preds = %29
  %38 = load i64, ptr %3, align 8, !tbaa !9
  %39 = call i32 @right(i64 noundef %38)
  %40 = load i64, ptr %4, align 8, !tbaa !9
  call void @deposit(i32 noundef %39, i64 noundef %40)
  br label %25, !llvm.loop !13

41:                                               ; preds = %25
  br label %6, !llvm.loop !15

42:                                               ; preds = %6
  br label %43

43:                                               ; preds = %42, %36
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %45 = load ptr, ptr @stdout, align 8, !tbaa !5
  %46 = call i32 @fflush(ptr noundef %45)
  store i32 0, ptr %5, align 4
  br label %47

47:                                               ; preds = %43, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %48 = load i32, ptr %5, align 4
  switch i32 %48, label %50 [
    i32 0, label %49
    i32 1, label %49
  ]

49:                                               ; preds = %47, %47
  ret void

50:                                               ; preds = %47
  unreachable
}

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

declare i64 @readwbak(ptr noundef) #2

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

declare i32 @right(i64 noundef) #2

declare i32 @fflush(ptr noundef) #2

declare void @cpu_setpc(i32 noundef) #2

declare i32 @left(i64 noundef) #2

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 = !{!"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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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.1 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @loadsav(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call i64 @readwbak(ptr noundef %0) #3
  %.not20 = icmp eq i64 %2, -1
  br i1 %.not20, label %.loopexit14, label %.lr.ph21

.loopexit:                                        ; preds = %15, %.preheader
  %3 = tail call i64 @readwbak(ptr noundef %0) #3
  %.not = icmp eq i64 %3, -1
  br i1 %.not, label %.loopexit14, label %.lr.ph21, !llvm.loop !5

.lr.ph21:                                         ; preds = %1, %.loopexit
  %4 = phi i64 [ %3, %.loopexit ], [ %2, %1 ]
  %.mask = and i64 %4, -134217728
  %5 = icmp eq i64 %.mask, 23085449216
  br i1 %5, label %7, label %.preheader

.preheader:                                       ; preds = %.lr.ph21
  %6 = tail call i32 @left(i64 noundef %4) #3
  %.not1318 = icmp eq i32 %6, 0
  br i1 %.not1318, label %.loopexit, label %.lr.ph

7:                                                ; preds = %.lr.ph21
  %8 = tail call i32 @right(i64 noundef %4) #3
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %8)
  %10 = load ptr, ptr @stdout, align 8, !tbaa !7
  %11 = tail call i32 @fflush(ptr noundef %10)
  %12 = tail call i32 @right(i64 noundef %4) #3
  tail call void @cpu_setpc(i32 noundef %12) #3
  store i32 1, ptr @started, align 4, !tbaa !11
  br label %22

.lr.ph:                                           ; preds = %.preheader, %15
  %.019 = phi i64 [ %16, %15 ], [ %4, %.preheader ]
  %13 = tail call i64 @readwbak(ptr noundef %0) #3
  %14 = icmp eq i64 %13, -1
  br i1 %14, label %.loopexit14, label %15

15:                                               ; preds = %.lr.ph
  %16 = add i64 %.019, 262145
  %17 = tail call i32 @right(i64 noundef %16) #3
  tail call void @deposit(i32 noundef %17, i64 noundef %13) #3
  %18 = tail call i32 @left(i64 noundef %16) #3
  %.not13 = icmp eq i32 %18, 0
  br i1 %.not13, label %.loopexit, label %.lr.ph, !llvm.loop !13

.loopexit14:                                      ; preds = %.loopexit, %.lr.ph, %1
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %20 = load ptr, ptr @stdout, align 8, !tbaa !7
  %21 = tail call i32 @fflush(ptr noundef %20)
  br label %22

22:                                               ; preds = %.loopexit14, %7
  ret void
}

declare i64 @readwbak(ptr noundef) local_unnamed_addr #1

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

declare i32 @right(i64 noundef) local_unnamed_addr #1

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

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

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


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