; LLVM IR from Aeternum-Veritas/Merry :: merry (merry_nreader)

; 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.MerryReader = type { i8, i8, i8, i8, %struct.MerryInstSection, %struct.MerryEAT, %struct.MerrySsT, %struct.MerryST, ptr, [2 x i64], i64, i64, ptr, i64, ptr, i64, ptr, ptr, ptr, ptr, i64, i64 }
%struct.MerryInstSection = type { i64, ptr, i64, i64 }
%struct.MerryEAT = type { ptr, i64, i64 }
%struct.MerrySsT = type { i64, i64, ptr, i8 }
%struct.MerryST = type { ptr, i64 }

@stdout = external global ptr, align 8
@stderr = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [40 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_reader_read_file(ptr noundef %0) #1 {
  %2 = alloca i8, align 1
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  br label %4

4:                                                ; preds = %1
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = icmp ne ptr %5, null
  %7 = xor i1 %6, true
  %8 = zext i1 %7 to i32
  %9 = sext i32 %8 to i64
  %10 = inttoptr i64 %9 to ptr
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %17

12:                                               ; preds = %4
  br label %13

13:                                               ; preds = %12
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef @.str.4, ptr noundef @.str.5, ptr noundef @.str.6, i32 noundef 120, ptr noundef @.str.7, ptr noundef @.str.8, ptr noundef @.str.6) #2
  br label %16

16:                                               ; preds = %13
  br label %17

17:                                               ; preds = %16, %4
  br label %18

18:                                               ; preds = %17
  %19 = load ptr, ptr @stdout, align 8, !tbaa !5
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str.9, ptr noundef null) #2
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = call zeroext i8 @merry_reader_is_file_fit_to_read(ptr noundef %21)
  %23 = zext i8 %22 to i32
  %24 = icmp eq i32 %23, 1
  br i1 %24, label %25, label %26

25:                                               ; preds = %18
  store i8 1, ptr %2, align 1
  br label %95

26:                                               ; preds = %18
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = call zeroext i8 @merry_reader_read_header(ptr noundef %27)
  %29 = zext i8 %28 to i32
  %30 = icmp eq i32 %29, 1
  br i1 %30, label %31, label %32

31:                                               ; preds = %26
  store i8 1, ptr %2, align 1
  br label %95

32:                                               ; preds = %26
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = call zeroext i8 @merry_reader_validate_header_info(ptr noundef %33)
  %35 = zext i8 %34 to i32
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %37, label %38

37:                                               ; preds = %32
  store i8 1, ptr %2, align 1
  br label %95

38:                                               ; preds = %32
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = call zeroext i8 @merry_reader_read_eat(ptr noundef %39)
  %41 = zext i8 %40 to i32
  %42 = icmp eq i32 %41, 1
  br i1 %42, label %43, label %44

43:                                               ; preds = %38
  store i8 1, ptr %2, align 1
  br label %95

44:                                               ; preds = %38
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = call zeroext i8 @merry_reader_read_instructions(ptr noundef %45)
  %47 = zext i8 %46 to i32
  %48 = icmp eq i32 %47, 1
  br i1 %48, label %49, label %50

49:                                               ; preds = %44
  br label %93

50:                                               ; preds = %44
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.MerryReader, ptr %51, i32 0, i32 6
  %53 = getelementptr inbounds %struct.MerrySsT, ptr %52, i32 0, i32 0
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = icmp ne i64 %54, 0
  br i1 %55, label %56, label %62

56:                                               ; preds = %50
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = call zeroext i8 @merry_reader_read_sst(ptr noundef %57)
  %59 = zext i8 %58 to i32
  %60 = icmp eq i32 %59, 1
  br i1 %60, label %61, label %62

61:                                               ; preds = %56
  br label %93

62:                                               ; preds = %56, %50
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.MerryReader, ptr %63, i32 0, i32 6
  %65 = getelementptr inbounds %struct.MerrySsT, ptr %64, i32 0, i32 0
  %66 = load i64, ptr %65, align 8, !tbaa !9
  %67 = icmp ne i64 %66, 0
  br i1 %67, label %68, label %74

68:                                               ; preds = %62
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = call zeroext i8 @merry_reader_read_sections(ptr noundef %69)
  %71 = zext i8 %70 to i32
  %72 = icmp eq i32 %71, 1
  br i1 %72, label %73, label %74

73:                                               ; preds = %68
  br label %93

74:                                               ; preds = %68, %62
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.MerryReader, ptr %75, i32 0, i32 1
  %77 = load i8, ptr %76, align 1, !tbaa !16
  %78 = zext i8 %77 to i32
  %79 = icmp eq i32 %78, 1
  br i1 %79, label %80, label %92

80:                                               ; preds = %74
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.MerryReader, ptr %81, i32 0, i32 7
  %83 = getelementptr inbounds %struct.MerryST, ptr %82, i32 0, i32 1
  %84 = load i64, ptr %83, align 8, !tbaa !17
  %85 = icmp ugt i64 %84, 0
  br i1 %85, label %86, label %92

86:                                               ; preds = %80
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = call zeroext i8 @merry_reader_read_st(ptr noundef %87)
  %89 = zext i8 %88 to i32
  %90 = icmp eq i32 %89, 1
  br i1 %90, label %91, label %92

91:                                               ; preds = %86
  br label %93

92:                                               ; preds = %86, %80, %74
  store i8 0, ptr %2, align 1
  br label %95

93:                                               ; preds = %91, %73, %61, %49
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  call void @merry_reader_return_all_mem(ptr noundef %94)
  store i8 1, ptr %2, align 1
  br label %95

95:                                               ; preds = %93, %92, %43, %37, %31, %25
  %96 = load i8, ptr %2, align 1
  ret i8 %96
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_is_file_fit_to_read(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_read_header(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_validate_header_info(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_read_eat(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_read_instructions(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_read_sst(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_read_sections(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_read_st(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @merry_reader_return_all_mem(ptr noundef) #1

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 = { 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, !12, i64 64}
!10 = !{!"MerryReader", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !11, i64 8, !13, i64 40, !14, i64 64, !15, i64 96, !6, i64 112, !7, i64 120, !12, i64 136, !12, i64 144, !6, i64 152, !12, i64 160, !6, i64 168, !12, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !12, i64 216, !12, i64 224}
!11 = !{!"MerryInstSection", !12, i64 0, !6, i64 8, !12, i64 16, !12, i64 24}
!12 = !{!"long", !7, i64 0}
!13 = !{!"MerryEAT", !6, i64 0, !12, i64 8, !12, i64 16}
!14 = !{!"MerrySsT", !12, i64 0, !12, i64 8, !6, i64 16, !7, i64 24}
!15 = !{!"MerryST", !6, i64 0, !12, i64 8}
!16 = !{!10, !7, i64 1}
!17 = !{!10, !12, i64 104}


; 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
@stderr = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [40 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_reader_read_file(ptr noundef %0) local_unnamed_addr #1 {
  %.not.not = icmp eq ptr %0, null
  br i1 %.not.not, label %2, label %5

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

5:                                                ; preds = %1, %2
  %6 = load ptr, ptr @stdout, align 8, !tbaa !5
  %7 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef nonnull @.str.9, ptr noundef null) #3
  %8 = tail call zeroext i8 @merry_reader_is_file_fit_to_read(ptr noundef %0)
  %9 = icmp eq i8 %8, 1
  br i1 %9, label %42, label %10

10:                                               ; preds = %5
  %11 = tail call zeroext i8 @merry_reader_read_header(ptr noundef %0)
  %12 = icmp eq i8 %11, 1
  br i1 %12, label %42, label %13

13:                                               ; preds = %10
  %14 = tail call zeroext i8 @merry_reader_validate_header_info(ptr noundef %0)
  %15 = icmp eq i8 %14, 1
  br i1 %15, label %42, label %16

16:                                               ; preds = %13
  %17 = tail call zeroext i8 @merry_reader_read_eat(ptr noundef %0)
  %18 = icmp eq i8 %17, 1
  br i1 %18, label %42, label %19

19:                                               ; preds = %16
  %20 = tail call zeroext i8 @merry_reader_read_instructions(ptr noundef %0)
  %21 = icmp eq i8 %20, 1
  br i1 %21, label %41, label %22

22:                                               ; preds = %19
  %23 = getelementptr inbounds i8, ptr %0, i64 64
  %24 = load i64, ptr %23, align 8, !tbaa !9
  %.not = icmp eq i64 %24, 0
  br i1 %.not, label %.thread, label %25

25:                                               ; preds = %22
  %26 = tail call zeroext i8 @merry_reader_read_sst(ptr noundef nonnull %0)
  %27 = icmp eq i8 %26, 1
  br i1 %27, label %41, label %28

28:                                               ; preds = %25
  %.pr = load i64, ptr %23, align 8, !tbaa !9
  %.not15 = icmp eq i64 %.pr, 0
  br i1 %.not15, label %.thread, label %29

29:                                               ; preds = %28
  %30 = tail call zeroext i8 @merry_reader_read_sections(ptr noundef nonnull %0)
  %31 = icmp eq i8 %30, 1
  br i1 %31, label %41, label %.thread

.thread:                                          ; preds = %22, %29, %28
  %32 = getelementptr inbounds i8, ptr %0, i64 1
  %33 = load i8, ptr %32, align 1, !tbaa !16
  %34 = icmp eq i8 %33, 1
  br i1 %34, label %35, label %42

35:                                               ; preds = %.thread
  %36 = getelementptr inbounds i8, ptr %0, i64 104
  %37 = load i64, ptr %36, align 8, !tbaa !17
  %.not16 = icmp eq i64 %37, 0
  br i1 %.not16, label %42, label %38

38:                                               ; preds = %35
  %39 = tail call zeroext i8 @merry_reader_read_st(ptr noundef nonnull %0)
  %40 = icmp eq i8 %39, 1
  br i1 %40, label %41, label %42

41:                                               ; preds = %38, %29, %25, %19
  tail call void @merry_reader_return_all_mem(ptr noundef %0)
  br label %42

42:                                               ; preds = %.thread, %35, %38, %16, %13, %10, %5, %41
  %.0 = phi i8 [ 1, %41 ], [ 1, %5 ], [ 1, %10 ], [ 1, %13 ], [ 1, %16 ], [ 0, %38 ], [ 0, %35 ], [ 0, %.thread ]
  ret i8 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_is_file_fit_to_read(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_read_header(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_validate_header_info(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_read_eat(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_read_instructions(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_read_sst(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_read_sections(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @merry_reader_read_st(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @merry_reader_return_all_mem(ptr noundef) local_unnamed_addr #1

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 = { cold nounwind }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 64}
!10 = !{!"MerryReader", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !11, i64 8, !13, i64 40, !14, i64 64, !15, i64 96, !6, i64 112, !7, i64 120, !12, i64 136, !12, i64 144, !6, i64 152, !12, i64 160, !6, i64 168, !12, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !12, i64 216, !12, i64 224}
!11 = !{!"MerryInstSection", !12, i64 0, !6, i64 8, !12, i64 16, !12, i64 24}
!12 = !{!"long", !7, i64 0}
!13 = !{!"MerryEAT", !6, i64 0, !12, i64 8, !12, i64 16}
!14 = !{!"MerrySsT", !12, i64 0, !12, i64 8, !6, i64 16, !7, i64 24}
!15 = !{!"MerryST", !6, i64 0, !12, i64 8}
!16 = !{!10, !7, i64 1}
!17 = !{!10, !12, i64 104}


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