; LLVM IR from Discngine/fpocket :: src (rpdb)

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

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

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #1

declare void @str_trim(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @guess_element(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = call i64 @strlen(ptr noundef %14) #7
  %16 = add i64 %15, 1
  %17 = call ptr @llvm.stacksave.p0()
  store ptr %17, ptr %7, align 8
  %18 = alloca i8, i64 %16, align 16
  store i64 %16, ptr %8, align 8
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = call ptr @strcpy(ptr noundef %18, ptr noundef %19) #8
  call void @str_trim(ptr noundef %18)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  store ptr %18, ptr %9, align 8, !tbaa !5
  %21 = call ptr @__ctype_b_loc() #9
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %18, i64 0
  %24 = load i8, ptr %23, align 16, !tbaa !9
  %25 = sext i8 %24 to i32
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds i16, ptr %22, i64 %26
  %28 = load i16, ptr %27, align 2, !tbaa !10
  %29 = zext i16 %28 to i32
  %30 = and i32 %29, 2048
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %35

32:                                               ; preds = %3
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %33, i64 1
  store ptr %34, ptr %9, align 8, !tbaa !5
  br label %35

35:                                               ; preds = %32, %3
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = call i32 @element_in_std_res(ptr noundef %36)
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %56

39:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = call i32 @is_valid_prot_element(ptr noundef %40, i32 noundef 1)
  store i32 %41, ptr %10, align 4, !tbaa !12
  %42 = load i32, ptr %10, align 4, !tbaa !12
  %43 = icmp ne i32 %42, -1
  br i1 %43, label %44, label %52

44:                                               ; preds = %39
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %45, i64 0
  %47 = load i8, ptr %46, align 1, !tbaa !9
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %48, i64 0
  store i8 %47, ptr %49, align 1, !tbaa !9
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %50, i64 1
  store i8 0, ptr %51, align 1, !tbaa !9
  store i32 1, ptr %11, align 4
  br label %53

52:                                               ; preds = %39
  store i32 0, ptr %11, align 4
  br label %53

53:                                               ; preds = %52, %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  %54 = load i32, ptr %11, align 4
  switch i32 %54, label %104 [
    i32 0, label %55
  ]

55:                                               ; preds = %53
  br label %91

56:                                               ; preds = %35
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = call i32 @element_in_nucl_acid(ptr noundef %57)
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %77

60:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = call i32 @is_valid_nucl_acid_element(ptr noundef %61, i32 noundef 1)
  store i32 %62, ptr %12, align 4, !tbaa !12
  %63 = load i32, ptr %12, align 4, !tbaa !12
  %64 = icmp ne i32 %63, -1
  br i1 %64, label %65, label %73

65:                                               ; preds = %60
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %66, i64 0
  %68 = load i8, ptr %67, align 1, !tbaa !9
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %69, i64 0
  store i8 %68, ptr %70, align 1, !tbaa !9
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds i8, ptr %71, i64 1
  store i8 0, ptr %72, align 1, !tbaa !9
  store i32 1, ptr %11, align 4
  br label %74

73:                                               ; preds = %60
  store i32 0, ptr %11, align 4
  br label %74

74:                                               ; preds = %73, %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  %75 = load i32, ptr %11, align 4
  switch i32 %75, label %104 [
    i32 0, label %76
  ]

76:                                               ; preds = %74
  br label %90

77:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = call i32 @is_valid_element(ptr noundef %78, i32 noundef 1)
  store i32 %79, ptr %13, align 4, !tbaa !12
  %80 = load i32, ptr %13, align 4, !tbaa !12
  %81 = icmp ne i32 %80, -1
  br i1 %81, label %82, label %86

82:                                               ; preds = %77
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  %85 = call ptr @strcpy(ptr noundef %83, ptr noundef %84) #8
  store i32 1, ptr %11, align 4
  br label %87

86:                                               ; preds = %77
  store i32 0, ptr %11, align 4
  br label %87

87:                                               ; preds = %86, %82
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  %88 = load i32, ptr %11, align 4
  switch i32 %88, label %104 [
    i32 0, label %89
  ]

89:                                               ; preds = %87
  br label %90

90:                                               ; preds = %89, %76
  br label %91

91:                                               ; preds = %90, %55
  %92 = load ptr, ptr %9, align 8, !tbaa !5
  %93 = getelementptr inbounds i8, ptr %92, i64 0
  %94 = load i8, ptr %93, align 1, !tbaa !9
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  %96 = getelementptr inbounds i8, ptr %95, i64 0
  store i8 %94, ptr %96, align 1, !tbaa !9
  %97 = load ptr, ptr %9, align 8, !tbaa !5
  %98 = getelementptr inbounds i8, ptr %97, i64 1
  %99 = load i8, ptr %98, align 1, !tbaa !9
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = getelementptr inbounds i8, ptr %100, i64 1
  store i8 %99, ptr %101, align 1, !tbaa !9
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  %103 = getelementptr inbounds i8, ptr %102, i64 2
  store i8 0, ptr %103, align 1, !tbaa !9
  store i32 0, ptr %11, align 4
  br label %104

104:                                              ; preds = %91, %87, %74, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  %105 = load ptr, ptr %7, align 8
  call void @llvm.stackrestore.p0(ptr %105)
  %106 = load i32, ptr %11, align 4
  switch i32 %106, label %108 [
    i32 0, label %107
    i32 1, label %107
  ]

107:                                              ; preds = %104, %104
  ret void

108:                                              ; preds = %104
  unreachable
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #4

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #5

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #6

declare i32 @element_in_std_res(ptr noundef) #2

declare i32 @is_valid_prot_element(ptr noundef, i32 noundef) #2

declare i32 @element_in_nucl_acid(ptr noundef) #2

declare i32 @is_valid_nucl_acid_element(ptr noundef, i32 noundef) #2

declare i32 @is_valid_element(ptr noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(read) "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 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 #4 = { nocallback nofree nosync nounwind willreturn }
attributes #5 = { 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 #6 = { nounwind willreturn memory(none) "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 #7 = { nounwind willreturn memory(read) }
attributes #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(none) }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}


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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #0

declare void @str_trim(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @guess_element(ptr nocapture noundef readonly %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #5
  %5 = add i64 %4, 1
  %6 = alloca i8, i64 %5, align 16
  %7 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) %0) #6
  call void @str_trim(ptr noundef nonnull %6) #6
  %8 = tail call ptr @__ctype_b_loc() #7
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = load i8, ptr %6, align 16, !tbaa !9
  %11 = sext i8 %10 to i64
  %12 = getelementptr inbounds i16, ptr %9, i64 %11
  %13 = load i16, ptr %12, align 2, !tbaa !10
  %14 = lshr i16 %13, 11
  %.lobit = and i16 %14, 1
  %spec.select.idx = zext nneg i16 %.lobit to i64
  %spec.select = getelementptr inbounds i8, ptr %6, i64 %spec.select.idx
  %15 = call i32 @element_in_std_res(ptr noundef %2) #6
  %.not30 = icmp eq i32 %15, 0
  br i1 %.not30, label %21, label %16

16:                                               ; preds = %3
  %17 = call i32 @is_valid_prot_element(ptr noundef nonnull %spec.select, i32 noundef 1) #6
  %.not34 = icmp eq i32 %17, -1
  br i1 %.not34, label %.critedge, label %18

18:                                               ; preds = %16
  %19 = load i8, ptr %spec.select, align 1, !tbaa !9
  store i8 %19, ptr %1, align 1, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %1, i64 1
  store i8 0, ptr %20, align 1, !tbaa !9
  br label %37

21:                                               ; preds = %3
  %22 = call i32 @element_in_nucl_acid(ptr noundef %2) #6
  %.not31 = icmp eq i32 %22, 0
  br i1 %.not31, label %28, label %23

23:                                               ; preds = %21
  %24 = call i32 @is_valid_nucl_acid_element(ptr noundef nonnull %spec.select, i32 noundef 1) #6
  %.not33 = icmp eq i32 %24, -1
  br i1 %.not33, label %.critedge, label %25

25:                                               ; preds = %23
  %26 = load i8, ptr %spec.select, align 1, !tbaa !9
  store i8 %26, ptr %1, align 1, !tbaa !9
  %27 = getelementptr inbounds i8, ptr %1, i64 1
  store i8 0, ptr %27, align 1, !tbaa !9
  br label %37

28:                                               ; preds = %21
  %29 = call i32 @is_valid_element(ptr noundef nonnull %spec.select, i32 noundef 1) #6
  %.not32 = icmp eq i32 %29, -1
  br i1 %.not32, label %.critedge, label %30

30:                                               ; preds = %28
  %31 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %spec.select) #6
  br label %37

.critedge:                                        ; preds = %28, %23, %16
  %32 = load i8, ptr %spec.select, align 1, !tbaa !9
  store i8 %32, ptr %1, align 1, !tbaa !9
  %33 = getelementptr inbounds i8, ptr %spec.select, i64 1
  %34 = load i8, ptr %33, align 1, !tbaa !9
  %35 = getelementptr inbounds i8, ptr %1, i64 1
  store i8 %34, ptr %35, align 1, !tbaa !9
  %36 = getelementptr inbounds i8, ptr %1, i64 2
  store i8 0, ptr %36, align 1, !tbaa !9
  br label %37

37:                                               ; preds = %30, %25, %18, %.critedge
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() local_unnamed_addr #4

declare i32 @element_in_std_res(ptr noundef) local_unnamed_addr #1

declare i32 @is_valid_prot_element(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @element_in_nucl_acid(ptr noundef) local_unnamed_addr #1

declare i32 @is_valid_nucl_acid_element(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @is_valid_element(ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { "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 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 #3 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 willreturn memory(read) }
attributes #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !7, i64 0}


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