; LLVM IR from Aeternum-Veritas/Merry :: childmain (merry_main_parse_options)

; 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.MerryCLP = type { i8, i8, i8, ptr, ptr, i8, ptr, i64, i8, ptr }

@stdout = external global ptr, align 8
@cmd_opts = external hidden global ptr, align 8
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @merry_main_parse_options(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %6 = load i32, ptr %4, align 4, !tbaa !5
  %7 = load ptr, ptr %5, align 8, !tbaa !9
  %8 = call ptr @merry_parse_options(i32 noundef %6, ptr noundef %7, i8 noundef zeroext 0)
  store ptr %8, ptr @cmd_opts, align 8, !tbaa !9
  %9 = load ptr, ptr @cmd_opts, align 8, !tbaa !9
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %14

11:                                               ; preds = %2
  %12 = load ptr, ptr @stderr, align 8, !tbaa !9
  %13 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef @.str.1) #3
  store i8 1, ptr %3, align 1
  br label %47

14:                                               ; preds = %2
  %15 = load ptr, ptr @cmd_opts, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.MerryCLP, ptr %15, i32 0, i32 0
  %17 = load i8, ptr %16, align 8, !tbaa !11
  %18 = zext i8 %17 to i32
  %19 = icmp eq i32 %18, 1
  br i1 %19, label %20, label %21

20:                                               ; preds = %14
  call void (...) @merry_print_help()
  call void @merry_cleanup_and_exit(i64 noundef 0)
  br label %21

21:                                               ; preds = %20, %14
  %22 = load ptr, ptr @cmd_opts, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct.MerryCLP, ptr %22, i32 0, i32 1
  %24 = load i8, ptr %23, align 1, !tbaa !14
  %25 = zext i8 %24 to i32
  %26 = icmp eq i32 %25, 1
  br i1 %26, label %27, label %30

27:                                               ; preds = %21
  %28 = load ptr, ptr @stdout, align 8, !tbaa !9
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str.2, i32 noundef 10001, ptr noundef @.str.3) #3
  call void @merry_cleanup_and_exit(i64 noundef 0)
  br label %30

30:                                               ; preds = %27, %21
  %31 = load ptr, ptr @cmd_opts, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.MerryCLP, ptr %31, i32 0, i32 3
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  %34 = icmp eq ptr %33, null
  br i1 %34, label %35, label %38

35:                                               ; preds = %30
  %36 = load ptr, ptr @stderr, align 8, !tbaa !9
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef @.str.4) #3
  call void (...) @merry_print_help()
  br label %44

38:                                               ; preds = %30
  %39 = load ptr, ptr @stdout, align 8, !tbaa !9
  %40 = load ptr, ptr @cmd_opts, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.MerryCLP, ptr %40, i32 0, i32 3
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  %43 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef @.str.5, ptr noundef @.str.6, ptr noundef %42, ptr noundef @.str.7) #3
  br label %46

44:                                               ; preds = %35
  %45 = load ptr, ptr @cmd_opts, align 8, !tbaa !9
  call void @merry_destroy_parser(ptr noundef %45)
  store i8 1, ptr %3, align 1
  br label %47

46:                                               ; preds = %38
  store i8 0, ptr %3, align 1
  br label %47

47:                                               ; preds = %46, %44, %11
  %48 = load i8, ptr %3, align 1
  ret i8 %48
}

; Function Attrs: nounwind uwtable
declare dso_local void @merry_cleanup_and_exit(i64 noundef) #1

declare ptr @merry_parse_options(i32 noundef, ptr noundef, i8 noundef zeroext) #2

declare void @merry_print_help(...) #2

declare void @merry_destroy_parser(ptr noundef) #2

attributes #0 = { 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 #1 = { 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 #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 = { 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 = !{!12, !7, i64 0}
!12 = !{!"MerryCLP", !7, i64 0, !7, i64 1, !7, i64 2, !10, i64 8, !10, i64 16, !7, i64 24, !10, i64 32, !13, i64 40, !7, i64 48, !10, i64 56}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !7, i64 1}
!15 = !{!12, !10, i64 8}


; 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
@cmd_opts = external hidden local_unnamed_addr global ptr, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [5 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @merry_main_parse_options(i32 noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = tail call ptr @merry_parse_options(i32 noundef %0, ptr noundef %1, i8 noundef zeroext 0) #3
  store ptr %3, ptr @cmd_opts, align 8, !tbaa !5
  %4 = icmp eq ptr %3, null
  br i1 %4, label %5, label %8

5:                                                ; preds = %2
  %6 = load ptr, ptr @stderr, align 8, !tbaa !5
  %7 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef nonnull @.str.1) #4
  br label %32

8:                                                ; preds = %2
  %9 = load i8, ptr %3, align 8, !tbaa !9
  %10 = icmp eq i8 %9, 1
  br i1 %10, label %11, label %12

11:                                               ; preds = %8
  tail call void (...) @merry_print_help() #3
  tail call void @merry_cleanup_and_exit(i64 noundef 0)
  %.pre = load ptr, ptr @cmd_opts, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %11, %8
  %13 = phi ptr [ %.pre, %11 ], [ %3, %8 ]
  %14 = getelementptr inbounds i8, ptr %13, i64 1
  %15 = load i8, ptr %14, align 1, !tbaa !12
  %16 = icmp eq i8 %15, 1
  br i1 %16, label %17, label %20

17:                                               ; preds = %12
  %18 = load ptr, ptr @stdout, align 8, !tbaa !5
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.2, i32 noundef 10001, ptr noundef nonnull @.str.3) #3
  tail call void @merry_cleanup_and_exit(i64 noundef 0)
  %.pre4 = load ptr, ptr @cmd_opts, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %17, %12
  %21 = phi ptr [ %.pre4, %17 ], [ %13, %12 ]
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %29

25:                                               ; preds = %20
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef nonnull @.str.4) #4
  tail call void (...) @merry_print_help() #3
  %28 = load ptr, ptr @cmd_opts, align 8, !tbaa !5
  tail call void @merry_destroy_parser(ptr noundef %28) #3
  br label %32

29:                                               ; preds = %20
  %30 = load ptr, ptr @stdout, align 8, !tbaa !5
  %31 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, ptr noundef nonnull %23, ptr noundef nonnull @.str.7) #3
  br label %32

32:                                               ; preds = %29, %25, %5
  %.0 = phi i8 [ 1, %5 ], [ 1, %25 ], [ 0, %29 ]
  ret i8 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local void @merry_cleanup_and_exit(i64 noundef) local_unnamed_addr #1

declare ptr @merry_parse_options(i32 noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #2

declare void @merry_print_help(...) local_unnamed_addr #2

declare void @merry_destroy_parser(ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { 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 #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 = { nounwind }
attributes #4 = { cold 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, !7, i64 0}
!10 = !{!"MerryCLP", !7, i64 0, !7, i64 1, !7, i64 2, !6, i64 8, !6, i64 16, !7, i64 24, !6, i64 32, !11, i64 40, !7, i64 48, !6, i64 56}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !7, i64 1}
!13 = !{!10, !6, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass