; LLVM IR from conradlee/network-community-benchmark :: comm_algs/louvain/main_convert.ll (Z10parse_argsiPPc)

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

@infile = external dso_local global ptr, align 8
@outfile = external dso_local global ptr, align 8
@type = external dso_local global i32, align 4
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5usagePcS_(ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10parse_argsiPPc(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %77, %2
  %7 = load i32, ptr %5, align 4, !tbaa !5
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = icmp slt i32 %7, %8
  br i1 %9, label %11, label %10

10:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %80

11:                                               ; preds = %6
  %12 = load ptr, ptr %4, align 8, !tbaa !9
  %13 = load i32, ptr %5, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds ptr, ptr %12, i64 %14
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %16, i64 0
  %18 = load i8, ptr %17, align 1, !tbaa !11
  %19 = sext i8 %18 to i32
  %20 = icmp eq i32 %19, 45
  br i1 %20, label %21, label %72

21:                                               ; preds = %11
  %22 = load ptr, ptr %4, align 8, !tbaa !9
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds ptr, ptr %22, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = getelementptr inbounds i8, ptr %26, i64 1
  %28 = load i8, ptr %27, align 1, !tbaa !11
  %29 = sext i8 %28 to i32
  switch i32 %29, label %67 [
    i32 105, label %30
    i32 111, label %48
    i32 119, label %66
  ]

30:                                               ; preds = %21
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = sub nsw i32 %32, 1
  %34 = icmp eq i32 %31, %33
  br i1 %34, label %35, label %39

35:                                               ; preds = %30
  %36 = load ptr, ptr %4, align 8, !tbaa !9
  %37 = getelementptr inbounds ptr, ptr %36, i64 0
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  call void @_Z5usagePcS_(ptr noundef %38, ptr noundef @.str.5)
  br label %39

39:                                               ; preds = %35, %30
  %40 = load ptr, ptr %4, align 8, !tbaa !9
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds ptr, ptr %40, i64 %43
  %45 = load ptr, ptr %44, align 8, !tbaa !9
  store ptr %45, ptr @infile, align 8, !tbaa !9
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %5, align 4, !tbaa !5
  br label %71

48:                                               ; preds = %21
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = sub nsw i32 %50, 1
  %52 = icmp eq i32 %49, %51
  br i1 %52, label %53, label %57

53:                                               ; preds = %48
  %54 = load ptr, ptr %4, align 8, !tbaa !9
  %55 = getelementptr inbounds ptr, ptr %54, i64 0
  %56 = load ptr, ptr %55, align 8, !tbaa !9
  call void @_Z5usagePcS_(ptr noundef %56, ptr noundef @.str.6)
  br label %57

57:                                               ; preds = %53, %48
  %58 = load ptr, ptr %4, align 8, !tbaa !9
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds ptr, ptr %58, i64 %61
  %63 = load ptr, ptr %62, align 8, !tbaa !9
  store ptr %63, ptr @outfile, align 8, !tbaa !9
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %5, align 4, !tbaa !5
  br label %71

66:                                               ; preds = %21
  store i32 0, ptr @type, align 4, !tbaa !5
  br label %71

67:                                               ; preds = %21
  %68 = load ptr, ptr %4, align 8, !tbaa !9
  %69 = getelementptr inbounds ptr, ptr %68, i64 0
  %70 = load ptr, ptr %69, align 8, !tbaa !9
  call void @_Z5usagePcS_(ptr noundef %70, ptr noundef @.str.7)
  br label %71

71:                                               ; preds = %67, %66, %57, %39
  br label %76

72:                                               ; preds = %11
  %73 = load ptr, ptr %4, align 8, !tbaa !9
  %74 = getelementptr inbounds ptr, ptr %73, i64 0
  %75 = load ptr, ptr %74, align 8, !tbaa !9
  call void @_Z5usagePcS_(ptr noundef %75, ptr noundef @.str.8)
  br label %76

76:                                               ; preds = %72, %71
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %5, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %5, align 4, !tbaa !5
  br label %6, !llvm.loop !12

80:                                               ; preds = %10
  %81 = load ptr, ptr @infile, align 8, !tbaa !9
  %82 = icmp eq ptr %81, null
  br i1 %82, label %86, label %83

83:                                               ; preds = %80
  %84 = load ptr, ptr @outfile, align 8, !tbaa !9
  %85 = icmp eq ptr %84, null
  br i1 %85, label %86, label %90

86:                                               ; preds = %83, %80
  %87 = load ptr, ptr %4, align 8, !tbaa !9
  %88 = getelementptr inbounds ptr, ptr %87, i64 0
  %89 = load ptr, ptr %88, align 8, !tbaa !9
  call void @_Z5usagePcS_(ptr noundef %89, ptr noundef @.str.9)
  br label %90

90:                                               ; preds = %86, %83
  ret void
}

; 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

attributes #0 = { mustprogress 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 }

!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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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

@infile = external dso_local local_unnamed_addr global ptr, align 8
@outfile = external dso_local local_unnamed_addr global ptr, align 8
@type = external dso_local local_unnamed_addr global i32, align 4
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5usagePcS_(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10parse_argsiPPc(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = icmp sgt i32 %0, 1
  br i1 %3, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %4 = add nsw i32 %0, -1
  br label %9

._crit_edge:                                      ; preds = %41, %2
  %5 = load ptr, ptr @infile, align 8, !tbaa !5
  %6 = icmp eq ptr %5, null
  %7 = load ptr, ptr @outfile, align 8
  %8 = icmp eq ptr %7, null
  %or.cond = select i1 %6, i1 true, i1 %8
  br i1 %or.cond, label %44, label %46

9:                                                ; preds = %.lr.ph, %41
  %.023 = phi i32 [ 1, %.lr.ph ], [ %42, %41 ]
  %10 = sext i32 %.023 to i64
  %11 = getelementptr inbounds ptr, ptr %1, i64 %10
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = load i8, ptr %12, align 1, !tbaa !9
  %14 = icmp eq i8 %13, 45
  br i1 %14, label %15, label %39

15:                                               ; preds = %9
  %16 = getelementptr inbounds i8, ptr %12, i64 1
  %17 = load i8, ptr %16, align 1, !tbaa !9
  switch i8 %17, label %37 [
    i8 105, label %18
    i8 111, label %27
    i8 119, label %36
  ]

18:                                               ; preds = %15
  %19 = icmp eq i32 %.023, %4
  br i1 %19, label %20, label %22

20:                                               ; preds = %18
  %21 = load ptr, ptr %1, align 8, !tbaa !5
  tail call void @_Z5usagePcS_(ptr noundef %21, ptr noundef nonnull @.str.5)
  br label %22

22:                                               ; preds = %20, %18
  %23 = add nsw i32 %.023, 1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds ptr, ptr %1, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  store ptr %26, ptr @infile, align 8, !tbaa !5
  br label %41

27:                                               ; preds = %15
  %28 = icmp eq i32 %.023, %4
  br i1 %28, label %29, label %31

29:                                               ; preds = %27
  %30 = load ptr, ptr %1, align 8, !tbaa !5
  tail call void @_Z5usagePcS_(ptr noundef %30, ptr noundef nonnull @.str.6)
  br label %31

31:                                               ; preds = %29, %27
  %32 = add nsw i32 %.023, 1
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds ptr, ptr %1, i64 %33
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  store ptr %35, ptr @outfile, align 8, !tbaa !5
  br label %41

36:                                               ; preds = %15
  store i32 0, ptr @type, align 4, !tbaa !10
  br label %41

37:                                               ; preds = %15
  %38 = load ptr, ptr %1, align 8, !tbaa !5
  tail call void @_Z5usagePcS_(ptr noundef %38, ptr noundef nonnull @.str.7)
  br label %41

39:                                               ; preds = %9
  %40 = load ptr, ptr %1, align 8, !tbaa !5
  tail call void @_Z5usagePcS_(ptr noundef %40, ptr noundef nonnull @.str.8)
  br label %41

41:                                               ; preds = %39, %37, %36, %31, %22
  %.1 = phi i32 [ %.023, %37 ], [ %.023, %36 ], [ %32, %31 ], [ %23, %22 ], [ %.023, %39 ]
  %42 = add nsw i32 %.1, 1
  %43 = icmp slt i32 %42, %0
  br i1 %43, label %9, label %._crit_edge, !llvm.loop !12

44:                                               ; preds = %._crit_edge
  %45 = load ptr, ptr %1, align 8, !tbaa !5
  tail call void @_Z5usagePcS_(ptr noundef %45, ptr noundef nonnull @.str.9)
  br label %46

46:                                               ; preds = %._crit_edge, %44
  ret void
}

attributes #0 = { mustprogress 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" }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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