; LLVM IR from lanl/Fierro :: src/EVPFFT/src/command_line_args.ll (ZN15CommandLineArgs18parse_command_lineEiPPc)

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

%struct.option = type { ptr, i32, ptr, i32 }
%struct.CommandLineArgs = type <{ %"class.std::__cxx11::basic_string", i32, [4 x i8], %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", i32, [4 x i8] }>
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@.str = external hidden unnamed_addr constant [14 x i8], align 1
@__const._ZN15CommandLineArgs18parse_command_lineEiPPc.long_opts = external hidden unnamed_addr constant [8 x %struct.option], align 16
@optarg = external global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15CommandLineArgs18parse_command_lineEiPPc(ptr noundef nonnull align 8 dereferenceable(140) %0, i32 noundef %1, ptr noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca [8 x %struct.option], align 16
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store ptr @.str, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 256, ptr %8) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %8, ptr align 16 @__const._ZN15CommandLineArgs18parse_command_lineEiPPc.long_opts, i64 256, i1 false)
  br label %12

12:                                               ; preds = %53, %3
  br label %13

13:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds [8 x %struct.option], ptr %8, i64 0, i64 0
  %17 = call i32 @getopt_long(i32 noundef %14, ptr noundef %15, ptr noundef @.str, ptr noundef %16, ptr noundef null) #5
  store i32 %17, ptr %9, align 4, !tbaa !9
  %18 = load i32, ptr %9, align 4, !tbaa !9
  %19 = icmp eq i32 -1, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %13
  store i32 3, ptr %10, align 4
  br label %51

21:                                               ; preds = %13
  %22 = load i32, ptr %9, align 4, !tbaa !9
  switch i32 %22, label %49 [
    i32 102, label %23
    i32 109, label %27
    i32 101, label %31
    i32 103, label %35
    i32 112, label %39
    i32 117, label %43
    i32 104, label %47
    i32 63, label %48
  ]

23:                                               ; preds = %21
  %24 = load ptr, ptr @optarg, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.CommandLineArgs, ptr %11, i32 0, i32 0
  %26 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %25, ptr noundef %24)
  br label %50

27:                                               ; preds = %21
  %28 = load ptr, ptr @optarg, align 8, !tbaa !5
  %29 = call i32 @atoi(ptr noundef %28) #6
  %30 = getelementptr inbounds %struct.CommandLineArgs, ptr %11, i32 0, i32 1
  store i32 %29, ptr %30, align 8, !tbaa !11
  br label %50

31:                                               ; preds = %21
  %32 = load ptr, ptr @optarg, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.CommandLineArgs, ptr %11, i32 0, i32 3
  %34 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %33, ptr noundef %32)
  br label %50

35:                                               ; preds = %21
  %36 = load ptr, ptr @optarg, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.CommandLineArgs, ptr %11, i32 0, i32 4
  %38 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %37, ptr noundef %36)
  br label %50

39:                                               ; preds = %21
  %40 = load ptr, ptr @optarg, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.CommandLineArgs, ptr %11, i32 0, i32 5
  %42 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %41, ptr noundef %40)
  br label %50

43:                                               ; preds = %21
  %44 = load ptr, ptr @optarg, align 8, !tbaa !5
  %45 = call i32 @atoi(ptr noundef %44) #6
  %46 = getelementptr inbounds %struct.CommandLineArgs, ptr %11, i32 0, i32 6
  store i32 %45, ptr %46, align 8, !tbaa !16
  br label %50

47:                                               ; preds = %21
  call void @_ZN15CommandLineArgs10print_helpEv(ptr noundef nonnull align 8 dereferenceable(140) %11)
  br label %50

48:                                               ; preds = %21
  call void @_ZN15CommandLineArgs10print_helpEv(ptr noundef nonnull align 8 dereferenceable(140) %11)
  br label %50

49:                                               ; preds = %21
  call void @_ZN15CommandLineArgs10print_helpEv(ptr noundef nonnull align 8 dereferenceable(140) %11)
  br label %50

50:                                               ; preds = %49, %48, %47, %43, %39, %35, %31, %27, %23
  store i32 0, ptr %10, align 4
  br label %51

51:                                               ; preds = %50, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  %52 = load i32, ptr %10, align 4
  switch i32 %52, label %55 [
    i32 0, label %53
    i32 3, label %54
  ]

53:                                               ; preds = %51
  br label %12, !llvm.loop !17

54:                                               ; preds = %51
  call void @_ZN15CommandLineArgs14check_cmd_argsEv(ptr noundef nonnull align 8 dereferenceable(140) %11)
  call void @llvm.lifetime.end.p0(i64 256, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void

55:                                               ; preds = %51
  unreachable
}

; 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: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind
declare i32 @getopt_long(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) #0 align 2

; Function Attrs: inlinehint mustprogress nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN15CommandLineArgs10print_helpEv(ptr noundef nonnull align 8 dereferenceable(140)) #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN15CommandLineArgs14check_cmd_argsEv(ptr noundef nonnull align 8 dereferenceable(140)) #0 align 2

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { inlinehint mustprogress nounwind willreturn memory(read) 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 #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

!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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 32}
!12 = !{!"_ZTS15CommandLineArgs", !13, i64 0, !10, i64 32, !13, i64 40, !13, i64 72, !13, i64 104, !10, i64 136}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !14, i64 0, !15, i64 8, !7, i64 16}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!12, !10, i64 136}
!17 = distinct !{!17, !18}
!18 = !{!"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"

%struct.option = type { ptr, i32, ptr, i32 }

@.str = external hidden unnamed_addr constant [14 x i8], align 1
@__const._ZN15CommandLineArgs18parse_command_lineEiPPc.long_opts = external hidden unnamed_addr constant [8 x %struct.option], align 16
@optarg = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15CommandLineArgs18parse_command_lineEiPPc(ptr noundef nonnull align 8 dereferenceable(140) %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 align 2 {
  %4 = alloca [8 x %struct.option], align 16
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %4) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(256) %4, ptr noundef nonnull align 16 dereferenceable(256) @__const._ZN15CommandLineArgs18parse_command_lineEiPPc.long_opts, i64 256, i1 false)
  %5 = getelementptr inbounds i8, ptr %0, i64 136
  %6 = getelementptr inbounds i8, ptr %0, i64 104
  %7 = getelementptr inbounds i8, ptr %0, i64 72
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  br label %10

10:                                               ; preds = %.backedge, %3
  %11 = call i32 @getopt_long(i32 noundef %1, ptr noundef %2, ptr noundef nonnull @.str, ptr noundef nonnull %4, ptr noundef null) #5
  switch i32 %11, label %32 [
    i32 -1, label %33
    i32 102, label %12
    i32 109, label %15
    i32 101, label %18
    i32 103, label %21
    i32 112, label %24
    i32 117, label %27
    i32 104, label %30
    i32 63, label %31
  ]

12:                                               ; preds = %10
  %13 = load ptr, ptr @optarg, align 8, !tbaa !5
  %14 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef %13)
  br label %.backedge

.backedge:                                        ; preds = %12, %15, %18, %21, %24, %27, %30, %31, %32
  br label %10

15:                                               ; preds = %10
  %16 = load ptr, ptr @optarg, align 8, !tbaa !5
  %17 = call i32 @atoi(ptr nocapture noundef %16) #6
  store i32 %17, ptr %9, align 8, !tbaa !9
  br label %.backedge

18:                                               ; preds = %10
  %19 = load ptr, ptr @optarg, align 8, !tbaa !5
  %20 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %8, ptr noundef %19)
  br label %.backedge

21:                                               ; preds = %10
  %22 = load ptr, ptr @optarg, align 8, !tbaa !5
  %23 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %7, ptr noundef %22)
  br label %.backedge

24:                                               ; preds = %10
  %25 = load ptr, ptr @optarg, align 8, !tbaa !5
  %26 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef %25)
  br label %.backedge

27:                                               ; preds = %10
  %28 = load ptr, ptr @optarg, align 8, !tbaa !5
  %29 = call i32 @atoi(ptr nocapture noundef %28) #6
  store i32 %29, ptr %5, align 8, !tbaa !15
  br label %.backedge

30:                                               ; preds = %10
  call void @_ZN15CommandLineArgs10print_helpEv(ptr noundef nonnull align 8 dereferenceable(140) %0)
  br label %.backedge

31:                                               ; preds = %10
  call void @_ZN15CommandLineArgs10print_helpEv(ptr noundef nonnull align 8 dereferenceable(140) %0)
  br label %.backedge

32:                                               ; preds = %10
  call void @_ZN15CommandLineArgs10print_helpEv(ptr noundef nonnull align 8 dereferenceable(140) %0)
  br label %.backedge

33:                                               ; preds = %10
  call void @_ZN15CommandLineArgs14check_cmd_argsEv(ptr noundef nonnull align 8 dereferenceable(140) %0)
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %4) #5
  ret void
}

; 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: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN15CommandLineArgs10print_helpEv(ptr noundef nonnull align 8 dereferenceable(140)) local_unnamed_addr #0 align 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: mustprogress uwtable
declare dso_local void @_ZN15CommandLineArgs14check_cmd_argsEv(ptr noundef nonnull align 8 dereferenceable(140)) local_unnamed_addr #0 align 2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

!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 = !{!10, !14, i64 32}
!10 = !{!"_ZTS15CommandLineArgs", !11, i64 0, !14, i64 32, !11, i64 40, !11, i64 72, !11, i64 104, !14, i64 136}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !12, i64 0, !13, i64 8, !7, i64 16}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!10, !14, i64 136}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopUnrollPass,SROAPass,SimplifyCFGPass