; LLVM IR from theck01/offbrand_lib :: src/classes (obint)

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

@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__.obint_from_string = external hidden unnamed_addr constant [43 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [21 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: nounwind uwtable
declare dso_local ptr @obint_create_default(i64 noundef) #1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

12:                                               ; preds = %1
  br label %14

13:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 74, ptr noundef @__PRETTY_FUNCTION__.obint_from_string) #5
  unreachable

14:                                               ; preds = %12
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = call i32 @obstring_length(ptr noundef %15)
  store i32 %16, ptr %6, align 4, !tbaa !9
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = call signext i8 @obstring_char_at_index(ptr noundef %17, i64 noundef 0)
  %19 = sext i8 %18 to i32
  %20 = icmp eq i32 %19, 45
  br i1 %20, label %21, label %25

21:                                               ; preds = %14
  store i8 -1, ptr %4, align 1, !tbaa !11
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = sub i32 %22, 1
  %24 = zext i32 %23 to i64
  store i64 %24, ptr %8, align 8, !tbaa !12
  store i8 1, ptr %3, align 1, !tbaa !11
  br label %28

25:                                               ; preds = %14
  store i8 1, ptr %4, align 1, !tbaa !11
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = zext i32 %26 to i64
  store i64 %27, ptr %8, align 8, !tbaa !12
  store i8 0, ptr %3, align 1, !tbaa !11
  br label %28

28:                                               ; preds = %25, %21
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = icmp ugt i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  br label %33

32:                                               ; preds = %28
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 87, ptr noundef @__PRETTY_FUNCTION__.obint_from_string) #5
  unreachable

33:                                               ; preds = %31
  %34 = load i64, ptr %8, align 8, !tbaa !12
  %35 = call ptr @obint_create_default(i64 noundef %34)
  store ptr %35, ptr %9, align 8, !tbaa !5
  %36 = load i8, ptr %4, align 1, !tbaa !11
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.obint_struct, ptr %37, i32 0, i32 1
  store i8 %36, ptr %38, align 8, !tbaa !14
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %73, %33
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = zext i32 %40 to i64
  %42 = load i64, ptr %8, align 8, !tbaa !12
  %43 = icmp ult i64 %41, %42
  br i1 %43, label %44, label %76

44:                                               ; preds = %39
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = load i8, ptr %3, align 1, !tbaa !11
  %48 = sext i8 %47 to i32
  %49 = add i32 %46, %48
  %50 = zext i32 %49 to i64
  %51 = call signext i8 @obstring_char_at_index(ptr noundef %45, i64 noundef %50)
  %52 = sext i8 %51 to i32
  %53 = sub nsw i32 %52, 48
  store i32 %53, ptr %5, align 4, !tbaa !9
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = icmp sge i32 %54, 0
  br i1 %55, label %56, label %60

56:                                               ; preds = %44
  %57 = load i32, ptr %5, align 4, !tbaa !9
  %58 = icmp sle i32 %57, 9
  br i1 %58, label %59, label %60

59:                                               ; preds = %56
  br label %61

60:                                               ; preds = %56, %44
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 93, ptr noundef @__PRETTY_FUNCTION__.obint_from_string) #5
  unreachable

61:                                               ; preds = %59
  %62 = load i32, ptr %5, align 4, !tbaa !9
  %63 = trunc i32 %62 to i8
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.obint_struct, ptr %64, i32 0, i32 2
  %66 = load ptr, ptr %65, align 8, !tbaa !16
  %67 = load i64, ptr %8, align 8, !tbaa !12
  %68 = load i32, ptr %7, align 4, !tbaa !9
  %69 = zext i32 %68 to i64
  %70 = sub i64 %67, %69
  %71 = sub i64 %70, 1
  %72 = getelementptr inbounds i8, ptr %66, i64 %71
  store i8 %63, ptr %72, align 1, !tbaa !11
  br label %73

73:                                               ; preds = %61
  %74 = load i32, ptr %7, align 4, !tbaa !9
  %75 = add i32 %74, 1
  store i32 %75, ptr %7, align 4, !tbaa !9
  br label %39, !llvm.loop !17

76:                                               ; preds = %39
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = call zeroext i8 @obint_is_zero(ptr noundef %77)
  %79 = icmp ne i8 %78, 0
  br i1 %79, label %80, label %83

80:                                               ; preds = %76
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.obint_struct, ptr %81, i32 0, i32 1
  store i8 1, ptr %82, align 8, !tbaa !14
  br label %83

83:                                               ; preds = %80, %76
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #4
  ret ptr %84
}

declare i32 @obstring_length(ptr noundef) #3

declare signext i8 @obstring_char_at_index(ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @obint_is_zero(ptr noundef) #1

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 = { noreturn nounwind "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 = { "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 #4 = { nounwind }
attributes #5 = { noreturn 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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !7, i64 8}
!15 = !{!"obint_struct", !6, i64 0, !7, i64 8, !6, i64 16, !13, i64 24}
!16 = !{!15, !6, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"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"

@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__.obint_from_string = external hidden unnamed_addr constant [43 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @obint_create_default(i64 noundef) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @obint_from_string(ptr noundef %0) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %2, label %3

2:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 74, ptr noundef nonnull @__PRETTY_FUNCTION__.obint_from_string) #3
  unreachable

3:                                                ; preds = %1
  %4 = tail call i32 @obstring_length(ptr noundef nonnull %0) #4
  %5 = tail call signext i8 @obstring_char_at_index(ptr noundef nonnull %0, i64 noundef 0) #4
  %6 = icmp eq i8 %5, 45
  %7 = sext i1 %6 to i32
  %.024.in = add i32 %4, %7
  %.024 = zext i32 %.024.in to i64
  %.not30 = icmp eq i32 %4, 0
  br i1 %.not30, label %8, label %9

8:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 87, ptr noundef nonnull @__PRETTY_FUNCTION__.obint_from_string) #3
  unreachable

9:                                                ; preds = %3
  %.026 = select i1 %6, i8 -1, i8 1
  %10 = tail call ptr @obint_create_default(i64 noundef %.024)
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  store i8 %.026, ptr %11, align 8, !tbaa !5
  %.not33 = icmp eq i32 %.024.in, 0
  br i1 %.not33, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %9
  %12 = getelementptr inbounds i8, ptr %10, i64 16
  %13 = zext i1 %6 to i64
  br label %14

14:                                               ; preds = %.lr.ph, %19
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %19 ]
  %15 = add nuw nsw i64 %indvars.iv, %13
  %16 = tail call signext i8 @obstring_char_at_index(ptr noundef nonnull %0, i64 noundef %15) #4
  %17 = add i8 %16, -48
  %or.cond = icmp ult i8 %17, 10
  br i1 %or.cond, label %19, label %18

18:                                               ; preds = %14
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 93, ptr noundef nonnull @__PRETTY_FUNCTION__.obint_from_string) #3
  unreachable

19:                                               ; preds = %14
  %20 = load ptr, ptr %12, align 8, !tbaa !11
  %21 = xor i64 %indvars.iv, -1
  %22 = getelementptr i8, ptr %20, i64 %21
  %23 = getelementptr i8, ptr %22, i64 %.024
  store i8 %17, ptr %23, align 1, !tbaa !12
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %.024
  br i1 %exitcond.not, label %._crit_edge, label %14, !llvm.loop !13

._crit_edge:                                      ; preds = %19, %9
  %24 = tail call zeroext i8 @obint_is_zero(ptr noundef nonnull %10)
  %.not31 = icmp eq i8 %24, 0
  br i1 %.not31, label %26, label %25

25:                                               ; preds = %._crit_edge
  store i8 1, ptr %11, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %25, %._crit_edge
  ret ptr %10
}

declare i32 @obstring_length(ptr noundef) local_unnamed_addr #2

declare signext i8 @obstring_char_at_index(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @obint_is_zero(ptr noundef) local_unnamed_addr #0

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 = { noreturn nounwind "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 = { noreturn nounwind }
attributes #4 = { 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, !8, i64 8}
!6 = !{!"obint_struct", !7, i64 0, !8, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !7, i64 16}
!12 = !{!8, !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass