; LLVM IR from hbatagelo/abcg :: abcg/external/glslang/glslang/MachineIndependent (ParseHelper)

; 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.68 = external hidden unnamed_addr constant [113 x i8], align 1
@.str.434 = external hidden unnamed_addr constant [28 x i8], align 1
@__PRETTY_FUNCTION__._ZN7glslang13TParseContext23computeSamplerTypeIndexERNS_8TSamplerE = external hidden unnamed_addr constant [64 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7glslang13TParseContext23computeSamplerTypeIndexERNS_8TSamplerE(ptr noundef nonnull align 8 dereferenceable(24912) %0, ptr noundef nonnull align 4 dereferenceable(4) %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = load i32, ptr %12, align 4
  %14 = lshr i32 %13, 16
  %15 = and i32 %14, 1
  %16 = trunc i32 %15 to i1
  %17 = zext i1 %16 to i64
  %18 = select i1 %16, i32 1, i32 0
  store i32 %18, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load i32, ptr %19, align 4
  %21 = lshr i32 %20, 17
  %22 = and i32 %21, 1
  %23 = trunc i32 %22 to i1
  %24 = zext i1 %23 to i64
  %25 = select i1 %23, i32 1, i32 0
  store i32 %25, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = call noundef zeroext i1 @_ZNK7glslang8TSampler10isExternalEv(ptr noundef nonnull align 4 dereferenceable(4) %26)
  %28 = zext i1 %27 to i64
  %29 = select i1 %27, i32 1, i32 0
  store i32 %29, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = call noundef zeroext i1 @_ZNK7glslang8TSampler12isImageClassEv(ptr noundef nonnull align 4 dereferenceable(4) %30)
  %32 = zext i1 %31 to i64
  %33 = select i1 %31, i32 1, i32 0
  store i32 %33, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = call noundef zeroext i1 @_ZNK7glslang8TSampler13isMultiSampleEv(ptr noundef nonnull align 4 dereferenceable(4) %34)
  %36 = zext i1 %35 to i64
  %37 = select i1 %35, i32 1, i32 0
  store i32 %37, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = mul nsw i32 2, %38
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = add nsw i32 %39, %40
  %42 = mul nsw i32 2, %41
  %43 = load i32, ptr %8, align 4, !tbaa !9
  %44 = add nsw i32 %42, %43
  %45 = mul nsw i32 2, %44
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = add nsw i32 %45, %46
  %48 = mul nsw i32 2, %47
  %49 = load i32, ptr %7, align 4, !tbaa !9
  %50 = add nsw i32 %48, %49
  %51 = mul nsw i32 22, %50
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = load i32, ptr %52, align 4
  %54 = and i32 %53, 255
  %55 = add nsw i32 %51, %54
  %56 = mul nsw i32 8, %55
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = load i32, ptr %57, align 4
  %59 = lshr i32 %58, 8
  %60 = and i32 %59, 255
  %61 = add nsw i32 %56, %60
  store i32 %61, ptr %10, align 4, !tbaa !9
  %62 = load i32, ptr %10, align 4, !tbaa !9
  %63 = icmp slt i32 %62, 5632
  br i1 %63, label %64, label %65

64:                                               ; preds = %2
  br label %67

65:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.434, ptr noundef @.str.68, i32 noundef 4107, ptr noundef @__PRETTY_FUNCTION__._ZN7glslang13TParseContext23computeSamplerTypeIndexERNS_8TSamplerE) #5
  unreachable

66:                                               ; No predecessors!
  br label %67

67:                                               ; preds = %66, %64
  %68 = 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
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret i32 %68
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7glslang8TSampler13isMultiSampleEv(ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7glslang8TSampler10isExternalEv(ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7glslang8TSampler12isImageClassEv(ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { 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 = { mustprogress 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 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"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"

@.str.68 = external hidden unnamed_addr constant [113 x i8], align 1
@.str.434 = external hidden unnamed_addr constant [28 x i8], align 1
@__PRETTY_FUNCTION__._ZN7glslang13TParseContext23computeSamplerTypeIndexERNS_8TSamplerE = external hidden unnamed_addr constant [64 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, 5632) i32 @_ZN7glslang13TParseContext23computeSamplerTypeIndexERNS_8TSamplerE(ptr nocapture noundef nonnull readnone align 8 dereferenceable(24912) %0, ptr noundef nonnull align 4 dereferenceable(4) %1) local_unnamed_addr #0 align 2 {
  %3 = load i32, ptr %1, align 4
  %4 = lshr i32 %3, 17
  %.lobit14 = and i32 %4, 1
  %5 = tail call noundef zeroext i1 @_ZNK7glslang8TSampler10isExternalEv(ptr noundef nonnull align 4 dereferenceable(4) %1)
  %6 = zext i1 %5 to i32
  %7 = tail call noundef zeroext i1 @_ZNK7glslang8TSampler12isImageClassEv(ptr noundef nonnull align 4 dereferenceable(4) %1)
  %8 = tail call noundef zeroext i1 @_ZNK7glslang8TSampler13isMultiSampleEv(ptr noundef nonnull align 4 dereferenceable(4) %1)
  %9 = zext i1 %8 to i32
  %10 = lshr i32 %3, 15
  %11 = and i32 %10, 2
  %12 = or disjoint i32 %11, %9
  %13 = shl nuw nsw i32 %12, 2
  %14 = select i1 %7, i32 2, i32 0
  %15 = or disjoint i32 %13, %14
  %16 = or disjoint i32 %15, %.lobit14
  %17 = shl nuw nsw i32 %16, 1
  %18 = or disjoint i32 %17, %6
  %19 = mul nuw nsw i32 %18, 22
  %20 = load i32, ptr %1, align 4
  %21 = and i32 %20, 255
  %22 = add nuw nsw i32 %19, %21
  %23 = shl nuw nsw i32 %22, 3
  %24 = lshr i32 %20, 8
  %25 = and i32 %24, 255
  %26 = add nuw nsw i32 %23, %25
  %27 = icmp ult i32 %26, 5632
  br i1 %27, label %29, label %28

28:                                               ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.434, ptr noundef nonnull @.str.68, i32 noundef 4107, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7glslang13TParseContext23computeSamplerTypeIndexERNS_8TSamplerE) #2
  unreachable

29:                                               ; preds = %2
  ret i32 %26
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7glslang8TSampler13isMultiSampleEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7glslang8TSampler10isExternalEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7glslang8TSampler12isImageClassEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0 align 2

attributes #0 = { mustprogress 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 = { 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 #2 = { 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)"}


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