; LLVM IR from samuell/gccontent-benchmark :: c (gc)

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [1000 x i8], align 16
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca [256 x i8], align 16
  %6 = alloca [256 x i8], align 16
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 1000, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 256, ptr %5) #4
  call void @llvm.memset.p0.i64(ptr align 16 %5, i8 0, i64 256, i1 false)
  call void @llvm.lifetime.start.p0(i64 256, ptr %6) #4
  call void @llvm.memset.p0.i64(ptr align 16 %6, i8 0, i64 256, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %10 = call noalias ptr @fopen(ptr noundef @.str, ptr noundef @.str.1)
  store ptr %10, ptr %7, align 8, !tbaa !9
  %11 = getelementptr inbounds [256 x i8], ptr %6, i64 0, i64 65
  store i8 1, ptr %11, align 1, !tbaa !11
  %12 = getelementptr inbounds [256 x i8], ptr %6, i64 0, i64 84
  store i8 1, ptr %12, align 4, !tbaa !11
  %13 = getelementptr inbounds [256 x i8], ptr %6, i64 0, i64 67
  store i8 1, ptr %13, align 1, !tbaa !11
  %14 = getelementptr inbounds [256 x i8], ptr %6, i64 0, i64 71
  store i8 1, ptr %14, align 1, !tbaa !11
  %15 = getelementptr inbounds [256 x i8], ptr %5, i64 0, i64 67
  store i8 1, ptr %15, align 1, !tbaa !11
  %16 = getelementptr inbounds [256 x i8], ptr %5, i64 0, i64 71
  store i8 1, ptr %16, align 1, !tbaa !11
  br label %17

17:                                               ; preds = %52, %0
  %18 = getelementptr inbounds [1000 x i8], ptr %2, i64 0, i64 0
  %19 = load ptr, ptr %7, align 8, !tbaa !9
  %20 = call ptr @fgets(ptr noundef %18, i32 noundef 1000, ptr noundef %19)
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %53

22:                                               ; preds = %17
  %23 = getelementptr inbounds [1000 x i8], ptr %2, i64 0, i64 0
  %24 = load i8, ptr %23, align 16, !tbaa !11
  %25 = sext i8 %24 to i32
  %26 = icmp ne i32 %25, 62
  br i1 %26, label %27, label %52

27:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %28 = getelementptr inbounds [1000 x i8], ptr %2, i64 0, i64 0
  store ptr %28, ptr %9, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %34, %27
  %30 = load ptr, ptr %9, align 8, !tbaa !9
  %31 = getelementptr inbounds i8, ptr %30, i32 1
  store ptr %31, ptr %9, align 8, !tbaa !9
  %32 = load i8, ptr %30, align 1, !tbaa !11
  store i8 %32, ptr %8, align 1, !tbaa !11
  %33 = icmp ne i8 %32, 0
  br i1 %33, label %34, label %51

34:                                               ; preds = %29
  %35 = load i8, ptr %8, align 1, !tbaa !11
  %36 = sext i8 %35 to i32
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [256 x i8], ptr %6, i64 0, i64 %37
  %39 = load i8, ptr %38, align 1, !tbaa !11
  %40 = sext i8 %39 to i32
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = add nsw i32 %41, %40
  store i32 %42, ptr %4, align 4, !tbaa !5
  %43 = load i8, ptr %8, align 1, !tbaa !11
  %44 = sext i8 %43 to i32
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [256 x i8], ptr %5, i64 0, i64 %45
  %47 = load i8, ptr %46, align 1, !tbaa !11
  %48 = sext i8 %47 to i32
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = add nsw i32 %49, %48
  store i32 %50, ptr %3, align 4, !tbaa !5
  br label %29, !llvm.loop !12

51:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  br label %52

52:                                               ; preds = %51, %22
  br label %17, !llvm.loop !14

53:                                               ; preds = %17
  %54 = load ptr, ptr %7, align 8, !tbaa !9
  %55 = call i32 @fclose(ptr noundef %54)
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = sitofp i32 %56 to double
  %58 = fmul double 1.000000e+02, %57
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = sitofp i32 %59 to double
  %61 = fdiv double %58, %60
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %61)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 256, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 256, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 1000, ptr %2) #4
  ret i32 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

declare ptr @fgets(ptr noundef, i32 noundef, ptr noundef) #3

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

declare i32 @fclose(ptr noundef) #3

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

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 #4 = { 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 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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

; Function Attrs: nofree nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [1000 x i8], align 16
  %2 = alloca [256 x i8], align 16
  %3 = alloca [256 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 1000, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %2) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(256) %2, i8 0, i64 256, i1 false)
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %3) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(256) %3, i8 0, i64 256, i1 false)
  %4 = tail call noalias ptr @fopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1)
  %5 = getelementptr inbounds i8, ptr %3, i64 65
  store i8 1, ptr %5, align 1, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %3, i64 84
  store i8 1, ptr %6, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %3, i64 67
  store i8 1, ptr %7, align 1, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %3, i64 71
  store i8 1, ptr %8, align 1, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %2, i64 67
  store i8 1, ptr %9, align 1, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %2, i64 71
  store i8 1, ptr %10, align 1, !tbaa !5
  %11 = call ptr @fgets(ptr noundef nonnull %1, i32 noundef 1000, ptr noundef %4)
  %.not20 = icmp eq ptr %11, null
  br i1 %.not20, label %._crit_edge, label %.lr.ph23

.lr.ph23:                                         ; preds = %0, %.loopexit
  %.0822 = phi i32 [ %.2, %.loopexit ], [ 0, %0 ]
  %.0921 = phi i32 [ %.211, %.loopexit ], [ 0, %0 ]
  %12 = load i8, ptr %1, align 16, !tbaa !5
  switch i8 %12, label %.lr.ph [
    i8 62, label %.loopexit
    i8 0, label %.loopexit
  ]

.lr.ph:                                           ; preds = %.lr.ph23, %.lr.ph
  %.018 = phi ptr [ %14, %.lr.ph ], [ %1, %.lr.ph23 ]
  %.117 = phi i32 [ %23, %.lr.ph ], [ %.0822, %.lr.ph23 ]
  %.11016 = phi i32 [ %19, %.lr.ph ], [ %.0921, %.lr.ph23 ]
  %13 = phi i8 [ %.pr, %.lr.ph ], [ %12, %.lr.ph23 ]
  %14 = getelementptr inbounds i8, ptr %.018, i64 1
  %15 = sext i8 %13 to i64
  %16 = getelementptr inbounds [256 x i8], ptr %3, i64 0, i64 %15
  %17 = load i8, ptr %16, align 1, !tbaa !5
  %18 = sext i8 %17 to i32
  %19 = add nsw i32 %.11016, %18
  %20 = getelementptr inbounds [256 x i8], ptr %2, i64 0, i64 %15
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %22 = sext i8 %21 to i32
  %23 = add nsw i32 %.117, %22
  %.pr = load i8, ptr %14, align 1, !tbaa !5
  %.not14 = icmp eq i8 %.pr, 0
  br i1 %.not14, label %.loopexit, label %.lr.ph, !llvm.loop !8

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph23, %.lr.ph23
  %.211 = phi i32 [ %.0921, %.lr.ph23 ], [ %.0921, %.lr.ph23 ], [ %19, %.lr.ph ]
  %.2 = phi i32 [ %.0822, %.lr.ph23 ], [ %.0822, %.lr.ph23 ], [ %23, %.lr.ph ]
  %24 = call ptr @fgets(ptr noundef nonnull %1, i32 noundef 1000, ptr noundef %4)
  %.not = icmp eq ptr %24, null
  br i1 %.not, label %._crit_edge.loopexit, label %.lr.ph23, !llvm.loop !10

._crit_edge.loopexit:                             ; preds = %.loopexit
  %25 = sitofp i32 %.2 to double
  %26 = fmul double %25, 1.000000e+02
  %27 = sitofp i32 %.211 to double
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %0
  %.09.lcssa = phi double [ 0.000000e+00, %0 ], [ %27, %._crit_edge.loopexit ]
  %.08.lcssa = phi double [ 0.000000e+00, %0 ], [ %26, %._crit_edge.loopexit ]
  %28 = call i32 @fclose(ptr noundef %4)
  %29 = fdiv double %.08.lcssa, %.09.lcssa
  %30 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %29)
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 1000, ptr nonnull %1) #4
  ret i32 0
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

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

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

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

attributes #0 = { nofree 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


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