; LLVM IR from snowballstem/snowball :: compiler (tokeniser)

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

%struct.tokeniser = type { ptr, ptr, i32, ptr, i32, i32, ptr, ptr, i32, i32, i32, ptr, i32, i32, i32, i32, i8, i8, i32, i32, ptr, i32, [94 x i8] }

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

declare ptr @create_s(i32 noundef) #1

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

declare ptr @check_malloc(i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @create_tokeniser(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %6 = call ptr @check_malloc(i64 noundef 224)
  store ptr %6, ptr %5, align 8, !tbaa !5
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.tokeniser, ptr %7, i32 0, i32 0
  store ptr null, ptr %8, align 8, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.tokeniser, ptr %10, i32 0, i32 1
  store ptr %9, ptr %11, align 8, !tbaa !12
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.tokeniser, ptr %12, i32 0, i32 2
  store i32 0, ptr %13, align 8, !tbaa !13
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.tokeniser, ptr %15, i32 0, i32 3
  store ptr %14, ptr %16, align 8, !tbaa !14
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.tokeniser, ptr %17, i32 0, i32 4
  store i32 0, ptr %18, align 8, !tbaa !15
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.tokeniser, ptr %19, i32 0, i32 5
  store i32 1, ptr %20, align 4, !tbaa !16
  %21 = call ptr @create_b(i32 noundef 0)
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.tokeniser, ptr %22, i32 0, i32 6
  store ptr %21, ptr %23, align 8, !tbaa !17
  %24 = call ptr @create_s(i32 noundef 0)
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.tokeniser, ptr %25, i32 0, i32 7
  store ptr %24, ptr %26, align 8, !tbaa !18
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.tokeniser, ptr %27, i32 0, i32 9
  store i32 -1, ptr %28, align 4, !tbaa !19
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.tokeniser, ptr %29, i32 0, i32 11
  store ptr null, ptr %30, align 8, !tbaa !20
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.tokeniser, ptr %31, i32 0, i32 12
  store i32 0, ptr %32, align 8, !tbaa !21
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.tokeniser, ptr %33, i32 0, i32 13
  store i32 0, ptr %34, align 4, !tbaa !22
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.tokeniser, ptr %35, i32 0, i32 16
  store i8 0, ptr %36, align 8, !tbaa !23
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.tokeniser, ptr %37, i32 0, i32 17
  store i8 0, ptr %38, align 1, !tbaa !24
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.tokeniser, ptr %39, i32 0, i32 14
  store i32 -2, ptr %40, align 8, !tbaa !25
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.tokeniser, ptr %41, i32 0, i32 15
  store i32 -2, ptr %42, align 4, !tbaa !26
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.tokeniser, ptr %43, i32 0, i32 21
  store i32 0, ptr %44, align 8, !tbaa !27
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.tokeniser, ptr %45, i32 0, i32 22
  %47 = getelementptr inbounds [94 x i8], ptr %46, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 4 %47, i8 0, i64 94, i1 false)
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret ptr %48
}

declare ptr @create_b(i32 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"tokeniser", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !6, i64 40, !6, i64 48, !11, i64 56, !11, i64 60, !11, i64 64, !6, i64 72, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !7, i64 96, !7, i64 97, !11, i64 100, !11, i64 104, !6, i64 112, !11, i64 120, !7, i64 124}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !11, i64 16}
!14 = !{!10, !6, i64 24}
!15 = !{!10, !11, i64 32}
!16 = !{!10, !11, i64 36}
!17 = !{!10, !6, i64 40}
!18 = !{!10, !6, i64 48}
!19 = !{!10, !11, i64 60}
!20 = !{!10, !6, i64 72}
!21 = !{!10, !11, i64 80}
!22 = !{!10, !11, i64 84}
!23 = !{!10, !7, i64 96}
!24 = !{!10, !7, i64 97}
!25 = !{!10, !11, i64 88}
!26 = !{!10, !11, i64 92}
!27 = !{!10, !11, i64 120}


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

declare ptr @create_s(i32 noundef) local_unnamed_addr #0

declare ptr @check_malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @create_tokeniser(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = tail call ptr @check_malloc(i64 noundef 224) #3
  store ptr null, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %0, ptr %4, align 8, !tbaa !11
  %5 = getelementptr inbounds i8, ptr %3, i64 16
  store i32 0, ptr %5, align 8, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %3, i64 24
  store ptr %1, ptr %6, align 8, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %3, i64 32
  store i32 0, ptr %7, align 8, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %3, i64 36
  store i32 1, ptr %8, align 4, !tbaa !15
  %9 = tail call ptr @create_b(i32 noundef 0) #3
  %10 = getelementptr inbounds i8, ptr %3, i64 40
  store ptr %9, ptr %10, align 8, !tbaa !16
  %11 = tail call ptr @create_s(i32 noundef 0) #3
  %12 = getelementptr inbounds i8, ptr %3, i64 48
  store ptr %11, ptr %12, align 8, !tbaa !17
  %13 = getelementptr inbounds i8, ptr %3, i64 60
  store i32 -1, ptr %13, align 4, !tbaa !18
  %14 = getelementptr inbounds i8, ptr %3, i64 72
  %15 = getelementptr inbounds i8, ptr %3, i64 96
  store i8 0, ptr %15, align 8, !tbaa !19
  %16 = getelementptr inbounds i8, ptr %3, i64 97
  store i8 0, ptr %16, align 1, !tbaa !20
  %17 = getelementptr inbounds i8, ptr %3, i64 88
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %14, i8 0, i64 16, i1 false)
  store i32 -2, ptr %17, align 8, !tbaa !21
  %18 = getelementptr inbounds i8, ptr %3, i64 92
  store i32 -2, ptr %18, align 4, !tbaa !22
  %19 = getelementptr inbounds i8, ptr %3, i64 120
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(98) %19, i8 0, i64 98, i1 false)
  ret ptr %3
}

declare ptr @create_b(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #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 = { 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 nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 0}
!6 = !{!"tokeniser", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !7, i64 40, !7, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !7, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !8, i64 96, !8, i64 97, !10, i64 100, !10, i64 104, !7, i64 112, !10, i64 120, !8, i64 124}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !10, i64 16}
!13 = !{!6, !7, i64 24}
!14 = !{!6, !10, i64 32}
!15 = !{!6, !10, i64 36}
!16 = !{!6, !7, i64 40}
!17 = !{!6, !7, i64 48}
!18 = !{!6, !10, i64 60}
!19 = !{!6, !8, i64 96}
!20 = !{!6, !8, i64 97}
!21 = !{!6, !10, i64 88}
!22 = !{!6, !10, i64 92}


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