; LLVM IR from thepowersgang/mrustc :: src/ast/types.ll (Z19coretype_fromstringPKc)

; 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.anon = type { ptr, i32 }

@_ZL9CORETYPES = external hidden constant [18 x %struct.anon], align 16

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

7:                                                ; preds = %36, %1
  %8 = load i32, ptr %4, align 4, !tbaa !9
  %9 = zext i32 %8 to i64
  %10 = icmp ult i64 %9, 18
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  store i32 2, ptr %5, align 4
  br label %39

12:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = zext i32 %14 to i64
  %16 = getelementptr inbounds [18 x %struct.anon], ptr @_ZL9CORETYPES, i64 0, i64 %15
  %17 = getelementptr inbounds %struct.anon, ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 16, !tbaa !11
  %19 = call i32 @strcmp(ptr noundef %13, ptr noundef %18) #4
  store i32 %19, ptr %6, align 4, !tbaa !9
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = icmp slt i32 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %12
  store i32 2, ptr %5, align 4
  br label %33

23:                                               ; preds = %12
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %32

26:                                               ; preds = %23
  %27 = load i32, ptr %4, align 4, !tbaa !9
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds [18 x %struct.anon], ptr @_ZL9CORETYPES, i64 0, i64 %28
  %30 = getelementptr inbounds %struct.anon, ptr %29, i32 0, i32 1
  %31 = load i32, ptr %30, align 8, !tbaa !14
  store i32 %31, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %33

32:                                               ; preds = %23
  store i32 0, ptr %5, align 4
  br label %33

33:                                               ; preds = %32, %26, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %34 = load i32, ptr %5, align 4
  switch i32 %34, label %39 [
    i32 0, label %35
  ]

35:                                               ; preds = %33
  br label %36

36:                                               ; preds = %35
  %37 = load i32, ptr %4, align 4, !tbaa !9
  %38 = add i32 %37, 1
  store i32 %38, ptr %4, align 4, !tbaa !9
  br label %7, !llvm.loop !15

39:                                               ; preds = %33, %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %40 = load i32, ptr %5, align 4
  switch i32 %40, label %44 [
    i32 2, label %41
    i32 1, label %42
  ]

41:                                               ; preds = %39
  store i32 0, ptr %2, align 4
  br label %42

42:                                               ; preds = %41, %39
  %43 = load i32, ptr %2, align 4
  ret i32 %43

44:                                               ; preds = %39
  unreachable
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind willreturn memory(read) "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 }
attributes #4 = { nounwind willreturn memory(read) }

!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}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS3$_0", !6, i64 0, !13, i64 8}
!13 = !{!"_ZTS9eCoreType", !7, i64 0}
!14 = !{!12, !13, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"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"

%struct.anon = type { ptr, i32 }

@_ZL9CORETYPES = external hidden local_unnamed_addr constant [18 x %struct.anon], align 16

; Function Attrs: mustprogress nofree nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef i32 @_Z19coretype_fromstringPKc(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr @_ZL9CORETYPES, align 16, !tbaa !5
  %3 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %2) #2
  %4 = icmp slt i32 %3, 0
  br i1 %4, label %.thread, label %105

5:                                                ; preds = %105
  %6 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 16), align 16, !tbaa !5
  %7 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %6) #2
  %8 = icmp slt i32 %7, 0
  br i1 %8, label %.thread, label %9

9:                                                ; preds = %5
  %10 = icmp eq i32 %7, 0
  br i1 %10, label %107, label %11

11:                                               ; preds = %9
  %12 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 32), align 16, !tbaa !5
  %13 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %12) #2
  %14 = icmp slt i32 %13, 0
  br i1 %14, label %.thread, label %15

15:                                               ; preds = %11
  %16 = icmp eq i32 %13, 0
  br i1 %16, label %107, label %17

17:                                               ; preds = %15
  %18 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 48), align 16, !tbaa !5
  %19 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %18) #2
  %20 = icmp slt i32 %19, 0
  br i1 %20, label %.thread, label %21

21:                                               ; preds = %17
  %22 = icmp eq i32 %19, 0
  br i1 %22, label %107, label %23

23:                                               ; preds = %21
  %24 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 64), align 16, !tbaa !5
  %25 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %24) #2
  %26 = icmp slt i32 %25, 0
  br i1 %26, label %.thread, label %27

27:                                               ; preds = %23
  %28 = icmp eq i32 %25, 0
  br i1 %28, label %107, label %29

29:                                               ; preds = %27
  %30 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 80), align 16, !tbaa !5
  %31 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %30) #2
  %32 = icmp slt i32 %31, 0
  br i1 %32, label %.thread, label %33

33:                                               ; preds = %29
  %34 = icmp eq i32 %31, 0
  br i1 %34, label %107, label %35

35:                                               ; preds = %33
  %36 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 96), align 16, !tbaa !5
  %37 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %36) #2
  %38 = icmp slt i32 %37, 0
  br i1 %38, label %.thread, label %39

39:                                               ; preds = %35
  %40 = icmp eq i32 %37, 0
  br i1 %40, label %107, label %41

41:                                               ; preds = %39
  %42 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 112), align 16, !tbaa !5
  %43 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %42) #2
  %44 = icmp slt i32 %43, 0
  br i1 %44, label %.thread, label %45

45:                                               ; preds = %41
  %46 = icmp eq i32 %43, 0
  br i1 %46, label %107, label %47

47:                                               ; preds = %45
  %48 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 128), align 16, !tbaa !5
  %49 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %48) #2
  %50 = icmp slt i32 %49, 0
  br i1 %50, label %.thread, label %51

51:                                               ; preds = %47
  %52 = icmp eq i32 %49, 0
  br i1 %52, label %107, label %53

53:                                               ; preds = %51
  %54 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 144), align 16, !tbaa !5
  %55 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %54) #2
  %56 = icmp slt i32 %55, 0
  br i1 %56, label %.thread, label %57

57:                                               ; preds = %53
  %58 = icmp eq i32 %55, 0
  br i1 %58, label %107, label %59

59:                                               ; preds = %57
  %60 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 160), align 16, !tbaa !5
  %61 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %60) #2
  %62 = icmp slt i32 %61, 0
  br i1 %62, label %.thread, label %63

63:                                               ; preds = %59
  %64 = icmp eq i32 %61, 0
  br i1 %64, label %107, label %65

65:                                               ; preds = %63
  %66 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 176), align 16, !tbaa !5
  %67 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %66) #2
  %68 = icmp slt i32 %67, 0
  br i1 %68, label %.thread, label %69

69:                                               ; preds = %65
  %70 = icmp eq i32 %67, 0
  br i1 %70, label %107, label %71

71:                                               ; preds = %69
  %72 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 192), align 16, !tbaa !5
  %73 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %72) #2
  %74 = icmp slt i32 %73, 0
  br i1 %74, label %.thread, label %75

75:                                               ; preds = %71
  %76 = icmp eq i32 %73, 0
  br i1 %76, label %107, label %77

77:                                               ; preds = %75
  %78 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 208), align 16, !tbaa !5
  %79 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %78) #2
  %80 = icmp slt i32 %79, 0
  br i1 %80, label %.thread, label %81

81:                                               ; preds = %77
  %82 = icmp eq i32 %79, 0
  br i1 %82, label %107, label %83

83:                                               ; preds = %81
  %84 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 224), align 16, !tbaa !5
  %85 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %84) #2
  %86 = icmp slt i32 %85, 0
  br i1 %86, label %.thread, label %87

87:                                               ; preds = %83
  %88 = icmp eq i32 %85, 0
  br i1 %88, label %107, label %89

89:                                               ; preds = %87
  %90 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 240), align 16, !tbaa !5
  %91 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %90) #2
  %92 = icmp slt i32 %91, 0
  br i1 %92, label %.thread, label %93

93:                                               ; preds = %89
  %94 = icmp eq i32 %91, 0
  br i1 %94, label %107, label %95

95:                                               ; preds = %93
  %96 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 256), align 16, !tbaa !5
  %97 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %96) #2
  %98 = icmp slt i32 %97, 0
  br i1 %98, label %.thread, label %99

99:                                               ; preds = %95
  %100 = icmp eq i32 %97, 0
  br i1 %100, label %107, label %101

101:                                              ; preds = %99
  %102 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 272), align 16, !tbaa !5
  %103 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %102) #2
  %104 = icmp eq i32 %103, 0
  br i1 %104, label %107, label %.thread

105:                                              ; preds = %1
  %106 = icmp eq i32 %3, 0
  br i1 %106, label %107, label %5

107:                                              ; preds = %101, %99, %93, %87, %81, %75, %69, %63, %57, %51, %45, %39, %33, %27, %21, %15, %9, %105
  %.lcssa18 = phi ptr [ @_ZL9CORETYPES, %105 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 16), %9 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 32), %15 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 48), %21 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 64), %27 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 80), %33 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 96), %39 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 112), %45 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 128), %51 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 144), %57 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 160), %63 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 176), %69 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 192), %75 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 208), %81 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 224), %87 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 240), %93 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 256), %99 ], [ getelementptr inbounds (i8, ptr @_ZL9CORETYPES, i64 272), %101 ]
  %108 = getelementptr inbounds i8, ptr %.lcssa18, i64 8
  %109 = load i32, ptr %108, align 8, !tbaa !11
  br label %.thread

.thread:                                          ; preds = %1, %5, %11, %17, %23, %29, %35, %41, %47, %53, %59, %65, %71, %77, %83, %89, %95, %101, %107
  %switch = phi i32 [ %109, %107 ], [ 0, %101 ], [ 0, %95 ], [ 0, %89 ], [ 0, %83 ], [ 0, %77 ], [ 0, %71 ], [ 0, %65 ], [ 0, %59 ], [ 0, %53 ], [ 0, %47 ], [ 0, %41 ], [ 0, %35 ], [ 0, %29 ], [ 0, %23 ], [ 0, %17 ], [ 0, %11 ], [ 0, %5 ], [ 0, %1 ]
  ret i32 %switch
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nofree nounwind willreturn memory(read, inaccessiblemem: none) 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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }

!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 = !{!"_ZTS3$_0", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS9eCoreType", !8, i64 0}
!11 = !{!6, !10, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass