; LLVM IR from seppo0010/rlite :: src (hirlite)

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

; 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 i32 @rliteCommandHasFlag(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.rliteCommand, ptr %6, i32 0, i32 3
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  store ptr %8, ptr %5, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %83, %2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = load i8, ptr %10, align 1, !tbaa !14
  %12 = sext i8 %11 to i32
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %86

14:                                               ; preds = %9
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load i8, ptr %15, align 1, !tbaa !14
  %17 = sext i8 %16 to i32
  switch i32 %17, label %83 [
    i32 119, label %18
    i32 114, label %23
    i32 109, label %28
    i32 97, label %33
    i32 112, label %38
    i32 115, label %43
    i32 82, label %48
    i32 83, label %53
    i32 108, label %58
    i32 116, label %63
    i32 77, label %68
    i32 107, label %73
    i32 70, label %78
  ]

18:                                               ; preds = %14
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.rliteCommand, ptr %19, i32 0, i32 4
  %21 = load i32, ptr %20, align 8, !tbaa !15
  %22 = or i32 %21, 1
  store i32 %22, ptr %20, align 8, !tbaa !15
  br label %83

23:                                               ; preds = %14
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.rliteCommand, ptr %24, i32 0, i32 4
  %26 = load i32, ptr %25, align 8, !tbaa !15
  %27 = or i32 %26, 2
  store i32 %27, ptr %25, align 8, !tbaa !15
  br label %83

28:                                               ; preds = %14
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.rliteCommand, ptr %29, i32 0, i32 4
  %31 = load i32, ptr %30, align 8, !tbaa !15
  %32 = or i32 %31, 4
  store i32 %32, ptr %30, align 8, !tbaa !15
  br label %83

33:                                               ; preds = %14
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.rliteCommand, ptr %34, i32 0, i32 4
  %36 = load i32, ptr %35, align 8, !tbaa !15
  %37 = or i32 %36, 16
  store i32 %37, ptr %35, align 8, !tbaa !15
  br label %83

38:                                               ; preds = %14
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.rliteCommand, ptr %39, i32 0, i32 4
  %41 = load i32, ptr %40, align 8, !tbaa !15
  %42 = or i32 %41, 32
  store i32 %42, ptr %40, align 8, !tbaa !15
  br label %83

43:                                               ; preds = %14
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.rliteCommand, ptr %44, i32 0, i32 4
  %46 = load i32, ptr %45, align 8, !tbaa !15
  %47 = or i32 %46, 64
  store i32 %47, ptr %45, align 8, !tbaa !15
  br label %83

48:                                               ; preds = %14
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.rliteCommand, ptr %49, i32 0, i32 4
  %51 = load i32, ptr %50, align 8, !tbaa !15
  %52 = or i32 %51, 128
  store i32 %52, ptr %50, align 8, !tbaa !15
  br label %83

53:                                               ; preds = %14
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.rliteCommand, ptr %54, i32 0, i32 4
  %56 = load i32, ptr %55, align 8, !tbaa !15
  %57 = or i32 %56, 256
  store i32 %57, ptr %55, align 8, !tbaa !15
  br label %83

58:                                               ; preds = %14
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.rliteCommand, ptr %59, i32 0, i32 4
  %61 = load i32, ptr %60, align 8, !tbaa !15
  %62 = or i32 %61, 512
  store i32 %62, ptr %60, align 8, !tbaa !15
  br label %83

63:                                               ; preds = %14
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.rliteCommand, ptr %64, i32 0, i32 4
  %66 = load i32, ptr %65, align 8, !tbaa !15
  %67 = or i32 %66, 1024
  store i32 %67, ptr %65, align 8, !tbaa !15
  br label %83

68:                                               ; preds = %14
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.rliteCommand, ptr %69, i32 0, i32 4
  %71 = load i32, ptr %70, align 8, !tbaa !15
  %72 = or i32 %71, 2048
  store i32 %72, ptr %70, align 8, !tbaa !15
  br label %83

73:                                               ; preds = %14
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.rliteCommand, ptr %74, i32 0, i32 4
  %76 = load i32, ptr %75, align 8, !tbaa !15
  %77 = or i32 %76, 4096
  store i32 %77, ptr %75, align 8, !tbaa !15
  br label %83

78:                                               ; preds = %14
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.rliteCommand, ptr %79, i32 0, i32 4
  %81 = load i32, ptr %80, align 8, !tbaa !15
  %82 = or i32 %81, 8192
  store i32 %82, ptr %80, align 8, !tbaa !15
  br label %83

83:                                               ; preds = %78, %73, %68, %63, %58, %53, %48, %43, %38, %33, %28, %23, %18, %14
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds i8, ptr %84, i32 1
  store ptr %85, ptr %5, align 8, !tbaa !5
  br label %9, !llvm.loop !16

86:                                               ; preds = %9
  %87 = load i32, ptr %4, align 4, !tbaa !9
  %88 = icmp eq i32 %87, 0
  %89 = zext i1 %88 to i32
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret i32 %89
}

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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 24}
!12 = !{!"rliteCommand", !6, i64 0, !6, i64 8, !10, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !13, i64 48, !13, i64 56}
!13 = !{!"long long", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!12, !10, i64 32}
!16 = distinct !{!16, !17}
!17 = !{!"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"

; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local range(i32 0, 2) i32 @rliteCommandHasFlag(ptr nocapture noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  br label %6

6:                                                ; preds = %22, %2
  %.0 = phi ptr [ %4, %2 ], [ %23, %22 ]
  %7 = load i8, ptr %.0, align 1, !tbaa !12
  switch i8 %7, label %22 [
    i8 0, label %24
    i8 119, label %.sink.split
    i8 114, label %8
    i8 109, label %9
    i8 97, label %10
    i8 112, label %11
    i8 115, label %12
    i8 82, label %13
    i8 83, label %14
    i8 108, label %15
    i8 116, label %16
    i8 77, label %17
    i8 107, label %18
    i8 70, label %19
  ]

8:                                                ; preds = %6
  br label %.sink.split

9:                                                ; preds = %6
  br label %.sink.split

10:                                               ; preds = %6
  br label %.sink.split

11:                                               ; preds = %6
  br label %.sink.split

12:                                               ; preds = %6
  br label %.sink.split

13:                                               ; preds = %6
  br label %.sink.split

14:                                               ; preds = %6
  br label %.sink.split

15:                                               ; preds = %6
  br label %.sink.split

16:                                               ; preds = %6
  br label %.sink.split

17:                                               ; preds = %6
  br label %.sink.split

18:                                               ; preds = %6
  br label %.sink.split

19:                                               ; preds = %6
  br label %.sink.split

.sink.split:                                      ; preds = %6, %8, %9, %10, %11, %12, %13, %14, %15, %16, %17, %18, %19
  %.sink19 = phi i32 [ 8192, %19 ], [ 4096, %18 ], [ 2048, %17 ], [ 1024, %16 ], [ 512, %15 ], [ 256, %14 ], [ 128, %13 ], [ 64, %12 ], [ 32, %11 ], [ 16, %10 ], [ 4, %9 ], [ 2, %8 ], [ 1, %6 ]
  %20 = load i32, ptr %5, align 8, !tbaa !13
  %21 = or i32 %20, %.sink19
  store i32 %21, ptr %5, align 8, !tbaa !13
  br label %22

22:                                               ; preds = %.sink.split, %6
  %23 = getelementptr inbounds i8, ptr %.0, i64 1
  br label %6, !llvm.loop !14

24:                                               ; preds = %6
  %25 = icmp eq i32 %1, 0
  %26 = zext i1 %25 to i32
  ret i32 %26
}

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

!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 24}
!6 = !{!"rliteCommand", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !11, i64 48, !11, 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 = !{!"long long", !8, i64 0}
!12 = !{!8, !8, i64 0}
!13 = !{!6, !10, i64 32}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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