change getString to cin alike

This commit is contained in:
2024-10-22 18:39:51 +00:00
parent ca0edc2b9e
commit c6e529ec0f
3 changed files with 76 additions and 263 deletions

View File

@ -65,30 +65,33 @@ char* toString(int n) {
return res;
}
char* getString() { // same as getline
char *res=(char*)malloc(11);
int allocated_length = 10;
int cur_length = 0;
char ch;
char started=0;
while(scanf("%c",&ch)==1) {
if(ch=='\n'||ch=='\r') {
if(started) break;
else continue;
}
started=1;
if(cur_length==allocated_length) {
char *new_res = (char*)malloc(allocated_length*2+1);
for(int i=0;i<allocated_length;i++) {
new_res[i] = res[i];
}
free(res);
res = new_res;
allocated_length *= 2;
}
res[cur_length++] = ch;
}
res[cur_length] = '\0';
char *res=(char*)malloc(1024);
scanf("%s", res);
return res;
// char *res=(char*)malloc(11);
// int allocated_length = 10;
// int cur_length = 0;
// char ch;
// char started=0;
// while(scanf("%c",&ch)==1) {
// if(ch=='\n'||ch=='\r') {
// if(started) break;
// else continue;
// }
// started=1;
// if(cur_length==allocated_length) {
// char *new_res = (char*)malloc(allocated_length*2+1);
// for(int i=0;i<allocated_length;i++) {
// new_res[i] = res[i];
// }
// free(res);
// res = new_res;
// allocated_length *= 2;
// }
// res[cur_length++] = ch;
// }
// res[cur_length] = '\0';
// return res;
}
int getInt() {
int res;

View File

@ -7,15 +7,14 @@ target triple = "riscv32-unknown-unknown-elf"
@.str.1 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
@.str.3 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
@.str.4 = private unnamed_addr constant [3 x i8] c"%c\00", align 1
; Function Attrs: nofree nounwind memory(write, argmem: read, inaccessiblemem: readwrite)
define dso_local noalias noundef ptr @.builtin.strcat(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
%3 = tail call i32 @strlen(ptr noundef nonnull dereferenceable(1) %0) #12
%4 = tail call i32 @strlen(ptr noundef nonnull dereferenceable(1) %1) #12
%3 = tail call i32 @strlen(ptr noundef nonnull dereferenceable(1) %0) #11
%4 = tail call i32 @strlen(ptr noundef nonnull dereferenceable(1) %1) #11
%5 = add nsw i32 %4, %3
%6 = add nsw i32 %5, 1
%7 = tail call ptr @malloc(i32 noundef %6) #13
%7 = tail call ptr @malloc(i32 noundef %6) #12
%8 = icmp sgt i32 %3, 0
br i1 %8, label %12, label %9
@ -82,7 +81,7 @@ define dso_local i32 @string.length(ptr nocapture noundef readonly %0) local_unn
define dso_local noalias noundef ptr @string.substring(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
%4 = sub nsw i32 %2, %1
%5 = add nsw i32 %4, 1
%6 = tail call ptr @malloc(i32 noundef %5) #13
%6 = tail call ptr @malloc(i32 noundef %5) #12
%7 = getelementptr i8, ptr %0, i32 %1
%8 = icmp sgt i32 %4, 0
br i1 %8, label %11, label %9
@ -106,10 +105,10 @@ define dso_local noalias noundef ptr @string.substring(ptr nocapture noundef rea
; Function Attrs: nofree nounwind
define dso_local i32 @string.parseInt(ptr nocapture noundef readonly %0) local_unnamed_addr #5 {
%2 = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #14
%3 = call i32 (ptr, ptr, ...) @sscanf(ptr noundef %0, ptr noundef nonnull @.str, ptr noundef nonnull %2) #12
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #13
%3 = call i32 (ptr, ptr, ...) @sscanf(ptr noundef %0, ptr noundef nonnull @.str, ptr noundef nonnull %2) #11
%4 = load i32, ptr %2, align 4, !tbaa !14
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #14
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #13
ret i32 %4
}
@ -126,7 +125,7 @@ define dso_local i32 @string.ord(ptr nocapture noundef readonly %0, i32 noundef
; Function Attrs: nounwind
define dso_local void @print(ptr noundef %0) local_unnamed_addr #7 {
%2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull @.str.1, ptr noundef %0) #15
%2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull @.str.1, ptr noundef %0) #14
ret void
}
@ -134,138 +133,55 @@ declare dso_local i32 @printf(ptr noundef, ...) local_unnamed_addr #8
; Function Attrs: nounwind
define dso_local void @println(ptr noundef %0) local_unnamed_addr #7 {
%2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull @.str.2, ptr noundef %0) #15
%2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull @.str.2, ptr noundef %0) #14
ret void
}
; Function Attrs: nounwind
define dso_local void @printInt(i32 noundef %0) local_unnamed_addr #7 {
%2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull @.str, i32 noundef %0) #15
%2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull @.str, i32 noundef %0) #14
ret void
}
; Function Attrs: nounwind
define dso_local void @printlnInt(i32 noundef %0) local_unnamed_addr #7 {
%2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull @.str.3, i32 noundef %0) #15
%2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull @.str.3, i32 noundef %0) #14
ret void
}
; Function Attrs: nofree nounwind
define dso_local noalias noundef ptr @toString(i32 noundef %0) local_unnamed_addr #5 {
%2 = tail call dereferenceable_or_null(15) ptr @malloc(i32 noundef 15) #13
%3 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0) #12
%2 = tail call dereferenceable_or_null(15) ptr @malloc(i32 noundef 15) #12
%3 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0) #11
ret ptr %2
}
; Function Attrs: nofree nounwind
declare dso_local noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nounwind
define dso_local noalias ptr @getString() local_unnamed_addr #7 {
%1 = alloca i8, align 1
%2 = tail call dereferenceable_or_null(11) ptr @malloc(i32 noundef 11) #13
call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %1) #14
%3 = call i32 (ptr, ...) @scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %1) #12
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %45
5: ; preds = %0, %37
%6 = phi ptr [ %40, %37 ], [ %2, %0 ]
%7 = phi i1 [ false, %37 ], [ true, %0 ]
%8 = phi i32 [ %41, %37 ], [ 0, %0 ]
%9 = phi i32 [ %39, %37 ], [ 10, %0 ]
%10 = load i8, ptr %1, align 1
switch i8 %10, label %20 [
i8 13, label %11
i8 10, label %11
]
11: ; preds = %5, %5
br i1 %7, label %12, label %45
12: ; preds = %11
%13 = call i32 (ptr, ...) @scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %1) #12
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %45
15: ; preds = %12, %17
%16 = load i8, ptr %1, align 1
switch i8 %16, label %20 [
i8 13, label %17
i8 10, label %17
]
17: ; preds = %15, %15
%18 = call i32 (ptr, ...) @scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %1) #12
%19 = icmp eq i32 %18, 1
br i1 %19, label %15, label %45
20: ; preds = %15, %5
%21 = phi i8 [ %10, %5 ], [ %16, %15 ]
%22 = icmp eq i32 %8, %9
br i1 %22, label %23, label %37
23: ; preds = %20
%24 = shl nsw i32 %9, 1
%25 = or disjoint i32 %24, 1
%26 = call ptr @malloc(i32 noundef %25) #13
%27 = icmp sgt i32 %9, 0
br i1 %27, label %30, label %28
28: ; preds = %30, %23
call void @free(ptr noundef %6) #12
%29 = load i8, ptr %1, align 1, !tbaa !6
br label %37
30: ; preds = %23, %30
%31 = phi i32 [ %35, %30 ], [ 0, %23 ]
%32 = getelementptr inbounds i8, ptr %6, i32 %31
%33 = load i8, ptr %32, align 1, !tbaa !6
%34 = getelementptr inbounds i8, ptr %26, i32 %31
store i8 %33, ptr %34, align 1, !tbaa !6
%35 = add nuw nsw i32 %31, 1
%36 = icmp eq i32 %35, %9
br i1 %36, label %28, label %30, !llvm.loop !16
37: ; preds = %28, %20
%38 = phi i8 [ %29, %28 ], [ %21, %20 ]
%39 = phi i32 [ %24, %28 ], [ %9, %20 ]
%40 = phi ptr [ %26, %28 ], [ %6, %20 ]
%41 = add nuw nsw i32 %8, 1
%42 = getelementptr inbounds i8, ptr %40, i32 %8
store i8 %38, ptr %42, align 1, !tbaa !6
%43 = call i32 (ptr, ...) @scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %1) #12
%44 = icmp eq i32 %43, 1
br i1 %44, label %5, label %45, !llvm.loop !17
45: ; preds = %37, %11, %12, %17, %0
%46 = phi i32 [ 0, %0 ], [ %8, %17 ], [ %8, %11 ], [ %41, %37 ], [ %8, %12 ]
%47 = phi ptr [ %2, %0 ], [ %6, %17 ], [ %6, %11 ], [ %40, %37 ], [ %6, %12 ]
%48 = getelementptr inbounds i8, ptr %47, i32 %46
store i8 0, ptr %48, align 1, !tbaa !6
call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %1) #14
ret ptr %47
; Function Attrs: nofree nounwind
define dso_local noundef ptr @getString() local_unnamed_addr #5 {
%1 = tail call dereferenceable_or_null(1024) ptr @malloc(i32 noundef 1024) #12
%2 = tail call i32 (ptr, ...) @scanf(ptr noundef nonnull @.str.1, ptr noundef %1) #11
ret ptr %1
}
; Function Attrs: nofree nounwind
declare dso_local noundef i32 @scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare dso_local void @free(ptr allocptr nocapture noundef) local_unnamed_addr #9
; Function Attrs: nofree nounwind
define dso_local i32 @getInt() local_unnamed_addr #5 {
%1 = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #14
%2 = call i32 (ptr, ...) @scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1) #12
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #13
%2 = call i32 (ptr, ...) @scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1) #11
%3 = load i32, ptr %1, align 4, !tbaa !14
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #14
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #13
ret i32 %3
}
; Function Attrs: mustprogress nofree nounwind willreturn memory(inaccessiblemem: readwrite)
define dso_local noalias noundef ptr @.builtin.AllocateClassBody(i32 noundef %0) local_unnamed_addr #10 {
%2 = tail call ptr @malloc(i32 noundef %0) #13
define dso_local noalias noundef ptr @.builtin.AllocateClassBody(i32 noundef %0) local_unnamed_addr #9 {
%2 = tail call ptr @malloc(i32 noundef %0) #12
ret ptr %2
}
@ -308,7 +224,7 @@ define dso_local noalias nonnull ptr @.builtin.RecursiveAllocateArray(i32 nounde
13: ; preds = %3
%14 = mul nsw i32 %5, %1
%15 = add nsw i32 %14, 4
%16 = tail call ptr @malloc(i32 noundef %15) #13
%16 = tail call ptr @malloc(i32 noundef %15) #12
store i8 %6, ptr %16, align 1, !tbaa !6
%17 = getelementptr inbounds i8, ptr %16, i32 1
store i8 %8, ptr %17, align 1, !tbaa !6
@ -322,7 +238,7 @@ define dso_local noalias nonnull ptr @.builtin.RecursiveAllocateArray(i32 nounde
21: ; preds = %3
%22 = shl i32 %5, 2
%23 = add i32 %22, 4
%24 = tail call ptr @malloc(i32 noundef %23) #13
%24 = tail call ptr @malloc(i32 noundef %23) #12
store i8 %6, ptr %24, align 1, !tbaa !6
%25 = getelementptr inbounds i8, ptr %24, i32 1
store i8 %8, ptr %25, align 1, !tbaa !6
@ -341,13 +257,13 @@ define dso_local noalias nonnull ptr @.builtin.RecursiveAllocateArray(i32 nounde
33: ; preds = %30, %33
%34 = phi i32 [ 0, %30 ], [ %37, %33 ]
%35 = tail call ptr @.builtin.RecursiveAllocateArray(i32 noundef %31, i32 noundef %1, ptr noundef nonnull %32) #12
%35 = tail call ptr @.builtin.RecursiveAllocateArray(i32 noundef %31, i32 noundef %1, ptr noundef nonnull %32) #11
%36 = getelementptr inbounds ptr, ptr %28, i32 %34
store ptr %35, ptr %36, align 4, !tbaa !18
store ptr %35, ptr %36, align 4, !tbaa !16
%37 = add nuw nsw i32 %34, 1
%38 = load i32, ptr %2, align 4, !tbaa !14
%39 = icmp slt i32 %37, %38
br i1 %39, label %33, label %40, !llvm.loop !20
br i1 %39, label %33, label %40, !llvm.loop !18
40: ; preds = %33, %21, %13
%41 = phi ptr [ %20, %13 ], [ %28, %21 ], [ %28, %33 ]
@ -355,10 +271,10 @@ define dso_local noalias nonnull ptr @.builtin.RecursiveAllocateArray(i32 nounde
}
; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: none, inaccessiblemem: readwrite)
define dso_local noalias nonnull ptr @.builtin.AllocateArray(i32 noundef %0, i32 noundef %1) local_unnamed_addr #11 {
define dso_local noalias nonnull ptr @.builtin.AllocateArray(i32 noundef %0, i32 noundef %1) local_unnamed_addr #10 {
%3 = mul nsw i32 %1, %0
%4 = add nsw i32 %3, 4
%5 = tail call ptr @malloc(i32 noundef %4) #13
%5 = tail call ptr @malloc(i32 noundef %4) #12
%6 = trunc i32 %1 to i8
store i8 %6, ptr %5, align 1, !tbaa !6
%7 = lshr i32 %1, 8
@ -386,13 +302,12 @@ attributes #5 = { nofree nounwind "no-builtin-memcpy" "no-builtin-printf" "no-tr
attributes #6 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) "no-builtin-memcpy" "no-builtin-printf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv32" "target-features"="+32bit,+a,+c,+m,+relax,-d,-e,-experimental-zacas,-experimental-zcmop,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-zimop,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-f,-h,-smaia,-smepmp,-ssaia,-svinval,-svnapot,-svpbmt,-v,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmp,-zcmt,-zdinx,-zfa,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zicsr,-zifencei,-zihintntl,-zihintpause,-zihpm,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvbb,-zvbc,-zve32f,-zve32x,-zve64d,-zve64f,-zve64x,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl128b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl32b,-zvl4096b,-zvl512b,-zvl64b,-zvl65536b,-zvl8192b" }
attributes #7 = { nounwind "no-builtin-memcpy" "no-builtin-printf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv32" "target-features"="+32bit,+a,+c,+m,+relax,-d,-e,-experimental-zacas,-experimental-zcmop,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-zimop,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-f,-h,-smaia,-smepmp,-ssaia,-svinval,-svnapot,-svpbmt,-v,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmp,-zcmt,-zdinx,-zfa,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zicsr,-zifencei,-zihintntl,-zihintpause,-zihpm,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvbb,-zvbc,-zve32f,-zve32x,-zve64d,-zve64f,-zve64x,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl128b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl32b,-zvl4096b,-zvl512b,-zvl64b,-zvl65536b,-zvl8192b" }
attributes #8 = { "no-builtin-memcpy" "no-builtin-printf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv32" "target-features"="+32bit,+a,+c,+m,+relax,-d,-e,-experimental-zacas,-experimental-zcmop,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-zimop,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-f,-h,-smaia,-smepmp,-ssaia,-svinval,-svnapot,-svpbmt,-v,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmp,-zcmt,-zdinx,-zfa,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zicsr,-zifencei,-zihintntl,-zihintpause,-zihpm,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvbb,-zvbc,-zve32f,-zve32x,-zve64d,-zve64f,-zve64x,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl128b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl32b,-zvl4096b,-zvl512b,-zvl64b,-zvl65536b,-zvl8192b" }
attributes #9 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "no-builtin-memcpy" "no-builtin-printf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv32" "target-features"="+32bit,+a,+c,+m,+relax,-d,-e,-experimental-zacas,-experimental-zcmop,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-zimop,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-f,-h,-smaia,-smepmp,-ssaia,-svinval,-svnapot,-svpbmt,-v,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmp,-zcmt,-zdinx,-zfa,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zicsr,-zifencei,-zihintntl,-zihintpause,-zihpm,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvbb,-zvbc,-zve32f,-zve32x,-zve64d,-zve64f,-zve64x,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl128b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl32b,-zvl4096b,-zvl512b,-zvl64b,-zvl65536b,-zvl8192b" }
attributes #10 = { mustprogress nofree nounwind willreturn memory(inaccessiblemem: readwrite) "no-builtin-memcpy" "no-builtin-printf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv32" "target-features"="+32bit,+a,+c,+m,+relax,-d,-e,-experimental-zacas,-experimental-zcmop,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-zimop,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-f,-h,-smaia,-smepmp,-ssaia,-svinval,-svnapot,-svpbmt,-v,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmp,-zcmt,-zdinx,-zfa,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zicsr,-zifencei,-zihintntl,-zihintpause,-zihpm,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvbb,-zvbc,-zve32f,-zve32x,-zve64d,-zve64f,-zve64x,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl128b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl32b,-zvl4096b,-zvl512b,-zvl64b,-zvl65536b,-zvl8192b" }
attributes #11 = { mustprogress nofree nounwind willreturn memory(write, argmem: none, inaccessiblemem: readwrite) "no-builtin-memcpy" "no-builtin-printf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv32" "target-features"="+32bit,+a,+c,+m,+relax,-d,-e,-experimental-zacas,-experimental-zcmop,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-zimop,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-f,-h,-smaia,-smepmp,-ssaia,-svinval,-svnapot,-svpbmt,-v,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmp,-zcmt,-zdinx,-zfa,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zicsr,-zifencei,-zihintntl,-zihintpause,-zihpm,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvbb,-zvbc,-zve32f,-zve32x,-zve64d,-zve64f,-zve64x,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl128b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl32b,-zvl4096b,-zvl512b,-zvl64b,-zvl65536b,-zvl8192b" }
attributes #12 = { "no-builtin-memcpy" "no-builtin-printf" }
attributes #13 = { allocsize(0) "no-builtin-memcpy" "no-builtin-printf" }
attributes #14 = { nounwind }
attributes #15 = { nobuiltin nounwind "no-builtin-memcpy" "no-builtin-printf" }
attributes #9 = { mustprogress nofree nounwind willreturn memory(inaccessiblemem: readwrite) "no-builtin-memcpy" "no-builtin-printf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv32" "target-features"="+32bit,+a,+c,+m,+relax,-d,-e,-experimental-zacas,-experimental-zcmop,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-zimop,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-f,-h,-smaia,-smepmp,-ssaia,-svinval,-svnapot,-svpbmt,-v,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmp,-zcmt,-zdinx,-zfa,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zicsr,-zifencei,-zihintntl,-zihintpause,-zihpm,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvbb,-zvbc,-zve32f,-zve32x,-zve64d,-zve64f,-zve64x,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl128b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl32b,-zvl4096b,-zvl512b,-zvl64b,-zvl65536b,-zvl8192b" }
attributes #10 = { mustprogress nofree nounwind willreturn memory(write, argmem: none, inaccessiblemem: readwrite) "no-builtin-memcpy" "no-builtin-printf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv32" "target-features"="+32bit,+a,+c,+m,+relax,-d,-e,-experimental-zacas,-experimental-zcmop,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-zimop,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-f,-h,-smaia,-smepmp,-ssaia,-svinval,-svnapot,-svpbmt,-v,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmp,-zcmt,-zdinx,-zfa,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zicsr,-zifencei,-zihintntl,-zihintpause,-zihpm,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvbb,-zvbc,-zve32f,-zve32x,-zve64d,-zve64f,-zve64x,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl128b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl32b,-zvl4096b,-zvl512b,-zvl64b,-zvl65536b,-zvl8192b" }
attributes #11 = { "no-builtin-memcpy" "no-builtin-printf" }
attributes #12 = { allocsize(0) "no-builtin-memcpy" "no-builtin-printf" }
attributes #13 = { nounwind }
attributes #14 = { nobuiltin nounwind "no-builtin-memcpy" "no-builtin-printf" }
!llvm.module.flags = !{!0, !1, !2, !4}
!llvm.ident = !{!5}
@ -413,8 +328,6 @@ attributes #15 = { nobuiltin nounwind "no-builtin-memcpy" "no-builtin-printf" }
!13 = distinct !{!13, !10}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = !{!19, !19, i64 0}
!19 = !{!"any pointer", !7, i64 0}
!20 = distinct !{!20, !10}
!16 = !{!17, !17, i64 0}
!17 = !{!"any pointer", !7, i64 0}
!18 = distinct !{!18, !10}

View File

@ -262,118 +262,20 @@ toString: # @toString
.type getString,@function
getString: # @getString
# %bb.0:
addi sp, sp, -48
sw ra, 44(sp) # 4-byte Folded Spill
sw s0, 40(sp) # 4-byte Folded Spill
sw s1, 36(sp) # 4-byte Folded Spill
sw s2, 32(sp) # 4-byte Folded Spill
sw s3, 28(sp) # 4-byte Folded Spill
sw s4, 24(sp) # 4-byte Folded Spill
sw s5, 20(sp) # 4-byte Folded Spill
sw s6, 16(sp) # 4-byte Folded Spill
sw s7, 12(sp) # 4-byte Folded Spill
sw s8, 8(sp) # 4-byte Folded Spill
sw s9, 4(sp) # 4-byte Folded Spill
li a0, 11
addi sp, sp, -16
sw ra, 12(sp) # 4-byte Folded Spill
sw s0, 8(sp) # 4-byte Folded Spill
li a0, 1024
call malloc
mv s3, a0
lui a0, %hi(.builtin_L.str.4)
addi s0, a0, %lo(.builtin_L.str.4)
addi a1, sp, 3
mv a0, s0
mv s0, a0
lui a0, %hi(.builtin_L.str.1)
addi a0, a0, %lo(.builtin_L.str.1)
mv a1, s0
call scanf
li s9, 1
bne a0, s9, .LBB10_15
# %bb.1: # %.preheader4
li s6, 0
li s4, 10
li s5, 13
mv s2, s3
li a1, 1
li s7, 10
.LBB10_2: # =>This Loop Header: Depth=1
# Child Loop BB10_5 Depth 2
# Child Loop BB10_11 Depth 2
lbu a0, 3(sp)
beq a0, s5, .LBB10_4
# %bb.3: # in Loop: Header=BB10_2 Depth=1
bne a0, s4, .LBB10_8
.LBB10_4: # in Loop: Header=BB10_2 Depth=1
andi a1, a1, 1
beqz a1, .LBB10_16
.LBB10_5: # Parent Loop BB10_2 Depth=1
# => This Inner Loop Header: Depth=2
addi a1, sp, 3
mv a0, s0
call scanf
bne a0, s9, .LBB10_16
# %bb.6: # in Loop: Header=BB10_5 Depth=2
lbu a0, 3(sp)
beq a0, s5, .LBB10_5
# %bb.7: # in Loop: Header=BB10_5 Depth=2
beq a0, s4, .LBB10_5
.LBB10_8: # in Loop: Header=BB10_2 Depth=1
bne s6, s7, .LBB10_13
# %bb.9: # in Loop: Header=BB10_2 Depth=1
slli s8, s7, 1
addi a0, s8, 1
call malloc
mv s3, a0
blez s7, .LBB10_12
# %bb.10: # %.preheader
# in Loop: Header=BB10_2 Depth=1
add s7, s7, s3
mv a0, s2
mv a1, s3
.LBB10_11: # Parent Loop BB10_2 Depth=1
# => This Inner Loop Header: Depth=2
lbu a2, 0(a0)
sb a2, 0(a1)
addi a1, a1, 1
addi a0, a0, 1
bne a1, s7, .LBB10_11
.LBB10_12: # in Loop: Header=BB10_2 Depth=1
mv a0, s2
call free
lbu a0, 3(sp)
mv s2, s3
mv s7, s8
j .LBB10_14
.LBB10_13: # in Loop: Header=BB10_2 Depth=1
mv s3, s2
.LBB10_14: # in Loop: Header=BB10_2 Depth=1
addi s1, s6, 1
add s6, s6, s3
sb a0, 0(s6)
addi a1, sp, 3
mv a0, s0
call scanf
li a1, 0
mv s6, s1
beq a0, s9, .LBB10_2
j .LBB10_17
.LBB10_15:
li s1, 0
j .LBB10_17
.LBB10_16:
mv s1, s6
mv s3, s2
.LBB10_17:
add s1, s1, s3
sb zero, 0(s1)
mv a0, s3
lw ra, 44(sp) # 4-byte Folded Reload
lw s0, 40(sp) # 4-byte Folded Reload
lw s1, 36(sp) # 4-byte Folded Reload
lw s2, 32(sp) # 4-byte Folded Reload
lw s3, 28(sp) # 4-byte Folded Reload
lw s4, 24(sp) # 4-byte Folded Reload
lw s5, 20(sp) # 4-byte Folded Reload
lw s6, 16(sp) # 4-byte Folded Reload
lw s7, 12(sp) # 4-byte Folded Reload
lw s8, 8(sp) # 4-byte Folded Reload
lw s9, 4(sp) # 4-byte Folded Reload
addi sp, sp, 48
lw ra, 12(sp) # 4-byte Folded Reload
lw s0, 8(sp) # 4-byte Folded Reload
addi sp, sp, 16
ret
.builtin_Lfunc_end10:
.size getString, .builtin_Lfunc_end10-getString
@ -566,10 +468,5 @@ getInt: # @getInt
.asciz "%d\n"
.size .builtin_L.str.3, 4
.type .builtin_L.str.4,@object # @.str.4
.builtin_L.str.4:
.asciz "%c"
.size .builtin_L.str.4, 3
.ident "Ubuntu clang version 18.1.8 (++20240731024944+3b5b5c1ec4a3-1~exp1~20240731145000.144)"
.section ".note.GNU-stack","",@progbits