; 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.TRex = type { ptr, ptr, ptr, i32, i32, ptr, i32, i32, i32, ptr, i32, ptr, ptr, i32 }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }
%struct.tagTRexNode = type { i32, i32, i32, i32 }

@.str.14 = 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @trex_compile(ptr noundef %0, ptr noundef %1, i32 noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %11 = call noalias ptr @malloc(i64 noundef 96) #7
  store ptr %11, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %8, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.TRex, ptr %12, i32 0, i32 1
  store ptr null, ptr %13, align 8, !tbaa !11
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.TRex, ptr %14, i32 0, i32 0
  store ptr null, ptr %15, align 8, !tbaa !13
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.TRex, ptr %17, i32 0, i32 2
  store ptr %16, ptr %18, align 8, !tbaa !14
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call i64 @strlen(ptr noundef %19) #8
  %21 = trunc i64 %20 to i32
  %22 = sext i32 %21 to i64
  %23 = mul i64 %22, 1
  %24 = trunc i64 %23 to i32
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.TRex, ptr %25, i32 0, i32 6
  store i32 %24, ptr %26, align 8, !tbaa !15
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.TRex, ptr %27, i32 0, i32 6
  %29 = load i32, ptr %28, align 8, !tbaa !15
  %30 = sext i32 %29 to i64
  %31 = mul i64 %30, 16
  %32 = call noalias ptr @malloc(i64 noundef %31) #7
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.TRex, ptr %33, i32 0, i32 5
  store ptr %32, ptr %34, align 8, !tbaa !16
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.TRex, ptr %35, i32 0, i32 7
  store i32 0, ptr %36, align 4, !tbaa !17
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.TRex, ptr %37, i32 0, i32 9
  store ptr null, ptr %38, align 8, !tbaa !18
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.TRex, ptr %39, i32 0, i32 8
  store i32 0, ptr %40, align 8, !tbaa !19
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = call i32 @trex_newnode(ptr noundef %41, i32 noundef 258)
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.TRex, ptr %43, i32 0, i32 3
  store i32 %42, ptr %44, align 8, !tbaa !20
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.TRex, ptr %46, i32 0, i32 12
  store ptr %45, ptr %47, align 8, !tbaa !21
  %48 = call noalias ptr @malloc(i64 noundef 200) #7
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.TRex, ptr %49, i32 0, i32 11
  store ptr %48, ptr %50, align 8, !tbaa !22
  %51 = load i32, ptr %7, align 4, !tbaa !9
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.TRex, ptr %52, i32 0, i32 13
  store i32 %51, ptr %53, align 8, !tbaa !23
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.TRex, ptr %54, i32 0, i32 11
  %56 = load ptr, ptr %55, align 8, !tbaa !22
  %57 = getelementptr inbounds [1 x %struct.__jmp_buf_tag], ptr %56, i64 0, i64 0
  %58 = call i32 @_setjmp(ptr noundef %57) #9
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %98

60:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = call i32 @trex_list(ptr noundef %61)
  store i32 %62, ptr %9, align 4, !tbaa !9
  %63 = load i32, ptr %9, align 4, !tbaa !9
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.TRex, ptr %64, i32 0, i32 5
  %66 = load ptr, ptr %65, align 8, !tbaa !16
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.TRex, ptr %67, i32 0, i32 3
  %69 = load i32, ptr %68, align 8, !tbaa !20
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds %struct.tagTRexNode, ptr %66, i64 %70
  %72 = getelementptr inbounds %struct.tagTRexNode, ptr %71, i32 0, i32 1
  store i32 %63, ptr %72, align 4, !tbaa !24
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.TRex, ptr %73, i32 0, i32 2
  %75 = load ptr, ptr %74, align 8, !tbaa !14
  %76 = load i8, ptr %75, align 1, !tbaa !26
  %77 = sext i8 %76 to i32
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %81

79:                                               ; preds = %60
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  call void @trex_error(ptr noundef %80, ptr noundef @.str.14)
  br label %81

81:                                               ; preds = %79, %60
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.TRex, ptr %82, i32 0, i32 8
  %84 = load i32, ptr %83, align 8, !tbaa !19
  %85 = sext i32 %84 to i64
  %86 = mul i64 %85, 16
  %87 = call noalias ptr @malloc(i64 noundef %86) #7
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.TRex, ptr %88, i32 0, i32 9
  store ptr %87, ptr %89, align 8, !tbaa !18
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.TRex, ptr %90, i32 0, i32 9
  %92 = load ptr, ptr %91, align 8, !tbaa !18
  %93 = load ptr, ptr %8, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.TRex, ptr %93, i32 0, i32 8
  %95 = load i32, ptr %94, align 8, !tbaa !19
  %96 = sext i32 %95 to i64
  %97 = mul i64 %96, 16
  call void @llvm.memset.p0.i64(ptr align 8 %92, i8 0, i64 %97, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %100

98:                                               ; preds = %3
  %99 = load ptr, ptr %8, align 8, !tbaa !5
  call void @trex_free(ptr noundef %99)
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %102

100:                                              ; preds = %81
  %101 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %101, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %102

102:                                              ; preds = %100, %98
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %103 = load ptr, ptr %4, align 8
  ret ptr %103
}

; Function Attrs: nounwind uwtable
declare dso_local void @trex_free(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @trex_newnode(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind returns_twice
declare i32 @_setjmp(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare hidden i32 @trex_list(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @trex_error(ptr noundef, ptr noundef) #3

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(read) "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 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 #3 = { 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 #4 = { nounwind returns_twice "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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { nounwind returns_twice }

!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 8}
!12 = !{!"TRex", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !6, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !6, i64 56, !10, i64 64, !6, i64 72, !6, i64 80, !10, i64 88}
!13 = !{!12, !6, i64 0}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !10, i64 40}
!16 = !{!12, !6, i64 32}
!17 = !{!12, !10, i64 44}
!18 = !{!12, !6, i64 56}
!19 = !{!12, !10, i64 48}
!20 = !{!12, !10, i64 24}
!21 = !{!12, !6, i64 80}
!22 = !{!12, !6, i64 72}
!23 = !{!12, !10, i64 88}
!24 = !{!25, !10, i64 4}
!25 = !{!"tagTRexNode", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!26 = !{!7, !7, i64 0}


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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @trex_compile(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = call noalias dereferenceable_or_null(96) ptr @malloc(i64 noundef 96) #6
  %5 = getelementptr inbounds i8, ptr %4, i64 16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, i8 0, i64 16, i1 false)
  store ptr %0, ptr %5, align 8, !tbaa !5
  %6 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #7
  %7 = trunc i64 %6 to i32
  %sext = shl i64 %6, 32
  %8 = getelementptr inbounds i8, ptr %4, i64 40
  store i32 %7, ptr %8, align 8, !tbaa !11
  %9 = ashr exact i64 %sext, 28
  %10 = call noalias ptr @malloc(i64 noundef %9) #6
  %11 = getelementptr inbounds i8, ptr %4, i64 32
  store ptr %10, ptr %11, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %4, i64 44
  store i32 0, ptr %12, align 4, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %4, i64 56
  store ptr null, ptr %13, align 8, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %4, i64 48
  store i32 0, ptr %14, align 8, !tbaa !15
  %15 = call i32 @trex_newnode(ptr noundef nonnull %4, i32 noundef 258)
  %16 = getelementptr inbounds i8, ptr %4, i64 24
  store i32 %15, ptr %16, align 8, !tbaa !16
  %17 = getelementptr inbounds i8, ptr %4, i64 80
  store ptr %1, ptr %17, align 8, !tbaa !17
  %18 = call noalias dereferenceable_or_null(200) ptr @malloc(i64 noundef 200) #6
  %19 = getelementptr inbounds i8, ptr %4, i64 72
  store ptr %18, ptr %19, align 8, !tbaa !18
  %20 = getelementptr inbounds i8, ptr %4, i64 88
  store i32 %2, ptr %20, align 8, !tbaa !19
  %21 = call i32 @_setjmp(ptr noundef %18) #8
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %36

23:                                               ; preds = %3
  %24 = call i32 @trex_list(ptr noundef nonnull %4)
  %25 = load ptr, ptr %11, align 8, !tbaa !12
  %26 = load i32, ptr %16, align 8, !tbaa !16
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds %struct.tagTRexNode, ptr %25, i64 %27, i32 1
  store i32 %24, ptr %28, align 4, !tbaa !20
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load i8, ptr %29, align 1, !tbaa !22
  %.not = icmp eq i8 %30, 0
  br i1 %.not, label %32, label %31

31:                                               ; preds = %23
  call void @trex_error(ptr noundef nonnull %4, ptr noundef nonnull @.str.14)
  br label %32

32:                                               ; preds = %31, %23
  %33 = load i32, ptr %14, align 8, !tbaa !15
  %34 = sext i32 %33 to i64
  %35 = shl nsw i64 %34, 4
  %calloc = call ptr @calloc(i64 1, i64 %35)
  store ptr %calloc, ptr %13, align 8, !tbaa !14
  br label %37

36:                                               ; preds = %3
  call void @trex_free(ptr noundef nonnull %4)
  br label %37

37:                                               ; preds = %32, %36
  %.0 = phi ptr [ %4, %32 ], [ null, %36 ]
  ret ptr %.0
}

; Function Attrs: nounwind uwtable
declare dso_local void @trex_free(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind returns_twice
declare i32 @_setjmp(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @trex_list(ptr noundef) local_unnamed_addr #2

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

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

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #5

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 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 #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 returns_twice "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { nounwind willreturn memory(read) }
attributes #8 = { nounwind returns_twice }

!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 16}
!6 = !{!"TRex", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !7, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !7, i64 56, !10, i64 64, !7, i64 72, !7, i64 80, !10, i64 88}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 40}
!12 = !{!6, !7, i64 32}
!13 = !{!6, !10, i64 44}
!14 = !{!6, !7, i64 56}
!15 = !{!6, !10, i64 48}
!16 = !{!6, !10, i64 24}
!17 = !{!6, !7, i64 80}
!18 = !{!6, !7, i64 72}
!19 = !{!6, !10, i64 88}
!20 = !{!21, !10, i64 4}
!21 = !{!"tagTRexNode", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!22 = !{!8, !8, i64 0}


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