; LLVM IR from huhuanming/leetcode :: C/LeetCode (main)

; 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.greatest_run_info = type { i8, i8, i32, i32, i32, i32, i32, %struct.greatest_suite_info, ptr, i32, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, ptr, i64, i64, [1 x %struct.__jmp_buf_tag] }
%struct.greatest_suite_info = type { i32, i32, i32, i32, i64, i64, i64, i64 }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }

@greatest_info = external dso_local global %struct.greatest_run_info, align 8
@stdout = external global ptr, align 8
@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @greatest_pre_test(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load i8, ptr @greatest_info, align 8, !tbaa !9
  %5 = zext i8 %4 to i32
  %6 = and i32 %5, 2
  %7 = icmp ne i32 %6, 0
  br i1 %7, label %38, label %8

8:                                                ; preds = %1
  %9 = load i8, ptr @greatest_info, align 8, !tbaa !9
  %10 = zext i8 %9 to i32
  %11 = and i32 %10, 1
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %13, label %16

13:                                               ; preds = %8
  %14 = load i32, ptr getelementptr inbounds (%struct.greatest_suite_info, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 7), i32 0, i32 2), align 8, !tbaa !14
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %38

16:                                               ; preds = %13, %8
  %17 = load ptr, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 18), align 8, !tbaa !15
  %18 = icmp eq ptr %17, null
  br i1 %18, label %24, label %19

19:                                               ; preds = %16
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load ptr, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 18), align 8, !tbaa !15
  %22 = call i32 @greatest_name_match(ptr noundef %20, ptr noundef %21)
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %38

24:                                               ; preds = %19, %16
  %25 = call i64 @clock() #3
  store i64 %25, ptr getelementptr inbounds (%struct.greatest_suite_info, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 7), i32 0, i32 6), align 8, !tbaa !16
  %26 = load i64, ptr getelementptr inbounds (%struct.greatest_suite_info, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 7), i32 0, i32 6), align 8, !tbaa !16
  %27 = icmp eq i64 %26, -1
  br i1 %27, label %28, label %31

28:                                               ; preds = %24
  %29 = load ptr, ptr @stdout, align 8, !tbaa !5
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef @.str, ptr noundef @.str.1) #3
  call void @exit(i32 noundef 1) #4
  unreachable

31:                                               ; preds = %24
  %32 = load ptr, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 11), align 8, !tbaa !17
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %37

34:                                               ; preds = %31
  %35 = load ptr, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 11), align 8, !tbaa !17
  %36 = load ptr, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 12), align 8, !tbaa !18
  call void %35(ptr noundef %36)
  br label %37

37:                                               ; preds = %34, %31
  store i32 1, ptr %2, align 4
  br label %39

38:                                               ; preds = %19, %13, %1
  store i32 0, ptr %2, align 4
  br label %39

39:                                               ; preds = %38, %37
  %40 = load i32, ptr %2, align 4
  ret i32 %40
}

; Function Attrs: nounwind uwtable
declare hidden i32 @greatest_name_match(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind
declare i64 @clock() #1

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

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 = { 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 #2 = { noreturn 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 = { nounwind }
attributes #4 = { noreturn 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 = !{!"greatest_run_info", !7, i64 0, !7, i64 1, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !12, i64 24, !6, i64 72, !11, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !11, i64 128, !11, i64 132, !6, i64 136, !6, i64 144, !13, i64 152, !13, i64 160, !7, i64 168}
!11 = !{!"int", !7, i64 0}
!12 = !{!"greatest_suite_info", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40}
!13 = !{!"long", !7, i64 0}
!14 = !{!10, !11, i64 32}
!15 = !{!10, !6, i64 144}
!16 = !{!10, !13, i64 56}
!17 = !{!10, !6, i64 96}
!18 = !{!10, !6, 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"

%struct.greatest_run_info = type { i8, i8, i32, i32, i32, i32, i32, %struct.greatest_suite_info, ptr, i32, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, ptr, i64, i64, [1 x %struct.__jmp_buf_tag] }
%struct.greatest_suite_info = type { i32, i32, i32, i32, i64, i64, i64, i64 }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }

@greatest_info = external dso_local local_unnamed_addr global %struct.greatest_run_info, align 8
@stdout = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @greatest_pre_test(ptr noundef %0) local_unnamed_addr #0 {
  %2 = load i8, ptr @greatest_info, align 8, !tbaa !5
  %3 = zext i8 %2 to i32
  %4 = and i32 %3, 2
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %5, label %25

5:                                                ; preds = %1
  %6 = and i32 %3, 1
  %7 = icmp eq i32 %6, 0
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 32), align 8
  %9 = icmp eq i32 %8, 0
  %or.cond = select i1 %7, i1 true, i1 %9
  br i1 %or.cond, label %10, label %25

10:                                               ; preds = %5
  %11 = load ptr, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 144), align 8, !tbaa !13
  %12 = icmp eq ptr %11, null
  br i1 %12, label %15, label %13

13:                                               ; preds = %10
  %14 = tail call i32 @greatest_name_match(ptr noundef %0, ptr noundef nonnull %11)
  %.not4 = icmp eq i32 %14, 0
  br i1 %.not4, label %25, label %15

15:                                               ; preds = %13, %10
  %16 = tail call i64 @clock() #4
  store i64 %16, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 56), align 8, !tbaa !14
  %17 = icmp eq i64 %16, -1
  br i1 %17, label %18, label %21

18:                                               ; preds = %15
  %19 = load ptr, ptr @stdout, align 8, !tbaa !15
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1) #4
  tail call void @exit(i32 noundef 1) #5
  unreachable

21:                                               ; preds = %15
  %22 = load ptr, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 96), align 8, !tbaa !16
  %.not5 = icmp eq ptr %22, null
  br i1 %.not5, label %25, label %23

23:                                               ; preds = %21
  %24 = load ptr, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 104), align 8, !tbaa !17
  tail call void %22(ptr noundef %24) #4
  br label %25

25:                                               ; preds = %1, %13, %5, %21, %23
  %.0 = phi i32 [ 1, %23 ], [ 1, %21 ], [ 0, %5 ], [ 0, %13 ], [ 0, %1 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @greatest_name_match(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind
declare i64 @clock() local_unnamed_addr #1

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #3

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 = { 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 #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 = { noreturn 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 = { nounwind }
attributes #5 = { noreturn 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, !7, i64 0}
!6 = !{!"greatest_run_info", !7, i64 0, !7, i64 1, !9, i64 4, !9, i64 8, !9, i64 12, !9, i64 16, !9, i64 20, !10, i64 24, !12, i64 72, !9, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !9, i64 128, !9, i64 132, !12, i64 136, !12, i64 144, !11, i64 152, !11, i64 160, !7, i64 168}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"greatest_suite_info", !9, i64 0, !9, i64 4, !9, i64 8, !9, i64 12, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40}
!11 = !{!"long", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!6, !12, i64 144}
!14 = !{!6, !11, i64 56}
!15 = !{!12, !12, i64 0}
!16 = !{!6, !12, i64 96}
!17 = !{!6, !12, i64 104}


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