; LLVM IR from Tencent-RoboticsX/jbdl :: src/jbdl/experimental/qpoases/src (MessageHandling)

; 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.qpOASES::MessageHandling::ReturnValueList" = type { i32, ptr, i32 }

@_ZN7qpOASES15returnValueListE = external dso_local global [152 x %"struct.qpOASES::MessageHandling::ReturnValueList"], align 16
@.str.153 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.154 = external hidden unnamed_addr constant [31 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: mustprogress nounwind uwtable
define dso_local noundef ptr @_ZN7qpOASES15MessageHandling19getErrorCodeMessageENS_11returnValueE(i32 noundef %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %25, %1
  %7 = load i32, ptr %4, align 4, !tbaa !9
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [152 x %"struct.qpOASES::MessageHandling::ReturnValueList"], ptr @_ZN7qpOASES15returnValueListE, i64 0, i64 %8
  %10 = getelementptr inbounds %"struct.qpOASES::MessageHandling::ReturnValueList", ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = icmp ne i32 %11, -1
  br i1 %12, label %13, label %26

13:                                               ; preds = %6
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [152 x %"struct.qpOASES::MessageHandling::ReturnValueList"], ptr @_ZN7qpOASES15returnValueListE, i64 0, i64 %15
  %17 = getelementptr inbounds %"struct.qpOASES::MessageHandling::ReturnValueList", ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = icmp eq i32 %18, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %13
  br label %26

22:                                               ; preds = %13
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %4, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %22
  br label %6, !llvm.loop !15

26:                                               ; preds = %21, %6
  %27 = load i32, ptr %4, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [152 x %"struct.qpOASES::MessageHandling::ReturnValueList"], ptr @_ZN7qpOASES15returnValueListE, i64 0, i64 %28
  %30 = getelementptr inbounds %"struct.qpOASES::MessageHandling::ReturnValueList", ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !11
  %32 = icmp eq i32 %31, -1
  br i1 %32, label %33, label %34

33:                                               ; preds = %26
  store ptr @.str.153, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %50

34:                                               ; preds = %26
  %35 = load i32, ptr %4, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [152 x %"struct.qpOASES::MessageHandling::ReturnValueList"], ptr @_ZN7qpOASES15returnValueListE, i64 0, i64 %36
  %38 = getelementptr inbounds %"struct.qpOASES::MessageHandling::ReturnValueList", ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !17
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %47

41:                                               ; preds = %34
  %42 = load i32, ptr %4, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [152 x %"struct.qpOASES::MessageHandling::ReturnValueList"], ptr @_ZN7qpOASES15returnValueListE, i64 0, i64 %43
  %45 = getelementptr inbounds %"struct.qpOASES::MessageHandling::ReturnValueList", ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !17
  br label %48

47:                                               ; preds = %34
  br label %48

48:                                               ; preds = %47, %41
  %49 = phi ptr [ %46, %41 ], [ @.str.154, %47 ]
  store ptr %49, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %50

50:                                               ; preds = %48, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %51 = load ptr, ptr %2, align 8
  ret ptr %51
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"_ZTSN7qpOASES11returnValueE", !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 = !{!"_ZTSN7qpOASES15MessageHandling15ReturnValueListE", !6, i64 0, !13, i64 8, !14, i64 16}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!"_ZTSN7qpOASES16VisibilityStatusE", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!12, !13, i64 8}


; 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.qpOASES::MessageHandling::ReturnValueList" = type { i32, ptr, i32 }

@_ZN7qpOASES15returnValueListE = external dso_local local_unnamed_addr global [152 x %"struct.qpOASES::MessageHandling::ReturnValueList"], align 16
@.str.153 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.154 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef nonnull ptr @_ZN7qpOASES15MessageHandling19getErrorCodeMessageENS_11returnValueE(i32 noundef %0) local_unnamed_addr #0 align 2 {
  br label %2

2:                                                ; preds = %2, %1
  %indvars.iv = phi i64 [ %indvars.iv.next, %2 ], [ 0, %1 ]
  %3 = getelementptr inbounds [152 x %"struct.qpOASES::MessageHandling::ReturnValueList"], ptr @_ZN7qpOASES15returnValueListE, i64 0, i64 %indvars.iv
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i32 %4, -1
  %5 = icmp eq i32 %4, %0
  %or.cond = or i1 %.not, %5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br i1 %or.cond, label %6, label %2, !llvm.loop !12

6:                                                ; preds = %2
  br i1 %.not, label %10, label %7

7:                                                ; preds = %6
  %8 = getelementptr inbounds i8, ptr %3, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !14
  %.not10 = icmp eq ptr %9, null
  %spec.select = select i1 %.not10, ptr @.str.154, ptr %9
  br label %10

10:                                               ; preds = %6, %7
  %.07 = phi ptr [ %spec.select, %7 ], [ @.str.153, %6 ]
  ret ptr %.07
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, 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 0}
!6 = !{!"_ZTSN7qpOASES15MessageHandling15ReturnValueListE", !7, i64 0, !10, i64 8, !11, i64 16}
!7 = !{!"_ZTSN7qpOASES11returnValueE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTSN7qpOASES16VisibilityStatusE", !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!6, !10, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass