; LLVM IR from masyagin1998/GCI :: src/lexer (pos)

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

@__const.pos_is_unknown.symbols = external hidden unnamed_addr constant [19 x i8], align 16

; Function Attrs: inlinehint nounwind uwtable
declare dso_local i32 @pos_is_whitespace(ptr noundef) #0

; Function Attrs: inlinehint nounwind uwtable
declare dso_local i32 @pos_get_code(ptr noundef) #0

; Function Attrs: inlinehint nounwind uwtable
declare dso_local i32 @pos_is_newline(ptr noundef) #0

; Function Attrs: inlinehint nounwind uwtable
declare dso_local i32 @pos_is_digit(ptr noundef) #0

; Function Attrs: inlinehint nounwind uwtable
declare dso_local i32 @pos_is_letter(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @pos_is_unknown(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca [19 x i8], align 16
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 19, ptr %5) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %5, ptr align 16 @__const.pos_is_unknown.symbols, i64 19, i1 false)
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = call i32 @pos_is_whitespace(ptr noundef %7)
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %22, label %10

10:                                               ; preds = %1
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = call i32 @pos_is_newline(ptr noundef %11)
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %22, label %14

14:                                               ; preds = %10
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = call i32 @pos_is_digit(ptr noundef %15)
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %22, label %18

18:                                               ; preds = %14
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = call i32 @pos_is_letter(ptr noundef %19)
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %18, %14, %10, %1
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %41

23:                                               ; preds = %18
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %37, %23
  %25 = load i64, ptr %4, align 8, !tbaa !9
  %26 = icmp ult i64 %25, 19
  br i1 %26, label %27, label %40

27:                                               ; preds = %24
  %28 = load i64, ptr %4, align 8, !tbaa !9
  %29 = getelementptr inbounds [19 x i8], ptr %5, i64 0, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !11
  %31 = sext i8 %30 to i32
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = call i32 @pos_get_code(ptr noundef %32)
  %34 = icmp eq i32 %31, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %27
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %41

36:                                               ; preds = %27
  br label %37

37:                                               ; preds = %36
  %38 = load i64, ptr %4, align 8, !tbaa !9
  %39 = add i64 %38, 1
  store i64 %39, ptr %4, align 8, !tbaa !9
  br label %24, !llvm.loop !12

40:                                               ; preds = %24
  store i32 1, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %41

41:                                               ; preds = %40, %35, %22
  call void @llvm.lifetime.end.p0(i64 19, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %42 = load i32, ptr %2, align 4
  ret i32 %42
}

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

; 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) #3

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

attributes #0 = { inlinehint 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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

@__const.pos_is_unknown.symbols = external hidden unnamed_addr constant [19 x i8], align 16

; Function Attrs: inlinehint nounwind uwtable
declare dso_local i32 @pos_is_whitespace(ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare dso_local i32 @pos_get_code(ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare dso_local i32 @pos_is_newline(ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare dso_local i32 @pos_is_digit(ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare dso_local i32 @pos_is_letter(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @pos_is_unknown(ptr noundef %0) local_unnamed_addr #1 {
  %2 = tail call i32 @pos_is_whitespace(ptr noundef %0)
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %3, label %.loopexit

3:                                                ; preds = %1
  %4 = tail call i32 @pos_is_newline(ptr noundef %0)
  %.not9 = icmp eq i32 %4, 0
  br i1 %.not9, label %5, label %.loopexit

5:                                                ; preds = %3
  %6 = tail call i32 @pos_is_digit(ptr noundef %0)
  %.not10 = icmp eq i32 %6, 0
  br i1 %.not10, label %7, label %.loopexit

7:                                                ; preds = %5
  %8 = tail call i32 @pos_is_letter(ptr noundef %0)
  %.not11 = icmp eq i32 %8, 0
  br i1 %.not11, label %.preheader.preheader, label %.loopexit

.preheader.preheader:                             ; preds = %7
  %9 = load i8, ptr @__const.pos_is_unknown.symbols, align 16, !tbaa !5
  %10 = sext i8 %9 to i32
  %11 = tail call i32 @pos_get_code(ptr noundef %0)
  %12 = icmp eq i32 %11, %10
  br i1 %12, label %.loopexit, label %.preheader.1

.preheader.1:                                     ; preds = %.preheader.preheader
  %13 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 1), align 1, !tbaa !5
  %14 = sext i8 %13 to i32
  %15 = tail call i32 @pos_get_code(ptr noundef %0)
  %16 = icmp eq i32 %15, %14
  br i1 %16, label %.loopexit, label %.preheader.2

.preheader.2:                                     ; preds = %.preheader.1
  %17 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 2), align 2, !tbaa !5
  %18 = sext i8 %17 to i32
  %19 = tail call i32 @pos_get_code(ptr noundef %0)
  %20 = icmp eq i32 %19, %18
  br i1 %20, label %.loopexit, label %.preheader.3

.preheader.3:                                     ; preds = %.preheader.2
  %21 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 3), align 1, !tbaa !5
  %22 = sext i8 %21 to i32
  %23 = tail call i32 @pos_get_code(ptr noundef %0)
  %24 = icmp eq i32 %23, %22
  br i1 %24, label %.loopexit, label %.preheader.4

.preheader.4:                                     ; preds = %.preheader.3
  %25 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 4), align 4, !tbaa !5
  %26 = sext i8 %25 to i32
  %27 = tail call i32 @pos_get_code(ptr noundef %0)
  %28 = icmp eq i32 %27, %26
  br i1 %28, label %.loopexit, label %.preheader.5

.preheader.5:                                     ; preds = %.preheader.4
  %29 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 5), align 1, !tbaa !5
  %30 = sext i8 %29 to i32
  %31 = tail call i32 @pos_get_code(ptr noundef %0)
  %32 = icmp eq i32 %31, %30
  br i1 %32, label %.loopexit, label %.preheader.6

.preheader.6:                                     ; preds = %.preheader.5
  %33 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 6), align 2, !tbaa !5
  %34 = sext i8 %33 to i32
  %35 = tail call i32 @pos_get_code(ptr noundef %0)
  %36 = icmp eq i32 %35, %34
  br i1 %36, label %.loopexit, label %.preheader.7

.preheader.7:                                     ; preds = %.preheader.6
  %37 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 7), align 1, !tbaa !5
  %38 = sext i8 %37 to i32
  %39 = tail call i32 @pos_get_code(ptr noundef %0)
  %40 = icmp eq i32 %39, %38
  br i1 %40, label %.loopexit, label %.preheader.8

.preheader.8:                                     ; preds = %.preheader.7
  %41 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 8), align 8, !tbaa !5
  %42 = sext i8 %41 to i32
  %43 = tail call i32 @pos_get_code(ptr noundef %0)
  %44 = icmp eq i32 %43, %42
  br i1 %44, label %.loopexit, label %.preheader.9

.preheader.9:                                     ; preds = %.preheader.8
  %45 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 9), align 1, !tbaa !5
  %46 = sext i8 %45 to i32
  %47 = tail call i32 @pos_get_code(ptr noundef %0)
  %48 = icmp eq i32 %47, %46
  br i1 %48, label %.loopexit, label %.preheader.10

.preheader.10:                                    ; preds = %.preheader.9
  %49 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 10), align 2, !tbaa !5
  %50 = sext i8 %49 to i32
  %51 = tail call i32 @pos_get_code(ptr noundef %0)
  %52 = icmp eq i32 %51, %50
  br i1 %52, label %.loopexit, label %.preheader.11

.preheader.11:                                    ; preds = %.preheader.10
  %53 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 11), align 1, !tbaa !5
  %54 = sext i8 %53 to i32
  %55 = tail call i32 @pos_get_code(ptr noundef %0)
  %56 = icmp eq i32 %55, %54
  br i1 %56, label %.loopexit, label %.preheader.12

.preheader.12:                                    ; preds = %.preheader.11
  %57 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 12), align 4, !tbaa !5
  %58 = sext i8 %57 to i32
  %59 = tail call i32 @pos_get_code(ptr noundef %0)
  %60 = icmp eq i32 %59, %58
  br i1 %60, label %.loopexit, label %.preheader.13

.preheader.13:                                    ; preds = %.preheader.12
  %61 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 13), align 1, !tbaa !5
  %62 = sext i8 %61 to i32
  %63 = tail call i32 @pos_get_code(ptr noundef %0)
  %64 = icmp eq i32 %63, %62
  br i1 %64, label %.loopexit, label %.preheader.14

.preheader.14:                                    ; preds = %.preheader.13
  %65 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 14), align 2, !tbaa !5
  %66 = sext i8 %65 to i32
  %67 = tail call i32 @pos_get_code(ptr noundef %0)
  %68 = icmp eq i32 %67, %66
  br i1 %68, label %.loopexit, label %.preheader.15

.preheader.15:                                    ; preds = %.preheader.14
  %69 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 15), align 1, !tbaa !5
  %70 = sext i8 %69 to i32
  %71 = tail call i32 @pos_get_code(ptr noundef %0)
  %72 = icmp eq i32 %71, %70
  br i1 %72, label %.loopexit, label %.preheader.16

.preheader.16:                                    ; preds = %.preheader.15
  %73 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 16), align 16, !tbaa !5
  %74 = sext i8 %73 to i32
  %75 = tail call i32 @pos_get_code(ptr noundef %0)
  %76 = icmp eq i32 %75, %74
  br i1 %76, label %.loopexit, label %.preheader.17

.preheader.17:                                    ; preds = %.preheader.16
  %77 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 17), align 1, !tbaa !5
  %78 = sext i8 %77 to i32
  %79 = tail call i32 @pos_get_code(ptr noundef %0)
  %80 = icmp eq i32 %79, %78
  br i1 %80, label %.loopexit, label %.preheader.18

.preheader.18:                                    ; preds = %.preheader.17
  %81 = load i8, ptr getelementptr inbounds (i8, ptr @__const.pos_is_unknown.symbols, i64 18), align 2, !tbaa !5
  %82 = sext i8 %81 to i32
  %83 = tail call i32 @pos_get_code(ptr noundef %0)
  %84 = icmp ne i32 %83, %82
  %spec.select = zext i1 %84 to i32
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.18, %.preheader.preheader, %.preheader.1, %.preheader.2, %.preheader.3, %.preheader.4, %.preheader.5, %.preheader.6, %.preheader.7, %.preheader.8, %.preheader.9, %.preheader.10, %.preheader.11, %.preheader.12, %.preheader.13, %.preheader.14, %.preheader.15, %.preheader.16, %.preheader.17, %1, %3, %5, %7
  %.08 = phi i32 [ 0, %7 ], [ 0, %5 ], [ 0, %3 ], [ 0, %1 ], [ 0, %.preheader.preheader ], [ 0, %.preheader.1 ], [ 0, %.preheader.2 ], [ 0, %.preheader.3 ], [ 0, %.preheader.4 ], [ 0, %.preheader.5 ], [ 0, %.preheader.6 ], [ 0, %.preheader.7 ], [ 0, %.preheader.8 ], [ 0, %.preheader.9 ], [ 0, %.preheader.10 ], [ 0, %.preheader.11 ], [ 0, %.preheader.12 ], [ 0, %.preheader.13 ], [ 0, %.preheader.14 ], [ 0, %.preheader.15 ], [ 0, %.preheader.16 ], [ 0, %.preheader.17 ], [ %spec.select, %.preheader.18 ]
  ret i32 %.08
}

attributes #0 = { inlinehint 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 = { 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" }

!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"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass