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

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

@mem = external dso_local global [262144 x i64], align 16
@locmin = external dso_local global i32, align 4
@locmax = external dso_local global i32, align 4
@start = external dso_local global i32, align 4
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @mustopen(ptr noundef, ptr 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

declare i64 @fw(i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @saverim(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = 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 4, ptr %4) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = call ptr @mustopen(ptr noundef %5, ptr noundef @.str.10)
  store ptr %6, ptr %3, align 8, !tbaa !5
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %13, %1
  %8 = load i32, ptr %4, align 4, !tbaa !9
  %9 = icmp ult i32 %8, 32
  br i1 %9, label %10, label %16

10:                                               ; preds = %7
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = call i32 @putc(i32 noundef 0, ptr noundef %11)
  br label %13

13:                                               ; preds = %10
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = add i32 %14, 1
  store i32 %15, ptr %4, align 4, !tbaa !9
  br label %7, !llvm.loop !11

16:                                               ; preds = %7
  %17 = load i32, ptr @locmin, align 4, !tbaa !9
  store i32 %17, ptr %4, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %31, %16
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = load i32, ptr @locmax, align 4, !tbaa !9
  %21 = icmp ule i32 %19, %20
  br i1 %21, label %22, label %34

22:                                               ; preds = %18
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = call i64 @fw(i32 noundef 233760, i32 noundef %23)
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  call void @writew(i64 noundef %24, ptr noundef %25)
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds [262144 x i64], ptr @mem, i64 0, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !13
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  call void @writew(i64 noundef %29, ptr noundef %30)
  br label %31

31:                                               ; preds = %22
  %32 = load i32, ptr %4, align 4, !tbaa !9
  %33 = add i32 %32, 1
  store i32 %33, ptr %4, align 4, !tbaa !9
  br label %18, !llvm.loop !15

34:                                               ; preds = %18
  %35 = load i32, ptr @start, align 4, !tbaa !9
  %36 = call i64 @fw(i32 noundef 88192, i32 noundef %35)
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  call void @writew(i64 noundef %36, ptr noundef %37)
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  call void @writew(i64 noundef 0, ptr noundef %38)
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %45, %34
  %40 = load i32, ptr %4, align 4, !tbaa !9
  %41 = icmp ult i32 %40, 32
  br i1 %41, label %42, label %48

42:                                               ; preds = %39
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = call i32 @putc(i32 noundef 0, ptr noundef %43)
  br label %45

45:                                               ; preds = %42
  %46 = load i32, ptr %4, align 4, !tbaa !9
  %47 = add i32 %46, 1
  store i32 %47, ptr %4, align 4, !tbaa !9
  br label %39, !llvm.loop !16

48:                                               ; preds = %39
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = call i32 @fclose(ptr noundef %49)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

declare i32 @putc(i32 noundef, ptr noundef) #2

declare void @writew(i64 noundef, ptr noundef) #2

declare i32 @fclose(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 = !{!"any pointer", !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 = !{!14, !14, i64 0}
!14 = !{!"long", !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"

@mem = external dso_local local_unnamed_addr global [262144 x i64], align 16
@locmin = external dso_local local_unnamed_addr global i32, align 4
@locmax = external dso_local local_unnamed_addr global i32, align 4
@start = external dso_local local_unnamed_addr global i32, align 4
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @mustopen(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i64 @fw(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @saverim(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call ptr @mustopen(ptr noundef %0, ptr noundef nonnull @.str.10)
  %3 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %4 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %5 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %6 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %7 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %8 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %9 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %10 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %11 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %12 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %13 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %14 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %15 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %16 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %17 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %18 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %19 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %20 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %21 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %22 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %23 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %24 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %25 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %26 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %27 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %28 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %29 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %30 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %31 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %32 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %33 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %34 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %35 = load i32, ptr @locmin, align 4, !tbaa !5
  %36 = load i32, ptr @locmax, align 4, !tbaa !5
  %.not16 = icmp ugt i32 %35, %36
  br i1 %.not16, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.117 = phi i32 [ %41, %.lr.ph ], [ %35, %1 ]
  %37 = tail call i64 @fw(i32 noundef 233760, i32 noundef %.117) #3
  tail call void @writew(i64 noundef %37, ptr noundef %2) #3
  %38 = zext i32 %.117 to i64
  %39 = getelementptr inbounds [262144 x i64], ptr @mem, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !9
  tail call void @writew(i64 noundef %40, ptr noundef %2) #3
  %41 = add i32 %.117, 1
  %42 = load i32, ptr @locmax, align 4, !tbaa !5
  %.not = icmp ugt i32 %41, %42
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %1
  %43 = load i32, ptr @start, align 4, !tbaa !5
  %44 = tail call i64 @fw(i32 noundef 88192, i32 noundef %43) #3
  tail call void @writew(i64 noundef %44, ptr noundef %2) #3
  tail call void @writew(i64 noundef 0, ptr noundef %2) #3
  %45 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %46 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %47 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %48 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %49 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %50 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %51 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %52 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %53 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %54 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %55 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %56 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %57 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %58 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %59 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %60 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %61 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %62 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %63 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %64 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %65 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %66 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %67 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %68 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %69 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %70 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %71 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %72 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %73 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %74 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %75 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %76 = tail call i32 @putc(i32 noundef 0, ptr noundef %2)
  %77 = tail call i32 @fclose(ptr noundef %2)
  ret void
}

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

declare void @writew(i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #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 = { "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 = !{!6, !6, i64 0}
!6 = !{!"int", !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"}


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