; LLVM IR from fwip/fastqz :: fapack (main)

; 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 [41 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i8, align 1
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = icmp slt i32 %13, 3
  br i1 %14, label %15, label %17

15:                                               ; preds = %2
  %16 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @exit(i32 noundef 1) #4
  unreachable

17:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %18 = load ptr, ptr %5, align 8, !tbaa !9
  %19 = getelementptr inbounds ptr, ptr %18, i64 1
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = call noalias ptr @fopen(ptr noundef %20, ptr noundef @.str.1)
  store ptr %21, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 2, ptr %9, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %107, %17
  %23 = load i32, ptr %9, align 4, !tbaa !5
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %110

27:                                               ; preds = %22
  %28 = load ptr, ptr %5, align 8, !tbaa !9
  %29 = load i32, ptr %9, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds ptr, ptr %28, i64 %30
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %32)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %34 = load ptr, ptr %5, align 8, !tbaa !9
  %35 = load i32, ptr %9, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds ptr, ptr %34, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = call noalias ptr @fopen(ptr noundef %38, ptr noundef @.str.3)
  store ptr %39, ptr %11, align 8, !tbaa !9
  %40 = load ptr, ptr %11, align 8, !tbaa !9
  %41 = icmp ne ptr %40, null
  br i1 %41, label %43, label %42

42:                                               ; preds = %27
  store i32 4, ptr %10, align 4
  br label %104

43:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #5
  store i8 1, ptr %12, align 1, !tbaa !11
  br label %44

44:                                               ; preds = %96, %43
  %45 = load ptr, ptr %11, align 8, !tbaa !9
  %46 = call i32 @getc(ptr noundef %45)
  store i32 %46, ptr %8, align 4, !tbaa !5
  %47 = icmp ne i32 %46, -1
  br i1 %47, label %48, label %97

48:                                               ; preds = %44
  %49 = load i32, ptr %8, align 4, !tbaa !5
  %50 = icmp eq i32 %49, 62
  br i1 %50, label %51, label %52

51:                                               ; preds = %48
  store i8 0, ptr %12, align 1, !tbaa !11
  br label %57

52:                                               ; preds = %48
  %53 = load i32, ptr %8, align 4, !tbaa !5
  %54 = icmp eq i32 %53, 10
  br i1 %54, label %55, label %56

55:                                               ; preds = %52
  store i8 1, ptr %12, align 1, !tbaa !11
  br label %56

56:                                               ; preds = %55, %52
  br label %57

57:                                               ; preds = %56, %51
  %58 = load i8, ptr %12, align 1, !tbaa !11, !range !13, !noundef !14
  %59 = trunc i8 %58 to i1
  br i1 %59, label %60, label %96

60:                                               ; preds = %57
  %61 = load i32, ptr %8, align 4, !tbaa !5
  %62 = icmp eq i32 %61, 65
  br i1 %62, label %63, label %66

63:                                               ; preds = %60
  %64 = load i32, ptr %7, align 4, !tbaa !5
  %65 = mul nsw i32 %64, 4
  store i32 %65, ptr %7, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %63, %60
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = icmp eq i32 %67, 67
  br i1 %68, label %69, label %73

69:                                               ; preds = %66
  %70 = load i32, ptr %7, align 4, !tbaa !5
  %71 = mul nsw i32 %70, 4
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %7, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %69, %66
  %74 = load i32, ptr %8, align 4, !tbaa !5
  %75 = icmp eq i32 %74, 71
  br i1 %75, label %76, label %80

76:                                               ; preds = %73
  %77 = load i32, ptr %7, align 4, !tbaa !5
  %78 = mul nsw i32 %77, 4
  %79 = add nsw i32 %78, 2
  store i32 %79, ptr %7, align 4, !tbaa !5
  br label %80

80:                                               ; preds = %76, %73
  %81 = load i32, ptr %8, align 4, !tbaa !5
  %82 = icmp eq i32 %81, 84
  br i1 %82, label %83, label %87

83:                                               ; preds = %80
  %84 = load i32, ptr %7, align 4, !tbaa !5
  %85 = mul nsw i32 %84, 4
  %86 = add nsw i32 %85, 3
  store i32 %86, ptr %7, align 4, !tbaa !5
  br label %87

87:                                               ; preds = %83, %80
  %88 = load i32, ptr %7, align 4, !tbaa !5
  %89 = icmp sge i32 %88, 256
  br i1 %89, label %90, label %95

90:                                               ; preds = %87
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = and i32 %91, 255
  %93 = load ptr, ptr %6, align 8, !tbaa !9
  %94 = call i32 @putc(i32 noundef %92, ptr noundef %93)
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %95

95:                                               ; preds = %90, %87
  br label %96

96:                                               ; preds = %95, %57
  br label %44, !llvm.loop !15

97:                                               ; preds = %44
  %98 = load ptr, ptr %11, align 8, !tbaa !9
  %99 = icmp ne ptr %98, null
  br i1 %99, label %100, label %103

100:                                              ; preds = %97
  %101 = load ptr, ptr %11, align 8, !tbaa !9
  %102 = call i32 @fclose(ptr noundef %101)
  br label %103

103:                                              ; preds = %100, %97
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #5
  store i32 0, ptr %10, align 4
  br label %104

104:                                              ; preds = %103, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  %105 = load i32, ptr %10, align 4
  switch i32 %105, label %114 [
    i32 0, label %106
    i32 4, label %107
  ]

106:                                              ; preds = %104
  br label %107

107:                                              ; preds = %106, %104
  %108 = load i32, ptr %9, align 4, !tbaa !5
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %9, align 4, !tbaa !5
  br label %22, !llvm.loop !17

110:                                              ; preds = %26
  %111 = load ptr, ptr %6, align 8, !tbaa !9
  %112 = call i32 @fclose(ptr noundef %111)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %113 = load i32, ptr %3, align 4
  ret i32 %113

114:                                              ; preds = %104
  unreachable
}

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

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

declare noalias ptr @fopen(ptr noundef, ptr noundef) #1

declare i32 @getc(ptr noundef) #1

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

declare i32 @fclose(ptr noundef) #1

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

attributes #0 = { mustprogress norecurse 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 = { noreturn 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { noreturn nounwind }
attributes #5 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 [41 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = icmp slt i32 %0, 3
  br i1 %3, label %4, label %6

4:                                                ; preds = %2
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  tail call void @exit(i32 noundef 1) #3
  unreachable

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = tail call noalias ptr @fopen(ptr noundef %8, ptr noundef nonnull @.str.1)
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %12

10:                                               ; preds = %36
  %11 = tail call i32 @fclose(ptr noundef %9)
  ret i32 0

12:                                               ; preds = %6, %36
  %indvars.iv = phi i64 [ 2, %6 ], [ %indvars.iv.next, %36 ]
  %.02940 = phi i32 [ 1, %6 ], [ %.7, %36 ]
  %13 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %14)
  %16 = load ptr, ptr %13, align 8, !tbaa !5
  %17 = tail call noalias ptr @fopen(ptr noundef %16, ptr noundef nonnull @.str.3)
  %.not = icmp eq ptr %17, null
  br i1 %.not, label %36, label %.preheader.outer

.preheader.outer:                                 ; preds = %12, %.preheader.outer.backedge
  %.130.ph = phi i32 [ %.130.ph.be, %.preheader.outer.backedge ], [ %.02940, %12 ]
  %18 = tail call i32 @getc(ptr noundef nonnull %17)
  switch i32 %18, label %.thread [
    i32 -1, label %.loopexit
    i32 62, label %.preheader
  ]

.preheader:                                       ; preds = %.preheader, %.preheader.outer
  %19 = tail call i32 @getc(ptr noundef nonnull %17)
  switch i32 %19, label %.preheader [
    i32 -1, label %.loopexit
    i32 10, label %.thread
  ], !llvm.loop !9

.thread:                                          ; preds = %.preheader, %.preheader.outer
  %.lcssa43 = phi i32 [ %18, %.preheader.outer ], [ %19, %.preheader ]
  %20 = icmp eq i32 %.lcssa43, 65
  %21 = shl nsw i32 %.130.ph, 2
  %spec.select = select i1 %20, i32 %21, i32 %.130.ph
  %22 = icmp eq i32 %.lcssa43, 67
  %23 = shl nsw i32 %spec.select, 2
  %24 = or disjoint i32 %23, 1
  %.3 = select i1 %22, i32 %24, i32 %spec.select
  %25 = icmp eq i32 %.lcssa43, 71
  %26 = shl nsw i32 %.3, 2
  %27 = or disjoint i32 %26, 2
  %.4 = select i1 %25, i32 %27, i32 %.3
  %28 = icmp eq i32 %.lcssa43, 84
  %29 = shl nsw i32 %.4, 2
  %30 = or disjoint i32 %29, 3
  %.5 = select i1 %28, i32 %30, i32 %.4
  %31 = icmp sgt i32 %.5, 255
  br i1 %31, label %32, label %.preheader.outer.backedge

32:                                               ; preds = %.thread
  %33 = and i32 %.5, 255
  %34 = tail call i32 @putc(i32 noundef %33, ptr noundef %9)
  br label %.preheader.outer.backedge

.preheader.outer.backedge:                        ; preds = %32, %.thread
  %.130.ph.be = phi i32 [ %.5, %.thread ], [ 1, %32 ]
  br label %.preheader.outer, !llvm.loop !12

.loopexit:                                        ; preds = %.preheader.outer, %.preheader
  %35 = tail call i32 @fclose(ptr noundef nonnull %17)
  br label %36

36:                                               ; preds = %12, %.loopexit
  %.7 = phi i32 [ %.130.ph, %.loopexit ], [ %.02940, %12 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %10, label %12, !llvm.loop !13
}

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #1

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

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

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

attributes #0 = { mustprogress norecurse 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" }
attributes #2 = { noreturn 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 = { noreturn 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++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.peeled.count", i32 1}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


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