; LLVM IR from theck01/offbrand_lib :: apps/pfinder (main)

; 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"

@.str = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %9 = call ptr @obvector_new(i32 noundef 1)
  store ptr %9, ptr %8, align 8, !tbaa !5
  %10 = call ptr @obint_new(i64 noundef 2)
  store ptr %10, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  call void @obvector_store_at_index(ptr noundef %11, ptr noundef %12, i64 noundef 0)
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = call ptr @ob_release(ptr noundef %13)
  %15 = call ptr @obint_new(i64 noundef 3)
  store ptr %15, ptr %4, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %60, %0
  br label %17

17:                                               ; preds = %16
  store i64 1, ptr %3, align 8, !tbaa !9
  store i64 0, ptr %2, align 8, !tbaa !9
  br label %18

18:                                               ; preds = %41, %17
  %19 = load i64, ptr %2, align 8, !tbaa !9
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = call i32 @obvector_length(ptr noundef %20)
  %22 = zext i32 %21 to i64
  %23 = icmp ult i64 %19, %22
  br i1 %23, label %24, label %44

24:                                               ; preds = %18
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = load i64, ptr %2, align 8, !tbaa !9
  %28 = call ptr @obvector_obj_at_index(ptr noundef %26, i64 noundef %27)
  %29 = call ptr @obint_mod(ptr noundef %25, ptr noundef %28)
  store ptr %29, ptr %6, align 8, !tbaa !5
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = call zeroext i8 @obint_is_zero(ptr noundef %30)
  %32 = icmp ne i8 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %24
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %33, %24
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = call ptr @ob_release(ptr noundef %35)
  %37 = load i64, ptr %3, align 8, !tbaa !9
  %38 = icmp ne i64 %37, 0
  br i1 %38, label %40, label %39

39:                                               ; preds = %34
  br label %44

40:                                               ; preds = %34
  br label %41

41:                                               ; preds = %40
  %42 = load i64, ptr %2, align 8, !tbaa !9
  %43 = add i64 %42, 1
  store i64 %43, ptr %2, align 8, !tbaa !9
  br label %18, !llvm.loop !11

44:                                               ; preds = %39, %18
  %45 = load i64, ptr %3, align 8, !tbaa !9
  %46 = icmp ne i64 %45, 0
  br i1 %46, label %47, label %60

47:                                               ; preds = %44
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = call i32 @obvector_length(ptr noundef %50)
  %52 = zext i32 %51 to i64
  call void @obvector_store_at_index(ptr noundef %48, ptr noundef %49, i64 noundef %52)
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = call ptr @obint_to_string(ptr noundef %53)
  store ptr %54, ptr %7, align 8, !tbaa !5
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = call ptr @obstring_cstring(ptr noundef %55)
  %57 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef %56)
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = call ptr @ob_release(ptr noundef %58)
  br label %60

60:                                               ; preds = %47, %44
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = call ptr @obint_add_primitive(ptr noundef %61, i64 noundef 2)
  store ptr %62, ptr %5, align 8, !tbaa !5
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = call ptr @ob_release(ptr noundef %63)
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %65, ptr %4, align 8, !tbaa !5
  br label %16
}

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

declare ptr @obvector_new(i32 noundef) #2

declare ptr @obint_new(i64 noundef) #2

declare void @obvector_store_at_index(ptr noundef, ptr noundef, i64 noundef) #2

declare ptr @ob_release(ptr noundef) #2

declare i32 @obvector_length(ptr noundef) #2

declare ptr @obint_mod(ptr noundef, ptr noundef) #2

declare ptr @obvector_obj_at_index(ptr noundef, i64 noundef) #2

declare zeroext i8 @obint_is_zero(ptr noundef) #2

declare ptr @obint_to_string(ptr noundef) #2

declare i32 @printf(ptr noundef, ...) #2

declare ptr @obstring_cstring(ptr noundef) #2

declare ptr @obint_add_primitive(ptr noundef, i64 noundef) #2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call ptr @obvector_new(i32 noundef 1) #3
  %2 = tail call ptr @obint_new(i64 noundef 2) #3
  tail call void @obvector_store_at_index(ptr noundef %1, ptr noundef %2, i64 noundef 0) #3
  %3 = tail call ptr @ob_release(ptr noundef %2) #3
  %4 = tail call ptr @obint_new(i64 noundef 3) #3
  br label %5

5:                                                ; preds = %.loopexit, %0
  %.022 = phi ptr [ %4, %0 ], [ %22, %.loopexit ]
  %6 = tail call i32 @obvector_length(ptr noundef %1) #3
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %.critedge, label %.lr.ph

7:                                                ; preds = %.lr.ph
  %8 = add nuw nsw i64 %.024, 1
  %9 = tail call i32 @obvector_length(ptr noundef %1) #3
  %10 = zext i32 %9 to i64
  %11 = icmp ult i64 %8, %10
  br i1 %11, label %.lr.ph, label %.critedge, !llvm.loop !5

.lr.ph:                                           ; preds = %5, %7
  %.024 = phi i64 [ %8, %7 ], [ 0, %5 ]
  %12 = tail call ptr @obvector_obj_at_index(ptr noundef %1, i64 noundef %.024) #3
  %13 = tail call ptr @obint_mod(ptr noundef %.022, ptr noundef %12) #3
  %14 = tail call zeroext i8 @obint_is_zero(ptr noundef %13) #3
  %.not.not = icmp eq i8 %14, 0
  %15 = tail call ptr @ob_release(ptr noundef %13) #3
  br i1 %.not.not, label %7, label %.loopexit

.critedge:                                        ; preds = %7, %5
  %16 = tail call i32 @obvector_length(ptr noundef %1) #3
  %17 = zext i32 %16 to i64
  tail call void @obvector_store_at_index(ptr noundef %1, ptr noundef %.022, i64 noundef %17) #3
  %18 = tail call ptr @obint_to_string(ptr noundef %.022) #3
  %19 = tail call ptr @obstring_cstring(ptr noundef %18) #3
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef %19)
  %21 = tail call ptr @ob_release(ptr noundef %18) #3
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %.critedge
  %22 = tail call ptr @obint_add_primitive(ptr noundef %.022, i64 noundef 2) #3
  %23 = tail call ptr @ob_release(ptr noundef %.022) #3
  br label %5
}

declare ptr @obvector_new(i32 noundef) local_unnamed_addr #1

declare ptr @obint_new(i64 noundef) local_unnamed_addr #1

declare void @obvector_store_at_index(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

declare ptr @ob_release(ptr noundef) local_unnamed_addr #1

declare i32 @obvector_length(ptr noundef) local_unnamed_addr #1

declare ptr @obint_mod(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @obvector_obj_at_index(ptr noundef, i64 noundef) local_unnamed_addr #1

declare zeroext i8 @obint_is_zero(ptr noundef) local_unnamed_addr #1

declare ptr @obint_to_string(ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

declare ptr @obstring_cstring(ptr noundef) local_unnamed_addr #1

declare ptr @obint_add_primitive(ptr noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { noreturn 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 = { nofree 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 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass