; LLVM IR from ryanlayer/giggle :: src (query_filter)

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

@.str.1 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [34 x i8], align 1

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

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @comparison_string_to_enum(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = 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
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 -1, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %56, %3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds i8, ptr %12, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !11
  %17 = icmp ne i8 %16, 0
  br i1 %17, label %18, label %59

18:                                               ; preds = %11
  %19 = call ptr @__ctype_b_loc() #5
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds i8, ptr %21, i64 %23
  %25 = load i8, ptr %24, align 1, !tbaa !11
  %26 = sext i8 %25 to i32
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i16, ptr %20, i64 %27
  %29 = load i16, ptr %28, align 2, !tbaa !12
  %30 = zext i16 %29 to i32
  %31 = and i32 %30, 1024
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %55, label %33

33:                                               ; preds = %18
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = load i32, ptr %7, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i8, ptr %34, i64 %36
  %38 = load i8, ptr %37, align 1, !tbaa !11
  %39 = sext i8 %38 to i32
  %40 = icmp eq i32 %39, 95
  br i1 %40, label %55, label %41

41:                                               ; preds = %33
  %42 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %42, ptr %9, align 4, !tbaa !9
  store i32 %42, ptr %8, align 4, !tbaa !9
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load i32, ptr %7, align 4, !tbaa !9
  %45 = add nsw i32 %44, 1
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds i8, ptr %43, i64 %46
  %48 = load i8, ptr %47, align 1, !tbaa !11
  %49 = sext i8 %48 to i32
  %50 = icmp eq i32 %49, 61
  br i1 %50, label %51, label %54

51:                                               ; preds = %41
  %52 = load i32, ptr %7, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %9, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %51, %41
  br label %59

55:                                               ; preds = %33, %18
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %7, align 4, !tbaa !9
  br label %11, !llvm.loop !14

59:                                               ; preds = %54, %11
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = icmp eq i32 %60, -1
  br i1 %61, label %62, label %63

62:                                               ; preds = %59
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.1) #6
  unreachable

63:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %64 = load i32, ptr %8, align 4, !tbaa !9
  %65 = load i32, ptr %9, align 4, !tbaa !9
  %66 = icmp eq i32 %64, %65
  br i1 %66, label %67, label %84

67:                                               ; preds = %63
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = load i32, ptr %8, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds i8, ptr %68, i64 %70
  %72 = load i8, ptr %71, align 1, !tbaa !11
  %73 = sext i8 %72 to i32
  switch i32 %73, label %76 [
    i32 60, label %74
    i32 62, label %75
  ]

74:                                               ; preds = %67
  store i32 2, ptr %10, align 4, !tbaa !9
  br label %83

75:                                               ; preds = %67
  store i32 3, ptr %10, align 4, !tbaa !9
  br label %83

76:                                               ; preds = %67
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds i8, ptr %77, i64 %79
  %81 = load i8, ptr %80, align 1, !tbaa !11
  %82 = sext i8 %81 to i32
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.2, i32 noundef %82) #6
  unreachable

83:                                               ; preds = %75, %74
  br label %103

84:                                               ; preds = %63
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = load i32, ptr %8, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds i8, ptr %85, i64 %87
  %89 = load i8, ptr %88, align 1, !tbaa !11
  %90 = sext i8 %89 to i32
  switch i32 %90, label %95 [
    i32 61, label %91
    i32 33, label %92
    i32 60, label %93
    i32 62, label %94
  ]

91:                                               ; preds = %84
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %102

92:                                               ; preds = %84
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %102

93:                                               ; preds = %84
  store i32 4, ptr %10, align 4, !tbaa !9
  br label %102

94:                                               ; preds = %84
  store i32 5, ptr %10, align 4, !tbaa !9
  br label %102

95:                                               ; preds = %84
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = load i32, ptr %8, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds i8, ptr %96, i64 %98
  %100 = load i8, ptr %99, align 1, !tbaa !11
  %101 = sext i8 %100 to i32
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.3, i32 noundef %101) #6
  unreachable

102:                                              ; preds = %94, %93, %92, %91
  br label %103

103:                                              ; preds = %102, %83
  %104 = load i32, ptr %8, align 4, !tbaa !9
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  store i32 %104, ptr %105, align 4, !tbaa !9
  %106 = load i32, ptr %9, align 4, !tbaa !9
  %107 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %106, ptr %107, align 4, !tbaa !9
  %108 = load i32, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret i32 %108
}

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

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

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

@.str.1 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 6) i32 @comparison_string_to_enum(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = load i8, ptr %0, align 1, !tbaa !5
  %.not35 = icmp eq i8 %4, 0
  br i1 %.not35, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %5 = tail call ptr @__ctype_b_loc() #3
  %6 = load ptr, ptr %5, align 8, !tbaa !8
  br label %7

7:                                                ; preds = %.lr.ph, %14
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %14 ]
  %8 = phi i8 [ %4, %.lr.ph ], [ %16, %14 ]
  %9 = sext i8 %8 to i64
  %10 = getelementptr inbounds i16, ptr %6, i64 %9
  %11 = load i16, ptr %10, align 2, !tbaa !10
  %12 = and i16 %11, 1024
  %.not30 = icmp ne i16 %12, 0
  %13 = icmp eq i8 %8, 95
  %or.cond = or i1 %13, %.not30
  br i1 %or.cond, label %14, label %17

14:                                               ; preds = %7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %.not = icmp eq i8 %16, 0
  br i1 %.not, label %.thread, label %7, !llvm.loop !12

17:                                               ; preds = %7
  %18 = trunc nuw nsw i64 %indvars.iv to i32
  %19 = add nuw nsw i32 %18, 1
  %20 = zext nneg i32 %19 to i64
  %21 = getelementptr inbounds i8, ptr %0, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %.not33 = icmp eq i8 %22, 61
  %23 = and i64 %indvars.iv, 4294967295
  %24 = getelementptr inbounds i8, ptr %0, i64 %23
  %25 = load i8, ptr %24, align 1, !tbaa !5
  br i1 %.not33, label %30, label %26

.thread:                                          ; preds = %14, %3
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.1) #4
  unreachable

26:                                               ; preds = %17
  switch i8 %25, label %28 [
    i8 60, label %36
    i8 62, label %27
  ]

27:                                               ; preds = %26
  br label %36

28:                                               ; preds = %26
  %29 = sext i8 %25 to i32
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.2, i32 noundef %29) #4
  unreachable

30:                                               ; preds = %17
  switch i8 %25, label %34 [
    i8 61, label %36
    i8 33, label %31
    i8 60, label %32
    i8 62, label %33
  ]

31:                                               ; preds = %30
  br label %36

32:                                               ; preds = %30
  br label %36

33:                                               ; preds = %30
  br label %36

34:                                               ; preds = %30
  %35 = sext i8 %25 to i32
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.3, i32 noundef %35) #4
  unreachable

36:                                               ; preds = %30, %26, %31, %32, %33, %27
  %spec.select = phi i32 [ %19, %30 ], [ %18, %26 ], [ %19, %31 ], [ %19, %32 ], [ %19, %33 ], [ %18, %27 ]
  %.0 = phi i32 [ 0, %30 ], [ 2, %26 ], [ 1, %31 ], [ 4, %32 ], [ 5, %33 ], [ 3, %27 ]
  store i32 %18, ptr %1, align 4, !tbaa !14
  store i32 %spec.select, ptr %2, align 4, !tbaa !14
  ret i32 %.0
}

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

attributes #0 = { noreturn "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 = { 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 #3 = { nounwind willreturn memory(none) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !6, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass