; LLVM IR from BrunoLevy/learn-fpga :: LiteX/software/Doom/mc1-doom/src (hu_stuff)

; 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.player_s = type { ptr, i32, %struct.ticcmd_t, i32, i32, i32, i32, i32, i32, i32, [6 x i32], [6 x i32], i32, [4 x i32], i32, i32, [9 x i32], [4 x i32], [4 x i32], i32, i32, i32, i32, i32, i32, i32, ptr, i32, i32, ptr, i32, i32, i32, [2 x %struct.pspdef_t], i32 }
%struct.ticcmd_t = type { i8, i8, i16, i16, i8, i8 }
%struct.pspdef_t = type { ptr, i32, i32, i32 }
%struct.hu_stext_t = type { [4 x %struct.hu_textline_t], i32, i32, ptr, i32 }
%struct.hu_textline_t = type { i32, i32, ptr, i32, [81 x i8], i32, i32 }
%struct.hu_itext_t = type { %struct.hu_textline_t, i32, ptr, i32 }

@player_names = external dso_local global [4 x ptr], align 16
@shiftxform = external dso_local global ptr, align 8
@players = external global [4 x %struct.player_s], align 16
@consoleplayer = external global i32, align 4
@plr = external hidden global ptr, align 8
@message_on = external hidden global i32, align 4
@message_dontfuckwithme = external dso_local global i32, align 4
@message_nottobefuckedwith = external hidden global i32, align 4
@w_message = external hidden global %struct.hu_stext_t, align 8
@gamemode = external global i32, align 4
@w_inputbuffer = external hidden global [4 x %struct.hu_itext_t], align 16
@message_counter = external hidden global i32, align 4
@showMessages = external global i32, align 4
@netgame = external global i32, align 4
@playeringame = external global [4 x i32], align 16
@chat_dest = external hidden global [4 x i8], align 1

; 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: nounwind uwtable
define dso_local void @HU_Ticker() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #3
  %4 = load i32, ptr @message_counter, align 4, !tbaa !5
  %5 = icmp ne i32 %4, 0
  br i1 %5, label %6, label %11

6:                                                ; preds = %0
  %7 = load i32, ptr @message_counter, align 4, !tbaa !5
  %8 = add nsw i32 %7, -1
  store i32 %8, ptr @message_counter, align 4, !tbaa !5
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %11, label %10

10:                                               ; preds = %6
  store i32 0, ptr @message_on, align 4, !tbaa !5
  store i32 0, ptr @message_nottobefuckedwith, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %10, %6, %0
  %12 = load i32, ptr @showMessages, align 4, !tbaa !5
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %17, label %14

14:                                               ; preds = %11
  %15 = load i32, ptr @message_dontfuckwithme, align 4, !tbaa !5
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %41

17:                                               ; preds = %14, %11
  %18 = load ptr, ptr @plr, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.player_s, ptr %18, i32 0, i32 26
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %25

22:                                               ; preds = %17
  %23 = load i32, ptr @message_nottobefuckedwith, align 4, !tbaa !5
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %33

25:                                               ; preds = %22, %17
  %26 = load ptr, ptr @plr, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.player_s, ptr %26, i32 0, i32 26
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %40

30:                                               ; preds = %25
  %31 = load i32, ptr @message_dontfuckwithme, align 4, !tbaa !5
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %40

33:                                               ; preds = %30, %22
  %34 = load ptr, ptr @plr, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.player_s, ptr %34, i32 0, i32 26
  %36 = load ptr, ptr %35, align 8, !tbaa !11
  call void @HUlib_addMessageToSText(ptr noundef @w_message, ptr noundef null, ptr noundef %36)
  %37 = load ptr, ptr @plr, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.player_s, ptr %37, i32 0, i32 26
  store ptr null, ptr %38, align 8, !tbaa !11
  store i32 1, ptr @message_on, align 4, !tbaa !5
  store i32 140, ptr @message_counter, align 4, !tbaa !5
  %39 = load i32, ptr @message_dontfuckwithme, align 4, !tbaa !5
  store i32 %39, ptr @message_nottobefuckedwith, align 4, !tbaa !5
  store i32 0, ptr @message_dontfuckwithme, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %33, %30, %25
  br label %41

41:                                               ; preds = %40, %14
  %42 = load i32, ptr @netgame, align 4, !tbaa !5
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %159

44:                                               ; preds = %41
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %155, %44
  %46 = load i32, ptr %1, align 4, !tbaa !5
  %47 = icmp slt i32 %46, 4
  br i1 %47, label %48, label %158

48:                                               ; preds = %45
  %49 = load i32, ptr %1, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [4 x i32], ptr @playeringame, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %55, label %54

54:                                               ; preds = %48
  br label %155

55:                                               ; preds = %48
  %56 = load i32, ptr %1, align 4, !tbaa !5
  %57 = load i32, ptr @consoleplayer, align 4, !tbaa !5
  %58 = icmp ne i32 %56, %57
  br i1 %58, label %59, label %154

59:                                               ; preds = %55
  %60 = load i32, ptr %1, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %61
  %63 = getelementptr inbounds %struct.player_s, ptr %62, i32 0, i32 2
  %64 = getelementptr inbounds %struct.ticcmd_t, ptr %63, i32 0, i32 4
  %65 = load i8, ptr %64, align 2, !tbaa !15
  store i8 %65, ptr %3, align 1, !tbaa !16
  %66 = sext i8 %65 to i32
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %154

68:                                               ; preds = %59
  %69 = load i8, ptr %3, align 1, !tbaa !16
  %70 = sext i8 %69 to i32
  %71 = icmp sle i32 %70, 5
  br i1 %71, label %72, label %77

72:                                               ; preds = %68
  %73 = load i8, ptr %3, align 1, !tbaa !16
  %74 = load i32, ptr %1, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [4 x i8], ptr @chat_dest, i64 0, i64 %75
  store i8 %73, ptr %76, align 1, !tbaa !16
  br label %148

77:                                               ; preds = %68
  %78 = load i8, ptr %3, align 1, !tbaa !16
  %79 = sext i8 %78 to i32
  %80 = icmp sge i32 %79, 97
  br i1 %80, label %81, label %91

81:                                               ; preds = %77
  %82 = load i8, ptr %3, align 1, !tbaa !16
  %83 = sext i8 %82 to i32
  %84 = icmp sle i32 %83, 122
  br i1 %84, label %85, label %91

85:                                               ; preds = %81
  %86 = load ptr, ptr @shiftxform, align 8, !tbaa !9
  %87 = load i8, ptr %3, align 1, !tbaa !16
  %88 = zext i8 %87 to i64
  %89 = getelementptr inbounds i8, ptr %86, i64 %88
  %90 = load i8, ptr %89, align 1, !tbaa !16
  store i8 %90, ptr %3, align 1, !tbaa !16
  br label %91

91:                                               ; preds = %85, %81, %77
  %92 = load i32, ptr %1, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [4 x %struct.hu_itext_t], ptr @w_inputbuffer, i64 0, i64 %93
  %95 = load i8, ptr %3, align 1, !tbaa !16
  %96 = call i32 @HUlib_keyInIText(ptr noundef %94, i8 noundef zeroext %95)
  store i32 %96, ptr %2, align 4, !tbaa !5
  %97 = load i32, ptr %2, align 4, !tbaa !5
  %98 = icmp ne i32 %97, 0
  br i1 %98, label %99, label %147

99:                                               ; preds = %91
  %100 = load i8, ptr %3, align 1, !tbaa !16
  %101 = sext i8 %100 to i32
  %102 = icmp eq i32 %101, 13
  br i1 %102, label %103, label %147

103:                                              ; preds = %99
  %104 = load i32, ptr %1, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [4 x %struct.hu_itext_t], ptr @w_inputbuffer, i64 0, i64 %105
  %107 = getelementptr inbounds %struct.hu_itext_t, ptr %106, i32 0, i32 0
  %108 = getelementptr inbounds %struct.hu_textline_t, ptr %107, i32 0, i32 5
  %109 = load i32, ptr %108, align 8, !tbaa !17
  %110 = icmp ne i32 %109, 0
  br i1 %110, label %111, label %143

111:                                              ; preds = %103
  %112 = load i32, ptr %1, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [4 x i8], ptr @chat_dest, i64 0, i64 %113
  %115 = load i8, ptr %114, align 1, !tbaa !16
  %116 = sext i8 %115 to i32
  %117 = load i32, ptr @consoleplayer, align 4, !tbaa !5
  %118 = add nsw i32 %117, 1
  %119 = icmp eq i32 %116, %118
  br i1 %119, label %127, label %120

120:                                              ; preds = %111
  %121 = load i32, ptr %1, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [4 x i8], ptr @chat_dest, i64 0, i64 %122
  %124 = load i8, ptr %123, align 1, !tbaa !16
  %125 = sext i8 %124 to i32
  %126 = icmp eq i32 %125, 5
  br i1 %126, label %127, label %143

