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

%union.metadata_data = type { i64 }
%struct.metadata_type = type { i32, i8, [32 x i8] }

@.str = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @parse_query_filter_data_string(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca %union.metadata_data, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.metadata_type, ptr %8, i32 0, i32 0
  %10 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %10, ptr %6, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %11 = load i32, ptr %6, align 4, !tbaa !12
  switch i32 %11, label %43 [
    i32 0, label %12
    i32 1, label %15
    i32 2, label %19
    i32 3, label %23
    i32 4, label %27
    i32 5, label %30
    i32 6, label %34
    i32 7, label %37
  ]

12:                                               ; preds = %2
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = load i8, ptr %13, align 1, !tbaa !13
  store i8 %14, ptr %3, align 8, !tbaa !13
  br label %45

15:                                               ; preds = %2
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call i32 @atoi(ptr noundef %16) #6
  %18 = trunc i32 %17 to i8
  store i8 %18, ptr %3, align 8, !tbaa !13
  br label %45

19:                                               ; preds = %2
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call i32 @atoi(ptr noundef %20) #6
  %22 = trunc i32 %21 to i16
  store i16 %22, ptr %3, align 8, !tbaa !13
  br label %45

23:                                               ; preds = %2
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call i64 @atol(ptr noundef %24) #6
  %26 = trunc i64 %25 to i32
  store i32 %26, ptr %3, align 8, !tbaa !13
  br label %45

27:                                               ; preds = %2
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call i64 @atoll(ptr noundef %28) #6
  store i64 %29, ptr %3, align 8, !tbaa !13
  br label %45

30:                                               ; preds = %2
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call double @atof(ptr noundef %31) #6
  %33 = fptrunc double %32 to float
  store float %33, ptr %3, align 8, !tbaa !13
  br label %45

34:                                               ; preds = %2
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call double @atof(ptr noundef %35) #6
  store double %36, ptr %3, align 8, !tbaa !13
  br label %45

37:                                               ; preds = %2
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.metadata_type, ptr %38, i32 0, i32 1
  %40 = load i8, ptr %39, align 4, !tbaa !14
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = call ptr @safe_sscanf(i8 noundef zeroext %40, ptr noundef %41)
  store ptr %42, ptr %3, align 8, !tbaa !13
  br label %45

43:                                               ; preds = %2
  %44 = load i32, ptr %6, align 4, !tbaa !12
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str, i32 noundef %44) #7
  unreachable

45:                                               ; preds = %37, %34, %30, %27, %23, %19, %15, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %46 = getelementptr inbounds %union.metadata_data, ptr %3, i32 0, i32 0
  %47 = load i64, ptr %46, align 8
  ret i64 %47
}

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

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #2

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i64 @atol(ptr noundef nonnull) #2

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i64 @atoll(ptr noundef nonnull) #2

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare double @atof(ptr noundef nonnull) #2

declare ptr @safe_sscanf(i8 noundef zeroext, ptr noundef) #3

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint nounwind willreturn memory(read) 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 = { "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 = { 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 #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { 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, !11, i64 0}
!10 = !{!"metadata_type", !11, i64 0, !7, i64 4, !7, i64 5}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!10, !7, i64 4}


; 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 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @parse_query_filter_data_string(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = load i32, ptr %0, align 4, !tbaa !5
  switch i32 %3, label %27 [
    i32 0, label %4
    i32 1, label %6
    i32 2, label %9
    i32 3, label %11
    i32 4, label %13
    i32 5, label %15
    i32 6, label %19
    i32 7, label %22
  ]

4:                                                ; preds = %2
  %5 = load i8, ptr %1, align 1, !tbaa !10
  br label %28

6:                                                ; preds = %2
  %7 = tail call i32 @atoi(ptr nocapture noundef %1) #4
  %8 = trunc i32 %7 to i8
  br label %28

9:                                                ; preds = %2
  %10 = tail call i32 @atoi(ptr nocapture noundef %1) #4
  %.sroa.0.sroa.0.sroa.0.sroa.0.0.extract.trunc = trunc i32 %10 to i8
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift53 = lshr i32 %10, 8
  br label %28

11:                                               ; preds = %2
  %12 = tail call i64 @atol(ptr nocapture noundef %1) #4
  %.sroa.0.sroa.0.sroa.0.sroa.0.0.extract.trunc30 = trunc i64 %12 to i8
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift3651 = lshr i64 %12, 8
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.trunc37 = trunc i64 %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift3651 to i32
  %.sroa.0.sroa.0.sroa.9.0.extract.shift2152 = lshr i64 %12, 16
  %.sroa.0.sroa.0.sroa.9.0.extract.trunc22 = trunc i64 %.sroa.0.sroa.0.sroa.9.0.extract.shift2152 to i32
  br label %28

13:                                               ; preds = %2
  %14 = tail call i64 @atoll(ptr nocapture noundef %1) #4
  %.sroa.0.sroa.0.sroa.0.sroa.0.0.extract.trunc33 = trunc i64 %14 to i8
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift4249 = lshr i64 %14, 8
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.trunc43 = trunc i64 %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift4249 to i32
  %.sroa.0.sroa.0.sroa.9.0.extract.shift2750 = lshr i64 %14, 16
  %.sroa.0.sroa.0.sroa.9.0.extract.trunc28 = trunc i64 %.sroa.0.sroa.0.sroa.9.0.extract.shift2750 to i32
  %.sroa.0.sroa.9.0.extract.shift15 = and i64 %14, -4294967296
  br label %28

15:                                               ; preds = %2
  %16 = tail call double @atof(ptr noundef %1) #4
  %17 = fptrunc double %16 to float
  %18 = bitcast float %17 to i32
  %.sroa.0.sroa.0.sroa.0.sroa.0.0.extract.trunc29 = trunc i32 %18 to i8
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift3448 = lshr i32 %18, 8
  %.sroa.0.sroa.0.sroa.9.0.extract.shift = lshr i32 %18, 16
  br label %28

19:                                               ; preds = %2
  %20 = tail call double @atof(ptr noundef %1) #4
  %21 = bitcast double %20 to i64
  %.sroa.0.sroa.0.sroa.0.sroa.0.0.extract.trunc31 = trunc i64 %21 to i8
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift3846 = lshr i64 %21, 8
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.trunc39 = trunc i64 %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift3846 to i32
  %.sroa.0.sroa.0.sroa.9.0.extract.shift2347 = lshr i64 %21, 16
  %.sroa.0.sroa.0.sroa.9.0.extract.trunc24 = trunc i64 %.sroa.0.sroa.0.sroa.9.0.extract.shift2347 to i32
  %.sroa.0.sroa.9.0.extract.shift = and i64 %21, -4294967296
  br label %28

22:                                               ; preds = %2
  %23 = getelementptr inbounds i8, ptr %0, i64 4
  %24 = load i8, ptr %23, align 4, !tbaa !11
  %25 = tail call ptr @safe_sscanf(i8 noundef zeroext %24, ptr noundef %1) #5
  %26 = ptrtoint ptr %25 to i64
  %.sroa.0.sroa.0.sroa.0.sroa.0.0.extract.trunc32 = trunc i64 %26 to i8
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift4044 = lshr i64 %26, 8
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.trunc41 = trunc i64 %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift4044 to i32
  %.sroa.0.sroa.0.sroa.9.0.extract.shift2545 = lshr i64 %26, 16
  %.sroa.0.sroa.0.sroa.9.0.extract.trunc26 = trunc i64 %.sroa.0.sroa.0.sroa.9.0.extract.shift2545 to i32
  %.sroa.0.sroa.9.0.extract.shift13 = and i64 %26, -4294967296
  br label %28

27:                                               ; preds = %2
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str, i32 noundef %3) #6
  unreachable

28:                                               ; preds = %22, %19, %15, %13, %11, %9, %6, %4
  %.sroa.0.sroa.9.0 = phi i64 [ %.sroa.0.sroa.9.0.extract.shift13, %22 ], [ %.sroa.0.sroa.9.0.extract.shift, %19 ], [ 0, %15 ], [ %.sroa.0.sroa.9.0.extract.shift15, %13 ], [ 0, %11 ], [ 0, %9 ], [ 0, %6 ], [ 0, %4 ]
  %.sroa.0.sroa.0.sroa.9.0 = phi i32 [ %.sroa.0.sroa.0.sroa.9.0.extract.trunc26, %22 ], [ %.sroa.0.sroa.0.sroa.9.0.extract.trunc24, %19 ], [ %.sroa.0.sroa.0.sroa.9.0.extract.shift, %15 ], [ %.sroa.0.sroa.0.sroa.9.0.extract.trunc28, %13 ], [ %.sroa.0.sroa.0.sroa.9.0.extract.trunc22, %11 ], [ 0, %9 ], [ 0, %6 ], [ 0, %4 ]
  %.sroa.0.sroa.0.sroa.0.sroa.0.0 = phi i8 [ %.sroa.0.sroa.0.sroa.0.sroa.0.0.extract.trunc32, %22 ], [ %.sroa.0.sroa.0.sroa.0.sroa.0.0.extract.trunc31, %19 ], [ %.sroa.0.sroa.0.sroa.0.sroa.0.0.extract.trunc29, %15 ], [ %.sroa.0.sroa.0.sroa.0.sroa.0.0.extract.trunc33, %13 ], [ %.sroa.0.sroa.0.sroa.0.sroa.0.0.extract.trunc30, %11 ], [ %.sroa.0.sroa.0.sroa.0.sroa.0.0.extract.trunc, %9 ], [ %8, %6 ], [ %5, %4 ]
  %.sroa.0.sroa.0.sroa.0.sroa.9.0 = phi i32 [ %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.trunc41, %22 ], [ %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.trunc39, %19 ], [ %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift3448, %15 ], [ %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.trunc43, %13 ], [ %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.trunc37, %11 ], [ %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift53, %9 ], [ 0, %6 ], [ 0, %4 ]
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.insert.ext = shl i32 %.sroa.0.sroa.0.sroa.0.sroa.9.0, 8
  %.sroa.0.sroa.0.sroa.0.sroa.0.0.insert.ext = zext i8 %.sroa.0.sroa.0.sroa.0.sroa.0.0 to i32
  %.sroa.0.sroa.0.sroa.9.0.insert.ext = shl i32 %.sroa.0.sroa.0.sroa.9.0, 16
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.insert.ext.masked = and i32 %.sroa.0.sroa.0.sroa.0.sroa.9.0.insert.ext, 65280
  %.sroa.0.sroa.0.sroa.0.0.insert.ext = or disjoint i32 %.sroa.0.sroa.0.sroa.0.sroa.9.0.insert.ext.masked, %.sroa.0.sroa.0.sroa.0.sroa.0.0.insert.ext
  %.sroa.0.sroa.0.sroa.0.0.insert.insert = or disjoint i32 %.sroa.0.sroa.0.sroa.0.0.insert.ext, %.sroa.0.sroa.0.sroa.9.0.insert.ext
  %.sroa.0.sroa.0.0.insert.ext = zext i32 %.sroa.0.sroa.0.sroa.0.0.insert.insert to i64
  %.sroa.0.sroa.0.0.insert.insert = or disjoint i64 %.sroa.0.sroa.9.0, %.sroa.0.sroa.0.0.insert.ext
  ret i64 %.sroa.0.sroa.0.0.insert.insert
}

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i64 @atol(ptr nocapture noundef nonnull) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i64 @atoll(ptr nocapture noundef nonnull) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare double @atof(ptr nocapture noundef nonnull) local_unnamed_addr #1

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

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr 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 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 = { 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 #4 = { nounwind willreturn memory(read) }
attributes #5 = { nounwind }
attributes #6 = { 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 = !{!"metadata_type", !7, i64 0, !8, i64 4, !8, i64 5}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!6, !8, i64 4}


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