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

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

%"class.glslang::TPpContext::tInput" = type { ptr, i8, ptr }
%"class.glslang::TPpContext::tUngotTokenInput" = type { %"class.glslang::TPpContext::tInput", i32, [4 x i8], %"class.glslang::TPpToken" }
%"class.glslang::TPpToken" = type <{ %"struct.glslang::TSourceLoc", i8, [7 x i8], %union.anon.0, [1025 x i8], [7 x i8] }>
%"struct.glslang::TSourceLoc" = type { ptr, i32, i32, i32 }
%union.anon.0 = type { double }

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN7glslang10TPpContext16tUngotTokenInput4scanEPNS_8TPpTokenE(ptr noundef nonnull align 8 dereferenceable(1104) %0, ptr noundef %1) unnamed_addr #2 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8
  %8 = getelementptr inbounds %"class.glslang::TPpContext::tInput", ptr %7, i32 0, i32 1
  %9 = load i8, ptr %8, align 8, !tbaa !9, !range !12, !noundef !13
  %10 = trunc i8 %9 to i1
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  store i32 -1, ptr %3, align 4
  br label %19

12:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %13 = getelementptr inbounds %"class.glslang::TPpContext::tUngotTokenInput", ptr %7, i32 0, i32 1
  %14 = load i32, ptr %13, align 8, !tbaa !14
  store i32 %14, ptr %6, align 4, !tbaa !19
  %15 = getelementptr inbounds %"class.glslang::TPpContext::tUngotTokenInput", ptr %7, i32 0, i32 3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 8 %15, i64 1065, i1 false), !tbaa.struct !20
  %17 = getelementptr inbounds %"class.glslang::TPpContext::tInput", ptr %7, i32 0, i32 1
  store i8 1, ptr %17, align 8, !tbaa !9
  %18 = load i32, ptr %6, align 4, !tbaa !19
  store i32 %18, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %19

19:                                               ; preds = %12, %11
  %20 = load i32, ptr %3, align 4
  ret i32 %20
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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, !11, i64 8}
!10 = !{!"_ZTSN7glslang10TPpContext6tInputE", !11, i64 8, !6, i64 16}
!11 = !{!"bool", !7, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!15, !16, i64 24}
!15 = !{!"_ZTSN7glslang10TPpContext16tUngotTokenInputE", !10, i64 0, !16, i64 24, !17, i64 32}
!16 = !{!"int", !7, i64 0}
!17 = !{!"_ZTSN7glslang8TPpTokenE", !18, i64 0, !11, i64 24, !7, i64 32, !7, i64 40}
!18 = !{!"_ZTSN7glslang10TSourceLocE", !6, i64 0, !16, i64 8, !16, i64 12, !16, i64 16}
!19 = !{!16, !16, i64 0}
!20 = !{i64 0, i64 8, !5, i64 8, i64 4, !19, i64 12, i64 4, !19, i64 16, i64 4, !19, i64 24, i64 1, !21, i64 32, i64 8, !22, i64 40, i64 1025, !22}
!21 = !{!11, !11, i64 0}
!22 = !{!7, !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 nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef i32 @_ZN7glslang10TPpContext16tUngotTokenInput4scanEPNS_8TPpTokenE(ptr nocapture noundef nonnull align 8 dereferenceable(1104) %0, ptr nocapture noundef writeonly %1) unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i8, ptr %3, align 8, !tbaa !5, !range !11, !noundef !12
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %10, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load i32, ptr %7, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(1065) %1, ptr noundef nonnull align 8 dereferenceable(1065) %9, i64 1065, i1 false), !tbaa.struct !18
  store i8 1, ptr %3, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %2, %6
  %.0 = phi i32 [ %8, %6 ], [ -1, %2 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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" }

!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 8}
!6 = !{!"_ZTSN7glslang10TPpContext6tInputE", !7, i64 8, !10, i64 16}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !15, i64 24}
!14 = !{!"_ZTSN7glslang10TPpContext16tUngotTokenInputE", !6, i64 0, !15, i64 24, !16, i64 32}
!15 = !{!"int", !8, i64 0}
!16 = !{!"_ZTSN7glslang8TPpTokenE", !17, i64 0, !7, i64 24, !8, i64 32, !8, i64 40}
!17 = !{!"_ZTSN7glslang10TSourceLocE", !10, i64 0, !15, i64 8, !15, i64 12, !15, i64 16}
!18 = !{i64 0, i64 8, !19, i64 8, i64 4, !20, i64 12, i64 4, !20, i64 16, i64 4, !20, i64 24, i64 1, !21, i64 32, i64 8, !22, i64 40, i64 1025, !22}
!19 = !{!10, !10, i64 0}
!20 = !{!15, !15, i64 0}
!21 = !{!7, !7, i64 0}
!22 = !{!8, !8, i64 0}


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