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

@stdout = external global ptr, align 8
@.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 [16 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local 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 i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca [256 x i64], align 16
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca double, align 8
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 512, ptr %6, align 4, !tbaa !5
  %15 = load ptr, ptr @stdout, align 8, !tbaa !9
  %16 = call i32 @setvbuf(ptr noundef %15, ptr noundef null, i32 noundef 2, i64 noundef 512) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %17 = call noalias ptr @fopen(ptr noundef @.str, ptr noundef @.str.1)
  store ptr %17, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2048, ptr %8) #6
  call void @llvm.memset.p0.i64(ptr align 16 %8, i8 0, i64 2048, i1 false)
  %18 = call ptr @llvm.stacksave.p0()
  store ptr %18, ptr %9, align 8
  %19 = alloca i8, i64 512, align 16
  br label %20

20:                                               ; preds = %45, %29, %2
  %21 = load ptr, ptr %7, align 8, !tbaa !9
  %22 = call ptr @fgets(ptr noundef %19, i32 noundef 512, ptr noundef %21)
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %46

24:                                               ; preds = %20
  %25 = getelementptr inbounds i8, ptr %19, i64 0
  %26 = load i8, ptr %25, align 16, !tbaa !11
  %27 = sext i8 %26 to i32
  %28 = icmp eq i32 %27, 62
  br i1 %28, label %29, label %30

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

30:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  store ptr %19, ptr %10, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %35, %30
  %32 = load ptr, ptr %10, align 8, !tbaa !9
  %33 = load i8, ptr %32, align 1, !tbaa !11
  %34 = icmp ne i8 %33, 0
  br i1 %34, label %35, label %45

35:                                               ; preds = %31
  %36 = load ptr, ptr %10, align 8, !tbaa !9
  %37 = load i8, ptr %36, align 1, !tbaa !11
  %38 = sext i8 %37 to i64
  %39 = getelementptr inbounds [256 x i64], ptr %8, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !14
  %41 = add i64 %40, 1
  store i64 %41, ptr %39, align 8, !tbaa !14
  %42 = load ptr, ptr %10, align 8, !tbaa !9
  %43 = getelementptr inbounds i8, ptr %42, i32 1
  store ptr %43, ptr %10, align 8, !tbaa !9
  %44 = load i8, ptr %42, align 1, !tbaa !11
  br label %31, !llvm.loop !16

45:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %20, !llvm.loop !12

46:                                               ; preds = %20
  %47 = load ptr, ptr %7, align 8, !tbaa !9
  %48 = call i32 @fclose(ptr noundef %47)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store i64 0, ptr %11, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  store i64 0, ptr %12, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store i64 0, ptr %13, align 8, !tbaa !14
  %49 = getelementptr inbounds [256 x i64], ptr %8, i64 0, i64 65
  %50 = load i64, ptr %49, align 8, !tbaa !14
  %51 = getelementptr inbounds [256 x i64], ptr %8, i64 0, i64 84
  %52 = load i64, ptr %51, align 16, !tbaa !14
  %53 = add i64 %50, %52
  store i64 %53, ptr %12, align 8, !tbaa !14
  %54 = getelementptr inbounds [256 x i64], ptr %8, i64 0, i64 71
  %55 = load i64, ptr %54, align 8, !tbaa !14
  %56 = getelementptr inbounds [256 x i64], ptr %8, i64 0, i64 67
  %57 = load i64, ptr %56, align 8, !tbaa !14
  %58 = add i64 %55, %57
  store i64 %58, ptr %13, align 8, !tbaa !14
  %59 = load i64, ptr %13, align 8, !tbaa !14
  %60 = load i64, ptr %12, align 8, !tbaa !14
  %61 = add i64 %59, %60
  store i64 %61, ptr %11, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %62 = load i64, ptr %13, align 8, !tbaa !14
  %63 = uitofp i64 %62 to double
  %64 = fmul double %63, 1.000000e+00
  %65 = load i64, ptr %11, align 8, !tbaa !14
  %66 = uitofp i64 %65 to double
  %67 = fmul double %66, 1.000000e+00
  %68 = fdiv double %64, %67
  store double %68, ptr %14, align 8, !tbaa !17
  %69 = load double, ptr %14, align 8, !tbaa !17
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %69)
  store i32 0, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  %71 = load ptr, ptr %9, align 8
  call void @llvm.stackrestore.p0(ptr %71)
  call void @llvm.lifetime.end.p0(i64 2048, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %72 = load i32, ptr %3, align 4
  ret i32 %72
}

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

; Function Attrs: nounwind
declare i32 @setvbuf(ptr noundef, ptr noundef, i32 noundef, i64 noundef) #2

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #5

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #5

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 = { 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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nosync nounwind willreturn }
attributes #6 = { 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 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = distinct !{!16, !13}
!17 = !{!18, !18, i64 0}
!18 = !{!"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"

@stdout = external local_unnamed_addr global ptr, align 8
@.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 [16 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca [256 x i64], align 16
  %4 = load ptr, ptr @stdout, align 8, !tbaa !5
  %5 = tail call i32 @setvbuf(ptr noundef %4, ptr noundef null, i32 noundef 2, i64 noundef 512) #5
  %6 = tail call noalias ptr @fopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1)
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %3) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(2048) %3, i8 0, i64 2048, i1 false)
  %7 = tail call ptr @llvm.stacksave.p0()
  %8 = alloca [512 x i8], align 16
  %9 = call ptr @fgets(ptr noundef nonnull %8, i32 noundef 512, ptr noundef %6)
  %.not15 = icmp eq ptr %9, null
  br i1 %.not15, label %._crit_edge, label %.lr.ph16

.lr.ph16:                                         ; preds = %2, %.backedge
  %10 = load i8, ptr %8, align 16, !tbaa !9
  switch i8 %10, label %.lr.ph [
    i8 62, label %.backedge
    i8 0, label %.backedge
  ]

.backedge:                                        ; preds = %.lr.ph, %.lr.ph16, %.lr.ph16
  %11 = call ptr @fgets(ptr noundef nonnull %8, i32 noundef 512, ptr noundef %6)
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %._crit_edge.loopexit, label %.lr.ph16, !llvm.loop !10

.lr.ph:                                           ; preds = %.lr.ph16, %.lr.ph
  %.014 = phi ptr [ %17, %.lr.ph ], [ %8, %.lr.ph16 ]
  %12 = phi i8 [ %.pr, %.lr.ph ], [ %10, %.lr.ph16 ]
  %13 = sext i8 %12 to i64
  %14 = getelementptr inbounds [256 x i64], ptr %3, i64 0, i64 %13
  %15 = load i64, ptr %14, align 8, !tbaa !12
  %16 = add i64 %15, 1
  store i64 %16, ptr %14, align 8, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %.014, i64 1
  %.pr = load i8, ptr %17, align 1, !tbaa !9
  %.not12 = icmp eq i8 %.pr, 0
  br i1 %.not12, label %.backedge, label %.lr.ph, !llvm.loop !14

._crit_edge.loopexit:                             ; preds = %.backedge
  %.phi.trans.insert = getelementptr inbounds i8, ptr %3, i64 520
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !12
  %.phi.trans.insert17 = getelementptr inbounds i8, ptr %3, i64 672
  %.pre18 = load i64, ptr %.phi.trans.insert17, align 16, !tbaa !12
  %.phi.trans.insert19 = getelementptr inbounds i8, ptr %3, i64 568
  %.pre20 = load i64, ptr %.phi.trans.insert19, align 8, !tbaa !12
  %.phi.trans.insert21 = getelementptr inbounds i8, ptr %3, i64 536
  %.pre22 = load i64, ptr %.phi.trans.insert21, align 8, !tbaa !12
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %2
  %18 = phi i64 [ %.pre22, %._crit_edge.loopexit ], [ 0, %2 ]
  %19 = phi i64 [ %.pre20, %._crit_edge.loopexit ], [ 0, %2 ]
  %20 = phi i64 [ %.pre18, %._crit_edge.loopexit ], [ 0, %2 ]
  %21 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ 0, %2 ]
  %22 = call i32 @fclose(ptr noundef %6)
  %23 = add i64 %20, %21
  %24 = add i64 %18, %19
  %25 = add i64 %23, %24
  %26 = uitofp i64 %24 to double
  %27 = uitofp i64 %25 to double
  %28 = fdiv double %26, %27
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %28)
  call void @llvm.stackrestore.p0(ptr %7)
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %3) #5
  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 noundef i32 @setvbuf(ptr nocapture noundef, ptr noundef, i32 noundef, i64 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 #2

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #4

; 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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #4

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


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