; LLVM IR from lionsoul2014/friso :: src (friso_ctype)

; 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.friso_task_entry = type { ptr, i32, i32, i32, i32, i32, ptr, ptr, ptr, [7 x i8] }

; Function Attrs: nounwind uwtable
define dso_local i32 @friso_enchar_type(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !5
  %8 = load i32, ptr %4, align 4, !tbaa !5
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %14

10:                                               ; preds = %2
  %11 = load ptr, ptr %5, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct.friso_task_entry, ptr %11, i32 0, i32 4
  %13 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %13, ptr %6, align 4, !tbaa !5
  br label %24

14:                                               ; preds = %2
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %23

17:                                               ; preds = %14
  %18 = load ptr, ptr %5, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.friso_task_entry, ptr %18, i32 0, i32 9
  %20 = getelementptr inbounds [7 x i8], ptr %19, i64 0, i64 0
  %21 = load i8, ptr %20, align 8, !tbaa !13
  %22 = zext i8 %21 to i32
  store i32 %22, ptr %6, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %17, %14
  br label %24

24:                                               ; preds = %23, %10
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = icmp ugt i32 %25, 126
  br i1 %26, label %30, label %27

27:                                               ; preds = %24
  %28 = load i32, ptr %6, align 4, !tbaa !5
  %29 = icmp ult i32 %28, 32
  br i1 %29, label %30, label %31

30:                                               ; preds = %27, %24
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %57

31:                                               ; preds = %27
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = icmp eq i32 %32, 32
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  store i32 3, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %57

35:                                               ; preds = %31
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = icmp uge i32 %36, 48
  br i1 %37, label %38, label %42

38:                                               ; preds = %35
  %39 = load i32, ptr %6, align 4, !tbaa !5
  %40 = icmp ule i32 %39, 57
  br i1 %40, label %41, label %42

41:                                               ; preds = %38
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %57

42:                                               ; preds = %38, %35
  %43 = load i32, ptr %6, align 4, !tbaa !5
  %44 = icmp uge i32 %43, 65
  br i1 %44, label %45, label %49

45:                                               ; preds = %42
  %46 = load i32, ptr %6, align 4, !tbaa !5
  %47 = icmp ule i32 %46, 90
  br i1 %47, label %48, label %49

48:                                               ; preds = %45
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %57

49:                                               ; preds = %45, %42
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = icmp uge i32 %50, 97
  br i1 %51, label %52, label %56

52:                                               ; preds = %49
  %53 = load i32, ptr %6, align 4, !tbaa !5
  %54 = icmp ule i32 %53, 122
  br i1 %54, label %55, label %56

55:                                               ; preds = %52
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %57

56:                                               ; preds = %52, %49
  store i32 2, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %57

57:                                               ; preds = %56, %55, %48, %41, %34, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %58 = load i32, ptr %3, align 4
  ret i32 %58
}

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

; 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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 20}
!12 = !{!"", !10, i64 0, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !7, i64 56}
!13 = !{!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 nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local range(i32 -1, 4) i32 @friso_enchar_type(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  switch i32 %0, label %.thread [
    i32 0, label %3
    i32 1, label %6
  ]

3:                                                ; preds = %2
  %4 = getelementptr inbounds i8, ptr %1, i64 20
  %5 = load i32, ptr %4, align 4, !tbaa !5
  br label %10

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 56
  %8 = load i8, ptr %7, align 8, !tbaa !11
  %9 = zext i8 %8 to i32
  br label %10

10:                                               ; preds = %6, %3
  %.0 = phi i32 [ %5, %3 ], [ %9, %6 ]
  %11 = add i32 %.0, -127
  %or.cond = icmp ult i32 %11, -95
  br i1 %or.cond, label %.thread, label %12

12:                                               ; preds = %10
  %13 = icmp eq i32 %.0, 32
  br i1 %13, label %.thread, label %14

14:                                               ; preds = %12
  %15 = add nsw i32 %.0, -48
  %or.cond3 = icmp ult i32 %15, 10
  br i1 %or.cond3, label %.thread, label %16

16:                                               ; preds = %14
  %17 = add nsw i32 %.0, -65
  %or.cond5 = icmp ult i32 %17, 26
  br i1 %or.cond5, label %.thread, label %18

18:                                               ; preds = %16
  %19 = add nsw i32 %.0, -97
  %or.cond7 = icmp ult i32 %19, 26
  %. = select i1 %or.cond7, i32 0, i32 2
  br label %.thread

.thread:                                          ; preds = %2, %18, %16, %14, %12, %10
  %.020 = phi i32 [ -1, %10 ], [ 3, %12 ], [ 1, %14 ], [ 0, %16 ], [ %., %18 ], [ -1, %2 ]
  ret i32 %.020
}

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

!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, !10, i64 20}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !8, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!8, !8, i64 0}


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