127:                                              ; preds = %120, %111
  %128 = load i32, ptr %1, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [4 x ptr], ptr @player_names, i64 0, i64 %129
  %131 = load ptr, ptr %130, align 8, !tbaa !9
  %132 = load i32, ptr %1, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [4 x %struct.hu_itext_t], ptr @w_inputbuffer, i64 0, i64 %133
  %135 = getelementptr inbounds %struct.hu_itext_t, ptr %134, i32 0, i32 0
  %136 = getelementptr inbounds %struct.hu_textline_t, ptr %135, i32 0, i32 4
  %137 = getelementptr inbounds [81 x i8], ptr %136, i64 0, i64 0
  call void @HUlib_addMessageToSText(ptr noundef @w_message, ptr noundef %131, ptr noundef %137)
  store i32 1, ptr @message_nottobefuckedwith, align 4, !tbaa !5
  store i32 1, ptr @message_on, align 4, !tbaa !5
  store i32 140, ptr @message_counter, align 4, !tbaa !5
  %138 = load i32, ptr @gamemode, align 4, !tbaa !5
  %139 = icmp eq i32 %138, 2
  br i1 %139, label %140, label %141

140:                                              ; preds = %127
  call void @S_StartSound(ptr noundef null, i32 noundef 108)
  br label %142

141:                                              ; preds = %127
  call void @S_StartSound(ptr noundef null, i32 noundef 87)
  br label %142

142:                                              ; preds = %141, %140
  br label %143

143:                                              ; preds = %142, %120, %103
  %144 = load i32, ptr %1, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [4 x %struct.hu_itext_t], ptr @w_inputbuffer, i64 0, i64 %145
  call void @HUlib_resetIText(ptr noundef %146)
  br label %147

147:                                              ; preds = %143, %99, %91
  br label %148

148:                                              ; preds = %147, %72
  %149 = load i32, ptr %1, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [4 x %struct.player_s], ptr @players, i64 0, i64 %150
  %152 = getelementptr inbounds %struct.player_s, ptr %151, i32 0, i32 2
  %153 = getelementptr inbounds %struct.ticcmd_t, ptr %152, i32 0, i32 4
  store i8 0, ptr %153, align 2, !tbaa !15
  br label %154

154:                                              ; preds = %148, %59, %55
  br label %155

155:                                              ; preds = %154, %54
  %156 = load i32, ptr %1, align 4, !tbaa !5
  %157 = add nsw i32 %156, 1
  store i32 %157, ptr %1, align 4, !tbaa !5
  br label %45, !llvm.loop !20

158:                                              ; preds = %45
  br label %159

159:                                              ; preds = %158, %41
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

declare void @HUlib_addMessageToSText(ptr noundef, ptr noundef, ptr noundef) #2

declare i32 @HUlib_keyInIText(ptr noundef, i8 noundef zeroext) #2

declare void @S_StartSound(ptr noundef, i32 noundef) #2

declare void @HUlib_resetIText(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{!"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, !10, i64 224}
!12 = !{!"player_s", !10, i64 0, !6, i64 8, !13, i64 12, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !7, i64 48, !7, i64 72, !6, i64 96, !7, i64 100, !6, i64 116, !6, i64 120, !7, i64 124, !7, i64 160, !7, i64 176, !6, i64 192, !6, i64 196, !6, i64 200, !6, i64 204, !6, i64 208, !6, i64 212, !6, i64 216, !10, i64 224, !6, i64 232, !6, i64 236, !10, i64 240, !6, i64 248, !6, i64 252, !6, i64 256, !7, i64 264, !6, i64 312}
!13 = !{!"", !7, i64 0, !7, i64 1, !14, i64 2, !14, i64 4, !7, i64 6, !7, i64 7}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !7, i64 18}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !6, i64 104}
!18 = !{!"", !19, i64 0, !6, i64 112, !10, i64 120, !6, i64 128}
!19 = !{!"", !6, i64 0, !6, i64 4, !10, i64 8, !6, i64 16, !7, i64 20, !6, i64 104, !6, i64 108}
!20 = distinct !{!20, !21}
!21 = !{!"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.player_s = type { ptr, i32, %struct.ticcmd_t, i32, i32, i32, i32, i32, i32, i32, [6 x i32], [6 x i32], i32, [4 x i32], i32, i32, [9 x i32], [4 x i32], [4 x i32], i32, i32, i32, i32, i32, i32, i32, ptr, i32, i32, ptr, i32, i32, i32, [2 x %struct.pspdef_t], i32 }
%struct.ticcmd_t = type { i8, i8, i16, i16, i8, i8 }
%struct.pspdef_t = type { ptr, i32, i32, i32 }
%struct.hu_stext_t = type { [4 x %struct.hu_textline_t], i32, i32, ptr, i32 }
%struct.hu_textline_t = type { i32, i32, ptr, i32, [81 x i8], i32, i32 }
%struct.hu_itext_t = type { %struct.hu_textline_t, i32, ptr, i32 }

@player_names = external dso_local local_unnamed_addr global [4 x ptr], align 16
@shiftxform = external dso_local local_unnamed_addr global ptr, align 8
@players = external local_unnamed_addr global [4 x %struct.player_s], align 16
@consoleplayer = external local_unnamed_addr global i32, align 4
@plr = external hidden local_unnamed_addr global ptr, align 8
@message_on = external hidden local_unnamed_addr global i32, align 4
@message_dontfuckwithme = external dso_local local_unnamed_addr global i32, align 4
@message_nottobefuckedwith = external hidden local_unnamed_addr global i32, align 4
@w_message = external hidden global %struct.hu_stext_t, align 8
@gamemode = external local_unnamed_addr global i32, align 4
@w_inputbuffer = external hidden global [4 x %struct.hu_itext_t], align 16
@message_counter = external hidden local_unnamed_addr global i32, align 4
@showMessages = external local_unnamed_addr global i32, align 4
@netgame = external local_unnamed_addr global i32, align 4
@playeringame = external local_unnamed_addr global [4 x i32], align 16
@chat_dest = external hidden local_unnamed_addr global [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @HU_Ticker() local_unnamed_addr #0 {
  %1 = load i32, ptr @message_counter, align 4, !tbaa !5
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %5, label %2

2:                                                ; preds = %0
  %3 = add nsw i32 %1, -1
  store i32 %3, ptr @message_counter, align 4, !tbaa !5
  %.not37 = icmp eq i32 %3, 0
  br i1 %.not37, label %4, label %5

4:                                                ; preds = %2
  store i32 0, ptr @message_on, align 4, !tbaa !5
  store i32 0, ptr @message_nottobefuckedwith, align 4, !tbaa !5
  br label %5

5:                                                ; preds = %4, %2, %0
  %6 = load i32, ptr @showMessages, align 4, !tbaa !5
  %7 = icmp ne i32 %6, 0
  %8 = load i32, ptr @message_dontfuckwithme, align 4
  %9 = icmp ne i32 %8, 0
  %or.cond = select i1 %7, i1 true, i1 %9
  br i1 %or.cond, label %10, label %22

10:                                               ; preds = %5
  %11 = load ptr, ptr @plr, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %11, i64 224
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = icmp ne ptr %13, null
  %15 = load i32, ptr @message_nottobefuckedwith, align 4
  %16 = icmp eq i32 %15, 0
  %17 = select i1 %16, i1 true, i1 %9
  %or.cond43 = select i1 %14, i1 %17, i1 false
  br i1 %or.cond43, label %18, label %22

18:                                               ; preds = %10
  tail call void @HUlib_addMessageToSText(ptr noundef nonnull @w_message, ptr noundef null, ptr noundef nonnull %13) #2
  %19 = load ptr, ptr @plr, align 8, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %19, i64 224
  store ptr null, ptr %20, align 8, !tbaa !11
  store i32 1, ptr @message_on, align 4, !tbaa !5
  store i32 140, ptr @message_counter, align 4, !tbaa !5
  %21 = load i32, ptr @message_dontfuckwithme, align 4, !tbaa !5
  store i32 %21, ptr @message_nottobefuckedwith, align 4, !tbaa !5
  store i32 0, ptr @message_dontfuckwithme, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %10, %18, %5
  %23 = load i32, ptr @netgame, align 4, !tbaa !5
  %.not38 = icmp eq i32 %23, 0
  br i1 %.not38, label %.loopexit, label %.preheader.preheader

.preheader.preheader:                             ; preds = %22
  %24 = load i32, ptr @playeringame, align 16, !tbaa !5
  %.not39 = icmp eq i32 %24, 0
  %25 = load i32, ptr @consoleplayer, align 4
  %.not40 = icmp eq i32 %25, 0
  %or.cond44 = select i1 %.not39, i1 true, i1 %.not40
  br i1 %or.cond44, label %.preheader.1, label %26

26:                                               ; preds = %.preheader.preheader
  %27 = load i8, ptr getelementptr inbounds (i8, ptr @players, i64 18), align 2, !tbaa !15
  %.not41 = icmp eq i8 %27, 0
  br i1 %.not41, label %.preheader.1, label %28

28:                                               ; preds = %26
  %29 = icmp slt i8 %27, 6
  br i1 %29, label %30, label %31

30:                                               ; preds = %28
  store i8 %27, ptr @chat_dest, align 1, !tbaa !16
  br label %55

31:                                               ; preds = %28
  %32 = add nsw i8 %27, -97
  %or.cond8 = icmp ult i8 %32, 26
  br i1 %or.cond8, label %33, label %38

33:                                               ; preds = %31
  %34 = load ptr, ptr @shiftxform, align 8, !tbaa !9
  %35 = zext nneg i8 %27 to i64
  %36 = getelementptr inbounds i8, ptr %34, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !16
  br label %38

38:                                               ; preds = %33, %31
  %.0 = phi i8 [ %37, %33 ], [ %27, %31 ]
  %39 = tail call i32 @HUlib_keyInIText(ptr noundef nonnull @w_inputbuffer, i8 noundef zeroext %.0) #2
  %40 = icmp ne i32 %39, 0
  %41 = icmp eq i8 %.0, 13
  %or.cond11 = and i1 %41, %40
  br i1 %or.cond11, label %42, label %55

42:                                               ; preds = %38
  %43 = load i32, ptr getelementptr inbounds (i8, ptr @w_inputbuffer, i64 104), align 8, !tbaa !17
  %.not42 = icmp eq i32 %43, 0
  br i1 %.not42, label %54, label %44

44:                                               ; preds = %42
  %45 = load i8, ptr @chat_dest, align 1, !tbaa !16
  %46 = sext i8 %45 to i32
  %47 = load i32, ptr @consoleplayer, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  %49 = icmp eq i32 %48, %46
  %50 = icmp eq i8 %45, 5
  %or.cond45 = or i1 %50, %49
  br i1 %or.cond45, label %.sink.split, label %54

.sink.split:                                      ; preds = %44
  %51 = load ptr, ptr @player_names, align 16, !tbaa !9
  tail call void @HUlib_addMessageToSText(ptr noundef nonnull @w_message, ptr noundef %51, ptr noundef nonnull getelementptr inbounds (i8, ptr @w_inputbuffer, i64 20)) #2
  store i32 1, ptr @message_nottobefuckedwith, align 4, !tbaa !5
  store i32 1, ptr @message_on, align 4, !tbaa !5
  store i32 140, ptr @message_counter, align 4, !tbaa !5
  %52 = load i32, ptr @gamemode, align 4, !tbaa !5
  %53 = icmp eq i32 %52, 2
  %. = select i1 %53, i32 108, i32 87
  tail call void @S_StartSound(ptr noundef null, i32 noundef %.) #2
  br label %54

54:                                               ; preds = %.sink.split, %44, %42
  tail call void @HUlib_resetIText(ptr noundef nonnull @w_inputbuffer) #2
  br label %55

55:                                               ; preds = %38, %54, %30
  store i8 0, ptr getelementptr inbounds (i8, ptr @players, i64 18), align 2, !tbaa !15
  %.pre = load i32, ptr @consoleplayer, align 4
  br label %.preheader.1

.preheader.1:                                     ; preds = %26, %55, %.preheader.preheader
  %.pre-phi.in = phi i32 [ %25, %26 ], [ %.pre, %55 ], [ %25, %.preheader.preheader ]
  %56 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 4), align 4, !tbaa !5
  %.not39.1 = icmp eq i32 %56, 0
  %.not40.1 = icmp eq i32 %.pre-phi.in, 1
  %or.cond44.1 = select i1 %.not39.1, i1 true, i1 %.not40.1
  br i1 %or.cond44.1, label %.preheader.2, label %57

57:                                               ; preds = %.preheader.1
  %58 = load i8, ptr getelementptr inbounds (i8, ptr @players, i64 338), align 2, !tbaa !15
  %.not41.1 = icmp eq i8 %58, 0
  br i1 %.not41.1, label %.preheader.2, label %59

59:                                               ; preds = %57
  %60 = icmp slt i8 %58, 6
  br i1 %60, label %85, label %61

61:                                               ; preds = %59
  %62 = add nsw i8 %58, -97
  %or.cond8.1 = icmp ult i8 %62, 26
  br i1 %or.cond8.1, label %63, label %68

63:                                               ; preds = %61
  %64 = load ptr, ptr @shiftxform, align 8, !tbaa !9
  %65 = zext nneg i8 %58 to i64
  %66 = getelementptr inbounds i8, ptr %64, i64 %65
  %67 = load i8, ptr %66, align 1, !tbaa !16
  br label %68

68:                                               ; preds = %63, %61
  %.0.1 = phi i8 [ %67, %63 ], [ %58, %61 ]
  %69 = tail call i32 @HUlib_keyInIText(ptr noundef nonnull getelementptr inbounds (i8, ptr @w_inputbuffer, i64 136), i8 noundef zeroext %.0.1) #2
  %70 = icmp ne i32 %69, 0
  %71 = icmp eq i8 %.0.1, 13
  %or.cond11.1 = and i1 %71, %70
  br i1 %or.cond11.1, label %72, label %86

72:                                               ; preds = %68
  %73 = load i32, ptr getelementptr inbounds (i8, ptr @w_inputbuffer, i64 240), align 16, !tbaa !17
  %.not42.1 = icmp eq i32 %73, 0
  br i1 %.not42.1, label %84, label %74

74:                                               ; preds = %72
  %75 = load i8, ptr getelementptr inbounds (i8, ptr @chat_dest, i64 1), align 1, !tbaa !16
  %76 = sext i8 %75 to i32
  %77 = load i32, ptr @consoleplayer, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  %79 = icmp eq i32 %78, %76
  %80 = icmp eq i8 %75, 5
  %or.cond45.1 = or i1 %80, %79
  br i1 %or.cond45.1, label %.sink.split58, label %84

.sink.split58:                                    ; preds = %74
  %81 = load ptr, ptr getelementptr inbounds (i8, ptr @player_names, i64 8), align 8, !tbaa !9
  tail call void @HUlib_addMessageToSText(ptr noundef nonnull @w_message, ptr noundef %81, ptr noundef nonnull getelementptr inbounds (i8, ptr @w_inputbuffer, i64 156)) #2
  store i32 1, ptr @message_nottobefuckedwith, align 4, !tbaa !5
  store i32 1, ptr @message_on, align 4, !tbaa !5
  store i32 140, ptr @message_counter, align 4, !tbaa !5
  %82 = load i32, ptr @gamemode, align 4, !tbaa !5
  %83 = icmp eq i32 %82, 2
  %.64 = select i1 %83, i32 108, i32 87
  tail call void @S_StartSound(ptr noundef null, i32 noundef %.64) #2
  br label %84

84:                                               ; preds = %.sink.split58, %74, %72
  tail call void @HUlib_resetIText(ptr noundef nonnull getelementptr inbounds (i8, ptr @w_inputbuffer, i64 136)) #2
  br label %86

85:                                               ; preds = %59
  store i8 %58, ptr getelementptr inbounds (i8, ptr @chat_dest, i64 1), align 1, !tbaa !16
  br label %86

86:                                               ; preds = %85, %84, %68
  store i8 0, ptr getelementptr inbounds (i8, ptr @players, i64 338), align 2, !tbaa !15
  %.pre51 = load i32, ptr @consoleplayer, align 4
  br label %.preheader.2

.preheader.2:                                     ; preds = %86, %57, %.preheader.1
  %.pre-phi55.in = phi i32 [ %.pre51, %86 ], [ %.pre-phi.in, %57 ], [ %.pre-phi.in, %.preheader.1 ]
  %87 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 8), align 8, !tbaa !5
  %.not39.2 = icmp eq i32 %87, 0
  %.not40.2 = icmp eq i32 %.pre-phi55.in, 2
  %or.cond44.2 = select i1 %.not39.2, i1 true, i1 %.not40.2
  br i1 %or.cond44.2, label %.preheader.3, label %88

88:                                               ; preds = %.preheader.2
  %89 = load i8, ptr getelementptr inbounds (i8, ptr @players, i64 658), align 2, !tbaa !15
  %.not41.2 = icmp eq i8 %89, 0
  br i1 %.not41.2, label %.preheader.3, label %90

90:                                               ; preds = %88
  %91 = icmp slt i8 %89, 6
  br i1 %91, label %116, label %92

92:                                               ; preds = %90
  %93 = add nsw i8 %89, -97
  %or.cond8.2 = icmp ult i8 %93, 26
  br i1 %or.cond8.2, label %94, label %99

94:                                               ; preds = %92
  %95 = load ptr, ptr @shiftxform, align 8, !tbaa !9
  %96 = zext nneg i8 %89 to i64
  %97 = getelementptr inbounds i8, ptr %95, i64 %96
  %98 = load i8, ptr %97, align 1, !tbaa !16
  br label %99

99:                                               ; preds = %94, %92
  %.0.2 = phi i8 [ %98, %94 ], [ %89, %92 ]
  %100 = tail call i32 @HUlib_keyInIText(ptr noundef nonnull getelementptr inbounds (i8, ptr @w_inputbuffer, i64 272), i8 noundef zeroext %.0.2) #2
  %101 = icmp ne i32 %100, 0
  %102 = icmp eq i8 %.0.2, 13
  %or.cond11.2 = and i1 %102, %101
  br i1 %or.cond11.2, label %103, label %117

103:                                              ; preds = %99
  %104 = load i32, ptr getelementptr inbounds (i8, ptr @w_inputbuffer, i64 376), align 8, !tbaa !17
  %.not42.2 = icmp eq i32 %104, 0
  br i1 %.not42.2, label %115, label %105

105:                                              ; preds = %103
  %106 = load i8, ptr getelementptr inbounds (i8, ptr @chat_dest, i64 2), align 1, !tbaa !16
  %107 = sext i8 %106 to i32
  %108 = load i32, ptr @consoleplayer, align 4, !tbaa !5
  %109 = add nsw i32 %108, 1
  %110 = icmp eq i32 %109, %107
  %111 = icmp eq i8 %106, 5
  %or.cond45.2 = or i1 %111, %110
  br i1 %or.cond45.2, label %.sink.split60, label %115

.sink.split60:                                    ; preds = %105
  %112 = load ptr, ptr getelementptr inbounds (i8, ptr @player_names, i64 16), align 16, !tbaa !9
  tail call void @HUlib_addMessageToSText(ptr noundef nonnull @w_message, ptr noundef %112, ptr noundef nonnull getelementptr inbounds (i8, ptr @w_inputbuffer, i64 292)) #2
  store i32 1, ptr @message_nottobefuckedwith, align 4, !tbaa !5
  store i32 1, ptr @message_on, align 4, !tbaa !5
  store i32 140, ptr @message_counter, align 4, !tbaa !5
  %113 = load i32, ptr @gamemode, align 4, !tbaa !5
  %114 = icmp eq i32 %113, 2
  %.65 = select i1 %114, i32 108, i32 87
  tail call void @S_StartSound(ptr noundef null, i32 noundef %.65) #2
  br label %115

115:                                              ; preds = %.sink.split60, %105, %103
  tail call void @HUlib_resetIText(ptr noundef nonnull getelementptr inbounds (i8, ptr @w_inputbuffer, i64 272)) #2
  br label %117

116:                                              ; preds = %90
  store i8 %89, ptr getelementptr inbounds (i8, ptr @chat_dest, i64 2), align 1, !tbaa !16
  br label %117

117:                                              ; preds = %116, %115, %99
  store i8 0, ptr getelementptr inbounds (i8, ptr @players, i64 658), align 2, !tbaa !15
  %.pre52 = load i32, ptr @consoleplayer, align 4
  br label %.preheader.3

.preheader.3:                                     ; preds = %117, %88, %.preheader.2
  %.pre-phi57.in = phi i32 [ %.pre52, %117 ], [ %.pre-phi55.in, %88 ], [ %.pre-phi55.in, %.preheader.2 ]
  %118 = load i32, ptr getelementptr inbounds (i8, ptr @playeringame, i64 12), align 4, !tbaa !5
  %.not39.3 = icmp eq i32 %118, 0
  %.not40.3 = icmp eq i32 %.pre-phi57.in, 3
  %or.cond44.3 = select i1 %.not39.3, i1 true, i1 %.not40.3
  br i1 %or.cond44.3, label %.loopexit, label %119

119:                                              ; preds = %.preheader.3
  %120 = load i8, ptr getelementptr inbounds (i8, ptr @players, i64 978), align 2, !tbaa !15
  %.not41.3 = icmp eq i8 %120, 0
  br i1 %.not41.3, label %.loopexit, label %121

121:                                              ; preds = %119
  %122 = icmp slt i8 %120, 6
  br i1 %122, label %147, label %123

123:                                              ; preds = %121
  %124 = add nsw i8 %120, -97
  %or.cond8.3 = icmp ult i8 %124, 26
  br i1 %or.cond8.3, label %125, label %130

125:                                              ; preds = %123
  %126 = load ptr, ptr @shiftxform, align 8, !tbaa !9
  %127 = zext nneg i8 %120 to i64
  %128 = getelementptr inbounds i8, ptr %126, i64 %127
  %129 = load i8, ptr %128, align 1, !tbaa !16
  br label %130

130:                                              ; preds = %125, %123
  %.0.3 = phi i8 [ %129, %125 ], [ %120, %123 ]
  %131 = tail call i32 @HUlib_keyInIText(ptr noundef nonnull getelementptr inbounds (i8, ptr @w_inputbuffer, i64 408), i8 noundef zeroext %.0.3) #2
  %132 = icmp ne i32 %131, 0
  %133 = icmp eq i8 %.0.3, 13
  %or.cond11.3 = and i1 %133, %132
  br i1 %or.cond11.3, label %134, label %148

134:                                              ; preds = %130
  %135 = load i32, ptr getelementptr inbounds (i8, ptr @w_inputbuffer, i64 512), align 16, !tbaa !17
  %.not42.3 = icmp eq i32 %135, 0
  br i1 %.not42.3, label %146, label %136

136:                                              ; preds = %134
  %137 = load i8, ptr getelementptr inbounds (i8, ptr @chat_dest, i64 3), align 1, !tbaa !16
  %138 = sext i8 %137 to i32
  %139 = load i32, ptr @consoleplayer, align 4, !tbaa !5
  %140 = add nsw i32 %139, 1
  %141 = icmp eq i32 %140, %138
  %142 = icmp eq i8 %137, 5
  %or.cond45.3 = or i1 %142, %141
  br i1 %or.cond45.3, label %.sink.split62, label %146

.sink.split62:                                    ; preds = %136
  %143 = load ptr, ptr getelementptr inbounds (i8, ptr @player_names, i64 24), align 8, !tbaa !9
  tail call void @HUlib_addMessageToSText(ptr noundef nonnull @w_message, ptr noundef %143, ptr noundef nonnull getelementptr inbounds (i8, ptr @w_inputbuffer, i64 428)) #2
  store i32 1, ptr @message_nottobefuckedwith, align 4, !tbaa !5
  store i32 1, ptr @message_on, align 4, !tbaa !5
  store i32 140, ptr @message_counter, align 4, !tbaa !5
  %144 = load i32, ptr @gamemode, align 4, !tbaa !5
  %145 = icmp eq i32 %144, 2
  %.66 = select i1 %145, i32 108, i32 87
  tail call void @S_StartSound(ptr noundef null, i32 noundef %.66) #2
  br label %146

146:                                              ; preds = %.sink.split62, %136, %134
  tail call void @HUlib_resetIText(ptr noundef nonnull getelementptr inbounds (i8, ptr @w_inputbuffer, i64 408)) #2
  br label %148

147:                                              ; preds = %121
  store i8 %120, ptr getelementptr inbounds (i8, ptr @chat_dest, i64 3), align 1, !tbaa !16
  br label %148

148:                                              ; preds = %147, %146, %130
  store i8 0, ptr getelementptr inbounds (i8, ptr @players, i64 978), align 2, !tbaa !15
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.3, %119, %148, %22
  ret void
}

declare void @HUlib_addMessageToSText(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @HUlib_keyInIText(ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

declare void @S_StartSound(ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @HUlib_resetIText(ptr noundef) local_unnamed_addr #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 = { "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 }

!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, !10, i64 224}
!12 = !{!"player_s", !10, i64 0, !6, i64 8, !13, i64 12, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !7, i64 48, !7, i64 72, !6, i64 96, !7, i64 100, !6, i64 116, !6, i64 120, !7, i64 124, !7, i64 160, !7, i64 176, !6, i64 192, !6, i64 196, !6, i64 200, !6, i64 204, !6, i64 208, !6, i64 212, !6, i64 216, !10, i64 224, !6, i64 232, !6, i64 236, !10, i64 240, !6, i64 248, !6, i64 252, !6, i64 256, !7, i64 264, !6, i64 312}
!13 = !{!"", !7, i64 0, !7, i64 1, !14, i64 2, !14, i64 4, !7, i64 6, !7, i64 7}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !7, i64 18}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !6, i64 104}
!18 = !{!"", !19, i64 0, !6, i64 112, !10, i64 120, !6, i64 128}
!19 = !{!"", !6, i64 0, !6, i64 4, !10, i64 8, !6, i64 16, !7, i64 20, !6, i64 104, !6, i64 108}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass