; LLVM IR from joltwallet/jolt_wallet :: components/console/argtable3 (argtable3)

; 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.arg_end = type { %struct.arg_hdr, i32, ptr, ptr, ptr }
%struct.arg_hdr = type { i8, ptr, ptr, ptr, ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr }

; 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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @arg_end(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = mul i64 %6, 4
  %8 = add i64 128, %7
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = mul i64 %10, 8
  %12 = add i64 %8, %11
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = mul i64 %14, 8
  %16 = add i64 %12, %15
  store i64 %16, ptr %3, align 8, !tbaa !9
  %17 = load i64, ptr %3, align 8, !tbaa !9
  %18 = call noalias ptr @malloc(i64 noundef %17) #4
  store ptr %18, ptr %4, align 8, !tbaa !11
  %19 = load ptr, ptr %4, align 8, !tbaa !11
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %80

21:                                               ; preds = %1
  %22 = load ptr, ptr %4, align 8, !tbaa !11
  %23 = getelementptr inbounds %struct.arg_end, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds %struct.arg_hdr, ptr %23, i32 0, i32 0
  store i8 1, ptr %24, align 8, !tbaa !13
  %25 = load ptr, ptr %4, align 8, !tbaa !11
  %26 = getelementptr inbounds %struct.arg_end, ptr %25, i32 0, i32 0
  %27 = getelementptr inbounds %struct.arg_hdr, ptr %26, i32 0, i32 1
  store ptr null, ptr %27, align 8, !tbaa !16
  %28 = load ptr, ptr %4, align 8, !tbaa !11
  %29 = getelementptr inbounds %struct.arg_end, ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds %struct.arg_hdr, ptr %29, i32 0, i32 2
  store ptr null, ptr %30, align 8, !tbaa !17
  %31 = load ptr, ptr %4, align 8, !tbaa !11
  %32 = getelementptr inbounds %struct.arg_end, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds %struct.arg_hdr, ptr %32, i32 0, i32 3
  store ptr null, ptr %33, align 8, !tbaa !18
  %34 = load ptr, ptr %4, align 8, !tbaa !11
  %35 = getelementptr inbounds %struct.arg_end, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds %struct.arg_hdr, ptr %35, i32 0, i32 4
  store ptr null, ptr %36, align 8, !tbaa !19
  %37 = load ptr, ptr %4, align 8, !tbaa !11
  %38 = getelementptr inbounds %struct.arg_end, ptr %37, i32 0, i32 0
  %39 = getelementptr inbounds %struct.arg_hdr, ptr %38, i32 0, i32 5
  store i32 1, ptr %39, align 8, !tbaa !20
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = load ptr, ptr %4, align 8, !tbaa !11
  %42 = getelementptr inbounds %struct.arg_end, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds %struct.arg_hdr, ptr %42, i32 0, i32 6
  store i32 %40, ptr %43, align 4, !tbaa !21
  %44 = load ptr, ptr %4, align 8, !tbaa !11
  %45 = load ptr, ptr %4, align 8, !tbaa !11
  %46 = getelementptr inbounds %struct.arg_end, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds %struct.arg_hdr, ptr %46, i32 0, i32 7
  store ptr %44, ptr %47, align 8, !tbaa !22
  %48 = load ptr, ptr %4, align 8, !tbaa !11
  %49 = getelementptr inbounds %struct.arg_end, ptr %48, i32 0, i32 0
  %50 = getelementptr inbounds %struct.arg_hdr, ptr %49, i32 0, i32 8
  store ptr @arg_end_resetfn, ptr %50, align 8, !tbaa !23
  %51 = load ptr, ptr %4, align 8, !tbaa !11
  %52 = getelementptr inbounds %struct.arg_end, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds %struct.arg_hdr, ptr %52, i32 0, i32 9
  store ptr null, ptr %53, align 8, !tbaa !24
  %54 = load ptr, ptr %4, align 8, !tbaa !11
  %55 = getelementptr inbounds %struct.arg_end, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds %struct.arg_hdr, ptr %55, i32 0, i32 10
  store ptr null, ptr %56, align 8, !tbaa !25
  %57 = load ptr, ptr %4, align 8, !tbaa !11
  %58 = getelementptr inbounds %struct.arg_end, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds %struct.arg_hdr, ptr %58, i32 0, i32 11
  store ptr @arg_end_errorfn, ptr %59, align 8, !tbaa !26
  %60 = load ptr, ptr %4, align 8, !tbaa !11
  %61 = getelementptr inbounds %struct.arg_end, ptr %60, i64 1
  %62 = load ptr, ptr %4, align 8, !tbaa !11
  %63 = getelementptr inbounds %struct.arg_end, ptr %62, i32 0, i32 2
  store ptr %61, ptr %63, align 8, !tbaa !27
  %64 = load ptr, ptr %4, align 8, !tbaa !11
  %65 = getelementptr inbounds %struct.arg_end, ptr %64, i32 0, i32 2
  %66 = load ptr, ptr %65, align 8, !tbaa !27
  %67 = load i32, ptr %2, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds i32, ptr %66, i64 %68
  %70 = load ptr, ptr %4, align 8, !tbaa !11
  %71 = getelementptr inbounds %struct.arg_end, ptr %70, i32 0, i32 3
  store ptr %69, ptr %71, align 8, !tbaa !28
  %72 = load ptr, ptr %4, align 8, !tbaa !11
  %73 = getelementptr inbounds %struct.arg_end, ptr %72, i32 0, i32 3
  %74 = load ptr, ptr %73, align 8, !tbaa !28
  %75 = load i32, ptr %2, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds ptr, ptr %74, i64 %76
  %78 = load ptr, ptr %4, align 8, !tbaa !11
  %79 = getelementptr inbounds %struct.arg_end, ptr %78, i32 0, i32 4
  store ptr %77, ptr %79, align 8, !tbaa !29
  br label %80

80:                                               ; preds = %21, %1
  br label %81

81:                                               ; preds = %80
  br label %82

82:                                               ; preds = %81
  br label %83

83:                                               ; preds = %82
  %84 = load ptr, ptr %4, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret ptr %84
}

; Function Attrs: nounwind uwtable
declare hidden void @arg_end_resetfn(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @arg_end_errorfn(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 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 #3 = { nounwind }
attributes #4 = { nounwind allocsize(0) }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !7, i64 0}
!14 = !{!"arg_end", !15, i64 0, !6, i64 96, !12, i64 104, !12, i64 112, !12, i64 120}
!15 = !{!"arg_hdr", !7, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !6, i64 40, !6, i64 44, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88}
!16 = !{!14, !12, i64 8}
!17 = !{!14, !12, i64 16}
!18 = !{!14, !12, i64 24}
!19 = !{!14, !12, i64 32}
!20 = !{!14, !6, i64 40}
!21 = !{!14, !6, i64 44}
!22 = !{!14, !12, i64 48}
!23 = !{!14, !12, i64 56}
!24 = !{!14, !12, i64 64}
!25 = !{!14, !12, i64 72}
!26 = !{!14, !12, i64 80}
!27 = !{!14, !12, i64 104}
!28 = !{!14, !12, i64 112}
!29 = !{!14, !12, i64 120}


; 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: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: none, inaccessiblemem: readwrite) uwtable
define dso_local noundef ptr @arg_end(i32 noundef %0) local_unnamed_addr #1 {
  %2 = sext i32 %0 to i64
  %reass.mul = mul nsw i64 %2, 20
  %3 = add nsw i64 %reass.mul, 128
  %4 = tail call noalias ptr @malloc(i64 noundef %3) #4
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %19, label %5

5:                                                ; preds = %1
  store i8 1, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %4, i64 8
  %7 = getelementptr inbounds i8, ptr %4, i64 40
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %6, i8 0, i64 32, i1 false)
  store i32 1, ptr %7, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %4, i64 44
  store i32 %0, ptr %8, align 4, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %4, i64 48
  store ptr %4, ptr %9, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %4, i64 56
  store ptr @arg_end_resetfn, ptr %10, align 8, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %4, i64 64
  %12 = getelementptr inbounds i8, ptr %4, i64 80
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %11, i8 0, i64 16, i1 false)
  store ptr @arg_end_errorfn, ptr %12, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %4, i64 128
  %14 = getelementptr inbounds i8, ptr %4, i64 104
  store ptr %13, ptr %14, align 8, !tbaa !17
  %15 = getelementptr inbounds i32, ptr %13, i64 %2
  %16 = getelementptr inbounds i8, ptr %4, i64 112
  store ptr %15, ptr %16, align 8, !tbaa !18
  %17 = getelementptr inbounds ptr, ptr %15, i64 %2
  %18 = getelementptr inbounds i8, ptr %4, i64 120
  store ptr %17, ptr %18, align 8, !tbaa !19
  br label %19

19:                                               ; preds = %1, %5
  ret ptr %4
}

; Function Attrs: nounwind uwtable
declare hidden void @arg_end_resetfn(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @arg_end_errorfn(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nofree nounwind willreturn memory(write, argmem: none, inaccessiblemem: readwrite) 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 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind allocsize(0) }

!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 0}
!6 = !{!"arg_end", !7, i64 0, !11, i64 96, !10, i64 104, !10, i64 112, !10, i64 120}
!7 = !{!"arg_hdr", !8, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !11, i64 40, !11, i64 44, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !11, i64 40}
!13 = !{!6, !11, i64 44}
!14 = !{!6, !10, i64 48}
!15 = !{!6, !10, i64 56}
!16 = !{!6, !10, i64 80}
!17 = !{!6, !10, i64 104}
!18 = !{!6, !10, i64 112}
!19 = !{!6, !10, i64 120}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass