; LLVM IR from Water-Melon/Melon :: t (bignum)

; 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.mln_bignum_t = type { i32, i32, [257 x i64] }
%struct.mln_string_t = type { ptr, i64, i32 }

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %struct.mln_bignum_t, align 8
  %8 = alloca %struct.mln_bignum_t, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 2064, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 2064, ptr %8) #5
  call void @llvm.memset.p0.i64(ptr align 8 %8, i8 0, i64 2064, i1 false)
  %11 = getelementptr inbounds %struct.mln_bignum_t, ptr %7, i32 0, i32 0
  store i32 0, ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds %struct.mln_bignum_t, ptr %7, i32 0, i32 1
  store i32 0, ptr %12, align 4, !tbaa !13
  %13 = getelementptr inbounds %struct.mln_bignum_t, ptr %7, i32 0, i32 2
  %14 = getelementptr inbounds [257 x i64], ptr %13, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 8 %14, i8 0, i64 2056, i1 false)
  store ptr %14, ptr %9, align 8, !tbaa !9
  %15 = load ptr, ptr %9, align 8, !tbaa !9
  %16 = call i32 @mln_bignum_assign(ptr noundef %7, ptr noundef @.str, i32 noundef 2)
  %17 = call i32 @mln_bignum_assign(ptr noundef %8, ptr noundef @.str.1, i32 noundef 2)
  %18 = call i32 @mln_bignum_pwr(ptr noundef %7, ptr noundef %8, ptr noundef null)
  %19 = call ptr @mln_bignum_tostring(ptr noundef %7)
  store ptr %19, ptr %6, align 8, !tbaa !9
  %20 = load ptr, ptr %6, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.mln_string_t, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %23 = load ptr, ptr %6, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.mln_string_t, ptr %23, i32 0, i32 1
  %25 = load i64, ptr %24, align 8, !tbaa !17
  %26 = call i64 @write(i32 noundef 1, ptr noundef %22, i64 noundef %25)
  %27 = call i64 @write(i32 noundef 1, ptr noundef @.str.2, i64 noundef 1)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %28 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %28, ptr %10, align 8, !tbaa !9
  %29 = load ptr, ptr %10, align 8, !tbaa !9
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %89

31:                                               ; preds = %2
  %32 = load ptr, ptr %10, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.mln_string_t, ptr %32, i32 0, i32 2
  %34 = load i32, ptr %33, align 8
  %35 = lshr i32 %34, 2
  %36 = zext i32 %35 to i64
  %37 = add i64 %36, -1
  %38 = trunc i64 %37 to i32
  %39 = load i32, ptr %33, align 8
  %40 = and i32 %38, 1073741823
  %41 = shl i32 %40, 2
  %42 = and i32 %39, 3
  %43 = or i32 %42, %41
  store i32 %43, ptr %33, align 8
  %44 = zext i32 %40 to i64
  %45 = icmp ule i64 %36, 1
  br i1 %45, label %46, label %88

46:                                               ; preds = %31
  %47 = load ptr, ptr %10, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.mln_string_t, ptr %47, i32 0, i32 2
  %49 = load i32, ptr %48, align 8
  %50 = and i32 %49, 1
  %51 = zext i32 %50 to i64
  %52 = icmp ne i64 %51, 0
  br i1 %52, label %75, label %53

53:                                               ; preds = %46
  %54 = load ptr, ptr %10, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.mln_string_t, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !14
  %57 = icmp ne ptr %56, null
  br i1 %57, label %58, label %75

58:                                               ; preds = %53
  %59 = load ptr, ptr %10, align 8, !tbaa !9
  %60 = getelementptr inbounds %struct.mln_string_t, ptr %59, i32 0, i32 2
  %61 = load i32, ptr %60, align 8
  %62 = lshr i32 %61, 1
  %63 = and i32 %62, 1
  %64 = zext i32 %63 to i64
  %65 = icmp ne i64 %64, 0
  br i1 %65, label %66, label %70

66:                                               ; preds = %58
  %67 = load ptr, ptr %10, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.mln_string_t, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !14
  call void @mln_alloc_free(ptr noundef %69)
  br label %74

70:                                               ; preds = %58
  %71 = load ptr, ptr %10, align 8, !tbaa !9
  %72 = getelementptr inbounds %struct.mln_string_t, ptr %71, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !14
  call void @free(ptr noundef %73) #5
  br label %74

74:                                               ; preds = %70, %66
  br label %75

75:                                               ; preds = %74, %53, %46
  %76 = load ptr, ptr %10, align 8, !tbaa !9
  %77 = getelementptr inbounds %struct.mln_string_t, ptr %76, i32 0, i32 2
  %78 = load i32, ptr %77, align 8
  %79 = lshr i32 %78, 1
  %80 = and i32 %79, 1
  %81 = zext i32 %80 to i64
  %82 = icmp ne i64 %81, 0
  br i1 %82, label %83, label %85

83:                                               ; preds = %75
  %84 = load ptr, ptr %10, align 8, !tbaa !9
  call void @mln_alloc_free(ptr noundef %84)
  br label %87

85:                                               ; preds = %75
  %86 = load ptr, ptr %10, align 8, !tbaa !9
  call void @free(ptr noundef %86) #5
  br label %87

87:                                               ; preds = %85, %83
  br label %88

88:                                               ; preds = %87, %31
  br label %89

89:                                               ; preds = %88, %2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 2064, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 2064, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  ret i32 0
}

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

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

declare i32 @mln_bignum_assign(ptr noundef, ptr noundef, i32 noundef) #3

declare i32 @mln_bignum_pwr(ptr noundef, ptr noundef, ptr noundef) #3

declare ptr @mln_bignum_tostring(ptr noundef) #3

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #3

declare void @mln_alloc_free(ptr noundef) #3

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

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

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 "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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"", !6, i64 0, !6, i64 4, !7, i64 8}
!13 = !{!12, !6, i64 4}
!14 = !{!15, !10, i64 0}
!15 = !{!"", !10, i64 0, !16, i64 8, !16, i64 16, !16, i64 16, !16, i64 16}
!16 = !{!"long", !7, i64 0}
!17 = !{!15, !16, 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.mln_bignum_t = type { i32, i32, [257 x i64] }

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca %struct.mln_bignum_t, align 8
  %4 = alloca %struct.mln_bignum_t, align 8
  call void @llvm.lifetime.start.p0(i64 2064, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 2064, ptr nonnull %4) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(2064) %4, i8 0, i64 2064, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(2064) %3, i8 0, i64 2064, i1 false)
  %5 = call i32 @mln_bignum_assign(ptr noundef nonnull %3, ptr noundef nonnull @.str, i32 noundef 2) #6
  %6 = call i32 @mln_bignum_assign(ptr noundef nonnull %4, ptr noundef nonnull @.str.1, i32 noundef 2) #6
  %7 = call i32 @mln_bignum_pwr(ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef null) #6
  %8 = call ptr @mln_bignum_tostring(ptr noundef nonnull %3) #6
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %8, i64 8
  %11 = load i64, ptr %10, align 8, !tbaa !11
  %12 = call i64 @write(i32 noundef 1, ptr noundef %9, i64 noundef %11) #6
  %13 = call i64 @write(i32 noundef 1, ptr noundef nonnull @.str.2, i64 noundef 1) #6
  %14 = getelementptr inbounds i8, ptr %8, i64 16
  %15 = load i32, ptr %14, align 8
  %16 = and i32 %15, -4
  %17 = add i32 %16, -4
  %18 = and i32 %15, 3
  %19 = or disjoint i32 %17, %18
  store i32 %19, ptr %14, align 8
  %20 = icmp ult i32 %15, 8
  br i1 %20, label %21, label %34

21:                                               ; preds = %2
  %22 = and i32 %15, 1
  %.not = icmp eq i32 %22, 0
  br i1 %.not, label %23, label %29

23:                                               ; preds = %21
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %.not14 = icmp eq ptr %24, null
  br i1 %.not14, label %29, label %25

25:                                               ; preds = %23
  %26 = and i32 %15, 2
  %.not15 = icmp eq i32 %26, 0
  br i1 %.not15, label %28, label %27

27:                                               ; preds = %25
  call void @mln_alloc_free(ptr noundef nonnull %24) #6
  br label %29

28:                                               ; preds = %25
  call void @free(ptr noundef nonnull %24) #6
  br label %29

29:                                               ; preds = %27, %28, %23, %21
  %30 = load i32, ptr %14, align 8
  %31 = and i32 %30, 2
  %.not16 = icmp eq i32 %31, 0
  br i1 %.not16, label %33, label %32

32:                                               ; preds = %29
  call void @mln_alloc_free(ptr noundef nonnull %8) #6
  br label %34

33:                                               ; preds = %29
  call void @free(ptr noundef nonnull %8) #6
  br label %34

34:                                               ; preds = %2, %33, %32
  call void @llvm.lifetime.end.p0(i64 2064, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 2064, ptr nonnull %3) #6
  ret i32 0
}

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

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

declare i32 @mln_bignum_assign(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @mln_bignum_pwr(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare ptr @mln_bignum_tostring(ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #4

declare void @mln_alloc_free(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { nofree "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #6 = { 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 16, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 8}


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