; LLVM IR from samuell/gccontent-benchmark :: c.001 (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"

@value = external dso_local global [256 x i64], align 16
@.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 [22 x i8], align 1
@.str.3 = 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 ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca [4096 x i8], align 16
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %10 = call noalias ptr @fopen(ptr noundef @.str, ptr noundef @.str.1)
  store ptr %10, ptr %2, align 8, !tbaa !5
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %0
  call void @perror(ptr noundef @.str.2)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %62

14:                                               ; preds = %0
  store i64 1, ptr getelementptr inbounds ([256 x i64], ptr @value, i64 0, i64 84), align 16, !tbaa !9
  store i64 1, ptr getelementptr inbounds ([256 x i64], ptr @value, i64 0, i64 65), align 8, !tbaa !9
  store i64 4294967296, ptr getelementptr inbounds ([256 x i64], ptr @value, i64 0, i64 67), align 8, !tbaa !9
  store i64 4294967296, ptr getelementptr inbounds ([256 x i64], ptr @value, i64 0, i64 71), align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 0, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4096, ptr %5) #4
  br label %15

15:                                               ; preds = %45, %29, %14
  %16 = getelementptr inbounds [4096 x i8], ptr %5, i64 0, i64 0
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = call ptr @fgets(ptr noundef %16, i32 noundef 4096, ptr noundef %17)
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %46

20:                                               ; preds = %15
  %21 = getelementptr inbounds [4096 x i8], ptr %5, i64 0, i64 0
  %22 = load i8, ptr %21, align 16, !tbaa !11
  %23 = sext i8 %22 to i32
  %24 = icmp eq i32 %23, 62
  %25 = zext i1 %24 to i32
  %26 = sext i32 %25 to i64
  %27 = call i64 @llvm.expect.i64(i64 %26, i64 0)
  %28 = icmp ne i64 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %20
  br label %15, !llvm.loop !12

30:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %31 = getelementptr inbounds [4096 x i8], ptr %5, i64 0, i64 0
  store ptr %31, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #4
  br label %32

32:                                               ; preds = %38, %30
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %33, i32 1
  store ptr %34, ptr %6, align 8, !tbaa !5
  %35 = load i8, ptr %33, align 1, !tbaa !11
  store i8 %35, ptr %7, align 1, !tbaa !11
  %36 = zext i8 %35 to i32
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %45

38:                                               ; preds = %32
  %39 = load i8, ptr %7, align 1, !tbaa !11
  %40 = zext i8 %39 to i64
  %41 = getelementptr inbounds [256 x i64], ptr @value, i64 0, i64 %40
  %42 = load i64, ptr %41, align 8, !tbaa !9
  %43 = load i64, ptr %4, align 8, !tbaa !9
  %44 = add i64 %43, %42
  store i64 %44, ptr %4, align 8, !tbaa !9
  br label %32, !llvm.loop !14

45:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %15, !llvm.loop !12

46:                                               ; preds = %15
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = call i32 @fclose(ptr noundef %47)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %49 = load i64, ptr %4, align 8, !tbaa !9
  %50 = and i64 %49, 4294967295
  %51 = uitofp i64 %50 to double
  store double %51, ptr %8, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %52 = load i64, ptr %4, align 8, !tbaa !9
  %53 = lshr i64 %52, 32
  %54 = uitofp i64 %53 to double
  store double %54, ptr %9, align 8, !tbaa !15
  %55 = load double, ptr %9, align 8, !tbaa !15
  %56 = load double, ptr %8, align 8, !tbaa !15
  %57 = load double, ptr %9, align 8, !tbaa !15
  %58 = fadd double %56, %57
  %59 = fdiv double %55, %58
  %60 = fmul double %59, 1.000000e+02
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, double noundef %60)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4096, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %62

62:                                               ; preds = %46, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  %63 = load i32, ptr %1, align 4
  ret i32 %63
}

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

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

declare void @perror(ptr noundef) #2

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #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) #2

declare i32 @printf(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 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 = !{!"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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !7, i64 0}


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

@value = external dso_local local_unnamed_addr global [256 x i64], align 16
@.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 [22 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 0, 2) i32 @main() local_unnamed_addr #0 {
  %1 = alloca [4096 x i8], align 16
  %2 = tail call noalias ptr @fopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1)
  %3 = icmp eq ptr %2, null
  br i1 %3, label %4, label %5

4:                                                ; preds = %0
  tail call void @perror(ptr noundef nonnull @.str.2) #3
  br label %26

5:                                                ; preds = %0
  store i64 1, ptr getelementptr inbounds (i8, ptr @value, i64 672), align 16, !tbaa !5
  store i64 1, ptr getelementptr inbounds (i8, ptr @value, i64 520), align 8, !tbaa !5
  store i64 4294967296, ptr getelementptr inbounds (i8, ptr @value, i64 536), align 8, !tbaa !5
  store i64 4294967296, ptr getelementptr inbounds (i8, ptr @value, i64 568), align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %1) #4
  br label %.outer.outer

.outer.outer:                                     ; preds = %.lr.ph, %5
  %.011.ph.ph = phi i64 [ 0, %5 ], [ %15, %.lr.ph ]
  br label %.outer

.outer:                                           ; preds = %8, %.outer.outer
  br label %6

6:                                                ; preds = %8, %.outer
  %7 = call ptr @fgets(ptr noundef nonnull %1, i32 noundef 4096, ptr noundef nonnull %2)
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %16, label %8

8:                                                ; preds = %6
  %9 = load i8, ptr %1, align 16, !tbaa !9
  switch i8 %9, label %.lr.ph [
    i8 62, label %6
    i8 0, label %.outer
  ], !prof !10

.lr.ph:                                           ; preds = %8, %.lr.ph
  %.117 = phi i64 [ %15, %.lr.ph ], [ %.011.ph.ph, %8 ]
  %.01216 = phi ptr [ %11, %.lr.ph ], [ %1, %8 ]
  %10 = phi i8 [ %.pr, %.lr.ph ], [ %9, %8 ]
  %11 = getelementptr inbounds i8, ptr %.01216, i64 1
  %12 = zext i8 %10 to i64
  %13 = getelementptr inbounds [256 x i64], ptr @value, i64 0, i64 %12
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %15 = add i64 %14, %.117
  %.pr = load i8, ptr %11, align 1, !tbaa !9
  %.not14 = icmp eq i8 %.pr, 0
  br i1 %.not14, label %.outer.outer, label %.lr.ph, !llvm.loop !11

16:                                               ; preds = %6
  %17 = call i32 @fclose(ptr noundef nonnull %2)
  %18 = and i64 %.011.ph.ph, 4294967295
  %19 = lshr i64 %.011.ph.ph, 32
  %20 = uitofp nneg i64 %19 to double
  %21 = add nuw nsw i64 %18, %19
  %22 = uitofp nneg i64 %21 to double
  %23 = fdiv double %20, %22
  %24 = fmul double %23, 1.000000e+02
  %25 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, double noundef %24)
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %1) #4
  br label %26

26:                                               ; preds = %16, %4
  %.0 = phi i32 [ 1, %4 ], [ 0, %16 ]
  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: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare void @perror(ptr nocapture noundef readonly) local_unnamed_addr #2

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

; 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 #2

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

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 = { 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 = { cold }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!"branch_weights", i32 2000, i32 2, i32 2000}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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