Source_Code stringlengths 69 484k | IR_Original stringlengths 2.05k 17.9M |
|---|---|
#include <stdio.h>
int main() {
int N, D, ans, sum;
scanf("%d%d", &N, &D);
sum = 2 * D + 1;
ans = 0;
for(;;){
N -= sum;
ans++;
if(N <= 0){
break;
}
}
printf("%d\n", ans);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_204900/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_204900/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%N = alloca i32, align 4
%D = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %D) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N, ptr noundef nonnull %D)
%0 = load i32, ptr %D, align 4, !tbaa !5
%mul = shl nsw i32 %0, 1
%add.neg = xor i32 %mul, -1
%N.promoted = load i32, ptr %N, align 4, !tbaa !5
br label %for.cond
for.cond: ; preds = %for.cond, %entry
%sub3 = phi i32 [ %N.promoted, %entry ], [ %sub, %for.cond ]
%ans.0 = phi i32 [ 0, %entry ], [ %inc, %for.cond ]
%sub = add i32 %sub3, %add.neg
%inc = add nuw nsw i32 %ans.0, 1
%cmp = icmp slt i32 %sub, 1
br i1 %cmp, label %for.end, label %for.cond
for.end: ; preds = %for.cond
store i32 %sub, ptr %N, align 4, !tbaa !5
%call1 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %inc)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %D) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>
#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))
int compare_sz_asc(const void* a, const void* b) {
return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}
int compare_sz_desc(const void* a, const void* b) {
return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}
int compare_i64_asc(const void* a, const void* b) {
return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}
int compare_i64_desc(const void* a, const void* b) {
return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}
int compare_c_asc(const void* a, const void* b) {
return *((char*)a) < *((char*)b) ? -1 : 1;
}
int compare_c_desc(const void* a, const void* b) {
return *((char*)a) > * ((char*)b) ? -1 : 1;
}
static size_t powSz(const size_t base, const size_t exp) {
if (exp == 0) {
return 1;
}
if (exp == 1) {
return base;
}
if (exp % 2 == 0) {
return powSz(base * base, exp / 2);
}
else {
return base * powSz(base, exp - 1);
}
}
static size_t comb(const size_t n, const size_t r) {
size_t result = 1;
for (size_t i = 0; i < r; i++) {
result *= n - i;
result /= i + 1;
}
return result;
}
static uint64_t combU64(const uint64_t n, const uint64_t r) {
uint64_t result = 1;
for (uint64_t i = 0; i < r; i++) {
result *= n - i;
result /= i + 1;
}
return result;
}
static size_t gcdZu(size_t m, size_t n) {
size_t temp;
while (m % n != 0) {
temp = n;
n = m % n;
m = temp;
}
return n;
}
static uint64_t gcdU64(uint64_t m, uint64_t n)
{
uint64_t temp;
while (m % n != 0) {
temp = n;
n = m % n;
m = temp;
}
return n;
}
int main(void) {
uint64_t N, D;
scanf("%"PRIu64"%"PRIu64, &N, &D);
const uint64_t numWatch = 2 * D + 1;
printf("%"PRIu64, (N + numWatch - 1) / numWatch);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_204944/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_204944/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [7 x i8] c"%lu%lu\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%lu\00", align 1
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @compare_sz_asc(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) local_unnamed_addr #0 {
entry:
%0 = load i64, ptr %a, align 8, !tbaa !5
%1 = load i64, ptr %b, align 8, !tbaa !5
%cmp = icmp ult i64 %0, %1
%cond = select i1 %cmp, i32 -1, i32 1
ret i32 %cond
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @compare_sz_desc(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) local_unnamed_addr #0 {
entry:
%0 = load i64, ptr %a, align 8, !tbaa !5
%1 = load i64, ptr %b, align 8, !tbaa !5
%cmp = icmp ugt i64 %0, %1
%cond = select i1 %cmp, i32 -1, i32 1
ret i32 %cond
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @compare_i64_asc(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) local_unnamed_addr #0 {
entry:
%0 = load i64, ptr %a, align 8, !tbaa !5
%1 = load i64, ptr %b, align 8, !tbaa !5
%cmp = icmp slt i64 %0, %1
%cond = select i1 %cmp, i32 -1, i32 1
ret i32 %cond
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @compare_i64_desc(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) local_unnamed_addr #0 {
entry:
%0 = load i64, ptr %a, align 8, !tbaa !5
%1 = load i64, ptr %b, align 8, !tbaa !5
%cmp = icmp sgt i64 %0, %1
%cond = select i1 %cmp, i32 -1, i32 1
ret i32 %cond
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @compare_c_asc(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) local_unnamed_addr #0 {
entry:
%0 = load i8, ptr %a, align 1, !tbaa !9
%1 = load i8, ptr %b, align 1, !tbaa !9
%cmp = icmp slt i8 %0, %1
%cond = select i1 %cmp, i32 -1, i32 1
ret i32 %cond
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @compare_c_desc(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) local_unnamed_addr #0 {
entry:
%0 = load i8, ptr %a, align 1, !tbaa !9
%1 = load i8, ptr %b, align 1, !tbaa !9
%cmp = icmp sgt i8 %0, %1
%cond = select i1 %cmp, i32 -1, i32 1
ret i32 %cond
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
entry:
%N = alloca i64, align 8
%D = alloca i64, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %N) #4
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %D) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N, ptr noundef nonnull %D)
%0 = load i64, ptr %D, align 8, !tbaa !5
%mul = shl i64 %0, 1
%add = or i64 %mul, 1
%1 = load i64, ptr %N, align 8, !tbaa !5
%add1 = add i64 %1, -1
%sub = add i64 %add1, %add
%div = udiv i64 %sub, %add
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %div)
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %D) #4
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %N) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 = { nofree 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
|
#include <stdio.h>
int main()
{
int N,A;
scanf("%d\n%d",&N,&A);
if((N%500)<=A)
printf("Yes");
else printf("No");
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_204988/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_204988/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d\0A%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"No\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%N = alloca i32, align 4
%A = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %A) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N, ptr noundef nonnull %A)
%0 = load i32, ptr %N, align 4, !tbaa !5
%rem = srem i32 %0, 500
%1 = load i32, ptr %A, align 4, !tbaa !5
%cmp.not = icmp sgt i32 %rem, %1
%.str.2..str.1 = select i1 %cmp.not, ptr @.str.2, ptr @.str.1
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.2..str.1)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %A) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(void){
int x,y;
scanf("%d%d",&x,&y);
if(x%500>y) printf("No");
else printf("Yes");
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_205073/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_205073/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"No\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%x = alloca i32, align 4
%y = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %y) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x, ptr noundef nonnull %y)
%0 = load i32, ptr %x, align 4, !tbaa !5
%rem = srem i32 %0, 500
%1 = load i32, ptr %y, align 4, !tbaa !5
%cmp = icmp sgt i32 %rem, %1
%.str.1..str.2 = select i1 %cmp, ptr @.str.1, ptr @.str.2
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.1..str.2)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %y) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main(void) {
int n,a;
scanf("%d\n%d",&n,&a);
if(n%500>a) printf("No");
else printf("Yes");
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_205116/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_205116/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d\0A%d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"No\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%a = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n, ptr noundef nonnull %a)
%0 = load i32, ptr %n, align 4, !tbaa !5
%rem = srem i32 %0, 500
%1 = load i32, ptr %a, align 4, !tbaa !5
%cmp = icmp sgt i32 %rem, %1
%.str.1..str.2 = select i1 %cmp, ptr @.str.1, ptr @.str.2
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.1..str.2)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main()
{
int a,b,c=0,i,sum,j,s,m=0,n,ar[10000],br[10000];
scanf("%d %d",&a,&b);
for(i=1;i<=a;i++)
{
scanf("%d",&ar[i]);
br[ar[i]]++;
}
for(i=1;i<=100;i++)
{
if(br[i]>m)
{
m=br[i];
}
if(br[i]>0)
{
c++;
}
}
n=m/b;
if(m%b!=0)
{
n+=1;
}
sum=(n*b*c)-a;
printf("%d\n",sum);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_20516/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_20516/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%ar = alloca [10000 x i32], align 16
%br = alloca [10000 x i32], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.start.p0(i64 40000, ptr nonnull %ar) #4
call void @llvm.lifetime.start.p0(i64 40000, ptr nonnull %br) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b)
%0 = load i32, ptr %a, align 4, !tbaa !5
%cmp.not42 = icmp slt i32 %0, 1
br i1 %cmp.not42, label %vector.body, label %for.body
vector.body: ; preds = %entry, %for.body
%.lcssa = phi i32 [ %0, %entry ], [ %130, %for.body ]
%1 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 1
%wide.load = load <4 x i32>, ptr %1, align 4, !tbaa !5
%2 = icmp sgt <4 x i32> %wide.load, zeroinitializer
%3 = zext <4 x i1> %2 to <4 x i32>
%4 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 5
%wide.load.1 = load <4 x i32>, ptr %4, align 4, !tbaa !5
%5 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load, <4 x i32> %wide.load.1)
%6 = icmp sgt <4 x i32> %wide.load.1, zeroinitializer
%7 = zext <4 x i1> %6 to <4 x i32>
%8 = add nuw nsw <4 x i32> %3, %7
%9 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 9
%wide.load.2 = load <4 x i32>, ptr %9, align 4, !tbaa !5
%10 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %5, <4 x i32> %wide.load.2)
%11 = icmp sgt <4 x i32> %wide.load.2, zeroinitializer
%12 = zext <4 x i1> %11 to <4 x i32>
%13 = add nuw nsw <4 x i32> %8, %12
%14 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 13
%wide.load.3 = load <4 x i32>, ptr %14, align 4, !tbaa !5
%15 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %10, <4 x i32> %wide.load.3)
%16 = icmp sgt <4 x i32> %wide.load.3, zeroinitializer
%17 = zext <4 x i1> %16 to <4 x i32>
%18 = add nuw nsw <4 x i32> %13, %17
%19 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 17
%wide.load.4 = load <4 x i32>, ptr %19, align 4, !tbaa !5
%20 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %15, <4 x i32> %wide.load.4)
%21 = icmp sgt <4 x i32> %wide.load.4, zeroinitializer
%22 = zext <4 x i1> %21 to <4 x i32>
%23 = add nuw nsw <4 x i32> %18, %22
%24 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 21
%wide.load.5 = load <4 x i32>, ptr %24, align 4, !tbaa !5
%25 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %20, <4 x i32> %wide.load.5)
%26 = icmp sgt <4 x i32> %wide.load.5, zeroinitializer
%27 = zext <4 x i1> %26 to <4 x i32>
%28 = add nuw nsw <4 x i32> %23, %27
%29 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 25
%wide.load.6 = load <4 x i32>, ptr %29, align 4, !tbaa !5
%30 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %25, <4 x i32> %wide.load.6)
%31 = icmp sgt <4 x i32> %wide.load.6, zeroinitializer
%32 = zext <4 x i1> %31 to <4 x i32>
%33 = add nuw nsw <4 x i32> %28, %32
%34 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 29
%wide.load.7 = load <4 x i32>, ptr %34, align 4, !tbaa !5
%35 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %30, <4 x i32> %wide.load.7)
%36 = icmp sgt <4 x i32> %wide.load.7, zeroinitializer
%37 = zext <4 x i1> %36 to <4 x i32>
%38 = add <4 x i32> %33, %37
%39 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 33
%wide.load.8 = load <4 x i32>, ptr %39, align 4, !tbaa !5
%40 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %35, <4 x i32> %wide.load.8)
%41 = icmp sgt <4 x i32> %wide.load.8, zeroinitializer
%42 = zext <4 x i1> %41 to <4 x i32>
%43 = add <4 x i32> %38, %42
%44 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 37
%wide.load.9 = load <4 x i32>, ptr %44, align 4, !tbaa !5
%45 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %40, <4 x i32> %wide.load.9)
%46 = icmp sgt <4 x i32> %wide.load.9, zeroinitializer
%47 = zext <4 x i1> %46 to <4 x i32>
%48 = add <4 x i32> %43, %47
%49 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 41
%wide.load.10 = load <4 x i32>, ptr %49, align 4, !tbaa !5
%50 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %45, <4 x i32> %wide.load.10)
%51 = icmp sgt <4 x i32> %wide.load.10, zeroinitializer
%52 = zext <4 x i1> %51 to <4 x i32>
%53 = add <4 x i32> %48, %52
%54 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 45
%wide.load.11 = load <4 x i32>, ptr %54, align 4, !tbaa !5
%55 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %50, <4 x i32> %wide.load.11)
%56 = icmp sgt <4 x i32> %wide.load.11, zeroinitializer
%57 = zext <4 x i1> %56 to <4 x i32>
%58 = add <4 x i32> %53, %57
%59 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 49
%wide.load.12 = load <4 x i32>, ptr %59, align 4, !tbaa !5
%60 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %55, <4 x i32> %wide.load.12)
%61 = icmp sgt <4 x i32> %wide.load.12, zeroinitializer
%62 = zext <4 x i1> %61 to <4 x i32>
%63 = add <4 x i32> %58, %62
%64 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 53
%wide.load.13 = load <4 x i32>, ptr %64, align 4, !tbaa !5
%65 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %60, <4 x i32> %wide.load.13)
%66 = icmp sgt <4 x i32> %wide.load.13, zeroinitializer
%67 = zext <4 x i1> %66 to <4 x i32>
%68 = add <4 x i32> %63, %67
%69 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 57
%wide.load.14 = load <4 x i32>, ptr %69, align 4, !tbaa !5
%70 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %65, <4 x i32> %wide.load.14)
%71 = icmp sgt <4 x i32> %wide.load.14, zeroinitializer
%72 = zext <4 x i1> %71 to <4 x i32>
%73 = add <4 x i32> %68, %72
%74 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 61
%wide.load.15 = load <4 x i32>, ptr %74, align 4, !tbaa !5
%75 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %70, <4 x i32> %wide.load.15)
%76 = icmp sgt <4 x i32> %wide.load.15, zeroinitializer
%77 = zext <4 x i1> %76 to <4 x i32>
%78 = add <4 x i32> %73, %77
%79 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 65
%wide.load.16 = load <4 x i32>, ptr %79, align 4, !tbaa !5
%80 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %75, <4 x i32> %wide.load.16)
%81 = icmp sgt <4 x i32> %wide.load.16, zeroinitializer
%82 = zext <4 x i1> %81 to <4 x i32>
%83 = add <4 x i32> %78, %82
%84 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 69
%wide.load.17 = load <4 x i32>, ptr %84, align 4, !tbaa !5
%85 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %80, <4 x i32> %wide.load.17)
%86 = icmp sgt <4 x i32> %wide.load.17, zeroinitializer
%87 = zext <4 x i1> %86 to <4 x i32>
%88 = add <4 x i32> %83, %87
%89 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 73
%wide.load.18 = load <4 x i32>, ptr %89, align 4, !tbaa !5
%90 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %85, <4 x i32> %wide.load.18)
%91 = icmp sgt <4 x i32> %wide.load.18, zeroinitializer
%92 = zext <4 x i1> %91 to <4 x i32>
%93 = add <4 x i32> %88, %92
%94 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 77
%wide.load.19 = load <4 x i32>, ptr %94, align 4, !tbaa !5
%95 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %90, <4 x i32> %wide.load.19)
%96 = icmp sgt <4 x i32> %wide.load.19, zeroinitializer
%97 = zext <4 x i1> %96 to <4 x i32>
%98 = add <4 x i32> %93, %97
%99 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 81
%wide.load.20 = load <4 x i32>, ptr %99, align 4, !tbaa !5
%100 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %95, <4 x i32> %wide.load.20)
%101 = icmp sgt <4 x i32> %wide.load.20, zeroinitializer
%102 = zext <4 x i1> %101 to <4 x i32>
%103 = add <4 x i32> %98, %102
%104 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 85
%wide.load.21 = load <4 x i32>, ptr %104, align 4, !tbaa !5
%105 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %100, <4 x i32> %wide.load.21)
%106 = icmp sgt <4 x i32> %wide.load.21, zeroinitializer
%107 = zext <4 x i1> %106 to <4 x i32>
%108 = add <4 x i32> %103, %107
%109 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 89
%wide.load.22 = load <4 x i32>, ptr %109, align 4, !tbaa !5
%110 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %105, <4 x i32> %wide.load.22)
%111 = icmp sgt <4 x i32> %wide.load.22, zeroinitializer
%112 = zext <4 x i1> %111 to <4 x i32>
%113 = add <4 x i32> %108, %112
%114 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 93
%wide.load.23 = load <4 x i32>, ptr %114, align 4, !tbaa !5
%115 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %110, <4 x i32> %wide.load.23)
%116 = icmp sgt <4 x i32> %wide.load.23, zeroinitializer
%117 = zext <4 x i1> %116 to <4 x i32>
%118 = add <4 x i32> %113, %117
%119 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 97
%wide.load.24 = load <4 x i32>, ptr %119, align 4, !tbaa !5
%120 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %115, <4 x i32> %wide.load.24)
%121 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %120, <4 x i32> zeroinitializer)
%122 = icmp sgt <4 x i32> %wide.load.24, zeroinitializer
%123 = zext <4 x i1> %122 to <4 x i32>
%124 = add <4 x i32> %118, %123
%125 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %124)
%126 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %121)
%127 = load i32, ptr %b, align 4, !tbaa !5
%div = sdiv i32 %126, %127
%rem = srem i32 %126, %127
%cmp24.not = icmp ne i32 %rem, 0
%add = zext i1 %cmp24.not to i32
%spec.select41 = add nsw i32 %div, %add
%mul = mul i32 %127, %125
%mul27 = mul i32 %mul, %spec.select41
%sub = sub nsw i32 %mul27, %.lcssa
%call28 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %sub)
call void @llvm.lifetime.end.p0(i64 40000, ptr nonnull %br) #4
call void @llvm.lifetime.end.p0(i64 40000, ptr nonnull %ar) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
ret i32 0
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 1, %entry ]
%arrayidx = getelementptr inbounds [10000 x i32], ptr %ar, i64 0, i64 %indvars.iv
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %arrayidx)
%128 = load i32, ptr %arrayidx, align 4, !tbaa !5
%idxprom4 = sext i32 %128 to i64
%arrayidx5 = getelementptr inbounds [10000 x i32], ptr %br, i64 0, i64 %idxprom4
%129 = load i32, ptr %arrayidx5, align 4, !tbaa !5
%inc = add nsw i32 %129, 1
store i32 %inc, ptr %arrayidx5, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%130 = load i32, ptr %a, align 4, !tbaa !5
%131 = sext i32 %130 to i64
%cmp.not.not = icmp slt i64 %indvars.iv, %131
br i1 %cmp.not.not, label %for.body, label %vector.body, !llvm.loop !9
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x i32> @llvm.smax.v4i32(<4 x i32>, <4 x i32>) #3
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.smax.v4i32(<4 x i32>) #3
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #3
attributes #0 = { nofree 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
#include <stdio.h>
int main(void){
// Your code here!
int N,A;
scanf("%d %d",&N,&A);
while(N>=500){
N = N - 500;
}
if(N<=A){
printf("Yes");
}
else{
printf("No");
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_205202/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_205202/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"No\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%N = alloca i32, align 4
%A = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %A) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N, ptr noundef nonnull %A)
%.pr = load i32, ptr %N, align 4, !tbaa !5
%cmp4 = icmp sgt i32 %.pr, 499
br i1 %cmp4, label %while.body.preheader, label %while.end
while.body.preheader: ; preds = %entry
%0 = add nuw i32 %.pr, 499
%smin = call i32 @llvm.smin.i32(i32 %.pr, i32 999)
%1 = sub nuw i32 %0, %smin
%.fr = freeze i32 %1
%2 = urem i32 %.fr, 500
%.neg = sub i32 %2, %.fr
%3 = add nsw i32 %.pr, -500
%4 = add i32 %.neg, %3
store i32 %4, ptr %N, align 4, !tbaa !5
br label %while.end
while.end: ; preds = %while.body.preheader, %entry
%.lcssa = phi i32 [ %4, %while.body.preheader ], [ %.pr, %entry ]
%5 = load i32, ptr %A, align 4, !tbaa !5
%cmp1.not = icmp sgt i32 %.lcssa, %5
%.str.2..str.1 = select i1 %cmp1.not, ptr @.str.2, ptr @.str.1
%call3 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.2..str.1)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %A) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #3
attributes #0 = { nofree 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main (void)
{
int N=0,A=0;
scanf("%d", &N);
scanf("%d", &A);
if(N%500<=A)
{
printf("Yes\n");
}
else
{
printf("No\n");
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_205246/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_205246/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@str = private unnamed_addr constant [3 x i8] c"No\00", align 1
@str.3 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%N = alloca i32, align 4
%A = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #4
store i32 0, ptr %N, align 4, !tbaa !5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %A) #4
store i32 0, ptr %A, align 4, !tbaa !5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N)
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %A)
%0 = load i32, ptr %N, align 4, !tbaa !5
%rem = srem i32 %0, 500
%1 = load i32, ptr %A, align 4, !tbaa !5
%cmp.not = icmp sgt i32 %rem, %1
%str.str.3 = select i1 %cmp.not, ptr @str, ptr @str.3
%puts = call i32 @puts(ptr nonnull dereferenceable(1) %str.str.3)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %A) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
attributes #0 = { nofree 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 = { 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 = { nofree nounwind }
attributes #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(){
int N,A;
scanf("%d",&N);
scanf("%d",&A);
N=N%500;
if(N<=A){
printf("Yes");
} else {
printf("No");
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_205297/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_205297/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"No\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%N = alloca i32, align 4
%A = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %A) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N)
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %A)
%0 = load i32, ptr %N, align 4, !tbaa !5
%rem = srem i32 %0, 500
store i32 %rem, ptr %N, align 4, !tbaa !5
%1 = load i32, ptr %A, align 4, !tbaa !5
%cmp.not = icmp sgt i32 %rem, %1
%.str.2..str.1 = select i1 %cmp.not, ptr @.str.2, ptr @.str.1
%call3 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.2..str.1)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %A) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int temp2=n;
double ans=0.0;
while(n-- > 0)
{
int temp;
scanf("%d",&temp);
ans+=(float)temp*1.0/100;
// printf("%lf\n",ans);
}
ans/=temp2;
printf("%.12lf\n",ans*100);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_20534/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_20534/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [8 x i8] c"%.12lf\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%temp = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%dec9 = add nsw i32 %0, -1
store i32 %dec9, ptr %n, align 4, !tbaa !5
%cmp10 = icmp sgt i32 %0, 0
br i1 %cmp10, label %while.body, label %while.end
while.body: ; preds = %entry, %while.body
%ans.011 = phi double [ %add, %while.body ], [ 0.000000e+00, %entry ]
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %temp) #3
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %temp)
%1 = load i32, ptr %temp, align 4, !tbaa !5
%conv = sitofp i32 %1 to float
%conv2 = fpext float %conv to double
%div = fdiv double %conv2, 1.000000e+02
%add = fadd double %ans.011, %div
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %temp) #3
%.pr = load i32, ptr %n, align 4, !tbaa !5
%dec = add nsw i32 %.pr, -1
store i32 %dec, ptr %n, align 4, !tbaa !5
%cmp = icmp sgt i32 %.pr, 0
br i1 %cmp, label %while.body, label %while.end, !llvm.loop !9
while.end: ; preds = %while.body, %entry
%ans.0.lcssa = phi double [ 0.000000e+00, %entry ], [ %add, %while.body ]
%conv3 = sitofp i32 %0 to double
%div4 = fdiv double %ans.0.lcssa, %conv3
%mul5 = fmul double %div4, 1.000000e+02
%call6 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %mul5)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
#include<stdio.h>
int main(){
int n,i,a=0,b;
char s[100010];
scanf("%d %s",&n,s);
for(i=0;s[i];i++){
if(s[i]=='(')a++;
else a--;
if(a<0){
b++;
a=0;
}
}
for(i=0;i<b;i++)printf("(");
printf("%s",s);
a=b=0;
while(n--){
if(s[n]==')')a++;
else a--;
if(a<0){
b++;
a=0;//printf("%d\n",n);
}
}
for(i=0;i<b;i++)printf(")");
printf("\n");
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_205398/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_205398/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d %s\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%s = alloca [100010 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #5
call void @llvm.lifetime.start.p0(i64 100010, ptr nonnull %s) #5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n, ptr noundef nonnull %s)
br label %for.cond
for.cond: ; preds = %if.end, %entry
%indvars.iv = phi i64 [ %indvars.iv.next, %if.end ], [ 0, %entry ]
%a.0 = phi i32 [ %spec.select, %if.end ], [ 0, %entry ]
%b.0 = phi i32 [ %spec.select62, %if.end ], [ undef, %entry ]
%arrayidx = getelementptr inbounds [100010 x i8], ptr %s, i64 0, i64 %indvars.iv
%0 = load i8, ptr %arrayidx, align 1, !tbaa !5
switch i8 %0, label %if.else [
i8 0, label %for.cond10.preheader
i8 40, label %if.end
]
for.cond10.preheader: ; preds = %for.cond
%cmp1163 = icmp sgt i32 %b.0, 0
br i1 %cmp1163, label %for.body13, label %for.end17
if.else: ; preds = %for.cond
br label %if.end
if.end: ; preds = %for.cond, %if.else
%.sink = phi i32 [ -1, %if.else ], [ 1, %for.cond ]
%dec = add nsw i32 %a.0, %.sink
%spec.select = call i32 @llvm.smax.i32(i32 %dec, i32 0)
%1 = lshr i32 %dec, 31
%spec.select62 = add i32 %1, %b.0
%indvars.iv.next = add nuw i64 %indvars.iv, 1
br label %for.cond, !llvm.loop !8
for.body13: ; preds = %for.cond10.preheader, %for.body13
%i.164 = phi i32 [ %inc16, %for.body13 ], [ 0, %for.cond10.preheader ]
%putchar61 = call i32 @putchar(i32 40)
%inc16 = add nuw nsw i32 %i.164, 1
%exitcond.not = icmp eq i32 %inc16, %b.0
br i1 %exitcond.not, label %for.end17, label %for.body13, !llvm.loop !10
for.end17: ; preds = %for.body13, %for.cond10.preheader
%call19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull %s)
%n.promoted = load i32, ptr %n, align 4, !tbaa !11
%dec2066 = add i32 %n.promoted, -1
%tobool21.not67 = icmp eq i32 %n.promoted, 0
br i1 %tobool21.not67, label %for.cond37.preheader.thread, label %while.body.preheader
for.cond37.preheader.thread: ; preds = %for.end17
store i32 %dec2066, ptr %n, align 4, !tbaa !11
br label %for.end44
while.body.preheader: ; preds = %for.end17
%2 = sext i32 %dec2066 to i64
%3 = add nsw i64 %2, 1
%xtraiter = and i64 %3, 1
%4 = icmp eq i32 %dec2066, 0
br i1 %4, label %for.cond37.preheader.unr-lcssa, label %while.body.preheader.new
while.body.preheader.new: ; preds = %while.body.preheader
%unroll_iter = and i64 %3, -2
br label %while.body
for.cond37.preheader.unr-lcssa: ; preds = %while.body, %while.body.preheader
%b.3.lcssa.ph = phi i32 [ undef, %while.body.preheader ], [ %b.3.1, %while.body ]
%indvars.iv76.unr = phi i64 [ %2, %while.body.preheader ], [ %indvars.iv.next77.1, %while.body ]
%b.269.unr = phi i32 [ 0, %while.body.preheader ], [ %b.3.1, %while.body ]
%a.368.unr = phi i32 [ 0, %while.body.preheader ], [ %a.5.1, %while.body ]
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br i1 %lcmp.mod.not, label %for.cond37.preheader, label %while.body.epil
while.body.epil: ; preds = %for.cond37.preheader.unr-lcssa
%arrayidx23.epil = getelementptr inbounds [100010 x i8], ptr %s, i64 0, i64 %indvars.iv76.unr
%5 = load i8, ptr %arrayidx23.epil, align 1, !tbaa !5
%cmp25.epil = icmp eq i8 %5, 41
%a.4.v.epil = select i1 %cmp25.epil, i32 1, i32 -1
%a.4.epil = add nsw i32 %a.4.v.epil, %a.368.unr
%6 = lshr i32 %a.4.epil, 31
%b.3.epil = add i32 %6, %b.269.unr
br label %for.cond37.preheader
for.cond37.preheader: ; preds = %for.cond37.preheader.unr-lcssa, %while.body.epil
%b.3.lcssa = phi i32 [ %b.3.lcssa.ph, %for.cond37.preheader.unr-lcssa ], [ %b.3.epil, %while.body.epil ]
store i32 -1, ptr %n, align 4, !tbaa !11
%cmp3872 = icmp sgt i32 %b.3.lcssa, 0
br i1 %cmp3872, label %for.body40, label %for.end44
while.body: ; preds = %while.body, %while.body.preheader.new
%indvars.iv76 = phi i64 [ %2, %while.body.preheader.new ], [ %indvars.iv.next77.1, %while.body ]
%b.269 = phi i32 [ 0, %while.body.preheader.new ], [ %b.3.1, %while.body ]
%a.368 = phi i32 [ 0, %while.body.preheader.new ], [ %a.5.1, %while.body ]
%niter = phi i64 [ 0, %while.body.preheader.new ], [ %niter.next.1, %while.body ]
%arrayidx23 = getelementptr inbounds [100010 x i8], ptr %s, i64 0, i64 %indvars.iv76
%7 = load i8, ptr %arrayidx23, align 1, !tbaa !5
%cmp25 = icmp eq i8 %7, 41
%a.4.v = select i1 %cmp25, i32 1, i32 -1
%a.4 = add nsw i32 %a.4.v, %a.368
%a.5 = call i32 @llvm.smax.i32(i32 %a.4, i32 0)
%8 = lshr i32 %a.4, 31
%b.3 = add i32 %8, %b.269
%indvars.iv.next77 = add nsw i64 %indvars.iv76, -1
%arrayidx23.1 = getelementptr inbounds [100010 x i8], ptr %s, i64 0, i64 %indvars.iv.next77
%9 = load i8, ptr %arrayidx23.1, align 1, !tbaa !5
%cmp25.1 = icmp eq i8 %9, 41
%a.4.v.1 = select i1 %cmp25.1, i32 1, i32 -1
%a.4.1 = add nsw i32 %a.4.v.1, %a.5
%a.5.1 = call i32 @llvm.smax.i32(i32 %a.4.1, i32 0)
%10 = lshr i32 %a.4.1, 31
%b.3.1 = add i32 %10, %b.3
%indvars.iv.next77.1 = add nsw i64 %indvars.iv76, -2
%niter.next.1 = add i64 %niter, 2
%niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
br i1 %niter.ncmp.1, label %for.cond37.preheader.unr-lcssa, label %while.body, !llvm.loop !13
for.body40: ; preds = %for.cond37.preheader, %for.body40
%i.273 = phi i32 [ %inc43, %for.body40 ], [ 0, %for.cond37.preheader ]
%putchar60 = call i32 @putchar(i32 41)
%inc43 = add nuw nsw i32 %i.273, 1
%exitcond79.not = icmp eq i32 %inc43, %b.3.lcssa
br i1 %exitcond79.not, label %for.end44, label %for.body40, !llvm.loop !14
for.end44: ; preds = %for.body40, %for.cond37.preheader.thread, %for.cond37.preheader
%putchar = call i32 @putchar(i32 10)
call void @llvm.lifetime.end.p0(i64 100010, ptr nonnull %s) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #5
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #3
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #4
attributes #0 = { nofree 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 = { 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 = { nofree nounwind }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !6, i64 0}
!13 = distinct !{!13, !9}
!14 = distinct !{!14, !9}
|
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char * argv[])
{
int a,b,c;
scanf("%d %d %d",&a, &b,&c);
if ( ( a == b ) && ( b == c ) && ( c == a ) )
printf("Yes");
else printf("No");
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_205440/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_205440/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [9 x i8] c"%d %d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"No\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main(i32 noundef %argc, ptr nocapture noundef readnone %argv) local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c)
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %b, align 4, !tbaa !5
%cmp = icmp eq i32 %0, %1
%2 = load i32, ptr %c, align 4
%cmp1 = icmp eq i32 %0, %2
%or.cond = select i1 %cmp, i1 %cmp1, i1 false
%.str.1..str.2 = select i1 %or.cond, ptr @.str.1, ptr @.str.2
%call5 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.1..str.2)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main(void){
int a[3];
scanf("%d %d %d",&a[0],&a[1],&a[2]);
if((a[0]==a[1])&&(a[1]==a[2])){
printf("Yes");
}else{
printf("No");
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_205484/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_205484/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [9 x i8] c"%d %d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"No\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca [3 x i32], align 4
call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %a) #3
%arrayidx1 = getelementptr inbounds [3 x i32], ptr %a, i64 0, i64 1
%arrayidx2 = getelementptr inbounds [3 x i32], ptr %a, i64 0, i64 2
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %arrayidx1, ptr noundef nonnull %arrayidx2)
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %arrayidx1, align 4, !tbaa !5
%cmp = icmp eq i32 %0, %1
%2 = load i32, ptr %arrayidx2, align 4
%cmp7 = icmp eq i32 %1, %2
%or.cond = select i1 %cmp, i1 %cmp7, i1 false
%.str.1..str.2 = select i1 %or.cond, ptr @.str.1, ptr @.str.2
%call9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.1..str.2)
call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %a) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void inp_str(int instr[]){
char *ptr;
int z,i,count;
char str[100]={'\0'};
char *ln;
fgets(str, 100, stdin); // 入力:"123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
*ln = '\0'; /* 改行文字を終端文字に置き換える */
}
else { /* 入力ストリーム上に文字が残ってる場合 */
while (1) { /* 改行文字が読み取られるまで空読みする */
z = getchar();
if (z == '\n' || z == EOF) break;
}
}
count=0;
ptr = strtok(str, " ");
i = atoi(ptr);
instr[count]=i;
count=count+1;
// 2回目以降
while(ptr != NULL) {
// strtok関数により変更されたNULLのポインタが先頭
ptr = strtok(NULL, " ");
// ptrがNULLの場合エラーが発生するので対処
if(ptr != NULL) {
i = atoi(ptr);
instr[count]=i;
count=count+1;
}
}
}
int main(void) {
int input[100];
int j,count;
int A,B,C;
inp_str(input);
A=input[0];
B=input[1];
C=input[2];
//printf("%d\n",A);
//printf("%d\n",B);
//printf("%d\n",C);
if((A==B)&&(B==C)) {
printf("Yes\n");
}else{
printf("No\n");
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_205527/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_205527/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@stdin = external local_unnamed_addr global ptr, align 8
@.str = private unnamed_addr constant [2 x i8] c" \00", align 1
@str = private unnamed_addr constant [3 x i8] c"No\00", align 1
@str.3 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local void @inp_str(ptr nocapture noundef writeonly %instr) local_unnamed_addr #0 {
entry:
%str = alloca [100 x i8], align 16
call void @llvm.lifetime.start.p0(i64 100, ptr nonnull %str) #7
call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(100) %str, i8 0, i64 100, i1 false)
%0 = load ptr, ptr @stdin, align 8, !tbaa !5
%call = call ptr @fgets(ptr noundef nonnull %str, i32 noundef 100, ptr noundef %0)
%call2 = call ptr @strchr(ptr noundef nonnull dereferenceable(1) %str, i32 noundef 10) #8
%cmp.not = icmp eq ptr %call2, null
br i1 %cmp.not, label %while.cond, label %if.then
if.then: ; preds = %entry
store i8 0, ptr %call2, align 1, !tbaa !9
br label %if.end7
while.cond: ; preds = %entry, %while.cond
%1 = load ptr, ptr @stdin, align 8, !tbaa !5
%call.i = call i32 @getc(ptr noundef %1)
switch i32 %call.i, label %while.cond [
i32 -1, label %if.end7
i32 10, label %if.end7
]
if.end7: ; preds = %while.cond, %while.cond, %if.then
%call9 = call ptr @strtok(ptr noundef nonnull %str, ptr noundef nonnull @.str) #7
%call.i33 = call i64 @strtol(ptr nocapture noundef nonnull %call9, ptr noundef null, i32 noundef 10) #7
%conv.i = trunc i64 %call.i33 to i32
store i32 %conv.i, ptr %instr, align 4, !tbaa !10
%cmp12.not36 = icmp eq ptr %call9, null
br i1 %cmp12.not36, label %while.end22, label %while.body13.preheader
while.body13.preheader: ; preds = %if.end7
%call1439 = call ptr @strtok(ptr noundef null, ptr noundef nonnull @.str) #7
%cmp15.not40 = icmp eq ptr %call1439, null
br i1 %cmp15.not40, label %while.end22, label %if.end21
if.end21: ; preds = %while.body13.preheader, %if.end21
%call1442 = phi ptr [ %call14, %if.end21 ], [ %call1439, %while.body13.preheader ]
%count.03741 = phi i32 [ %add20, %if.end21 ], [ 1, %while.body13.preheader ]
%call.i34 = call i64 @strtol(ptr nocapture noundef nonnull %call1442, ptr noundef null, i32 noundef 10) #7
%conv.i35 = trunc i64 %call.i34 to i32
%idxprom18 = zext i32 %count.03741 to i64
%arrayidx19 = getelementptr inbounds i32, ptr %instr, i64 %idxprom18
store i32 %conv.i35, ptr %arrayidx19, align 4, !tbaa !10
%add20 = add nuw nsw i32 %count.03741, 1
%call14 = call ptr @strtok(ptr noundef null, ptr noundef nonnull @.str) #7
%cmp15.not = icmp eq ptr %call14, null
br i1 %cmp15.not, label %while.end22, label %if.end21, !llvm.loop !12
while.end22: ; preds = %if.end21, %while.body13.preheader, %if.end7
call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %str) #7
ret void
}
; 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
; Function Attrs: nofree nounwind
declare noundef ptr @fgets(ptr noundef, i32 noundef, ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strchr(ptr noundef, i32 noundef) local_unnamed_addr #4
; Function Attrs: mustprogress nofree nounwind willreturn
declare ptr @strtok(ptr noundef, ptr nocapture noundef readonly) 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
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%input = alloca [100 x i32], align 16
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %input) #7
call void @inp_str(ptr noundef nonnull %input)
%0 = load i32, ptr %input, align 16, !tbaa !10
%arrayidx1 = getelementptr inbounds [100 x i32], ptr %input, i64 0, i64 1
%1 = load i32, ptr %arrayidx1, align 4, !tbaa !10
%cmp = icmp eq i32 %0, %1
%arrayidx2 = getelementptr inbounds [100 x i32], ptr %input, i64 0, i64 2
%2 = load i32, ptr %arrayidx2, align 8
%cmp3 = icmp eq i32 %1, %2
%or.cond = select i1 %cmp, i1 %cmp3, i1 false
%str.3.str = select i1 %or.cond, ptr @str.3, ptr @str
%puts = tail call i32 @puts(ptr nonnull dereferenceable(1) %str.3.str)
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %input) #7
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @getc(ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: mustprogress nofree nounwind willreturn
declare i64 @strtol(ptr noundef readonly, ptr nocapture noundef, i32 noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
attributes #0 = { nofree 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 = { 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 #4 = { 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 #5 = { mustprogress nofree nounwind willreturn "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 = { nofree nounwind }
attributes #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
|
#include <stdio.h>
int main(){
int a,b,c;
scanf("%d%d%d", &a, &b, &c);
if(a == b && b == c){
puts("Yes");
}else{
puts("No");
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_205578/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_205578/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [7 x i8] c"%d%d%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"No\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c)
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %b, align 4, !tbaa !5
%cmp = icmp eq i32 %0, %1
%2 = load i32, ptr %c, align 4
%cmp1 = icmp eq i32 %1, %2
%or.cond = select i1 %cmp, i1 %cmp1, i1 false
%.str.1..str.2 = select i1 %or.cond, ptr @.str.1, ptr @.str.2
%call3 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.1..str.2)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main()
{
int m, d;
scanf("%*d/%d/%d", &m, &d);
printf("2018/%02d/%02d\n", m, d);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_205714/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_205714/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [10 x i8] c"%*d/%d/%d\00", align 1
@.str.1 = private unnamed_addr constant [16 x i8] c"2018/%02d/%02d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%m = alloca i32, align 4
%d = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %m) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %d) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %m, ptr noundef nonnull %d)
%0 = load i32, ptr %m, align 4, !tbaa !5
%1 = load i32, ptr %d, align 4, !tbaa !5
%call1 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %0, i32 noundef %1)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %d) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %m) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main(void){
char s[20];
scanf("%s", s);
printf("2018/01/%c%c\n", s[8], s[9]);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_205916/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_205916/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.1 = private unnamed_addr constant [14 x i8] c"2018/01/%c%c\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %s) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s)
%arrayidx = getelementptr inbounds [20 x i8], ptr %s, i64 0, i64 8
%0 = load i8, ptr %arrayidx, align 8, !tbaa !5
%conv = sext i8 %0 to i32
%arrayidx1 = getelementptr inbounds [20 x i8], ptr %s, i64 0, i64 9
%1 = load i8, ptr %arrayidx1, align 1, !tbaa !5
%conv2 = sext i8 %1 to i32
%call3 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %conv, i32 noundef %conv2)
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %s) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <string.h>
int main ()
{
char s[100000];
int q,n,m,i,j,flag,a[100001];
scanf("%d",&q);
for(i=0;i<q;i++)
{
scanf("%d",&n);
getchar();
for(j=0;j<n;j++)
{
scanf("%c",&s[j]);
a[j]=s[j]-'0';
}
if(n==2)
{
if(a[0]<a[1]) printf("YES\n2\n%d %d\n",a[0],a[1]);
else if(a[0]>=a[1]) printf("NO\n");
}
else if(n>=2)
{
printf("YES\n2\n%d ",a[0]);
for(j=1;j<n;j++) {printf("%d",a[j]);}
printf("\n");
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_20596/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_20596/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%c\00", align 1
@.str.2 = private unnamed_addr constant [13 x i8] c"YES\0A2\0A%d %d\0A\00", align 1
@.str.4 = private unnamed_addr constant [10 x i8] c"YES\0A2\0A%d \00", align 1
@stdin = external local_unnamed_addr global ptr, align 8
@str = private unnamed_addr constant [3 x i8] c"NO\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca [100000 x i8], align 16
%q = alloca i32, align 4
%n = alloca i32, align 4
%a = alloca [100001 x i32], align 16
call void @llvm.lifetime.start.p0(i64 100000, ptr nonnull %s) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %q) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
call void @llvm.lifetime.start.p0(i64 400004, ptr nonnull %a) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %q)
%0 = load i32, ptr %q, align 4, !tbaa !5
%cmp64 = icmp sgt i32 %0, 0
br i1 %cmp64, label %for.body.lr.ph, label %for.end49
for.body.lr.ph: ; preds = %entry
%arrayidx14 = getelementptr inbounds [100001 x i32], ptr %a, i64 0, i64 1
br label %for.body
for.body: ; preds = %for.body.lr.ph, %for.inc47
%i.065 = phi i32 [ 0, %for.body.lr.ph ], [ %inc48, %for.inc47 ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%1 = load ptr, ptr @stdin, align 8, !tbaa !9
%call.i = call i32 @getc(ptr noundef %1)
%2 = load i32, ptr %n, align 4, !tbaa !5
%cmp460 = icmp sgt i32 %2, 0
br i1 %cmp460, label %for.body5, label %for.inc47
for.body5: ; preds = %for.body, %for.body5
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body5 ], [ 0, %for.body ]
%arrayidx = getelementptr inbounds [100000 x i8], ptr %s, i64 0, i64 %indvars.iv
%call6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %arrayidx)
%3 = load i8, ptr %arrayidx, align 1, !tbaa !11
%conv = sext i8 %3 to i32
%sub = add nsw i32 %conv, -48
%arrayidx10 = getelementptr inbounds [100001 x i32], ptr %a, i64 0, i64 %indvars.iv
store i32 %sub, ptr %arrayidx10, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%4 = load i32, ptr %n, align 4, !tbaa !5
%5 = sext i32 %4 to i64
%cmp4 = icmp slt i64 %indvars.iv.next, %5
br i1 %cmp4, label %for.body5, label %for.end, !llvm.loop !12
for.end: ; preds = %for.body5
%cmp11 = icmp eq i32 %4, 2
br i1 %cmp11, label %if.then, label %if.else28
if.then: ; preds = %for.end
%6 = load i32, ptr %a, align 16, !tbaa !5
%7 = load i32, ptr %arrayidx14, align 4, !tbaa !5
%cmp15 = icmp slt i32 %6, %7
br i1 %cmp15, label %if.then17, label %if.then25
if.then17: ; preds = %if.then
%call20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %6, i32 noundef %7)
br label %for.inc47
if.then25: ; preds = %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc47
if.else28: ; preds = %for.end
%cmp29 = icmp sgt i32 %4, 1
br i1 %cmp29, label %if.then31, label %for.inc47
if.then31: ; preds = %if.else28
%8 = load i32, ptr %a, align 16, !tbaa !5
%call33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %8)
%9 = load i32, ptr %n, align 4, !tbaa !5
%cmp3562 = icmp sgt i32 %9, 1
br i1 %cmp3562, label %for.body37, label %for.end43
for.body37: ; preds = %if.then31, %for.body37
%indvars.iv68 = phi i64 [ %indvars.iv.next69, %for.body37 ], [ 1, %if.then31 ]
%arrayidx39 = getelementptr inbounds [100001 x i32], ptr %a, i64 0, i64 %indvars.iv68
%10 = load i32, ptr %arrayidx39, align 4, !tbaa !5
%call40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %10)
%indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
%11 = load i32, ptr %n, align 4, !tbaa !5
%12 = sext i32 %11 to i64
%cmp35 = icmp slt i64 %indvars.iv.next69, %12
br i1 %cmp35, label %for.body37, label %for.end43, !llvm.loop !14
for.end43: ; preds = %for.body37, %if.then31
%putchar = call i32 @putchar(i32 10)
br label %for.inc47
for.inc47: ; preds = %for.body, %if.then25, %if.then17, %for.end43, %if.else28
%inc48 = add nuw nsw i32 %i.065, 1
%13 = load i32, ptr %q, align 4, !tbaa !5
%cmp = icmp slt i32 %inc48, %13
br i1 %cmp, label %for.body, label %for.end49, !llvm.loop !15
for.end49: ; preds = %for.inc47, %entry
call void @llvm.lifetime.end.p0(i64 400004, ptr nonnull %a) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %q) #4
call void @llvm.lifetime.end.p0(i64 100000, ptr nonnull %s) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @getc(ptr nocapture noundef) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
attributes #0 = { nofree 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 = { 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 = { nofree nounwind }
attributes #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
|
#include <stdio.h>
#define MAX (2000000)
char prime[MAX + 1];
int main(void)
{
int i, j;
int a, d, n;
prime[0] = prime[1] = 0;
for (i = 2; i <= MAX; i++){
prime[i] = 1;
}
for (i = 2; i * i <= MAX; i++){
for (j = i * i; j <= MAX; j += i){
prime[j] = 0;
}
}
while (1){
scanf("%d %d %d", &a, &d, &n);
if (!a && !d && !n){
break;
}
i = 0;
while (1){
if (prime[a]){
i++;
}
if (i == n){
break;
}
a += d;
}
printf("%d\n", a);
}
return (0);
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206052/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206052/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@prime = dso_local local_unnamed_addr global [2000001 x i8] zeroinitializer, align 16
@.str = private unnamed_addr constant [9 x i8] c"%d %d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%d = alloca i32, align 4
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %d) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
store i8 0, ptr getelementptr inbounds ([2000001 x i8], ptr @prime, i64 0, i64 1), align 1, !tbaa !5
store i8 0, ptr @prime, align 16, !tbaa !5
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 2 dereferenceable(1999999) getelementptr inbounds ([2000001 x i8], ptr @prime, i64 0, i64 2), i8 1, i64 1999999, i1 false), !tbaa !5
br label %for.cond5.preheader
for.cond5.preheader: ; preds = %for.inc12.1, %entry
%indvars.iv = phi i64 [ 2, %entry ], [ %indvars.iv.next.1, %for.inc12.1 ]
%mul48 = phi i64 [ 4, %entry ], [ %mul.1, %for.inc12.1 ]
%0 = and i64 %mul48, 4294967295
br label %for.body7
while.cond.preheader: ; preds = %for.inc12
%call57 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %d, ptr noundef nonnull %n)
%1 = load i32, ptr %a, align 4, !tbaa !8
%tobool58 = icmp ne i32 %1, 0
%2 = load i32, ptr %d, align 4
%tobool1559 = icmp ne i32 %2, 0
%or.cond60 = select i1 %tobool58, i1 true, i1 %tobool1559
%3 = load i32, ptr %n, align 4
%tobool1761 = icmp ne i32 %3, 0
%or.cond3262 = select i1 %or.cond60, i1 true, i1 %tobool1761
br i1 %or.cond3262, label %while.cond18.preheader, label %while.end31
for.body7: ; preds = %for.cond5.preheader, %for.body7
%indvars.iv64 = phi i64 [ %0, %for.cond5.preheader ], [ %indvars.iv.next65, %for.body7 ]
%arrayidx9 = getelementptr inbounds [2000001 x i8], ptr @prime, i64 0, i64 %indvars.iv64
store i8 0, ptr %arrayidx9, align 1, !tbaa !5
%indvars.iv.next65 = add nuw nsw i64 %indvars.iv64, %indvars.iv
%cmp6 = icmp ult i64 %indvars.iv.next65, 2000001
br i1 %cmp6, label %for.body7, label %for.inc12, !llvm.loop !10
for.inc12: ; preds = %for.body7
%indvars.iv.next = or i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, 1415
br i1 %exitcond.not, label %while.cond.preheader, label %for.cond5.preheader.1, !llvm.loop !12
for.cond5.preheader.1: ; preds = %for.inc12
%mul = mul i64 %indvars.iv.next, %indvars.iv.next
%4 = and i64 %mul, 4294967295
br label %for.body7.1
for.body7.1: ; preds = %for.body7.1, %for.cond5.preheader.1
%indvars.iv64.1 = phi i64 [ %4, %for.cond5.preheader.1 ], [ %indvars.iv.next65.1, %for.body7.1 ]
%arrayidx9.1 = getelementptr inbounds [2000001 x i8], ptr @prime, i64 0, i64 %indvars.iv64.1
store i8 0, ptr %arrayidx9.1, align 1, !tbaa !5
%indvars.iv.next65.1 = add nuw nsw i64 %indvars.iv64.1, %indvars.iv.next
%cmp6.1 = icmp ult i64 %indvars.iv.next65.1, 2000001
br i1 %cmp6.1, label %for.body7.1, label %for.inc12.1, !llvm.loop !10
for.inc12.1: ; preds = %for.body7.1
%indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
%mul.1 = mul i64 %indvars.iv.next.1, %indvars.iv.next.1
br label %for.cond5.preheader
while.cond18.preheader: ; preds = %while.cond.preheader, %while.end
%a.promoted = phi i32 [ %11, %while.end ], [ %1, %while.cond.preheader ]
%5 = phi i32 [ %13, %while.end ], [ %3, %while.cond.preheader ]
%6 = phi i32 [ %12, %while.end ], [ %2, %while.cond.preheader ]
%idxprom2050 = sext i32 %a.promoted to i64
%arrayidx2151 = getelementptr inbounds [2000001 x i8], ptr @prime, i64 0, i64 %idxprom2050
%7 = load i8, ptr %arrayidx2151, align 1, !tbaa !5
%tobool22.not52 = icmp ne i8 %7, 0
%inc2453 = zext i1 %tobool22.not52 to i32
%cmp2654 = icmp eq i32 %5, %inc2453
br i1 %cmp2654, label %while.end, label %if.end28.preheader
if.end28.preheader: ; preds = %while.cond18.preheader
%8 = sext i32 %6 to i64
br label %if.end28
if.end28: ; preds = %if.end28.preheader, %if.end28
%indvars.iv68 = phi i64 [ %idxprom2050, %if.end28.preheader ], [ %indvars.iv.next69, %if.end28 ]
%spec.select56 = phi i32 [ %inc2453, %if.end28.preheader ], [ %spec.select, %if.end28 ]
%indvars.iv.next69 = add i64 %indvars.iv68, %8
%arrayidx21 = getelementptr inbounds [2000001 x i8], ptr @prime, i64 0, i64 %indvars.iv.next69
%9 = load i8, ptr %arrayidx21, align 1, !tbaa !5
%tobool22.not = icmp ne i8 %9, 0
%inc24 = zext i1 %tobool22.not to i32
%spec.select = add nuw nsw i32 %spec.select56, %inc24
%cmp26 = icmp eq i32 %spec.select, %5
br i1 %cmp26, label %while.cond18.while.end_crit_edge, label %if.end28
while.cond18.while.end_crit_edge: ; preds = %if.end28
%10 = trunc i64 %indvars.iv.next69 to i32
store i32 %10, ptr %a, align 4, !tbaa !8
br label %while.end
while.end: ; preds = %while.cond18.while.end_crit_edge, %while.cond18.preheader
%.lcssa = phi i32 [ %10, %while.cond18.while.end_crit_edge ], [ %a.promoted, %while.cond18.preheader ]
%call30 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.lcssa)
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %d, ptr noundef nonnull %n)
%11 = load i32, ptr %a, align 4, !tbaa !8
%tobool = icmp ne i32 %11, 0
%12 = load i32, ptr %d, align 4
%tobool15 = icmp ne i32 %12, 0
%or.cond = select i1 %tobool, i1 true, i1 %tobool15
%13 = load i32, ptr %n, align 4
%tobool17 = icmp ne i32 %13, 0
%or.cond32 = select i1 %or.cond, i1 true, i1 %tobool17
br i1 %or.cond32, label %while.cond18.preheader, label %while.end31
while.end31: ; preds = %while.end, %while.cond.preheader
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %d) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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) #3
attributes #0 = { nofree 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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
|
#include <stdio.h>
#include <string.h>
#define MAX 1000020
int p[MAX],size;
int flg[MAX];
int isPrime(int x){
int i;
for(i=0;p[i]*p[i]<=x;i++){
if(x % p[i] == 0) return 0;
}
return 1;
}
int main(void){
int i;
int a,d,n;
p[0] = 2;
size = flg[2] = 1;
flg[0] = flg[1] = 0;
for(i=3;i<MAX;i++){
if(isPrime(i)){
p[size++] = i;
flg[i] = 1;
}
else{
flg[i] = 0;
}
}
while(scanf("%d%d%d",&a,&d,&n) && (a||d||n)){
while(1){
if(flg[a]){
n--;
if(n == 0) break;
}
a += d;
}
printf("%d\n",a);
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206096/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206096/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@p = dso_local local_unnamed_addr global [1000020 x i32] zeroinitializer, align 16
@flg = dso_local local_unnamed_addr global [1000020 x i32] zeroinitializer, align 16
@size = dso_local local_unnamed_addr global i32 0, align 4
@.str = private unnamed_addr constant [7 x i8] c"%d%d%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local i32 @isPrime(i32 noundef %x) local_unnamed_addr #0 {
entry:
%0 = load i32, ptr @p, align 16, !tbaa !5
%mul10 = mul nsw i32 %0, %0
%cmp.not11 = icmp sgt i32 %mul10, %x
br i1 %cmp.not11, label %cleanup, label %for.body
for.cond: ; preds = %for.body
%indvars.iv.next = add nuw i64 %indvars.iv, 1
%arrayidx = getelementptr inbounds [1000020 x i32], ptr @p, i64 0, i64 %indvars.iv.next
%1 = load i32, ptr %arrayidx, align 4, !tbaa !5
%mul = mul nsw i32 %1, %1
%cmp.not = icmp sgt i32 %mul, %x
br i1 %cmp.not, label %cleanup, label %for.body, !llvm.loop !9
for.body: ; preds = %entry, %for.cond
%indvars.iv = phi i64 [ %indvars.iv.next, %for.cond ], [ 0, %entry ]
%2 = phi i32 [ %1, %for.cond ], [ %0, %entry ]
%rem = srem i32 %x, %2
%cmp5 = icmp eq i32 %rem, 0
br i1 %cmp5, label %cleanup, label %for.cond
cleanup: ; preds = %for.body, %for.cond, %entry
%retval.0 = phi i32 [ 1, %entry ], [ 1, %for.cond ], [ 0, %for.body ]
ret i32 %retval.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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #2 {
entry:
%a = alloca i32, align 4
%d = alloca i32, align 4
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %d) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
store i32 2, ptr @p, align 16, !tbaa !5
store i32 1, ptr getelementptr inbounds ([1000020 x i32], ptr @flg, i64 0, i64 2), align 8, !tbaa !5
store i32 1, ptr @size, align 4, !tbaa !5
store i32 0, ptr getelementptr inbounds ([1000020 x i32], ptr @flg, i64 0, i64 1), align 4, !tbaa !5
store i32 0, ptr @flg, align 16, !tbaa !5
br label %for.body
while.cond.preheader: ; preds = %for.inc
%call638 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %d, ptr noundef nonnull %n)
%tobool7.not39 = icmp eq i32 %call638, 0
br i1 %tobool7.not39, label %while.end22, label %land.rhs
for.body: ; preds = %entry, %for.inc
%0 = phi i32 [ 2, %entry ], [ %5, %for.inc ]
%indvars.iv = phi i64 [ 3, %entry ], [ %indvars.iv.next, %for.inc ]
%inc3233 = phi i32 [ 1, %entry ], [ %inc31, %for.inc ]
%mul10.i = mul nsw i32 %0, %0
%1 = zext i32 %mul10.i to i64
%cmp.not11.i = icmp ult i64 %indvars.iv, %1
%.pre45 = trunc i64 %indvars.iv to i32
br i1 %cmp.not11.i, label %if.then, label %for.body.i
for.cond.i: ; preds = %for.body.i
%indvars.iv.next.i = add nuw i64 %indvars.iv.i, 1
%arrayidx.i = getelementptr inbounds [1000020 x i32], ptr @p, i64 0, i64 %indvars.iv.next.i
%2 = load i32, ptr %arrayidx.i, align 4, !tbaa !5
%mul.i = mul nsw i32 %2, %2
%3 = zext i32 %mul.i to i64
%cmp.not.i = icmp ult i64 %indvars.iv, %3
br i1 %cmp.not.i, label %if.then, label %for.body.i, !llvm.loop !9
for.body.i: ; preds = %for.body, %for.cond.i
%indvars.iv.i = phi i64 [ %indvars.iv.next.i, %for.cond.i ], [ 0, %for.body ]
%4 = phi i32 [ %2, %for.cond.i ], [ %0, %for.body ]
%rem.i = srem i32 %.pre45, %4
%cmp5.i = icmp eq i32 %rem.i, 0
br i1 %cmp5.i, label %if.else, label %for.cond.i
if.then: ; preds = %for.cond.i, %for.body
%inc = add nsw i32 %inc3233, 1
store i32 %inc, ptr @size, align 4, !tbaa !5
%idxprom = sext i32 %inc3233 to i64
%arrayidx = getelementptr inbounds [1000020 x i32], ptr @p, i64 0, i64 %idxprom
store i32 %.pre45, ptr %arrayidx, align 4, !tbaa !5
%arrayidx2 = getelementptr inbounds [1000020 x i32], ptr @flg, i64 0, i64 %indvars.iv
store i32 1, ptr %arrayidx2, align 4, !tbaa !5
%.pre = load i32, ptr @p, align 16, !tbaa !5
br label %for.inc
if.else: ; preds = %for.body.i
%arrayidx4 = getelementptr inbounds [1000020 x i32], ptr @flg, i64 0, i64 %indvars.iv
store i32 0, ptr %arrayidx4, align 4, !tbaa !5
br label %for.inc
for.inc: ; preds = %if.then, %if.else
%5 = phi i32 [ %.pre, %if.then ], [ %0, %if.else ]
%inc31 = phi i32 [ %inc, %if.then ], [ %inc3233, %if.else ]
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, 1000020
br i1 %exitcond.not, label %while.cond.preheader, label %for.body, !llvm.loop !11
land.rhs: ; preds = %while.cond.preheader, %while.end
%6 = load i32, ptr %a, align 4, !tbaa !5
%tobool8 = icmp ne i32 %6, 0
%7 = load i32, ptr %d, align 4
%tobool9 = icmp ne i32 %7, 0
%or.cond = select i1 %tobool8, i1 true, i1 %tobool9
%8 = load i32, ptr %n, align 4
%tobool10 = icmp ne i32 %8, 0
%or.cond23 = select i1 %or.cond, i1 true, i1 %tobool10
br i1 %or.cond23, label %while.cond11.preheader, label %while.end22
while.cond11.preheader: ; preds = %land.rhs
%9 = sext i32 %6 to i64
%10 = sext i32 %7 to i64
br label %while.cond11
while.cond11: ; preds = %while.cond11.preheader, %if.end20
%indvars.iv41 = phi i64 [ %9, %while.cond11.preheader ], [ %indvars.iv.next42, %if.end20 ]
%dec37 = phi i32 [ %8, %while.cond11.preheader ], [ %dec36, %if.end20 ]
%arrayidx14 = getelementptr inbounds [1000020 x i32], ptr @flg, i64 0, i64 %indvars.iv41
%11 = load i32, ptr %arrayidx14, align 4, !tbaa !5
%tobool15.not = icmp eq i32 %11, 0
br i1 %tobool15.not, label %if.end20, label %if.then16
if.then16: ; preds = %while.cond11
%dec = add nsw i32 %dec37, -1
%cmp17 = icmp eq i32 %dec, 0
br i1 %cmp17, label %while.end, label %if.end20
if.end20: ; preds = %if.then16, %while.cond11
%dec36 = phi i32 [ %dec, %if.then16 ], [ %dec37, %while.cond11 ]
%indvars.iv.next42 = add i64 %indvars.iv41, %10
%12 = trunc i64 %indvars.iv.next42 to i32
store i32 %12, ptr %a, align 4, !tbaa !5
br label %while.cond11
while.end: ; preds = %if.then16
%13 = trunc i64 %indvars.iv41 to i32
store i32 0, ptr %n, align 4, !tbaa !5
%call21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %13)
%call6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %d, ptr noundef nonnull %n)
%tobool7.not = icmp eq i32 %call6, 0
br i1 %tobool7.not, label %while.end22, label %land.rhs, !llvm.loop !12
while.end22: ; preds = %while.end, %land.rhs, %while.cond.preheader
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %d) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: none, inaccessiblemem: none) 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 = { nofree 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 = { 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 #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
|
/* Coached by rainboy */
#include <stdio.h>
#include <string.h>
#define N 100000
int main() {
static char s[N + 1];
int n, i, tcd;
scanf("%s", s);
n = strlen(s);
tcd = 0;
for (i = 0; i < n; i++)
if (s[i] == 'p')
tcd++;
printf("%d\n", n / 2 - tcd);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206139/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206139/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@main.s = internal global [100001 x i8] zeroinitializer, align 16
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @main.s)
%call1 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @main.s) #4
%conv = trunc i64 %call1 to i32
%cmp12 = icmp sgt i32 %conv, 0
br i1 %cmp12, label %for.body.preheader, label %for.end
for.body.preheader: ; preds = %entry
%wide.trip.count = and i64 %call1, 4294967295
%min.iters.check = icmp ult i64 %wide.trip.count, 8
br i1 %min.iters.check, label %for.body.preheader18, label %vector.ph
vector.ph: ; preds = %for.body.preheader
%n.mod.vf = and i64 %call1, 7
%n.vec = sub nsw i64 %wide.trip.count, %n.mod.vf
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %6, %vector.body ]
%vec.phi16 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %7, %vector.body ]
%0 = getelementptr inbounds [100001 x i8], ptr @main.s, i64 0, i64 %index
%wide.load = load <4 x i8>, ptr %0, align 8, !tbaa !5
%1 = getelementptr inbounds i8, ptr %0, i64 4
%wide.load17 = load <4 x i8>, ptr %1, align 4, !tbaa !5
%2 = icmp eq <4 x i8> %wide.load, <i8 112, i8 112, i8 112, i8 112>
%3 = icmp eq <4 x i8> %wide.load17, <i8 112, i8 112, i8 112, i8 112>
%4 = zext <4 x i1> %2 to <4 x i32>
%5 = zext <4 x i1> %3 to <4 x i32>
%6 = add <4 x i32> %vec.phi, %4
%7 = add <4 x i32> %vec.phi16, %5
%index.next = add nuw i64 %index, 8
%8 = icmp eq i64 %index.next, %n.vec
br i1 %8, label %middle.block, label %vector.body, !llvm.loop !8
middle.block: ; preds = %vector.body
%bin.rdx = add <4 x i32> %7, %6
%9 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
%cmp.n = icmp eq i64 %n.mod.vf, 0
br i1 %cmp.n, label %for.end, label %for.body.preheader18
for.body.preheader18: ; preds = %for.body.preheader, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.body.preheader ], [ %n.vec, %middle.block ]
%tcd.014.ph = phi i32 [ 0, %for.body.preheader ], [ %9, %middle.block ]
br label %for.body
for.body: ; preds = %for.body.preheader18, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader18 ]
%tcd.014 = phi i32 [ %spec.select, %for.body ], [ %tcd.014.ph, %for.body.preheader18 ]
%arrayidx = getelementptr inbounds [100001 x i8], ptr @main.s, i64 0, i64 %indvars.iv
%10 = load i8, ptr %arrayidx, align 1, !tbaa !5
%cmp4 = icmp eq i8 %10, 112
%inc = zext i1 %cmp4 to i32
%spec.select = add nuw nsw i32 %tcd.014, %inc
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !12
for.end: ; preds = %for.body, %middle.block, %entry
%tcd.0.lcssa = phi i32 [ 0, %entry ], [ %9, %middle.block ], [ %spec.select, %for.body ]
%div = sdiv i32 %conv, 2
%sub = sub nsw i32 %div, %tcd.0.lcssa
%call7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %sub)
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #3
attributes #0 = { nofree 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 = { 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 #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind willreturn memory(read) }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9, !10, !11}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !9, !11, !10}
|
// AOJ GRL_3_C Connected Components - Strongly Connected Components
// 2018.4.26 bal4u
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#define MAX_V 10002
int V; // 頂点数
int *to[MAX_V], hi[MAX_V];
int *r_to[MAX_V], r_hi[MAX_V];
int vs[MAX_V], vsz;
char used[MAX_V];
int cmp[MAX_V]; // 属する強連結成分のトポロジカル順序
void add_edge(int _from, int _to)
{
to[_from][hi[_from]++] = _to;
r_to[_to][r_hi[_to]++] = _from;
}
void dfs(int v)
{
int i;
used[v] = 1;
for (i = 0; i < hi[v]; i++) {
if (!used[to[v][i]]) dfs(to[v][i]);
}
vs[vsz++] = v;
}
void rdfs(int v, int k)
{
int i;
used[v] = 1;
cmp[v] = k;
for (i = 0; i < r_hi[v]; i++) {
if (!used[r_to[v][i]]) rdfs(r_to[v][i], k);
}
}
#if 0
void init(int n)
{
V = n;
memset( lim, 0, V<<2), memset( hi, 0, V<<2);
memset(r_lim, 0, V<<2), memset(r_hi, 0, V<<2);
}
#endif
// 強連結成分への分解
int scc()
{
int v, i, k;
memset(used, 0, V);
vsz = 0;
for (v = 0; v < V; v++) if (!used[v]) dfs(v);
memset(used, 0, V);
k = 0;
for (i = vsz-1; i >= 0; i--) {
if (!used[vs[i]]) rdfs(vs[i], k++);
}
return k; // 得られた強連結成分の数
}
// バッファを経ずstdinから数値を得る
//#define getchar_unlocked() getchar()
int in()
{
int n = 0, c = getchar_unlocked();
do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
return n;
}
int main()
{
int E, Q, s, t, i, j;
int *memo;
V = in(), E = in();
memo = malloc(E<<3);
j = 0; for (i = 0; i < E; i++) {
memo[j++] = s = in(), memo[j++] = t = in();
hi[s]++, r_hi[t]++;
}
for (i = 0; i < V; i++) {
if ( hi[i]) to[i] = malloc( hi[i]<<2);
if (r_hi[i]) r_to[i] = malloc(r_hi[i]<<2);
}
memset(hi, 0, V<<2), memset(r_hi, 0, V<<2);
j = 0; while (E--) {
s = memo[j++], t = memo[j++];
add_edge(s, t);
}
scc();
Q = in();
while (Q--) {
s = in(), t = in();
putchar('0'+ (cmp[s] == cmp[t]));
putchar('\n');
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206182/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206182/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct._IO_FILE = type { i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i64, i16, i8, [1 x i8], ptr, i64, ptr, ptr, ptr, ptr, i64, i32, [20 x i8] }
@to = dso_local local_unnamed_addr global [10002 x ptr] zeroinitializer, align 16
@hi = dso_local local_unnamed_addr global [10002 x i32] zeroinitializer, align 16
@r_to = dso_local local_unnamed_addr global [10002 x ptr] zeroinitializer, align 16
@r_hi = dso_local local_unnamed_addr global [10002 x i32] zeroinitializer, align 16
@used = dso_local local_unnamed_addr global [10002 x i8] zeroinitializer, align 16
@vs = dso_local local_unnamed_addr global [10002 x i32] zeroinitializer, align 16
@vsz = dso_local local_unnamed_addr global i32 0, align 4
@cmp = dso_local local_unnamed_addr global [10002 x i32] zeroinitializer, align 16
@V = dso_local local_unnamed_addr global i32 0, align 4
@stdin = external local_unnamed_addr global ptr, align 8
@stdout = external local_unnamed_addr global ptr, align 8
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: write, inaccessiblemem: none) uwtable
define dso_local void @add_edge(i32 noundef %_from, i32 noundef %_to) local_unnamed_addr #0 {
entry:
%idxprom = sext i32 %_from to i64
%arrayidx = getelementptr inbounds [10002 x ptr], ptr @to, i64 0, i64 %idxprom
%0 = load ptr, ptr %arrayidx, align 8, !tbaa !5
%arrayidx2 = getelementptr inbounds [10002 x i32], ptr @hi, i64 0, i64 %idxprom
%1 = load i32, ptr %arrayidx2, align 4, !tbaa !9
%inc = add nsw i32 %1, 1
store i32 %inc, ptr %arrayidx2, align 4, !tbaa !9
%idxprom3 = sext i32 %1 to i64
%arrayidx4 = getelementptr inbounds i32, ptr %0, i64 %idxprom3
store i32 %_to, ptr %arrayidx4, align 4, !tbaa !9
%idxprom5 = sext i32 %_to to i64
%arrayidx6 = getelementptr inbounds [10002 x ptr], ptr @r_to, i64 0, i64 %idxprom5
%2 = load ptr, ptr %arrayidx6, align 8, !tbaa !5
%arrayidx8 = getelementptr inbounds [10002 x i32], ptr @r_hi, i64 0, i64 %idxprom5
%3 = load i32, ptr %arrayidx8, align 4, !tbaa !9
%inc9 = add nsw i32 %3, 1
store i32 %inc9, ptr %arrayidx8, align 4, !tbaa !9
%idxprom10 = sext i32 %3 to i64
%arrayidx11 = getelementptr inbounds i32, ptr %2, i64 %idxprom10
store i32 %_from, ptr %arrayidx11, align 4, !tbaa !9
ret void
}
; Function Attrs: nofree nosync nounwind memory(readwrite, argmem: read, inaccessiblemem: none) uwtable
define dso_local void @dfs(i32 noundef %v) local_unnamed_addr #1 {
entry:
%idxprom = sext i32 %v to i64
%arrayidx = getelementptr inbounds [10002 x i8], ptr @used, i64 0, i64 %idxprom
store i8 1, ptr %arrayidx, align 1, !tbaa !11
%arrayidx2 = getelementptr inbounds [10002 x i32], ptr @hi, i64 0, i64 %idxprom
%0 = load i32, ptr %arrayidx2, align 4, !tbaa !9
%cmp23 = icmp sgt i32 %0, 0
br i1 %cmp23, label %for.body.lr.ph, label %for.end
for.body.lr.ph: ; preds = %entry
%arrayidx4 = getelementptr inbounds [10002 x ptr], ptr @to, i64 0, i64 %idxprom
br label %for.body
for.body: ; preds = %for.body.lr.ph, %for.inc
%1 = phi i32 [ %0, %for.body.lr.ph ], [ %5, %for.inc ]
%indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.inc ]
%2 = load ptr, ptr %arrayidx4, align 8, !tbaa !5
%arrayidx6 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv
%3 = load i32, ptr %arrayidx6, align 4, !tbaa !9
%idxprom7 = sext i32 %3 to i64
%arrayidx8 = getelementptr inbounds [10002 x i8], ptr @used, i64 0, i64 %idxprom7
%4 = load i8, ptr %arrayidx8, align 1, !tbaa !11
%tobool.not = icmp eq i8 %4, 0
br i1 %tobool.not, label %if.then, label %for.inc
if.then: ; preds = %for.body
tail call void @dfs(i32 noundef %3)
%.pre = load i32, ptr %arrayidx2, align 4, !tbaa !9
br label %for.inc
for.inc: ; preds = %for.body, %if.then
%5 = phi i32 [ %1, %for.body ], [ %.pre, %if.then ]
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%6 = sext i32 %5 to i64
%cmp = icmp slt i64 %indvars.iv.next, %6
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !12
for.end: ; preds = %for.inc, %entry
%7 = load i32, ptr @vsz, align 4, !tbaa !9
%inc13 = add nsw i32 %7, 1
store i32 %inc13, ptr @vsz, align 4, !tbaa !9
%idxprom14 = sext i32 %7 to i64
%arrayidx15 = getelementptr inbounds [10002 x i32], ptr @vs, i64 0, i64 %idxprom14
store i32 %v, ptr %arrayidx15, align 4, !tbaa !9
ret void
}
; Function Attrs: nofree nosync nounwind memory(readwrite, argmem: read, inaccessiblemem: none) uwtable
define dso_local void @rdfs(i32 noundef %v, i32 noundef %k) local_unnamed_addr #1 {
entry:
%idxprom = sext i32 %v to i64
%arrayidx = getelementptr inbounds [10002 x i8], ptr @used, i64 0, i64 %idxprom
store i8 1, ptr %arrayidx, align 1, !tbaa !11
%arrayidx2 = getelementptr inbounds [10002 x i32], ptr @cmp, i64 0, i64 %idxprom
store i32 %k, ptr %arrayidx2, align 4, !tbaa !9
%arrayidx4 = getelementptr inbounds [10002 x i32], ptr @r_hi, i64 0, i64 %idxprom
%0 = load i32, ptr %arrayidx4, align 4, !tbaa !9
%cmp23 = icmp sgt i32 %0, 0
br i1 %cmp23, label %for.body.lr.ph, label %for.end
for.body.lr.ph: ; preds = %entry
%arrayidx6 = getelementptr inbounds [10002 x ptr], ptr @r_to, i64 0, i64 %idxprom
br label %for.body
for.body: ; preds = %for.body.lr.ph, %for.inc
%1 = phi i32 [ %0, %for.body.lr.ph ], [ %5, %for.inc ]
%indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.inc ]
%2 = load ptr, ptr %arrayidx6, align 8, !tbaa !5
%arrayidx8 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv
%3 = load i32, ptr %arrayidx8, align 4, !tbaa !9
%idxprom9 = sext i32 %3 to i64
%arrayidx10 = getelementptr inbounds [10002 x i8], ptr @used, i64 0, i64 %idxprom9
%4 = load i8, ptr %arrayidx10, align 1, !tbaa !11
%tobool.not = icmp eq i8 %4, 0
br i1 %tobool.not, label %if.then, label %for.inc
if.then: ; preds = %for.body
tail call void @rdfs(i32 noundef %3, i32 noundef %k)
%.pre = load i32, ptr %arrayidx4, align 4, !tbaa !9
br label %for.inc
for.inc: ; preds = %for.body, %if.then
%5 = phi i32 [ %1, %for.body ], [ %.pre, %if.then ]
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%6 = sext i32 %5 to i64
%cmp = icmp slt i64 %indvars.iv.next, %6
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !14
for.end: ; preds = %for.inc, %entry
ret void
}
; Function Attrs: nofree nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local i32 @scc() local_unnamed_addr #2 {
entry:
%0 = load i32, ptr @V, align 4, !tbaa !9
%conv = sext i32 %0 to i64
tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @used, i8 0, i64 %conv, i1 false)
store i32 0, ptr @vsz, align 4, !tbaa !9
%cmp26 = icmp sgt i32 %0, 0
br i1 %cmp26, label %for.body, label %for.end.thread
for.end.thread: ; preds = %entry
tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @used, i8 0, i64 %conv, i1 false)
br label %for.end18
for.body: ; preds = %entry, %for.inc
%1 = phi i32 [ %4, %for.inc ], [ %0, %entry ]
%indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
%arrayidx = getelementptr inbounds [10002 x i8], ptr @used, i64 0, i64 %indvars.iv
%2 = load i8, ptr %arrayidx, align 1, !tbaa !11
%tobool.not = icmp eq i8 %2, 0
br i1 %tobool.not, label %if.then, label %for.inc
if.then: ; preds = %for.body
%3 = trunc i64 %indvars.iv to i32
tail call void @dfs(i32 noundef %3)
%.pre = load i32, ptr @V, align 4, !tbaa !9
br label %for.inc
for.inc: ; preds = %for.body, %if.then
%4 = phi i32 [ %1, %for.body ], [ %.pre, %if.then ]
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%5 = sext i32 %4 to i64
%cmp = icmp slt i64 %indvars.iv.next, %5
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !15
for.end: ; preds = %for.inc
%.pre38 = load i32, ptr @vsz, align 4, !tbaa !9
tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @used, i8 0, i64 %5, i1 false)
%cmp429 = icmp sgt i32 %.pre38, 0
br i1 %cmp429, label %for.body6.preheader, label %for.end18
for.body6.preheader: ; preds = %for.end
%6 = zext i32 %.pre38 to i64
br label %for.body6
for.body6: ; preds = %for.body6.preheader, %for.inc17
%indvars.iv35 = phi i64 [ %6, %for.body6.preheader ], [ %indvars.iv.next36, %for.inc17 ]
%k.030 = phi i32 [ 0, %for.body6.preheader ], [ %k.1, %for.inc17 ]
%indvars.iv.next36 = add nsw i64 %indvars.iv35, -1
%idxprom7 = and i64 %indvars.iv.next36, 4294967295
%arrayidx8 = getelementptr inbounds [10002 x i32], ptr @vs, i64 0, i64 %idxprom7
%7 = load i32, ptr %arrayidx8, align 4, !tbaa !9
%idxprom9 = sext i32 %7 to i64
%arrayidx10 = getelementptr inbounds [10002 x i8], ptr @used, i64 0, i64 %idxprom9
%8 = load i8, ptr %arrayidx10, align 1, !tbaa !11
%tobool11.not = icmp eq i8 %8, 0
br i1 %tobool11.not, label %if.then12, label %for.inc17
if.then12: ; preds = %for.body6
%inc15 = add nsw i32 %k.030, 1
tail call void @rdfs(i32 noundef %7, i32 noundef %k.030)
br label %for.inc17
for.inc17: ; preds = %for.body6, %if.then12
%k.1 = phi i32 [ %k.030, %for.body6 ], [ %inc15, %if.then12 ]
%cmp4 = icmp ugt i64 %indvars.iv35, 1
br i1 %cmp4, label %for.body6, label %for.end18, !llvm.loop !16
for.end18: ; preds = %for.inc17, %for.end.thread, %for.end
%k.0.lcssa = phi i32 [ 0, %for.end ], [ 0, %for.end.thread ], [ %k.1, %for.inc17 ]
ret i32 %k.0.lcssa
}
; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3
; Function Attrs: nounwind uwtable
define dso_local i32 @in() local_unnamed_addr #4 {
entry:
%0 = load ptr, ptr @stdin, align 8, !tbaa !5
%_IO_read_ptr.i = getelementptr inbounds %struct._IO_FILE, ptr %0, i64 0, i32 1
%1 = load ptr, ptr %_IO_read_ptr.i, align 8, !tbaa !17
%_IO_read_end.i = getelementptr inbounds %struct._IO_FILE, ptr %0, i64 0, i32 2
%2 = load ptr, ptr %_IO_read_end.i, align 8, !tbaa !21
%cmp.not.i = icmp ult ptr %1, %2
br i1 %cmp.not.i, label %cond.false.i, label %cond.true.i, !prof !22
cond.true.i: ; preds = %entry
%call.i = tail call i32 @__uflow(ptr noundef nonnull %0) #8
%.pre14.pre = load ptr, ptr @stdin, align 8, !tbaa !5
br label %do.body.preheader
cond.false.i: ; preds = %entry
%incdec.ptr.i = getelementptr inbounds i8, ptr %1, i64 1
store ptr %incdec.ptr.i, ptr %_IO_read_ptr.i, align 8, !tbaa !17
%3 = load i8, ptr %1, align 1, !tbaa !11
%conv3.i = zext i8 %3 to i32
br label %do.body.preheader
do.body.preheader: ; preds = %cond.true.i, %cond.false.i
%.ph = phi ptr [ %0, %cond.false.i ], [ %.pre14.pre, %cond.true.i ]
%c.0.ph = phi i32 [ %conv3.i, %cond.false.i ], [ %call.i, %cond.true.i ]
br label %do.body
do.body: ; preds = %do.body.preheader, %getchar_unlocked.exit13
%4 = phi ptr [ %8, %getchar_unlocked.exit13 ], [ %.ph, %do.body.preheader ]
%n.0 = phi i32 [ %add, %getchar_unlocked.exit13 ], [ 0, %do.body.preheader ]
%c.0 = phi i32 [ %cond.i9, %getchar_unlocked.exit13 ], [ %c.0.ph, %do.body.preheader ]
%mul = mul nsw i32 %n.0, 10
%and = and i32 %c.0, 15
%add = add nsw i32 %and, %mul
%_IO_read_ptr.i4 = getelementptr inbounds %struct._IO_FILE, ptr %4, i64 0, i32 1
%5 = load ptr, ptr %_IO_read_ptr.i4, align 8, !tbaa !17
%_IO_read_end.i5 = getelementptr inbounds %struct._IO_FILE, ptr %4, i64 0, i32 2
%6 = load ptr, ptr %_IO_read_end.i5, align 8, !tbaa !21
%cmp.not.i6 = icmp ult ptr %5, %6
br i1 %cmp.not.i6, label %cond.false.i10, label %cond.true.i7, !prof !22
cond.true.i7: ; preds = %do.body
%call.i8 = tail call i32 @__uflow(ptr noundef nonnull %4) #8
%.pre = load ptr, ptr @stdin, align 8, !tbaa !5
br label %getchar_unlocked.exit13
cond.false.i10: ; preds = %do.body
%incdec.ptr.i11 = getelementptr inbounds i8, ptr %5, i64 1
store ptr %incdec.ptr.i11, ptr %_IO_read_ptr.i4, align 8, !tbaa !17
%7 = load i8, ptr %5, align 1, !tbaa !11
%conv3.i12 = zext i8 %7 to i32
br label %getchar_unlocked.exit13
getchar_unlocked.exit13: ; preds = %cond.true.i7, %cond.false.i10
%8 = phi ptr [ %.pre, %cond.true.i7 ], [ %4, %cond.false.i10 ]
%cond.i9 = phi i32 [ %call.i8, %cond.true.i7 ], [ %conv3.i12, %cond.false.i10 ]
%cmp = icmp sgt i32 %cond.i9, 47
br i1 %cmp, label %do.body, label %do.end, !llvm.loop !23
do.end: ; preds = %getchar_unlocked.exit13
ret i32 %add
}
; Function Attrs: nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #4 {
entry:
%0 = load ptr, ptr @stdin, align 8, !tbaa !5
%_IO_read_ptr.i.i = getelementptr inbounds %struct._IO_FILE, ptr %0, i64 0, i32 1
%1 = load ptr, ptr %_IO_read_ptr.i.i, align 8, !tbaa !17
%_IO_read_end.i.i = getelementptr inbounds %struct._IO_FILE, ptr %0, i64 0, i32 2
%2 = load ptr, ptr %_IO_read_end.i.i, align 8, !tbaa !21
%cmp.not.i.i = icmp ult ptr %1, %2
br i1 %cmp.not.i.i, label %cond.false.i.i, label %cond.true.i.i, !prof !22
cond.true.i.i: ; preds = %entry
%call.i.i = tail call i32 @__uflow(ptr noundef nonnull %0) #8
%.pre14.pre.i = load ptr, ptr @stdin, align 8, !tbaa !5
br label %do.body.i.preheader
cond.false.i.i: ; preds = %entry
%incdec.ptr.i.i = getelementptr inbounds i8, ptr %1, i64 1
store ptr %incdec.ptr.i.i, ptr %_IO_read_ptr.i.i, align 8, !tbaa !17
%3 = load i8, ptr %1, align 1, !tbaa !11
%conv3.i.i = zext i8 %3 to i32
br label %do.body.i.preheader
do.body.i.preheader: ; preds = %cond.false.i.i, %cond.true.i.i
%.ph331 = phi ptr [ %0, %cond.false.i.i ], [ %.pre14.pre.i, %cond.true.i.i ]
%c.0.i.ph = phi i32 [ %conv3.i.i, %cond.false.i.i ], [ %call.i.i, %cond.true.i.i ]
br label %do.body.i
do.body.i: ; preds = %do.body.i.preheader, %getchar_unlocked.exit13.i
%4 = phi ptr [ %8, %getchar_unlocked.exit13.i ], [ %.ph331, %do.body.i.preheader ]
%n.0.i = phi i32 [ %add.i, %getchar_unlocked.exit13.i ], [ 0, %do.body.i.preheader ]
%c.0.i = phi i32 [ %cond.i9.i, %getchar_unlocked.exit13.i ], [ %c.0.i.ph, %do.body.i.preheader ]
%mul.i = mul nsw i32 %n.0.i, 10
%and.i = and i32 %c.0.i, 15
%add.i = add nsw i32 %and.i, %mul.i
%_IO_read_ptr.i4.i = getelementptr inbounds %struct._IO_FILE, ptr %4, i64 0, i32 1
%5 = load ptr, ptr %_IO_read_ptr.i4.i, align 8, !tbaa !17
%_IO_read_end.i5.i = getelementptr inbounds %struct._IO_FILE, ptr %4, i64 0, i32 2
%6 = load ptr, ptr %_IO_read_end.i5.i, align 8, !tbaa !21
%cmp.not.i6.i = icmp ult ptr %5, %6
br i1 %cmp.not.i6.i, label %cond.false.i10.i, label %cond.true.i7.i, !prof !22
cond.true.i7.i: ; preds = %do.body.i
%call.i8.i = tail call i32 @__uflow(ptr noundef nonnull %4) #8
%.pre.i = load ptr, ptr @stdin, align 8, !tbaa !5
br label %getchar_unlocked.exit13.i
cond.false.i10.i: ; preds = %do.body.i
%incdec.ptr.i11.i = getelementptr inbounds i8, ptr %5, i64 1
store ptr %incdec.ptr.i11.i, ptr %_IO_read_ptr.i4.i, align 8, !tbaa !17
%7 = load i8, ptr %5, align 1, !tbaa !11
%conv3.i12.i = zext i8 %7 to i32
br label %getchar_unlocked.exit13.i
getchar_unlocked.exit13.i: ; preds = %cond.false.i10.i, %cond.true.i7.i
%8 = phi ptr [ %.pre.i, %cond.true.i7.i ], [ %4, %cond.false.i10.i ]
%cond.i9.i = phi i32 [ %call.i8.i, %cond.true.i7.i ], [ %conv3.i12.i, %cond.false.i10.i ]
%cmp.i = icmp sgt i32 %cond.i9.i, 47
br i1 %cmp.i, label %do.body.i, label %in.exit, !llvm.loop !23
in.exit: ; preds = %getchar_unlocked.exit13.i
store i32 %add.i, ptr @V, align 4, !tbaa !9
%_IO_read_ptr.i.i95 = getelementptr inbounds %struct._IO_FILE, ptr %8, i64 0, i32 1
%9 = load ptr, ptr %_IO_read_ptr.i.i95, align 8, !tbaa !17
%_IO_read_end.i.i96 = getelementptr inbounds %struct._IO_FILE, ptr %8, i64 0, i32 2
%10 = load ptr, ptr %_IO_read_end.i.i96, align 8, !tbaa !21
%cmp.not.i.i97 = icmp ult ptr %9, %10
br i1 %cmp.not.i.i97, label %cond.false.i.i122, label %cond.true.i.i98, !prof !22
cond.true.i.i98: ; preds = %in.exit
%call.i.i99 = tail call i32 @__uflow(ptr noundef nonnull %8) #8
%.pre14.pre.i100 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %do.body.i104.preheader
cond.false.i.i122: ; preds = %in.exit
%incdec.ptr.i.i123 = getelementptr inbounds i8, ptr %9, i64 1
store ptr %incdec.ptr.i.i123, ptr %_IO_read_ptr.i.i95, align 8, !tbaa !17
%11 = load i8, ptr %9, align 1, !tbaa !11
%conv3.i.i124 = zext i8 %11 to i32
br label %do.body.i104.preheader
do.body.i104.preheader: ; preds = %cond.false.i.i122, %cond.true.i.i98
%.ph329 = phi ptr [ %8, %cond.false.i.i122 ], [ %.pre14.pre.i100, %cond.true.i.i98 ]
%c.0.i106.ph = phi i32 [ %conv3.i.i124, %cond.false.i.i122 ], [ %call.i.i99, %cond.true.i.i98 ]
br label %do.body.i104
do.body.i104: ; preds = %do.body.i104.preheader, %getchar_unlocked.exit13.i116
%12 = phi ptr [ %16, %getchar_unlocked.exit13.i116 ], [ %.ph329, %do.body.i104.preheader ]
%n.0.i105 = phi i32 [ %add.i109, %getchar_unlocked.exit13.i116 ], [ 0, %do.body.i104.preheader ]
%c.0.i106 = phi i32 [ %cond.i9.i117, %getchar_unlocked.exit13.i116 ], [ %c.0.i106.ph, %do.body.i104.preheader ]
%mul.i107 = mul nsw i32 %n.0.i105, 10
%and.i108 = and i32 %c.0.i106, 15
%add.i109 = add nsw i32 %and.i108, %mul.i107
%_IO_read_ptr.i4.i110 = getelementptr inbounds %struct._IO_FILE, ptr %12, i64 0, i32 1
%13 = load ptr, ptr %_IO_read_ptr.i4.i110, align 8, !tbaa !17
%_IO_read_end.i5.i111 = getelementptr inbounds %struct._IO_FILE, ptr %12, i64 0, i32 2
%14 = load ptr, ptr %_IO_read_end.i5.i111, align 8, !tbaa !21
%cmp.not.i6.i112 = icmp ult ptr %13, %14
br i1 %cmp.not.i6.i112, label %cond.false.i10.i119, label %cond.true.i7.i113, !prof !22
cond.true.i7.i113: ; preds = %do.body.i104
%call.i8.i114 = tail call i32 @__uflow(ptr noundef nonnull %12) #8
%.pre.i115 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %getchar_unlocked.exit13.i116
cond.false.i10.i119: ; preds = %do.body.i104
%incdec.ptr.i11.i120 = getelementptr inbounds i8, ptr %13, i64 1
store ptr %incdec.ptr.i11.i120, ptr %_IO_read_ptr.i4.i110, align 8, !tbaa !17
%15 = load i8, ptr %13, align 1, !tbaa !11
%conv3.i12.i121 = zext i8 %15 to i32
br label %getchar_unlocked.exit13.i116
getchar_unlocked.exit13.i116: ; preds = %cond.false.i10.i119, %cond.true.i7.i113
%16 = phi ptr [ %.pre.i115, %cond.true.i7.i113 ], [ %12, %cond.false.i10.i119 ]
%cond.i9.i117 = phi i32 [ %call.i8.i114, %cond.true.i7.i113 ], [ %conv3.i12.i121, %cond.false.i10.i119 ]
%cmp.i118 = icmp sgt i32 %cond.i9.i117, 47
br i1 %cmp.i118, label %do.body.i104, label %in.exit125, !llvm.loop !23
in.exit125: ; preds = %getchar_unlocked.exit13.i116
%shl = shl i32 %add.i109, 3
%conv = sext i32 %shl to i64
%call2 = tail call noalias ptr @malloc(i64 noundef %conv) #9
%cmp287 = icmp sgt i32 %add.i109, 0
br i1 %cmp287, label %for.body, label %for.cond16.preheader
for.cond16.preheader: ; preds = %in.exit187, %in.exit125
%17 = load i32, ptr @V, align 4, !tbaa !9
%cmp17290 = icmp sgt i32 %17, 0
br i1 %cmp17290, label %for.body19.preheader, label %for.end43
for.body19.preheader: ; preds = %for.cond16.preheader
%wide.trip.count = zext i32 %17 to i64
br label %for.body19
for.body: ; preds = %in.exit125, %in.exit187
%18 = phi ptr [ %39, %in.exit187 ], [ %16, %in.exit125 ]
%19 = phi ptr [ %40, %in.exit187 ], [ %16, %in.exit125 ]
%indvars.iv = phi i64 [ %indvars.iv.next, %in.exit187 ], [ 0, %in.exit125 ]
%i.0288 = phi i32 [ %inc15, %in.exit187 ], [ 0, %in.exit125 ]
%_IO_read_ptr.i.i126 = getelementptr inbounds %struct._IO_FILE, ptr %19, i64 0, i32 1
%20 = load ptr, ptr %_IO_read_ptr.i.i126, align 8, !tbaa !17
%_IO_read_end.i.i127 = getelementptr inbounds %struct._IO_FILE, ptr %19, i64 0, i32 2
%21 = load ptr, ptr %_IO_read_end.i.i127, align 8, !tbaa !21
%cmp.not.i.i128 = icmp ult ptr %20, %21
br i1 %cmp.not.i.i128, label %cond.false.i.i153, label %cond.true.i.i129, !prof !22
cond.true.i.i129: ; preds = %for.body
%call.i.i130 = tail call i32 @__uflow(ptr noundef nonnull %19) #8
%.pre14.pre.i131 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %do.body.i135.preheader
cond.false.i.i153: ; preds = %for.body
%incdec.ptr.i.i154 = getelementptr inbounds i8, ptr %20, i64 1
store ptr %incdec.ptr.i.i154, ptr %_IO_read_ptr.i.i126, align 8, !tbaa !17
%22 = load i8, ptr %20, align 1, !tbaa !11
%conv3.i.i155 = zext i8 %22 to i32
br label %do.body.i135.preheader
do.body.i135.preheader: ; preds = %cond.false.i.i153, %cond.true.i.i129
%.ph324 = phi ptr [ %18, %cond.false.i.i153 ], [ %.pre14.pre.i131, %cond.true.i.i129 ]
%.ph325 = phi ptr [ %19, %cond.false.i.i153 ], [ %.pre14.pre.i131, %cond.true.i.i129 ]
%c.0.i137.ph = phi i32 [ %conv3.i.i155, %cond.false.i.i153 ], [ %call.i.i130, %cond.true.i.i129 ]
br label %do.body.i135
do.body.i135: ; preds = %do.body.i135.preheader, %getchar_unlocked.exit13.i147
%23 = phi ptr [ %28, %getchar_unlocked.exit13.i147 ], [ %.ph324, %do.body.i135.preheader ]
%24 = phi ptr [ %29, %getchar_unlocked.exit13.i147 ], [ %.ph325, %do.body.i135.preheader ]
%n.0.i136 = phi i32 [ %add.i140, %getchar_unlocked.exit13.i147 ], [ 0, %do.body.i135.preheader ]
%c.0.i137 = phi i32 [ %cond.i9.i148, %getchar_unlocked.exit13.i147 ], [ %c.0.i137.ph, %do.body.i135.preheader ]
%mul.i138 = mul nsw i32 %n.0.i136, 10
%and.i139 = and i32 %c.0.i137, 15
%add.i140 = add nsw i32 %and.i139, %mul.i138
%_IO_read_ptr.i4.i141 = getelementptr inbounds %struct._IO_FILE, ptr %24, i64 0, i32 1
%25 = load ptr, ptr %_IO_read_ptr.i4.i141, align 8, !tbaa !17
%_IO_read_end.i5.i142 = getelementptr inbounds %struct._IO_FILE, ptr %24, i64 0, i32 2
%26 = load ptr, ptr %_IO_read_end.i5.i142, align 8, !tbaa !21
%cmp.not.i6.i143 = icmp ult ptr %25, %26
br i1 %cmp.not.i6.i143, label %cond.false.i10.i150, label %cond.true.i7.i144, !prof !22
cond.true.i7.i144: ; preds = %do.body.i135
%call.i8.i145 = tail call i32 @__uflow(ptr noundef nonnull %24) #8
%.pre.i146 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %getchar_unlocked.exit13.i147
cond.false.i10.i150: ; preds = %do.body.i135
%incdec.ptr.i11.i151 = getelementptr inbounds i8, ptr %25, i64 1
store ptr %incdec.ptr.i11.i151, ptr %_IO_read_ptr.i4.i141, align 8, !tbaa !17
%27 = load i8, ptr %25, align 1, !tbaa !11
%conv3.i12.i152 = zext i8 %27 to i32
br label %getchar_unlocked.exit13.i147
getchar_unlocked.exit13.i147: ; preds = %cond.false.i10.i150, %cond.true.i7.i144
%28 = phi ptr [ %.pre.i146, %cond.true.i7.i144 ], [ %23, %cond.false.i10.i150 ]
%29 = phi ptr [ %.pre.i146, %cond.true.i7.i144 ], [ %24, %cond.false.i10.i150 ]
%cond.i9.i148 = phi i32 [ %call.i8.i145, %cond.true.i7.i144 ], [ %conv3.i12.i152, %cond.false.i10.i150 ]
%cmp.i149 = icmp sgt i32 %cond.i9.i148, 47
br i1 %cmp.i149, label %do.body.i135, label %in.exit156, !llvm.loop !23
in.exit156: ; preds = %getchar_unlocked.exit13.i147
%30 = or i64 %indvars.iv, 1
%arrayidx = getelementptr inbounds i32, ptr %call2, i64 %indvars.iv
store i32 %add.i140, ptr %arrayidx, align 4, !tbaa !9
%_IO_read_ptr.i.i157 = getelementptr inbounds %struct._IO_FILE, ptr %28, i64 0, i32 1
%31 = load ptr, ptr %_IO_read_ptr.i.i157, align 8, !tbaa !17
%_IO_read_end.i.i158 = getelementptr inbounds %struct._IO_FILE, ptr %28, i64 0, i32 2
%32 = load ptr, ptr %_IO_read_end.i.i158, align 8, !tbaa !21
%cmp.not.i.i159 = icmp ult ptr %31, %32
br i1 %cmp.not.i.i159, label %cond.false.i.i184, label %cond.true.i.i160, !prof !22
cond.true.i.i160: ; preds = %in.exit156
%call.i.i161 = tail call i32 @__uflow(ptr noundef nonnull %28) #8
%.pre14.pre.i162 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %do.body.i166.preheader
cond.false.i.i184: ; preds = %in.exit156
%incdec.ptr.i.i185 = getelementptr inbounds i8, ptr %31, i64 1
store ptr %incdec.ptr.i.i185, ptr %_IO_read_ptr.i.i157, align 8, !tbaa !17
%33 = load i8, ptr %31, align 1, !tbaa !11
%conv3.i.i186 = zext i8 %33 to i32
br label %do.body.i166.preheader
do.body.i166.preheader: ; preds = %cond.false.i.i184, %cond.true.i.i160
%.ph323 = phi ptr [ %28, %cond.false.i.i184 ], [ %.pre14.pre.i162, %cond.true.i.i160 ]
%c.0.i168.ph = phi i32 [ %conv3.i.i186, %cond.false.i.i184 ], [ %call.i.i161, %cond.true.i.i160 ]
br label %do.body.i166
do.body.i166: ; preds = %do.body.i166.preheader, %getchar_unlocked.exit13.i178
%34 = phi ptr [ %39, %getchar_unlocked.exit13.i178 ], [ %.ph323, %do.body.i166.preheader ]
%35 = phi ptr [ %40, %getchar_unlocked.exit13.i178 ], [ %.ph323, %do.body.i166.preheader ]
%n.0.i167 = phi i32 [ %add.i171, %getchar_unlocked.exit13.i178 ], [ 0, %do.body.i166.preheader ]
%c.0.i168 = phi i32 [ %cond.i9.i179, %getchar_unlocked.exit13.i178 ], [ %c.0.i168.ph, %do.body.i166.preheader ]
%mul.i169 = mul nsw i32 %n.0.i167, 10
%and.i170 = and i32 %c.0.i168, 15
%add.i171 = add nsw i32 %and.i170, %mul.i169
%_IO_read_ptr.i4.i172 = getelementptr inbounds %struct._IO_FILE, ptr %35, i64 0, i32 1
%36 = load ptr, ptr %_IO_read_ptr.i4.i172, align 8, !tbaa !17
%_IO_read_end.i5.i173 = getelementptr inbounds %struct._IO_FILE, ptr %35, i64 0, i32 2
%37 = load ptr, ptr %_IO_read_end.i5.i173, align 8, !tbaa !21
%cmp.not.i6.i174 = icmp ult ptr %36, %37
br i1 %cmp.not.i6.i174, label %cond.false.i10.i181, label %cond.true.i7.i175, !prof !22
cond.true.i7.i175: ; preds = %do.body.i166
%call.i8.i176 = tail call i32 @__uflow(ptr noundef nonnull %35) #8
%.pre.i177 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %getchar_unlocked.exit13.i178
cond.false.i10.i181: ; preds = %do.body.i166
%incdec.ptr.i11.i182 = getelementptr inbounds i8, ptr %36, i64 1
store ptr %incdec.ptr.i11.i182, ptr %_IO_read_ptr.i4.i172, align 8, !tbaa !17
%38 = load i8, ptr %36, align 1, !tbaa !11
%conv3.i12.i183 = zext i8 %38 to i32
br label %getchar_unlocked.exit13.i178
getchar_unlocked.exit13.i178: ; preds = %cond.false.i10.i181, %cond.true.i7.i175
%39 = phi ptr [ %.pre.i177, %cond.true.i7.i175 ], [ %34, %cond.false.i10.i181 ]
%40 = phi ptr [ %.pre.i177, %cond.true.i7.i175 ], [ %35, %cond.false.i10.i181 ]
%cond.i9.i179 = phi i32 [ %call.i8.i176, %cond.true.i7.i175 ], [ %conv3.i12.i183, %cond.false.i10.i181 ]
%cmp.i180 = icmp sgt i32 %cond.i9.i179, 47
br i1 %cmp.i180, label %do.body.i166, label %in.exit187, !llvm.loop !23
in.exit187: ; preds = %getchar_unlocked.exit13.i178
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
%arrayidx8 = getelementptr inbounds i32, ptr %call2, i64 %30
store i32 %add.i171, ptr %arrayidx8, align 4, !tbaa !9
%idxprom9 = sext i32 %add.i140 to i64
%arrayidx10 = getelementptr inbounds [10002 x i32], ptr @hi, i64 0, i64 %idxprom9
%41 = load i32, ptr %arrayidx10, align 4, !tbaa !9
%inc11 = add nsw i32 %41, 1
store i32 %inc11, ptr %arrayidx10, align 4, !tbaa !9
%idxprom12 = sext i32 %add.i171 to i64
%arrayidx13 = getelementptr inbounds [10002 x i32], ptr @r_hi, i64 0, i64 %idxprom12
%42 = load i32, ptr %arrayidx13, align 4, !tbaa !9
%inc14 = add nsw i32 %42, 1
store i32 %inc14, ptr %arrayidx13, align 4, !tbaa !9
%inc15 = add nuw nsw i32 %i.0288, 1
%exitcond.not = icmp eq i32 %inc15, %add.i109
br i1 %exitcond.not, label %for.cond16.preheader, label %for.body, !llvm.loop !24
for.body19: ; preds = %for.body19.preheader, %for.inc41
%indvars.iv299 = phi i64 [ 0, %for.body19.preheader ], [ %indvars.iv.next300, %for.inc41 ]
%arrayidx21 = getelementptr inbounds [10002 x i32], ptr @hi, i64 0, i64 %indvars.iv299
%43 = load i32, ptr %arrayidx21, align 4, !tbaa !9
%tobool.not = icmp eq i32 %43, 0
br i1 %tobool.not, label %if.end, label %if.then
if.then: ; preds = %for.body19
%shl24 = shl i32 %43, 2
%conv25 = sext i32 %shl24 to i64
%call26 = tail call noalias ptr @malloc(i64 noundef %conv25) #9
%arrayidx28 = getelementptr inbounds [10002 x ptr], ptr @to, i64 0, i64 %indvars.iv299
store ptr %call26, ptr %arrayidx28, align 8, !tbaa !5
br label %if.end
if.end: ; preds = %if.then, %for.body19
%arrayidx30 = getelementptr inbounds [10002 x i32], ptr @r_hi, i64 0, i64 %indvars.iv299
%44 = load i32, ptr %arrayidx30, align 4, !tbaa !9
%tobool31.not = icmp eq i32 %44, 0
br i1 %tobool31.not, label %for.inc41, label %if.then32
if.then32: ; preds = %if.end
%shl35 = shl i32 %44, 2
%conv36 = sext i32 %shl35 to i64
%call37 = tail call noalias ptr @malloc(i64 noundef %conv36) #9
%arrayidx39 = getelementptr inbounds [10002 x ptr], ptr @r_to, i64 0, i64 %indvars.iv299
store ptr %call37, ptr %arrayidx39, align 8, !tbaa !5
br label %for.inc41
for.inc41: ; preds = %if.end, %if.then32
%indvars.iv.next300 = add nuw nsw i64 %indvars.iv299, 1
%exitcond302.not = icmp eq i64 %indvars.iv.next300, %wide.trip.count
br i1 %exitcond302.not, label %for.end43, label %for.body19, !llvm.loop !25
for.end43: ; preds = %for.inc41, %for.cond16.preheader
%shl44 = shl i32 %17, 2
%conv45 = sext i32 %shl44 to i64
tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @hi, i8 0, i64 %conv45, i1 false)
tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @r_hi, i8 0, i64 %conv45, i1 false)
%tobool48.not292 = icmp eq i32 %add.i109, 0
br i1 %tobool48.not292, label %while.end, label %while.body
while.body: ; preds = %for.end43, %while.body
%indvars.iv303 = phi i64 [ %indvars.iv.next304, %while.body ], [ 0, %for.end43 ]
%E.0294 = phi i32 [ %dec, %while.body ], [ %add.i109, %for.end43 ]
%dec = add nsw i32 %E.0294, -1
%45 = or i64 %indvars.iv303, 1
%arrayidx51 = getelementptr inbounds i32, ptr %call2, i64 %indvars.iv303
%46 = load i32, ptr %arrayidx51, align 4, !tbaa !9
%indvars.iv.next304 = add nuw nsw i64 %indvars.iv303, 2
%arrayidx54 = getelementptr inbounds i32, ptr %call2, i64 %45
%47 = load i32, ptr %arrayidx54, align 4, !tbaa !9
%idxprom.i = sext i32 %46 to i64
%arrayidx.i = getelementptr inbounds [10002 x ptr], ptr @to, i64 0, i64 %idxprom.i
%48 = load ptr, ptr %arrayidx.i, align 8, !tbaa !5
%arrayidx2.i = getelementptr inbounds [10002 x i32], ptr @hi, i64 0, i64 %idxprom.i
%49 = load i32, ptr %arrayidx2.i, align 4, !tbaa !9
%inc.i = add nsw i32 %49, 1
store i32 %inc.i, ptr %arrayidx2.i, align 4, !tbaa !9
%idxprom3.i = sext i32 %49 to i64
%arrayidx4.i = getelementptr inbounds i32, ptr %48, i64 %idxprom3.i
store i32 %47, ptr %arrayidx4.i, align 4, !tbaa !9
%idxprom5.i = sext i32 %47 to i64
%arrayidx6.i = getelementptr inbounds [10002 x ptr], ptr @r_to, i64 0, i64 %idxprom5.i
%50 = load ptr, ptr %arrayidx6.i, align 8, !tbaa !5
%arrayidx8.i = getelementptr inbounds [10002 x i32], ptr @r_hi, i64 0, i64 %idxprom5.i
%51 = load i32, ptr %arrayidx8.i, align 4, !tbaa !9
%inc9.i = add nsw i32 %51, 1
store i32 %inc9.i, ptr %arrayidx8.i, align 4, !tbaa !9
%idxprom10.i = sext i32 %51 to i64
%arrayidx11.i = getelementptr inbounds i32, ptr %50, i64 %idxprom10.i
store i32 %46, ptr %arrayidx11.i, align 4, !tbaa !9
%tobool48.not = icmp eq i32 %dec, 0
br i1 %tobool48.not, label %while.end.loopexit, label %while.body, !llvm.loop !26
while.end.loopexit: ; preds = %while.body
%.pre = load i32, ptr @V, align 4, !tbaa !9
br label %while.end
while.end: ; preds = %while.end.loopexit, %for.end43
%52 = phi i32 [ %.pre, %while.end.loopexit ], [ %17, %for.end43 ]
%conv.i = sext i32 %52 to i64
tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @used, i8 0, i64 %conv.i, i1 false)
store i32 0, ptr @vsz, align 4, !tbaa !9
%cmp26.i = icmp sgt i32 %52, 0
br i1 %cmp26.i, label %for.body.i, label %for.end.thread.i
for.end.thread.i: ; preds = %while.end
tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @used, i8 0, i64 %conv.i, i1 false)
br label %scc.exit
for.body.i: ; preds = %while.end, %for.inc.i
%53 = phi i32 [ %56, %for.inc.i ], [ %52, %while.end ]
%indvars.iv.i = phi i64 [ %indvars.iv.next.i, %for.inc.i ], [ 0, %while.end ]
%arrayidx.i188 = getelementptr inbounds [10002 x i8], ptr @used, i64 0, i64 %indvars.iv.i
%54 = load i8, ptr %arrayidx.i188, align 1, !tbaa !11
%tobool.not.i = icmp eq i8 %54, 0
br i1 %tobool.not.i, label %if.then.i, label %for.inc.i
if.then.i: ; preds = %for.body.i
%55 = trunc i64 %indvars.iv.i to i32
tail call void @dfs(i32 noundef %55)
%.pre.i191 = load i32, ptr @V, align 4, !tbaa !9
br label %for.inc.i
for.inc.i: ; preds = %if.then.i, %for.body.i
%56 = phi i32 [ %53, %for.body.i ], [ %.pre.i191, %if.then.i ]
%indvars.iv.next.i = add nuw nsw i64 %indvars.iv.i, 1
%57 = sext i32 %56 to i64
%cmp.i189 = icmp slt i64 %indvars.iv.next.i, %57
br i1 %cmp.i189, label %for.body.i, label %for.end.i, !llvm.loop !15
for.end.i: ; preds = %for.inc.i
%.pre38.i = load i32, ptr @vsz, align 4, !tbaa !9
tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @used, i8 0, i64 %57, i1 false)
%cmp429.i = icmp sgt i32 %.pre38.i, 0
br i1 %cmp429.i, label %for.body6.preheader.i, label %scc.exit
for.body6.preheader.i: ; preds = %for.end.i
%58 = zext i32 %.pre38.i to i64
br label %for.body6.i
for.body6.i: ; preds = %for.inc17.i, %for.body6.preheader.i
%indvars.iv35.i = phi i64 [ %58, %for.body6.preheader.i ], [ %indvars.iv.next36.i, %for.inc17.i ]
%k.030.i = phi i32 [ 0, %for.body6.preheader.i ], [ %k.1.i, %for.inc17.i ]
%indvars.iv.next36.i = add nsw i64 %indvars.iv35.i, -1
%idxprom7.i = and i64 %indvars.iv.next36.i, 4294967295
%arrayidx8.i190 = getelementptr inbounds [10002 x i32], ptr @vs, i64 0, i64 %idxprom7.i
%59 = load i32, ptr %arrayidx8.i190, align 4, !tbaa !9
%idxprom9.i = sext i32 %59 to i64
%arrayidx10.i = getelementptr inbounds [10002 x i8], ptr @used, i64 0, i64 %idxprom9.i
%60 = load i8, ptr %arrayidx10.i, align 1, !tbaa !11
%tobool11.not.i = icmp eq i8 %60, 0
br i1 %tobool11.not.i, label %if.then12.i, label %for.inc17.i
if.then12.i: ; preds = %for.body6.i
%inc15.i = add nsw i32 %k.030.i, 1
tail call void @rdfs(i32 noundef %59, i32 noundef %k.030.i)
br label %for.inc17.i
for.inc17.i: ; preds = %if.then12.i, %for.body6.i
%k.1.i = phi i32 [ %k.030.i, %for.body6.i ], [ %inc15.i, %if.then12.i ]
%cmp4.i = icmp ugt i64 %indvars.iv35.i, 1
br i1 %cmp4.i, label %for.body6.i, label %scc.exit, !llvm.loop !16
scc.exit: ; preds = %for.inc17.i, %for.end.thread.i, %for.end.i
%61 = load ptr, ptr @stdin, align 8, !tbaa !5
%_IO_read_ptr.i.i192 = getelementptr inbounds %struct._IO_FILE, ptr %61, i64 0, i32 1
%62 = load ptr, ptr %_IO_read_ptr.i.i192, align 8, !tbaa !17
%_IO_read_end.i.i193 = getelementptr inbounds %struct._IO_FILE, ptr %61, i64 0, i32 2
%63 = load ptr, ptr %_IO_read_end.i.i193, align 8, !tbaa !21
%cmp.not.i.i194 = icmp ult ptr %62, %63
br i1 %cmp.not.i.i194, label %cond.false.i.i219, label %cond.true.i.i195, !prof !22
cond.true.i.i195: ; preds = %scc.exit
%call.i.i196 = tail call i32 @__uflow(ptr noundef nonnull %61) #8
%.pre14.pre.i197 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %do.body.i201.preheader
cond.false.i.i219: ; preds = %scc.exit
%incdec.ptr.i.i220 = getelementptr inbounds i8, ptr %62, i64 1
store ptr %incdec.ptr.i.i220, ptr %_IO_read_ptr.i.i192, align 8, !tbaa !17
%64 = load i8, ptr %62, align 1, !tbaa !11
%conv3.i.i221 = zext i8 %64 to i32
br label %do.body.i201.preheader
do.body.i201.preheader: ; preds = %cond.false.i.i219, %cond.true.i.i195
%.ph320 = phi ptr [ %61, %cond.false.i.i219 ], [ %.pre14.pre.i197, %cond.true.i.i195 ]
%c.0.i203.ph = phi i32 [ %conv3.i.i221, %cond.false.i.i219 ], [ %call.i.i196, %cond.true.i.i195 ]
br label %do.body.i201
do.body.i201: ; preds = %do.body.i201.preheader, %getchar_unlocked.exit13.i213
%65 = phi ptr [ %69, %getchar_unlocked.exit13.i213 ], [ %.ph320, %do.body.i201.preheader ]
%n.0.i202 = phi i32 [ %add.i206, %getchar_unlocked.exit13.i213 ], [ 0, %do.body.i201.preheader ]
%c.0.i203 = phi i32 [ %cond.i9.i214, %getchar_unlocked.exit13.i213 ], [ %c.0.i203.ph, %do.body.i201.preheader ]
%mul.i204 = mul nsw i32 %n.0.i202, 10
%and.i205 = and i32 %c.0.i203, 15
%add.i206 = add nsw i32 %and.i205, %mul.i204
%_IO_read_ptr.i4.i207 = getelementptr inbounds %struct._IO_FILE, ptr %65, i64 0, i32 1
%66 = load ptr, ptr %_IO_read_ptr.i4.i207, align 8, !tbaa !17
%_IO_read_end.i5.i208 = getelementptr inbounds %struct._IO_FILE, ptr %65, i64 0, i32 2
%67 = load ptr, ptr %_IO_read_end.i5.i208, align 8, !tbaa !21
%cmp.not.i6.i209 = icmp ult ptr %66, %67
br i1 %cmp.not.i6.i209, label %cond.false.i10.i216, label %cond.true.i7.i210, !prof !22
cond.true.i7.i210: ; preds = %do.body.i201
%call.i8.i211 = tail call i32 @__uflow(ptr noundef nonnull %65) #8
%.pre.i212 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %getchar_unlocked.exit13.i213
cond.false.i10.i216: ; preds = %do.body.i201
%incdec.ptr.i11.i217 = getelementptr inbounds i8, ptr %66, i64 1
store ptr %incdec.ptr.i11.i217, ptr %_IO_read_ptr.i4.i207, align 8, !tbaa !17
%68 = load i8, ptr %66, align 1, !tbaa !11
%conv3.i12.i218 = zext i8 %68 to i32
br label %getchar_unlocked.exit13.i213
getchar_unlocked.exit13.i213: ; preds = %cond.false.i10.i216, %cond.true.i7.i210
%69 = phi ptr [ %.pre.i212, %cond.true.i7.i210 ], [ %65, %cond.false.i10.i216 ]
%cond.i9.i214 = phi i32 [ %call.i8.i211, %cond.true.i7.i210 ], [ %conv3.i12.i218, %cond.false.i10.i216 ]
%cmp.i215 = icmp sgt i32 %cond.i9.i214, 47
br i1 %cmp.i215, label %do.body.i201, label %while.cond57.preheader, !llvm.loop !23
while.cond57.preheader: ; preds = %getchar_unlocked.exit13.i213
%tobool59.not295 = icmp eq i32 %add.i206, 0
br i1 %tobool59.not295, label %while.end71, label %while.body60
while.body60: ; preds = %while.cond57.preheader, %in.exit284
%Q.0296 = phi i32 [ %dec58, %in.exit284 ], [ %add.i206, %while.cond57.preheader ]
%dec58 = add nsw i32 %Q.0296, -1
%70 = load ptr, ptr @stdin, align 8, !tbaa !5
%_IO_read_ptr.i.i223 = getelementptr inbounds %struct._IO_FILE, ptr %70, i64 0, i32 1
%71 = load ptr, ptr %_IO_read_ptr.i.i223, align 8, !tbaa !17
%_IO_read_end.i.i224 = getelementptr inbounds %struct._IO_FILE, ptr %70, i64 0, i32 2
%72 = load ptr, ptr %_IO_read_end.i.i224, align 8, !tbaa !21
%cmp.not.i.i225 = icmp ult ptr %71, %72
br i1 %cmp.not.i.i225, label %cond.false.i.i250, label %cond.true.i.i226, !prof !22
cond.true.i.i226: ; preds = %while.body60
%call.i.i227 = tail call i32 @__uflow(ptr noundef nonnull %70) #8
%.pre14.pre.i228 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %do.body.i232.preheader
cond.false.i.i250: ; preds = %while.body60
%incdec.ptr.i.i251 = getelementptr inbounds i8, ptr %71, i64 1
store ptr %incdec.ptr.i.i251, ptr %_IO_read_ptr.i.i223, align 8, !tbaa !17
%73 = load i8, ptr %71, align 1, !tbaa !11
%conv3.i.i252 = zext i8 %73 to i32
br label %do.body.i232.preheader
do.body.i232.preheader: ; preds = %cond.false.i.i250, %cond.true.i.i226
%.ph319 = phi ptr [ %70, %cond.false.i.i250 ], [ %.pre14.pre.i228, %cond.true.i.i226 ]
%c.0.i234.ph = phi i32 [ %conv3.i.i252, %cond.false.i.i250 ], [ %call.i.i227, %cond.true.i.i226 ]
br label %do.body.i232
do.body.i232: ; preds = %do.body.i232.preheader, %getchar_unlocked.exit13.i244
%74 = phi ptr [ %78, %getchar_unlocked.exit13.i244 ], [ %.ph319, %do.body.i232.preheader ]
%n.0.i233 = phi i32 [ %add.i237, %getchar_unlocked.exit13.i244 ], [ 0, %do.body.i232.preheader ]
%c.0.i234 = phi i32 [ %cond.i9.i245, %getchar_unlocked.exit13.i244 ], [ %c.0.i234.ph, %do.body.i232.preheader ]
%mul.i235 = mul nsw i32 %n.0.i233, 10
%and.i236 = and i32 %c.0.i234, 15
%add.i237 = add nsw i32 %and.i236, %mul.i235
%_IO_read_ptr.i4.i238 = getelementptr inbounds %struct._IO_FILE, ptr %74, i64 0, i32 1
%75 = load ptr, ptr %_IO_read_ptr.i4.i238, align 8, !tbaa !17
%_IO_read_end.i5.i239 = getelementptr inbounds %struct._IO_FILE, ptr %74, i64 0, i32 2
%76 = load ptr, ptr %_IO_read_end.i5.i239, align 8, !tbaa !21
%cmp.not.i6.i240 = icmp ult ptr %75, %76
br i1 %cmp.not.i6.i240, label %cond.false.i10.i247, label %cond.true.i7.i241, !prof !22
cond.true.i7.i241: ; preds = %do.body.i232
%call.i8.i242 = tail call i32 @__uflow(ptr noundef nonnull %74) #8
%.pre.i243 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %getchar_unlocked.exit13.i244
cond.false.i10.i247: ; preds = %do.body.i232
%incdec.ptr.i11.i248 = getelementptr inbounds i8, ptr %75, i64 1
store ptr %incdec.ptr.i11.i248, ptr %_IO_read_ptr.i4.i238, align 8, !tbaa !17
%77 = load i8, ptr %75, align 1, !tbaa !11
%conv3.i12.i249 = zext i8 %77 to i32
br label %getchar_unlocked.exit13.i244
getchar_unlocked.exit13.i244: ; preds = %cond.false.i10.i247, %cond.true.i7.i241
%78 = phi ptr [ %.pre.i243, %cond.true.i7.i241 ], [ %74, %cond.false.i10.i247 ]
%cond.i9.i245 = phi i32 [ %call.i8.i242, %cond.true.i7.i241 ], [ %conv3.i12.i249, %cond.false.i10.i247 ]
%cmp.i246 = icmp sgt i32 %cond.i9.i245, 47
br i1 %cmp.i246, label %do.body.i232, label %in.exit253, !llvm.loop !23
in.exit253: ; preds = %getchar_unlocked.exit13.i244
%_IO_read_ptr.i.i254 = getelementptr inbounds %struct._IO_FILE, ptr %78, i64 0, i32 1
%79 = load ptr, ptr %_IO_read_ptr.i.i254, align 8, !tbaa !17
%_IO_read_end.i.i255 = getelementptr inbounds %struct._IO_FILE, ptr %78, i64 0, i32 2
%80 = load ptr, ptr %_IO_read_end.i.i255, align 8, !tbaa !21
%cmp.not.i.i256 = icmp ult ptr %79, %80
br i1 %cmp.not.i.i256, label %cond.false.i.i281, label %cond.true.i.i257, !prof !22
cond.true.i.i257: ; preds = %in.exit253
%call.i.i258 = tail call i32 @__uflow(ptr noundef nonnull %78) #8
%.pre14.pre.i259 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %do.body.i263.preheader
cond.false.i.i281: ; preds = %in.exit253
%incdec.ptr.i.i282 = getelementptr inbounds i8, ptr %79, i64 1
store ptr %incdec.ptr.i.i282, ptr %_IO_read_ptr.i.i254, align 8, !tbaa !17
%81 = load i8, ptr %79, align 1, !tbaa !11
%conv3.i.i283 = zext i8 %81 to i32
br label %do.body.i263.preheader
do.body.i263.preheader: ; preds = %cond.false.i.i281, %cond.true.i.i257
%.ph = phi ptr [ %78, %cond.false.i.i281 ], [ %.pre14.pre.i259, %cond.true.i.i257 ]
%c.0.i265.ph = phi i32 [ %conv3.i.i283, %cond.false.i.i281 ], [ %call.i.i258, %cond.true.i.i257 ]
br label %do.body.i263
do.body.i263: ; preds = %do.body.i263.preheader, %getchar_unlocked.exit13.i275
%82 = phi ptr [ %86, %getchar_unlocked.exit13.i275 ], [ %.ph, %do.body.i263.preheader ]
%n.0.i264 = phi i32 [ %add.i268, %getchar_unlocked.exit13.i275 ], [ 0, %do.body.i263.preheader ]
%c.0.i265 = phi i32 [ %cond.i9.i276, %getchar_unlocked.exit13.i275 ], [ %c.0.i265.ph, %do.body.i263.preheader ]
%mul.i266 = mul nsw i32 %n.0.i264, 10
%and.i267 = and i32 %c.0.i265, 15
%add.i268 = add nsw i32 %and.i267, %mul.i266
%_IO_read_ptr.i4.i269 = getelementptr inbounds %struct._IO_FILE, ptr %82, i64 0, i32 1
%83 = load ptr, ptr %_IO_read_ptr.i4.i269, align 8, !tbaa !17
%_IO_read_end.i5.i270 = getelementptr inbounds %struct._IO_FILE, ptr %82, i64 0, i32 2
%84 = load ptr, ptr %_IO_read_end.i5.i270, align 8, !tbaa !21
%cmp.not.i6.i271 = icmp ult ptr %83, %84
br i1 %cmp.not.i6.i271, label %cond.false.i10.i278, label %cond.true.i7.i272, !prof !22
cond.true.i7.i272: ; preds = %do.body.i263
%call.i8.i273 = tail call i32 @__uflow(ptr noundef nonnull %82) #8
%.pre.i274 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %getchar_unlocked.exit13.i275
cond.false.i10.i278: ; preds = %do.body.i263
%incdec.ptr.i11.i279 = getelementptr inbounds i8, ptr %83, i64 1
store ptr %incdec.ptr.i11.i279, ptr %_IO_read_ptr.i4.i269, align 8, !tbaa !17
%85 = load i8, ptr %83, align 1, !tbaa !11
%conv3.i12.i280 = zext i8 %85 to i32
br label %getchar_unlocked.exit13.i275
getchar_unlocked.exit13.i275: ; preds = %cond.false.i10.i278, %cond.true.i7.i272
%86 = phi ptr [ %.pre.i274, %cond.true.i7.i272 ], [ %82, %cond.false.i10.i278 ]
%cond.i9.i276 = phi i32 [ %call.i8.i273, %cond.true.i7.i272 ], [ %conv3.i12.i280, %cond.false.i10.i278 ]
%cmp.i277 = icmp sgt i32 %cond.i9.i276, 47
br i1 %cmp.i277, label %do.body.i263, label %in.exit284, !llvm.loop !23
in.exit284: ; preds = %getchar_unlocked.exit13.i275
%idxprom63 = sext i32 %add.i237 to i64
%arrayidx64 = getelementptr inbounds [10002 x i32], ptr @cmp, i64 0, i64 %idxprom63
%87 = load i32, ptr %arrayidx64, align 4, !tbaa !9
%idxprom65 = sext i32 %add.i268 to i64
%arrayidx66 = getelementptr inbounds [10002 x i32], ptr @cmp, i64 0, i64 %idxprom65
%88 = load i32, ptr %arrayidx66, align 4, !tbaa !9
%cmp67 = icmp eq i32 %87, %88
%add = select i1 %cmp67, i32 49, i32 48
%89 = load ptr, ptr @stdout, align 8, !tbaa !5
%call.i = tail call i32 @putc(i32 noundef %add, ptr noundef %89)
%90 = load ptr, ptr @stdout, align 8, !tbaa !5
%call.i285 = tail call i32 @putc(i32 noundef 10, ptr noundef %90)
%tobool59.not = icmp eq i32 %dec58, 0
br i1 %tobool59.not, label %while.end71, label %while.body60, !llvm.loop !27
while.end71: ; preds = %in.exit284, %while.cond57.preheader
ret i32 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 #5
declare i32 @__uflow(ptr noundef) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @putc(i32 noundef, ptr nocapture noundef) local_unnamed_addr #7
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: write, inaccessiblemem: none) 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 = { nofree nosync nounwind memory(readwrite, argmem: read, inaccessiblemem: none) 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 = { nofree nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { 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 #6 = { "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 #7 = { 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 #8 = { nounwind }
attributes #9 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}
!17 = !{!18, !6, i64 8}
!18 = !{!"_IO_FILE", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !10, i64 112, !10, i64 116, !19, i64 120, !20, i64 128, !7, i64 130, !7, i64 131, !6, i64 136, !19, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !19, i64 184, !10, i64 192, !7, i64 196}
!19 = !{!"long", !7, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = !{!18, !6, i64 16}
!22 = !{!"branch_weights", i32 2000, i32 1}
!23 = distinct !{!23, !13}
!24 = distinct !{!24, !13}
!25 = distinct !{!25, !13}
!26 = distinct !{!26, !13}
!27 = distinct !{!27, !13}
|
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INF 10000000000
#define mod 1000000007
#define X 100000
#define N 20
#define M 46
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
if(a>b)return b;
return a;
}
ll max(ll a,ll b){
if(a>b)return a;
return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
ll sum=0;
while(a){
a/=10;
sum++;
}
return sum;
}
ll ks(ll a){
ll sum=0;
while(a){
sum+=a%10;
a/=10;
}
return sum;
}
void nCrReady(){
fac[0]=fac[1]=1;
finv[0]=finv[1]=1;
inv[1]=1;
for (ll i=2;i<X;i++){
fac[i]=fac[i-1]*i%mod;
inv[i]=mod-inv[mod%i]*(mod/i)%mod;
finv[i]=finv[i-1]*inv[i]%mod;
}
}
ll nCr(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%mod)%mod;}
int main(void){
double l;
scanf("%lf",&l);
PRF(l*l*l/27);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206254/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206254/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@fac = dso_local local_unnamed_addr global [100000 x i64] zeroinitializer, align 16
@finv = dso_local local_unnamed_addr global [100000 x i64] zeroinitializer, align 16
@inv = dso_local local_unnamed_addr global [100000 x i64] zeroinitializer, align 16
@.str = private unnamed_addr constant [4 x i8] c"%lf\00", align 1
@.str.1 = private unnamed_addr constant [5 x i8] c"%lf\0A\00", align 1
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i64 @usort(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) local_unnamed_addr #0 {
entry:
%0 = load i64, ptr %a, align 8, !tbaa !5
%1 = load i64, ptr %b, align 8, !tbaa !5
%sub = sub nsw i64 %0, %1
ret i64 %sub
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i64 @dsort(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) local_unnamed_addr #0 {
entry:
%0 = load i64, ptr %b, align 8, !tbaa !5
%1 = load i64, ptr %a, align 8, !tbaa !5
%sub = sub nsw i64 %0, %1
ret i64 %sub
}
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read) uwtable
define dso_local i64 @ssort(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) local_unnamed_addr #1 {
entry:
%call = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %a, ptr noundef nonnull dereferenceable(1) %b) #11
%conv = sext i32 %call to i64
ret i64 %conv
}
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable
define dso_local i64 @min(i64 noundef %a, i64 noundef %b) local_unnamed_addr #3 {
entry:
%b.a = tail call i64 @llvm.smin.i64(i64 %a, i64 %b)
ret i64 %b.a
}
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable
define dso_local i64 @max(i64 noundef %a, i64 noundef %b) local_unnamed_addr #3 {
entry:
%a.b = tail call i64 @llvm.smax.i64(i64 %a, i64 %b)
ret i64 %a.b
}
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable
define dso_local i64 @z(i64 noundef %a) local_unnamed_addr #3 {
entry:
%a.b.i = tail call i64 @llvm.abs.i64(i64 %a, i1 true)
ret i64 %a.b.i
}
; Function Attrs: nofree norecurse nosync nounwind memory(none) uwtable
define dso_local i64 @gcd(i64 noundef %a, i64 noundef %b) local_unnamed_addr #4 {
entry:
%tobool.not4 = icmp eq i64 %b, 0
br i1 %tobool.not4, label %return, label %if.else
if.else: ; preds = %entry, %if.else
%b.tr6 = phi i64 [ %rem, %if.else ], [ %b, %entry ]
%a.tr5 = phi i64 [ %b.tr6, %if.else ], [ %a, %entry ]
%rem = srem i64 %a.tr5, %b.tr6
%tobool.not = icmp eq i64 %rem, 0
br i1 %tobool.not, label %return, label %if.else
return: ; preds = %if.else, %entry
%a.tr.lcssa = phi i64 [ %a, %entry ], [ %b.tr6, %if.else ]
ret i64 %a.tr.lcssa
}
; Function Attrs: nofree norecurse nosync nounwind memory(none) uwtable
define dso_local i64 @lcm(i64 noundef %a, i64 noundef %b) local_unnamed_addr #4 {
entry:
%tobool.not4.i = icmp eq i64 %b, 0
br i1 %tobool.not4.i, label %gcd.exit, label %if.else.i
if.else.i: ; preds = %entry, %if.else.i
%b.tr6.i = phi i64 [ %rem.i, %if.else.i ], [ %b, %entry ]
%a.tr5.i = phi i64 [ %b.tr6.i, %if.else.i ], [ %a, %entry ]
%rem.i = srem i64 %a.tr5.i, %b.tr6.i
%tobool.not.i = icmp eq i64 %rem.i, 0
br i1 %tobool.not.i, label %gcd.exit, label %if.else.i
gcd.exit: ; preds = %if.else.i, %entry
%a.tr.lcssa.i = phi i64 [ %a, %entry ], [ %b.tr6.i, %if.else.i ]
%mul = mul nsw i64 %b, %a
%div = sdiv i64 %mul, %a.tr.lcssa.i
ret i64 %div
}
; Function Attrs: nofree norecurse nosync nounwind memory(none) uwtable
define dso_local i64 @kt(i64 noundef %a) local_unnamed_addr #4 {
entry:
%tobool.not3 = icmp eq i64 %a, 0
br i1 %tobool.not3, label %while.end, label %while.body
while.body: ; preds = %entry, %while.body
%sum.05 = phi i64 [ %inc, %while.body ], [ 0, %entry ]
%a.addr.04 = phi i64 [ %div, %while.body ], [ %a, %entry ]
%div = sdiv i64 %a.addr.04, 10
%inc = add nuw nsw i64 %sum.05, 1
%a.addr.04.off = add i64 %a.addr.04, 9
%tobool.not = icmp ult i64 %a.addr.04.off, 19
br i1 %tobool.not, label %while.end, label %while.body, !llvm.loop !9
while.end: ; preds = %while.body, %entry
%sum.0.lcssa = phi i64 [ 0, %entry ], [ %inc, %while.body ]
ret i64 %sum.0.lcssa
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #5
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #5
; Function Attrs: nofree norecurse nosync nounwind memory(none) uwtable
define dso_local i64 @ks(i64 noundef %a) local_unnamed_addr #4 {
entry:
%tobool.not4 = icmp eq i64 %a, 0
br i1 %tobool.not4, label %while.end, label %while.body
while.body: ; preds = %entry, %while.body
%sum.06 = phi i64 [ %add, %while.body ], [ 0, %entry ]
%a.addr.05 = phi i64 [ %div, %while.body ], [ %a, %entry ]
%rem = srem i64 %a.addr.05, 10
%add = add nsw i64 %sum.06, %rem
%div = sdiv i64 %a.addr.05, 10
%a.addr.05.off = add i64 %a.addr.05, 9
%tobool.not = icmp ult i64 %a.addr.05.off, 19
br i1 %tobool.not, label %while.end, label %while.body, !llvm.loop !11
while.end: ; preds = %while.body, %entry
%sum.0.lcssa = phi i64 [ 0, %entry ], [ %add, %while.body ]
ret i64 %sum.0.lcssa
}
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @nCrReady() local_unnamed_addr #6 {
entry:
store i64 1, ptr getelementptr inbounds ([100000 x i64], ptr @fac, i64 0, i64 1), align 8, !tbaa !5
store i64 1, ptr @fac, align 16, !tbaa !5
store i64 1, ptr getelementptr inbounds ([100000 x i64], ptr @finv, i64 0, i64 1), align 8, !tbaa !5
store i64 1, ptr @finv, align 16, !tbaa !5
store i64 1, ptr getelementptr inbounds ([100000 x i64], ptr @inv, i64 0, i64 1), align 8, !tbaa !5
br label %for.body
for.cond.cleanup: ; preds = %for.body
ret void
for.body: ; preds = %entry, %for.body
%0 = phi i64 [ 1, %entry ], [ %rem12, %for.body ]
%1 = phi i64 [ 1, %entry ], [ %rem, %for.body ]
%i.026 = phi i64 [ 2, %entry ], [ %inc, %for.body ]
%mul = mul nsw i64 %1, %i.026
%rem = srem i64 %mul, 1000000007
%arrayidx1 = getelementptr inbounds [100000 x i64], ptr @fac, i64 0, i64 %i.026
store i64 %rem, ptr %arrayidx1, align 8, !tbaa !5
%rem2.rhs.trunc = trunc i64 %i.026 to i32
%rem224 = urem i32 1000000007, %rem2.rhs.trunc
%rem2.zext = zext i32 %rem224 to i64
%arrayidx3 = getelementptr inbounds [100000 x i64], ptr @inv, i64 0, i64 %rem2.zext
%2 = load i64, ptr %arrayidx3, align 8, !tbaa !5
%div25 = udiv i32 1000000007, %rem2.rhs.trunc
%div.zext = zext i32 %div25 to i64
%mul4 = mul nsw i64 %2, %div.zext
%rem5 = srem i64 %mul4, 1000000007
%sub6 = sub nsw i64 1000000007, %rem5
%arrayidx7 = getelementptr inbounds [100000 x i64], ptr @inv, i64 0, i64 %i.026
store i64 %sub6, ptr %arrayidx7, align 8, !tbaa !5
%mul11 = mul nuw nsw i64 %sub6, %0
%rem12 = urem i64 %mul11, 1000000007
%arrayidx13 = getelementptr inbounds [100000 x i64], ptr @finv, i64 0, i64 %i.026
store i64 %rem12, ptr %arrayidx13, align 8, !tbaa !5
%inc = add nuw nsw i64 %i.026, 1
%exitcond.not = icmp eq i64 %inc, 100000
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body, !llvm.loop !12
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local i64 @nCr(i64 noundef %n, i64 noundef %k) local_unnamed_addr #7 {
entry:
%arrayidx = getelementptr inbounds [100000 x i64], ptr @fac, i64 0, i64 %n
%0 = load i64, ptr %arrayidx, align 8, !tbaa !5
%arrayidx1 = getelementptr inbounds [100000 x i64], ptr @finv, i64 0, i64 %k
%1 = load i64, ptr %arrayidx1, align 8, !tbaa !5
%sub = sub nsw i64 %n, %k
%arrayidx2 = getelementptr inbounds [100000 x i64], ptr @finv, i64 0, i64 %sub
%2 = load i64, ptr %arrayidx2, align 8, !tbaa !5
%mul = mul nsw i64 %2, %1
%rem = srem i64 %mul, 1000000007
%mul3 = mul nsw i64 %rem, %0
%rem4 = srem i64 %mul3, 1000000007
ret i64 %rem4
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #8 {
entry:
%l = alloca double, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %l) #12
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %l)
%0 = load double, ptr %l, align 8, !tbaa !13
%mul = fmul double %0, %0
%mul1 = fmul double %0, %mul
%div = fdiv double %mul1, 2.700000e+01
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %div)
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %l) #12
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #9
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #9
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #10
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #10
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.abs.i64(i64, i1 immarg) #10
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 nofree nounwind willreturn memory(argmem: read) 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 = { 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 #3 = { mustprogress nofree nosync nounwind willreturn memory(none) 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 = { nofree norecurse nosync nounwind memory(none) 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 #5 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) 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 #7 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) 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 #8 = { nofree 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 #9 = { 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 #10 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #11 = { nounwind willreturn memory(read) }
attributes #12 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
|
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
int main()
{
double L;
scanf("%lf",&L);
{
printf("%lf\n",(L/3)*(L/3)*(L/3));
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206298/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206298/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [4 x i8] c"%lf\00", align 1
@.str.1 = private unnamed_addr constant [5 x i8] c"%lf\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%L = alloca double, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %L) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %L)
%0 = load double, ptr %L, align 8, !tbaa !5
%div = fdiv double %0, 3.000000e+00
%mul = fmul double %div, %div
%mul3 = fmul double %div, %mul
%call4 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %mul3)
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %L) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main()
{
int X;
scanf("%d",&X);
printf("%.12f\n",(double)X*X*X/27);
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206340/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206340/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [7 x i8] c"%.12f\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%X = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %X) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %X)
%0 = load i32, ptr %X, align 4, !tbaa !5
%conv = sitofp i32 %0 to double
%mul = fmul double %conv, %conv
%mul3 = fmul double %mul, %conv
%div = fdiv double %mul3, 2.700000e+01
%call4 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %div)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %X) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
#include<math.h>
int main()
{
double L,V;
scanf("%lf",&L);
V=pow(L/3,3);
printf("%lf",V);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206384/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206384/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [4 x i8] c"%lf\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%L = alloca double, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %L) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %L)
%0 = load double, ptr %L, align 8, !tbaa !5
%div = fdiv double %0, 3.000000e+00
%call1 = call double @pow(double noundef %div, double noundef 3.000000e+00) #4
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %call1)
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %L) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = { mustprogress nofree nounwind willreturn memory(write) "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 }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main(){
double L;
scanf("%lf", &L);
double max = 0, res = 0;
max = L / 3;
res = max * max * max;
printf("%lf", res);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206427/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206427/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [4 x i8] c"%lf\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%L = alloca double, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %L) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %L)
%0 = load double, ptr %L, align 8, !tbaa !5
%div = fdiv double %0, 3.000000e+00
%mul = fmul double %div, %div
%mul1 = fmul double %div, %mul
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %mul1)
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %L) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
#include<math.h>
int main(void)
{
int l;
double n,sum;
scanf("%d",&l);
n=1.0*l/3;
sum=pow(n,3);
printf("%.12f",sum);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206470/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206470/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [6 x i8] c"%.12f\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%l = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %l) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %l)
%0 = load i32, ptr %l, align 4, !tbaa !5
%conv = sitofp i32 %0 to double
%div = fdiv double %conv, 3.000000e+00
%call1 = call double @pow(double noundef %div, double noundef 3.000000e+00) #4
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %call1)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %l) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = { mustprogress nofree nounwind willreturn memory(write) "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 }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
//3変数の相加相乗平均の関係式より、p+q+r=Lでp, q, rが正数の時に、
//L/3=(p+q+r)/3 >= (pqr)^1/3
//よりVの最大値は(L/3)^3=L*L*L/27.0
int main (void)
{
int L; //unsignedは使わなかった。
scanf ("%d", &L);
double V = ((double) L) * ((double) L) * ((double) L) / 27.0;
printf ("%lf\n", V);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206513/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206513/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [5 x i8] c"%lf\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%L = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %L) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %L)
%0 = load i32, ptr %L, align 4, !tbaa !5
%conv = sitofp i32 %0 to double
%mul = fmul double %conv, %conv
%mul3 = fmul double %mul, %conv
%div = fdiv double %mul3, 2.700000e+01
%call4 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %div)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %L) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(void){
int l;
scanf("%d",&l);
long double num = l/3.0l;
printf("%Lf",num*num*num);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206557/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206557/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%Lf\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%l = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %l) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %l)
%0 = load i32, ptr %l, align 4, !tbaa !5
%conv = sitofp i32 %0 to x86_fp80
%div = fdiv x86_fp80 %conv, 0xK4000C000000000000000
%mul = fmul x86_fp80 %div, %div
%mul1 = fmul x86_fp80 %div, %mul
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, x86_fp80 noundef %mul1)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %l) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <stdlib.h>
struct node{
int key;
struct node *left;
struct node *right;
struct node *parent;
};
typedef struct node* Node;
Node rootnode,NIL;
Node getMinimum(Node node){
while(node->left!=NIL)
node=node->left;
return node;
}
Node getSuccessor(Node node){
Node delete=node->parent;
if(node->right!=NIL)
return getMinimum(node->right);
while(delete!=NIL && node==delete->right){
node=delete;
delete=delete->parent;
}
return delete;
}
Node Find(Node node,int key){
while(node!=NIL && node->key!=key){
if(node->key<key)
node=node->right;
else
node=node->left;
}
return node;
}
void Insert(int key){
Node node=rootnode,z,y=NIL;
z=(Node)malloc(sizeof(struct node));
z->key=key;
z->left=NIL;
z->right=NIL;
while(node!=NIL){
y=node;
if(key>node->key)
node=node->right;
else
node=node->left;
}
z->parent=y;
if(y==NIL)rootnode=z;
else{
if(key>y->key)
y->right=z;
else
y->left=z;
}
}
void Preorder(Node node){
if(node!=NIL){
printf(" %d",node->key);
Preorder(node->left);
Preorder(node->right);
}
}
void Inorder(Node node){
if(node->left!=NIL)
Inorder(node->left);
printf(" %d",node->key);
if(node->right!=NIL)
Inorder(node->right);
}
void Delete(Node node){
Node delete;
Node child;
if(node->left==NIL || node->right==NIL)
delete=node;
else
delete=getSuccessor(node);
//setting child
if(delete->left!=NIL)
child=delete->left;
else
child=delete->right;
if(child!=NIL)
child->parent=delete->parent;
//if deletenode is rootnode
if(delete->parent==NIL)
rootnode=child;
//deletenode is not rootnode
else{
if(delete->parent->left==delete)
delete->parent->left=child;
else
delete->parent->right=child;
}
if(delete!=node)
node->key=delete->key;
free(delete);
}
int main(void){
int n,i,key;
char command[7];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",command);
if(command[0]=='i'){
scanf("%d",&key);
Insert(key);
}
else if(command[0]=='p'){
Inorder(rootnode);
printf("\n");
Preorder(rootnode);
printf("\n");
}
else if(command[0]=='f'){
scanf("%d",&key);
if(Find(rootnode,key)!=NIL)
printf("yes\n");
else printf("no\n");
}
else if(command[0]=='d'){
scanf("%d",&key);
Delete(Find(rootnode,key));
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206607/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206607/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { i32, ptr, ptr, ptr }
@NIL = dso_local local_unnamed_addr global ptr null, align 8
@rootnode = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @getMinimum(ptr noundef readonly %node) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%node.addr.0 = phi ptr [ %node, %entry ], [ %1, %while.cond ]
%left = getelementptr inbounds %struct.node, ptr %node.addr.0, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !9
%cmp.not = icmp eq ptr %1, %0
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !12
while.end: ; preds = %while.cond
ret ptr %node.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @getSuccessor(ptr noundef readonly %node) local_unnamed_addr #0 {
entry:
%right = getelementptr inbounds %struct.node, ptr %node, i64 0, i32 2
%0 = load ptr, ptr %right, align 8, !tbaa !14
%1 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not = icmp eq ptr %0, %1
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%node.addr.0.i = phi ptr [ %2, %while.cond.i ], [ %0, %entry ]
%left.i = getelementptr inbounds %struct.node, ptr %node.addr.0.i, i64 0, i32 1
%2 = load ptr, ptr %left.i, align 8, !tbaa !9
%cmp.not.i = icmp eq ptr %2, %1
br i1 %cmp.not.i, label %cleanup, label %while.cond.i, !llvm.loop !12
while.cond: ; preds = %entry, %land.rhs
%node.addr.0 = phi ptr [ %delete.0, %land.rhs ], [ %node, %entry ]
%delete.0.in = getelementptr inbounds %struct.node, ptr %node.addr.0, i64 0, i32 3
%delete.0 = load ptr, ptr %delete.0.in, align 8, !tbaa !15
%cmp2.not = icmp eq ptr %delete.0, %0
br i1 %cmp2.not, label %cleanup, label %land.rhs
land.rhs: ; preds = %while.cond
%right3 = getelementptr inbounds %struct.node, ptr %delete.0, i64 0, i32 2
%3 = load ptr, ptr %right3, align 8, !tbaa !14
%cmp4 = icmp eq ptr %node.addr.0, %3
br i1 %cmp4, label %while.cond, label %cleanup, !llvm.loop !16
cleanup: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi ptr [ %delete.0, %land.rhs ], [ %0, %while.cond ], [ %node.addr.0.i, %while.cond.i ]
ret ptr %retval.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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @Find(ptr noundef readonly %node, i32 noundef %key) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not11 = icmp eq ptr %0, %node
br i1 %cmp.not11, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%node.addr.012 = phi ptr [ %node.addr.1, %while.body ], [ %node, %entry ]
%1 = load i32, ptr %node.addr.012, align 8, !tbaa !17
%cmp2.not = icmp eq i32 %1, %key
br i1 %cmp2.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp4 = icmp slt i32 %1, %key
%right = getelementptr inbounds %struct.node, ptr %node.addr.012, i64 0, i32 2
%left = getelementptr inbounds %struct.node, ptr %node.addr.012, i64 0, i32 1
%node.addr.1.in = select i1 %cmp4, ptr %right, ptr %left
%node.addr.1 = load ptr, ptr %node.addr.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %node.addr.1, %0
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !18
while.end: ; preds = %land.rhs, %while.body, %entry
%node.addr.0.lcssa = phi ptr [ %node, %entry ], [ %0, %while.body ], [ %node.addr.012, %land.rhs ]
ret ptr %node.addr.0.lcssa
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @Insert(i32 noundef %key) local_unnamed_addr #2 {
entry:
%0 = load ptr, ptr @rootnode, align 8, !tbaa !5
%1 = load ptr, ptr @NIL, align 8, !tbaa !5
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
store i32 %key, ptr %call, align 8, !tbaa !17
%left = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 1
store ptr %1, ptr %left, align 8, !tbaa !9
%right = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr %1, ptr %right, align 8, !tbaa !14
%cmp.not33 = icmp eq ptr %0, %1
br i1 %cmp.not33, label %while.end, label %while.body
while.body: ; preds = %entry, %while.body
%node.034 = phi ptr [ %node.1, %while.body ], [ %0, %entry ]
%2 = load i32, ptr %node.034, align 8, !tbaa !17
%cmp3 = icmp slt i32 %2, %key
%right4 = getelementptr inbounds %struct.node, ptr %node.034, i64 0, i32 2
%left5 = getelementptr inbounds %struct.node, ptr %node.034, i64 0, i32 1
%node.1.in = select i1 %cmp3, ptr %right4, ptr %left5
%node.1 = load ptr, ptr %node.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %node.1, %1
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !19
while.end: ; preds = %while.body, %entry
%y.0.lcssa = phi ptr [ %0, %entry ], [ %node.034, %while.body ]
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store ptr %y.0.lcssa, ptr %parent, align 8, !tbaa !15
%cmp6 = icmp eq ptr %y.0.lcssa, %1
br i1 %cmp6, label %if.end16, label %if.else8
if.else8: ; preds = %while.end
%3 = load i32, ptr %y.0.lcssa, align 8, !tbaa !17
%cmp10 = icmp slt i32 %3, %key
br i1 %cmp10, label %if.then11, label %if.else13
if.then11: ; preds = %if.else8
%right12 = getelementptr inbounds %struct.node, ptr %y.0.lcssa, i64 0, i32 2
br label %if.end16
if.else13: ; preds = %if.else8
%left14 = getelementptr inbounds %struct.node, ptr %y.0.lcssa, i64 0, i32 1
br label %if.end16
if.end16: ; preds = %while.end, %if.then11, %if.else13
%right12.sink = phi ptr [ %right12, %if.then11 ], [ %left14, %if.else13 ], [ @rootnode, %while.end ]
store ptr %call, ptr %right12.sink, align 8, !tbaa !5
ret void
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind uwtable
define dso_local void @Preorder(ptr noundef readonly %node) local_unnamed_addr #2 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not4 = icmp eq ptr %0, %node
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%node.tr5 = phi ptr [ %3, %if.then ], [ %node, %entry ]
%1 = load i32, ptr %node.tr5, align 8, !tbaa !17
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%left = getelementptr inbounds %struct.node, ptr %node.tr5, i64 0, i32 1
%2 = load ptr, ptr %left, align 8, !tbaa !9
tail call void @Preorder(ptr noundef %2)
%right = getelementptr inbounds %struct.node, ptr %node.tr5, i64 0, i32 2
%3 = load ptr, ptr %right, align 8, !tbaa !14
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not = icmp eq ptr %4, %3
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @Inorder(ptr nocapture noundef readonly %node) local_unnamed_addr #2 {
entry:
%.pre = load ptr, ptr @NIL, align 8, !tbaa !5
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%0 = phi ptr [ %.pre, %entry ], [ %4, %if.end ]
%node.tr = phi ptr [ %node, %entry ], [ %3, %if.end ]
%left = getelementptr inbounds %struct.node, ptr %node.tr, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !9
%cmp.not = icmp eq ptr %1, %0
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @Inorder(ptr noundef %1)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%2 = load i32, ptr %node.tr, align 8, !tbaa !17
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %2)
%right = getelementptr inbounds %struct.node, ptr %node.tr, i64 0, i32 2
%3 = load ptr, ptr %right, align 8, !tbaa !14
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp2.not = icmp eq ptr %3, %4
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nounwind uwtable
define dso_local void @Delete(ptr noundef %node) local_unnamed_addr #5 {
entry:
%left = getelementptr inbounds %struct.node, ptr %node, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !9
%1 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %0, %1
br i1 %cmp, label %if.end, label %lor.lhs.false
lor.lhs.false: ; preds = %entry
%right = getelementptr inbounds %struct.node, ptr %node, i64 0, i32 2
%2 = load ptr, ptr %right, align 8, !tbaa !14
%cmp1 = icmp eq ptr %2, %1
br i1 %cmp1, label %if.end, label %while.cond.i.i
while.cond.i.i: ; preds = %lor.lhs.false, %while.cond.i.i
%node.addr.0.i.i = phi ptr [ %3, %while.cond.i.i ], [ %2, %lor.lhs.false ]
%left.i.i = getelementptr inbounds %struct.node, ptr %node.addr.0.i.i, i64 0, i32 1
%3 = load ptr, ptr %left.i.i, align 8, !tbaa !9
%cmp.not.i.i = icmp eq ptr %3, %1
br i1 %cmp.not.i.i, label %if.else6, label %while.cond.i.i, !llvm.loop !12
if.end: ; preds = %entry, %lor.lhs.false
%cmp3.not = icmp eq ptr %0, %1
br i1 %cmp3.not, label %if.else6, label %if.end8
if.else6: ; preds = %while.cond.i.i, %if.end
%delete.057 = phi ptr [ %node, %if.end ], [ %node.addr.0.i.i, %while.cond.i.i ]
%right7 = getelementptr inbounds %struct.node, ptr %delete.057, i64 0, i32 2
%4 = load ptr, ptr %right7, align 8, !tbaa !14
br label %if.end8
if.end8: ; preds = %if.end, %if.else6
%delete.056 = phi ptr [ %delete.057, %if.else6 ], [ %node, %if.end ]
%child.0 = phi ptr [ %4, %if.else6 ], [ %0, %if.end ]
%cmp9.not = icmp eq ptr %child.0, %1
br i1 %cmp9.not, label %if.end12, label %if.then10
if.then10: ; preds = %if.end8
%parent = getelementptr inbounds %struct.node, ptr %delete.056, i64 0, i32 3
%5 = load ptr, ptr %parent, align 8, !tbaa !15
%parent11 = getelementptr inbounds %struct.node, ptr %child.0, i64 0, i32 3
store ptr %5, ptr %parent11, align 8, !tbaa !15
br label %if.end12
if.end12: ; preds = %if.then10, %if.end8
%parent13 = getelementptr inbounds %struct.node, ptr %delete.056, i64 0, i32 3
%6 = load ptr, ptr %parent13, align 8, !tbaa !15
%cmp14 = icmp eq ptr %6, %1
br i1 %cmp14, label %if.end27, label %if.else16
if.else16: ; preds = %if.end12
%left18 = getelementptr inbounds %struct.node, ptr %6, i64 0, i32 1
%7 = load ptr, ptr %left18, align 8, !tbaa !9
%cmp19 = icmp eq ptr %7, %delete.056
%right25 = getelementptr inbounds %struct.node, ptr %6, i64 0, i32 2
%spec.select = select i1 %cmp19, ptr %left18, ptr %right25
br label %if.end27
if.end27: ; preds = %if.else16, %if.end12
%left18.sink = phi ptr [ @rootnode, %if.end12 ], [ %spec.select, %if.else16 ]
store ptr %child.0, ptr %left18.sink, align 8, !tbaa !5
%cmp28.not = icmp eq ptr %delete.056, %node
br i1 %cmp28.not, label %if.end31, label %if.then29
if.then29: ; preds = %if.end27
%8 = load i32, ptr %delete.056, align 8, !tbaa !17
store i32 %8, ptr %node, align 8, !tbaa !17
br label %if.end31
if.end31: ; preds = %if.then29, %if.end27
tail call void @free(ptr noundef nonnull %delete.056) #9
ret void
}
; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #6
; Function Attrs: nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #5 {
entry:
%n = alloca i32, align 4
%key = alloca i32, align 4
%command = alloca [7 x i8], align 1
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #9
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %key) #9
call void @llvm.lifetime.start.p0(i64 7, ptr nonnull %command) #9
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !20
%cmp66 = icmp sgt i32 %0, 0
br i1 %cmp66, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.067 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %command)
%1 = load i8, ptr %command, align 1, !tbaa !21
switch i8 %1, label %for.inc [
i8 105, label %if.then
i8 112, label %if.then9
i8 102, label %if.then17
i8 100, label %if.then31
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %key)
%2 = load i32, ptr %key, align 4, !tbaa !20
%3 = load ptr, ptr @rootnode, align 8, !tbaa !5
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
store i32 %2, ptr %call.i, align 8, !tbaa !17
%left.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 1
store ptr %4, ptr %left.i, align 8, !tbaa !9
%right.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
store ptr %4, ptr %right.i, align 8, !tbaa !14
%cmp.not33.i = icmp eq ptr %3, %4
br i1 %cmp.not33.i, label %while.end.i, label %while.body.i
while.body.i: ; preds = %if.then, %while.body.i
%node.034.i = phi ptr [ %node.1.i, %while.body.i ], [ %3, %if.then ]
%5 = load i32, ptr %node.034.i, align 8, !tbaa !17
%cmp3.i = icmp slt i32 %5, %2
%right4.i = getelementptr inbounds %struct.node, ptr %node.034.i, i64 0, i32 2
%left5.i = getelementptr inbounds %struct.node, ptr %node.034.i, i64 0, i32 1
%node.1.in.i = select i1 %cmp3.i, ptr %right4.i, ptr %left5.i
%node.1.i = load ptr, ptr %node.1.in.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %node.1.i, %4
br i1 %cmp.not.i, label %while.end.i, label %while.body.i, !llvm.loop !19
while.end.i: ; preds = %while.body.i, %if.then
%y.0.lcssa.i = phi ptr [ %3, %if.then ], [ %node.034.i, %while.body.i ]
%parent.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store ptr %y.0.lcssa.i, ptr %parent.i, align 8, !tbaa !15
%cmp6.i = icmp eq ptr %y.0.lcssa.i, %4
br i1 %cmp6.i, label %Insert.exit, label %if.else8.i
if.else8.i: ; preds = %while.end.i
%6 = load i32, ptr %y.0.lcssa.i, align 8, !tbaa !17
%cmp10.i = icmp slt i32 %6, %2
br i1 %cmp10.i, label %if.then11.i, label %if.else13.i
if.then11.i: ; preds = %if.else8.i
%right12.i = getelementptr inbounds %struct.node, ptr %y.0.lcssa.i, i64 0, i32 2
br label %Insert.exit
if.else13.i: ; preds = %if.else8.i
%left14.i = getelementptr inbounds %struct.node, ptr %y.0.lcssa.i, i64 0, i32 1
br label %Insert.exit
Insert.exit: ; preds = %while.end.i, %if.then11.i, %if.else13.i
%right12.sink.i = phi ptr [ %right12.i, %if.then11.i ], [ %left14.i, %if.else13.i ], [ @rootnode, %while.end.i ]
store ptr %call.i, ptr %right12.sink.i, align 8, !tbaa !5
br label %for.inc
if.then9: ; preds = %for.body
%7 = load ptr, ptr @rootnode, align 8, !tbaa !5
call void @Inorder(ptr noundef %7)
%putchar = call i32 @putchar(i32 10)
%8 = load ptr, ptr @rootnode, align 8, !tbaa !5
call void @Preorder(ptr noundef %8)
%putchar40 = call i32 @putchar(i32 10)
br label %for.inc
if.then17: ; preds = %for.body
%call18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %key)
%9 = load ptr, ptr @rootnode, align 8, !tbaa !5
%10 = load i32, ptr %key, align 4, !tbaa !20
%11 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not11.i = icmp eq ptr %11, %9
br i1 %cmp.not11.i, label %Find.exit, label %land.rhs.i
land.rhs.i: ; preds = %if.then17, %while.body.i41
%node.addr.012.i = phi ptr [ %node.addr.1.i, %while.body.i41 ], [ %9, %if.then17 ]
%12 = load i32, ptr %node.addr.012.i, align 8, !tbaa !17
%cmp2.not.i = icmp eq i32 %12, %10
br i1 %cmp2.not.i, label %Find.exit, label %while.body.i41
while.body.i41: ; preds = %land.rhs.i
%cmp4.i = icmp slt i32 %12, %10
%right.i42 = getelementptr inbounds %struct.node, ptr %node.addr.012.i, i64 0, i32 2
%left.i43 = getelementptr inbounds %struct.node, ptr %node.addr.012.i, i64 0, i32 1
%node.addr.1.in.i = select i1 %cmp4.i, ptr %right.i42, ptr %left.i43
%node.addr.1.i = load ptr, ptr %node.addr.1.in.i, align 8, !tbaa !5
%cmp.not.i44 = icmp eq ptr %node.addr.1.i, %11
br i1 %cmp.not.i44, label %if.else24, label %land.rhs.i, !llvm.loop !18
Find.exit: ; preds = %land.rhs.i, %if.then17
%node.addr.0.lcssa.i = phi ptr [ %9, %if.then17 ], [ %node.addr.012.i, %land.rhs.i ]
%cmp20.not = icmp eq ptr %node.addr.0.lcssa.i, %11
br i1 %cmp20.not, label %if.else24, label %if.then22
if.then22: ; preds = %Find.exit
%puts39 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else24: ; preds = %while.body.i41, %Find.exit
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then31: ; preds = %for.body
%call32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %key)
%13 = load ptr, ptr @rootnode, align 8, !tbaa !5
%14 = load i32, ptr %key, align 4, !tbaa !20
%15 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not11.i46 = icmp eq ptr %15, %13
br i1 %cmp.not11.i46, label %Find.exit59, label %land.rhs.i47
land.rhs.i47: ; preds = %if.then31, %while.body.i50
%node.addr.012.i48 = phi ptr [ %node.addr.1.i55, %while.body.i50 ], [ %13, %if.then31 ]
%16 = load i32, ptr %node.addr.012.i48, align 8, !tbaa !17
%cmp2.not.i49 = icmp eq i32 %16, %14
br i1 %cmp2.not.i49, label %Find.exit59, label %while.body.i50
while.body.i50: ; preds = %land.rhs.i47
%cmp4.i51 = icmp slt i32 %16, %14
%right.i52 = getelementptr inbounds %struct.node, ptr %node.addr.012.i48, i64 0, i32 2
%left.i53 = getelementptr inbounds %struct.node, ptr %node.addr.012.i48, i64 0, i32 1
%node.addr.1.in.i54 = select i1 %cmp4.i51, ptr %right.i52, ptr %left.i53
%node.addr.1.i55 = load ptr, ptr %node.addr.1.in.i54, align 8, !tbaa !5
%cmp.not.i56 = icmp eq ptr %node.addr.1.i55, %15
br i1 %cmp.not.i56, label %Find.exit59, label %land.rhs.i47, !llvm.loop !18
Find.exit59: ; preds = %land.rhs.i47, %while.body.i50, %if.then31
%node.addr.0.lcssa.i58 = phi ptr [ %13, %if.then31 ], [ %node.addr.012.i48, %land.rhs.i47 ], [ %15, %while.body.i50 ]
%left.i60 = getelementptr inbounds %struct.node, ptr %node.addr.0.lcssa.i58, i64 0, i32 1
%17 = load ptr, ptr %left.i60, align 8, !tbaa !9
%cmp.i = icmp eq ptr %17, %15
br i1 %cmp.i, label %if.else6.i, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %Find.exit59
%right.i61 = getelementptr inbounds %struct.node, ptr %node.addr.0.lcssa.i58, i64 0, i32 2
%18 = load ptr, ptr %right.i61, align 8, !tbaa !14
%cmp1.i = icmp eq ptr %18, %15
br i1 %cmp1.i, label %if.end8.i, label %while.cond.i.i.i
while.cond.i.i.i: ; preds = %lor.lhs.false.i, %while.cond.i.i.i
%node.addr.0.i.i.i = phi ptr [ %19, %while.cond.i.i.i ], [ %18, %lor.lhs.false.i ]
%left.i.i.i = getelementptr inbounds %struct.node, ptr %node.addr.0.i.i.i, i64 0, i32 1
%19 = load ptr, ptr %left.i.i.i, align 8, !tbaa !9
%cmp.not.i.i.i = icmp eq ptr %19, %15
br i1 %cmp.not.i.i.i, label %if.else6.i, label %while.cond.i.i.i, !llvm.loop !12
if.else6.i: ; preds = %while.cond.i.i.i, %Find.exit59
%delete.057.i = phi ptr [ %node.addr.0.lcssa.i58, %Find.exit59 ], [ %node.addr.0.i.i.i, %while.cond.i.i.i ]
%right7.i = getelementptr inbounds %struct.node, ptr %delete.057.i, i64 0, i32 2
%20 = load ptr, ptr %right7.i, align 8, !tbaa !14
br label %if.end8.i
if.end8.i: ; preds = %lor.lhs.false.i, %if.else6.i
%delete.056.i = phi ptr [ %delete.057.i, %if.else6.i ], [ %node.addr.0.lcssa.i58, %lor.lhs.false.i ]
%child.0.i = phi ptr [ %20, %if.else6.i ], [ %17, %lor.lhs.false.i ]
%cmp9.not.i = icmp eq ptr %child.0.i, %15
br i1 %cmp9.not.i, label %if.end12.i, label %if.then10.i
if.then10.i: ; preds = %if.end8.i
%parent.i62 = getelementptr inbounds %struct.node, ptr %delete.056.i, i64 0, i32 3
%21 = load ptr, ptr %parent.i62, align 8, !tbaa !15
%parent11.i = getelementptr inbounds %struct.node, ptr %child.0.i, i64 0, i32 3
store ptr %21, ptr %parent11.i, align 8, !tbaa !15
br label %if.end12.i
if.end12.i: ; preds = %if.then10.i, %if.end8.i
%parent13.i = getelementptr inbounds %struct.node, ptr %delete.056.i, i64 0, i32 3
%22 = load ptr, ptr %parent13.i, align 8, !tbaa !15
%cmp14.i = icmp eq ptr %22, %15
br i1 %cmp14.i, label %if.end27.i, label %if.else16.i
if.else16.i: ; preds = %if.end12.i
%left18.i = getelementptr inbounds %struct.node, ptr %22, i64 0, i32 1
%23 = load ptr, ptr %left18.i, align 8, !tbaa !9
%cmp19.i = icmp eq ptr %23, %delete.056.i
%right25.i = getelementptr inbounds %struct.node, ptr %22, i64 0, i32 2
%spec.select.i = select i1 %cmp19.i, ptr %left18.i, ptr %right25.i
br label %if.end27.i
if.end27.i: ; preds = %if.else16.i, %if.end12.i
%left18.sink.i = phi ptr [ @rootnode, %if.end12.i ], [ %spec.select.i, %if.else16.i ]
store ptr %child.0.i, ptr %left18.sink.i, align 8, !tbaa !5
%cmp28.not.i = icmp eq ptr %delete.056.i, %node.addr.0.lcssa.i58
br i1 %cmp28.not.i, label %Delete.exit, label %if.then29.i
if.then29.i: ; preds = %if.end27.i
%24 = load i32, ptr %delete.056.i, align 8, !tbaa !17
store i32 %24, ptr %node.addr.0.lcssa.i58, align 8, !tbaa !17
br label %Delete.exit
Delete.exit: ; preds = %if.end27.i, %if.then29.i
call void @free(ptr noundef nonnull %delete.056.i) #9
br label %for.inc
for.inc: ; preds = %for.body, %Insert.exit, %if.else24, %if.then22, %Delete.exit, %if.then9
%inc = add nuw nsw i32 %i.067, 1
%25 = load i32, ptr %n, align 4, !tbaa !20
%cmp = icmp slt i32 %inc, %25
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !22
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 7, ptr nonnull %command) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %key) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #9
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #7
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #7
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 = { nofree 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 = { 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 #4 = { 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 #5 = { 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 #6 = { 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 #7 = { nofree nounwind }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"node", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !6, i64 16}
!15 = !{!10, !6, i64 24}
!16 = distinct !{!16, !13}
!17 = !{!10, !11, i64 0}
!18 = distinct !{!18, !13}
!19 = distinct !{!19, !13}
!20 = !{!11, !11, i64 0}
!21 = !{!7, !7, i64 0}
!22 = distinct !{!22, !13}
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node {
int key;
struct node *parent, *left, *right;
};
struct node *tree, *z;
void insert(struct node *T, struct node *z);
struct node *find(int key);
void delete(int key);
void inorder(struct node *p);
void preorder(struct node *p);
int main(int argc, char*argv[])
{
int m, i, key;
char cmd[6 + 1];
tree = NULL;
scanf("%d", &m);
for (i = 0; i < m; i++) {
scanf("%s", cmd);
if (!strcmp(cmd, "insert")) {
z = (struct node *)malloc(sizeof(struct node));
scanf("%d", &(z->key));
z->parent = NULL;
z->left = NULL;
z->right = NULL;
insert(tree, z);
} else if (!strcmp(cmd, "print")) {
inorder(tree);
printf("\n");
preorder(tree);
printf("\n");
} else if (!strcmp(cmd, "find")) {
scanf("%d", &key);
if (find(key) != NULL) printf("yes\n");
else printf("no\n");
} else if (!strcmp(cmd, "delete")) {
scanf("%d", &key);
delete(key);
}
}
return 0;
}
void insert(struct node *T, struct node *z)
{
struct node *x, *y;
y = NULL;
x = tree;
while (x != NULL) {
y = x;
if (z->key < x->key) x = x->left;
else x = x->right;
}
z->parent = y;
if (y == NULL) tree = z;
else if (z->key < y->key) y->left = z;
else y->right = z;
}
struct node *find(int key)
{
struct node *x = tree;
if (x == NULL) {
return NULL;
}
while (x != NULL) {
if (x->key == key) {
return x;
} else if (x->key < key) x = x->right;
else x = x->left;
}
return NULL;
}
void delete(int key)
{
struct node *x = find(key);
struct node *y;
if (x == NULL) {
printf("error\n");
return;
}
if (x->left == NULL && x->right == NULL) {
if (x->parent->key < x->key) x->parent->right = NULL;
else x->parent->left = NULL;
free(x);
} else if (x->left != NULL && x->right != NULL) {
y = x->right;
while (y->left != NULL) y = y->left;
x->key = y->key;
if (y->right != NULL) {
if (y->parent->key == y->key) y->parent->right = y->right;
else y->parent->left = y->right;
y->right->parent = y->parent;
} else {
if (y->parent->key == y->key) y->parent->right = NULL;
else y->parent->left = NULL;
}
free(y);
} else {
if (x->left != NULL) {
if (x->parent->key < x->key) x->parent->right = x->left;
else x->parent->left = x->left;
x->left->parent = x->parent;
} else {
if (x->parent->key < x->key) x->parent->right = x->right;
else x->parent->left = x->right;
x->right->parent = x->parent;
}
free(x);
}
}
void inorder(struct node *p)
{
if (p->left != NULL) inorder(p->left);
printf(" %d", p->key);
if (p->right != NULL) inorder(p->right);
}
void preorder(struct node *p)
{
printf(" %d", p->key);
if (p->left != NULL) preorder(p->left);
if (p->right != NULL) preorder(p->right);
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206650/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206650/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { i32, ptr, ptr, ptr }
@tree = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.2 = private unnamed_addr constant [7 x i8] c"insert\00", align 1
@z = dso_local local_unnamed_addr global ptr null, align 8
@.str.3 = private unnamed_addr constant [6 x i8] c"print\00", align 1
@.str.5 = private unnamed_addr constant [5 x i8] c"find\00", align 1
@.str.8 = private unnamed_addr constant [7 x i8] c"delete\00", align 1
@.str.10 = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.11 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
@str.12 = private unnamed_addr constant [6 x i8] c"error\00", align 1
; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %argc, ptr nocapture noundef readnone %argv) local_unnamed_addr #0 {
entry:
%m = alloca i32, align 4
%key = alloca i32, align 4
%cmd = alloca [7 x i8], align 1
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %m) #11
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %key) #11
call void @llvm.lifetime.start.p0(i64 7, ptr nonnull %cmd) #11
store ptr null, ptr @tree, align 8, !tbaa !5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %m)
%0 = load i32, ptr %m, align 4, !tbaa !9
%cmp47 = icmp sgt i32 %0, 0
br i1 %cmp47, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.048 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %cmd)
%bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(7) %cmd, ptr noundef nonnull dereferenceable(7) @.str.2, i64 7)
%tobool.not = icmp eq i32 %bcmp, 0
br i1 %tobool.not, label %if.then, label %if.else
if.then: ; preds = %for.body
%call4 = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #12
store ptr %call4, ptr @z, align 8, !tbaa !5
%call6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef %call4)
%1 = load ptr, ptr @z, align 8, !tbaa !5
%parent = getelementptr inbounds %struct.node, ptr %1, i64 0, i32 1
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %parent, i8 0, i64 24, i1 false)
%x.028.i = load ptr, ptr @tree, align 8, !tbaa !5
%cmp.not29.i = icmp eq ptr %x.028.i, null
br i1 %cmp.not29.i, label %insert.exit, label %while.body.lr.ph.i
while.body.lr.ph.i: ; preds = %if.then
%2 = load i32, ptr %1, align 8, !tbaa !11
br label %while.body.i
while.body.i: ; preds = %while.body.i, %while.body.lr.ph.i
%x.030.i = phi ptr [ %x.028.i, %while.body.lr.ph.i ], [ %x.0.i, %while.body.i ]
%3 = load i32, ptr %x.030.i, align 8, !tbaa !11
%cmp2.i = icmp slt i32 %2, %3
%left.i = getelementptr inbounds %struct.node, ptr %x.030.i, i64 0, i32 2
%right.i = getelementptr inbounds %struct.node, ptr %x.030.i, i64 0, i32 3
%x.1.in.i = select i1 %cmp2.i, ptr %left.i, ptr %right.i
%x.0.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %x.0.i, null
br i1 %cmp.not.i, label %insert.exit, label %while.body.i, !llvm.loop !13
insert.exit: ; preds = %while.body.i, %if.then
%storemerge = phi ptr [ null, %if.then ], [ %x.030.i, %while.body.i ]
%left10.sink.i = phi ptr [ @tree, %if.then ], [ %x.1.in.i, %while.body.i ]
store ptr %storemerge, ptr %parent, align 8, !tbaa !15
store ptr %1, ptr %left10.sink.i, align 8, !tbaa !5
br label %for.inc
if.else: ; preds = %for.body
%bcmp36 = call i32 @bcmp(ptr noundef nonnull dereferenceable(6) %cmd, ptr noundef nonnull dereferenceable(6) @.str.3, i64 6)
%tobool9.not = icmp eq i32 %bcmp36, 0
br i1 %tobool9.not, label %if.then10, label %if.else13
if.then10: ; preds = %if.else
%4 = load ptr, ptr @tree, align 8, !tbaa !5
call void @inorder(ptr noundef %4)
%putchar = call i32 @putchar(i32 10)
%5 = load ptr, ptr @tree, align 8, !tbaa !5
call void @preorder(ptr noundef %5)
%putchar37 = call i32 @putchar(i32 10)
br label %for.inc
if.else13: ; preds = %if.else
%bcmp38 = call i32 @bcmp(ptr noundef nonnull dereferenceable(5) %cmd, ptr noundef nonnull dereferenceable(5) @.str.5, i64 5)
%tobool16.not = icmp eq i32 %bcmp38, 0
br i1 %tobool16.not, label %if.then17, label %if.else25
if.then17: ; preds = %if.else13
%call18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %key)
%6 = load i32, ptr %key, align 4, !tbaa !9
%7 = load ptr, ptr @tree, align 8, !tbaa !5
%cmp.i = icmp eq ptr %7, null
br i1 %cmp.i, label %if.else23, label %while.body.i41
while.body.i41: ; preds = %if.then17, %if.else.i
%x.019.i = phi ptr [ %x.1.i, %if.else.i ], [ %7, %if.then17 ]
%8 = load i32, ptr %x.019.i, align 8, !tbaa !11
%cmp3.i = icmp eq i32 %8, %6
br i1 %cmp3.i, label %if.then21, label %if.else.i
if.else.i: ; preds = %while.body.i41
%cmp6.i = icmp slt i32 %8, %6
%right.i42 = getelementptr inbounds %struct.node, ptr %x.019.i, i64 0, i32 3
%left.i43 = getelementptr inbounds %struct.node, ptr %x.019.i, i64 0, i32 2
%x.1.in.i44 = select i1 %cmp6.i, ptr %right.i42, ptr %left.i43
%x.1.i = load ptr, ptr %x.1.in.i44, align 8, !tbaa !5
%cmp1.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp1.not.i, label %if.else23, label %while.body.i41, !llvm.loop !16
if.then21: ; preds = %while.body.i41
%puts39 = call i32 @puts(ptr nonnull dereferenceable(1) @str.11)
br label %for.inc
if.else23: ; preds = %if.else.i, %if.then17
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.else25: ; preds = %if.else13
%bcmp40 = call i32 @bcmp(ptr noundef nonnull dereferenceable(7) %cmd, ptr noundef nonnull dereferenceable(7) @.str.8, i64 7)
%tobool28.not = icmp eq i32 %bcmp40, 0
br i1 %tobool28.not, label %if.then29, label %for.inc
if.then29: ; preds = %if.else25
%call30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %key)
%9 = load i32, ptr %key, align 4, !tbaa !9
call void @delete(i32 noundef %9)
br label %for.inc
for.inc: ; preds = %insert.exit, %if.else23, %if.then21, %if.then29, %if.else25, %if.then10
%inc = add nuw nsw i32 %i.048, 1
%10 = load i32, ptr %m, align 4, !tbaa !9
%cmp = icmp slt i32 %inc, %10
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !17
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 7, ptr nonnull %cmd) #11
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %key) #11
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %m) #11
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @insert(ptr nocapture noundef readnone %T, ptr noundef %z) local_unnamed_addr #4 {
entry:
%x.028 = load ptr, ptr @tree, align 8, !tbaa !5
%cmp.not29 = icmp eq ptr %x.028, null
br i1 %cmp.not29, label %if.then4, label %while.body.lr.ph
while.body.lr.ph: ; preds = %entry
%0 = load i32, ptr %z, align 8, !tbaa !11
br label %while.body
while.body: ; preds = %while.body.lr.ph, %while.body
%x.030 = phi ptr [ %x.028, %while.body.lr.ph ], [ %x.0, %while.body ]
%1 = load i32, ptr %x.030, align 8, !tbaa !11
%cmp2 = icmp slt i32 %0, %1
%left = getelementptr inbounds %struct.node, ptr %x.030, i64 0, i32 2
%right = getelementptr inbounds %struct.node, ptr %x.030, i64 0, i32 3
%x.1.in = select i1 %cmp2, ptr %left, ptr %right
%x.0 = load ptr, ptr %x.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %x.0, null
br i1 %cmp.not, label %if.else5, label %while.body, !llvm.loop !13
if.then4: ; preds = %entry
%parent32 = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 1
store ptr null, ptr %parent32, align 8, !tbaa !15
br label %if.end14
if.else5: ; preds = %while.body
%parent = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 1
store ptr %x.030, ptr %parent, align 8, !tbaa !15
%2 = load i32, ptr %z, align 8, !tbaa !11
%3 = load i32, ptr %x.030, align 8, !tbaa !11
%cmp8 = icmp slt i32 %2, %3
br i1 %cmp8, label %if.then9, label %if.else11
if.then9: ; preds = %if.else5
%left10 = getelementptr inbounds %struct.node, ptr %x.030, i64 0, i32 2
br label %if.end14
if.else11: ; preds = %if.else5
%right12 = getelementptr inbounds %struct.node, ptr %x.030, i64 0, i32 3
br label %if.end14
if.end14: ; preds = %if.then9, %if.else11, %if.then4
%left10.sink = phi ptr [ %left10, %if.then9 ], [ %right12, %if.else11 ], [ @tree, %if.then4 ]
store ptr %z, ptr %left10.sink, align 8, !tbaa !5
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr nocapture noundef readonly %p) local_unnamed_addr #5 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%p.tr = phi ptr [ %p, %entry ], [ %2, %if.end ]
%left = getelementptr inbounds %struct.node, ptr %p.tr, i64 0, i32 2
%0 = load ptr, ptr %left, align 8, !tbaa !18
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @inorder(ptr noundef nonnull %0)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%1 = load i32, ptr %p.tr, align 8, !tbaa !11
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10, i32 noundef %1)
%right = getelementptr inbounds %struct.node, ptr %p.tr, i64 0, i32 3
%2 = load ptr, ptr %right, align 8, !tbaa !19
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr nocapture noundef readonly %p) local_unnamed_addr #5 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%p.tr = phi ptr [ %p, %entry ], [ %2, %if.end ]
%0 = load i32, ptr %p.tr, align 8, !tbaa !11
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %p.tr, i64 0, i32 2
%1 = load ptr, ptr %left, align 8, !tbaa !18
%cmp.not = icmp eq ptr %1, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @preorder(ptr noundef nonnull %1)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%right = getelementptr inbounds %struct.node, ptr %p.tr, i64 0, i32 3
%2 = load ptr, ptr %right, align 8, !tbaa !19
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @find(i32 noundef %key) local_unnamed_addr #6 {
entry:
%0 = load ptr, ptr @tree, align 8, !tbaa !5
%cmp = icmp eq ptr %0, null
br i1 %cmp, label %cleanup, label %while.body
while.body: ; preds = %entry, %if.else
%x.019 = phi ptr [ %x.1, %if.else ], [ %0, %entry ]
%1 = load i32, ptr %x.019, align 8, !tbaa !11
%cmp3 = icmp eq i32 %1, %key
br i1 %cmp3, label %cleanup, label %if.else
if.else: ; preds = %while.body
%cmp6 = icmp slt i32 %1, %key
%right = getelementptr inbounds %struct.node, ptr %x.019, i64 0, i32 3
%left = getelementptr inbounds %struct.node, ptr %x.019, i64 0, i32 2
%x.1.in = select i1 %cmp6, ptr %right, ptr %left
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !5
%cmp1.not = icmp eq ptr %x.1, null
br i1 %cmp1.not, label %cleanup, label %while.body, !llvm.loop !16
cleanup: ; preds = %if.else, %while.body, %entry
%retval.0 = phi ptr [ null, %entry ], [ null, %if.else ], [ %x.019, %while.body ]
ret ptr %retval.0
}
; Function Attrs: nounwind uwtable
define dso_local void @delete(i32 noundef %key) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @tree, align 8, !tbaa !5
%cmp.i = icmp eq ptr %0, null
br i1 %cmp.i, label %if.then, label %while.body.i
while.body.i: ; preds = %entry, %if.else.i
%x.019.i = phi ptr [ %x.1.i, %if.else.i ], [ %0, %entry ]
%1 = load i32, ptr %x.019.i, align 8, !tbaa !11
%cmp3.i = icmp eq i32 %1, %key
br i1 %cmp3.i, label %if.end, label %if.else.i
if.else.i: ; preds = %while.body.i
%cmp6.i = icmp slt i32 %1, %key
%right.i = getelementptr inbounds %struct.node, ptr %x.019.i, i64 0, i32 3
%left.i = getelementptr inbounds %struct.node, ptr %x.019.i, i64 0, i32 2
%x.1.in.i = select i1 %cmp6.i, ptr %right.i, ptr %left.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !5
%cmp1.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp1.not.i, label %if.then, label %while.body.i, !llvm.loop !16
if.then: ; preds = %if.else.i, %entry
%puts = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.12)
br label %cleanup
if.end: ; preds = %while.body.i
%left = getelementptr inbounds %struct.node, ptr %x.019.i, i64 0, i32 2
%2 = load ptr, ptr %left, align 8, !tbaa !18
%cmp2 = icmp eq ptr %2, null
%right = getelementptr inbounds %struct.node, ptr %x.019.i, i64 0, i32 3
%3 = load ptr, ptr %right, align 8, !tbaa !19
%cmp3 = icmp eq ptr %3, null
br i1 %cmp2, label %land.lhs.true, label %land.lhs.true17
land.lhs.true: ; preds = %if.end
%parent = getelementptr inbounds %struct.node, ptr %x.019.i, i64 0, i32 1
%4 = load ptr, ptr %parent, align 8, !tbaa !15
%5 = load i32, ptr %4, align 8, !tbaa !11
%cmp7 = icmp slt i32 %5, %key
br i1 %cmp3, label %if.then4, label %if.else79
if.then4: ; preds = %land.lhs.true
%left12 = getelementptr inbounds %struct.node, ptr %4, i64 0, i32 2
%right10 = getelementptr inbounds %struct.node, ptr %4, i64 0, i32 3
%left12.sink = select i1 %cmp7, ptr %right10, ptr %left12
store ptr null, ptr %left12.sink, align 8, !tbaa !5
tail call void @free(ptr noundef nonnull %x.019.i) #11
br label %cleanup
land.lhs.true17: ; preds = %if.end
br i1 %cmp3, label %if.then62, label %while.cond
while.cond: ; preds = %land.lhs.true17, %while.cond
%y.0 = phi ptr [ %6, %while.cond ], [ %3, %land.lhs.true17 ]
%left22 = getelementptr inbounds %struct.node, ptr %y.0, i64 0, i32 2
%6 = load ptr, ptr %left22, align 8, !tbaa !18
%cmp23.not = icmp eq ptr %6, null
br i1 %cmp23.not, label %while.end, label %while.cond, !llvm.loop !20
while.end: ; preds = %while.cond
%7 = load i32, ptr %y.0, align 8, !tbaa !11
store i32 %7, ptr %x.019.i, align 8, !tbaa !11
%right27 = getelementptr inbounds %struct.node, ptr %y.0, i64 0, i32 3
%8 = load ptr, ptr %right27, align 8, !tbaa !19
%cmp28.not = icmp eq ptr %8, null
%parent47 = getelementptr inbounds %struct.node, ptr %y.0, i64 0, i32 1
%9 = load ptr, ptr %parent47, align 8, !tbaa !15
%10 = load i32, ptr %9, align 8, !tbaa !11
%11 = load i32, ptr %y.0, align 8, !tbaa !11
%cmp50 = icmp eq i32 %10, %11
br i1 %cmp28.not, label %if.else46, label %if.then29
if.then29: ; preds = %while.end
br i1 %cmp50, label %if.then34, label %if.else38
if.then34: ; preds = %if.then29
%right37 = getelementptr inbounds %struct.node, ptr %9, i64 0, i32 3
store ptr %8, ptr %right37, align 8, !tbaa !19
%.pre = load ptr, ptr %right27, align 8, !tbaa !19
br label %if.end42
if.else38: ; preds = %if.then29
%left41 = getelementptr inbounds %struct.node, ptr %9, i64 0, i32 2
store ptr %8, ptr %left41, align 8, !tbaa !18
br label %if.end42
if.end42: ; preds = %if.else38, %if.then34
%12 = phi ptr [ %8, %if.else38 ], [ %.pre, %if.then34 ]
%parent45 = getelementptr inbounds %struct.node, ptr %12, i64 0, i32 1
store ptr %9, ptr %parent45, align 8, !tbaa !15
br label %if.end58
if.else46: ; preds = %while.end
br i1 %cmp50, label %if.then51, label %if.else54
if.then51: ; preds = %if.else46
%right53 = getelementptr inbounds %struct.node, ptr %9, i64 0, i32 3
store ptr null, ptr %right53, align 8, !tbaa !19
br label %if.end58
if.else54: ; preds = %if.else46
%left56 = getelementptr inbounds %struct.node, ptr %9, i64 0, i32 2
store ptr null, ptr %left56, align 8, !tbaa !18
br label %if.end58
if.end58: ; preds = %if.then51, %if.else54, %if.end42
tail call void @free(ptr noundef nonnull %y.0) #11
br label %cleanup
if.then62: ; preds = %land.lhs.true17
%parent63 = getelementptr inbounds %struct.node, ptr %x.019.i, i64 0, i32 1
%13 = load ptr, ptr %parent63, align 8, !tbaa !15
%14 = load i32, ptr %13, align 8, !tbaa !11
%cmp66 = icmp slt i32 %14, %key
br i1 %cmp66, label %if.then67, label %if.else71
if.then67: ; preds = %if.then62
%right70 = getelementptr inbounds %struct.node, ptr %13, i64 0, i32 3
store ptr %2, ptr %right70, align 8, !tbaa !19
br label %if.end96
if.else71: ; preds = %if.then62
%left74 = getelementptr inbounds %struct.node, ptr %13, i64 0, i32 2
store ptr %2, ptr %left74, align 8, !tbaa !18
%.pre152 = load ptr, ptr %left, align 8, !tbaa !18
br label %if.end96
if.else79: ; preds = %land.lhs.true
br i1 %cmp7, label %if.then84, label %if.else88
if.then84: ; preds = %if.else79
%right87 = getelementptr inbounds %struct.node, ptr %4, i64 0, i32 3
store ptr %3, ptr %right87, align 8, !tbaa !19
%.pre153 = load ptr, ptr %right, align 8, !tbaa !19
br label %if.end96
if.else88: ; preds = %if.else79
%left91 = getelementptr inbounds %struct.node, ptr %4, i64 0, i32 2
store ptr %3, ptr %left91, align 8, !tbaa !18
br label %if.end96
if.end96: ; preds = %if.then84, %if.else88, %if.then67, %if.else71
%.sink155 = phi ptr [ %.pre152, %if.else71 ], [ %2, %if.then67 ], [ %3, %if.else88 ], [ %.pre153, %if.then84 ]
%.sink = phi ptr [ %13, %if.else71 ], [ %13, %if.then67 ], [ %4, %if.else88 ], [ %4, %if.then84 ]
%parent95 = getelementptr inbounds %struct.node, ptr %.sink155, i64 0, i32 1
store ptr %.sink, ptr %parent95, align 8, !tbaa !15
tail call void @free(ptr noundef nonnull %x.019.i) #11
br label %cleanup
cleanup: ; preds = %if.then4, %if.end96, %if.end58, %if.then
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #7
; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #8
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #9
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #9
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #10
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 = { 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 = { 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 #4 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 #5 = { nofree 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 #6 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 #7 = { 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 #8 = { nofree nounwind willreturn memory(argmem: read) }
attributes #9 = { nofree nounwind }
attributes #10 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #11 = { nounwind }
attributes #12 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!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, !10, i64 0}
!12 = !{!"node", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!12, !6, i64 8}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = !{!12, !6, i64 16}
!19 = !{!12, !6, i64 24}
!20 = distinct !{!20, !14}
|
#include<stdio.h>
#include<stdlib.h>
struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x){
while(x->left!=NIL){
x=x->left;
}
return x;
}
Node treeSearch(Node u, int k){
if(u==NIL || k==u->key) return u;
if(k<u->key) return treeSearch(u->left,k);
else return treeSearch(u->right,k);
}
Node treeSuccessor(Node x){
if (x->right!=NIL) return treeMinimum(x->right);
root=x->parent;
while(root!=NIL && x==root->right){
x=root;
root=root->parent;
}
return root;
}
void treeDelete(Node z){
Node y; // node to be deleted
Node x; // child of y
if(z->left==NIL || z->right==NIL){ y=z;
}
else y=treeSuccessor(z);
if(y->left!=NIL) {x=y->left;
}
else x=y->right;
if(x!=NIL) {x->parent=y->parent;
}
if(y->parent==NIL){ root=x;
}
else if(y==y->parent->left) {y->parent->left=x;
}
else y->parent->right=x;
if(y!=z) {z->key=y->key;
}
}
void insert(int k){
Node y = NIL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
while(x!=NIL){
y=x;
if(z->key<x->key) x=x->left;
else x=x->right;
z->parent=y;
}
if(y==NIL) root=z;
else if (z->key<y->key)
y->left=z;
else y->right=z;
}
void inorder(Node u){
if(u!=NIL) {
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
}
void preorder(Node u){
if(u!=NIL){
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
}
int main(){
int n, i, x;
char com[20];
scanf("%d", &n);
for ( i = 0; i < n; i++ ){
scanf("%s", com);
if ( com[0] == 'f' ){
scanf("%d", &x);
Node t = treeSearch(root, x);
if ( t != NIL ) printf("yes\n");
else printf("no\n");
} else if ( com[0] == 'i' ){
scanf("%d", &x);
insert(x);
} else if ( com[0] == 'p' ){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
} else if ( com[0] == 'd' ){
scanf("%d", &x);
treeDelete(treeSearch(root, x));
}
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206694/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206694/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { ptr, ptr, ptr, i32 }
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeMinimum(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%x.addr.0 = phi ptr [ %x, %entry ], [ %0, %while.cond ]
%left = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !11
while.end: ; preds = %while.cond
ret ptr %x.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSearch(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #0 {
entry:
%cmp14 = icmp eq ptr %u, null
br i1 %cmp14, label %return, label %lor.lhs.false
lor.lhs.false: ; preds = %entry, %if.end
%u.tr15 = phi ptr [ %u.tr.be, %if.end ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !13
%cmp1 = icmp eq i32 %0, %k
br i1 %cmp1, label %return, label %if.end
if.end: ; preds = %lor.lhs.false
%cmp3 = icmp sgt i32 %0, %k
%left = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 1
%spec.select = select i1 %cmp3, ptr %left, ptr %u.tr15
%u.tr.be = load ptr, ptr %spec.select, align 8, !tbaa !14
%cmp = icmp eq ptr %u.tr.be, null
br i1 %cmp, label %return, label %lor.lhs.false
return: ; preds = %lor.lhs.false, %if.end, %entry
%retval.0 = phi ptr [ null, %entry ], [ null, %if.end ], [ %u.tr15, %lor.lhs.false ]
ret ptr %retval.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSuccessor(ptr noundef readonly %x) local_unnamed_addr #1 {
entry:
%0 = load ptr, ptr %x, align 8, !tbaa !15
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%x.addr.0.i = phi ptr [ %1, %while.cond.i ], [ %0, %entry ]
%left.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i, i64 0, i32 1
%1 = load ptr, ptr %left.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %1, null
br i1 %cmp.not.i, label %return, label %while.cond.i, !llvm.loop !11
while.cond: ; preds = %entry, %land.rhs
%x.addr.0 = phi ptr [ %storemerge, %land.rhs ], [ %x, %entry ]
%storemerge.in = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 2
%storemerge = load ptr, ptr %storemerge.in, align 8, !tbaa !16
store ptr %storemerge, ptr @root, align 8, !tbaa !14
%cmp2.not = icmp eq ptr %storemerge, null
br i1 %cmp2.not, label %return, label %land.rhs
land.rhs: ; preds = %while.cond
%2 = load ptr, ptr %storemerge, align 8, !tbaa !15
%cmp4 = icmp eq ptr %x.addr.0, %2
br i1 %cmp4, label %while.cond, label %return, !llvm.loop !17
return: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi ptr [ %storemerge, %land.rhs ], [ null, %while.cond ], [ %x.addr.0.i, %while.cond.i ]
ret ptr %retval.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @treeDelete(ptr noundef %z) local_unnamed_addr #2 {
entry:
%left = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
%cmp = icmp eq ptr %0, null
br i1 %cmp, label %if.end8, label %lor.lhs.false
lor.lhs.false: ; preds = %entry
%1 = load ptr, ptr %z, align 8, !tbaa !15
%cmp1 = icmp eq ptr %1, null
br i1 %cmp1, label %if.then10, label %while.cond.i.i
while.cond.i.i: ; preds = %lor.lhs.false, %while.cond.i.i
%x.addr.0.i.i = phi ptr [ %2, %while.cond.i.i ], [ %1, %lor.lhs.false ]
%left.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i, i64 0, i32 1
%2 = load ptr, ptr %left.i.i, align 8, !tbaa !5
%cmp.not.i.i = icmp eq ptr %2, null
br i1 %cmp.not.i.i, label %if.end8, label %while.cond.i.i, !llvm.loop !11
if.end8: ; preds = %while.cond.i.i, %entry
%y.0.ph = phi ptr [ %z, %entry ], [ %x.addr.0.i.i, %while.cond.i.i ]
%3 = load ptr, ptr %y.0.ph, align 8, !tbaa !15
%cmp9.not = icmp eq ptr %3, null
br i1 %cmp9.not, label %if.end12, label %if.then10
if.then10: ; preds = %lor.lhs.false, %if.end8
%y.058 = phi ptr [ %y.0.ph, %if.end8 ], [ %z, %lor.lhs.false ]
%x.054 = phi ptr [ %3, %if.end8 ], [ %0, %lor.lhs.false ]
%parent = getelementptr inbounds %struct.node, ptr %y.058, i64 0, i32 2
%4 = load ptr, ptr %parent, align 8, !tbaa !16
%parent11 = getelementptr inbounds %struct.node, ptr %x.054, i64 0, i32 2
store ptr %4, ptr %parent11, align 8, !tbaa !16
br label %if.end12
if.end12: ; preds = %if.then10, %if.end8
%y.060 = phi ptr [ %y.058, %if.then10 ], [ %y.0.ph, %if.end8 ]
%x.055 = phi ptr [ %x.054, %if.then10 ], [ null, %if.end8 ]
%parent13 = getelementptr inbounds %struct.node, ptr %y.060, i64 0, i32 2
%5 = load ptr, ptr %parent13, align 8, !tbaa !16
%cmp14 = icmp eq ptr %5, null
br i1 %cmp14, label %if.end27, label %if.else16
if.else16: ; preds = %if.end12
%left18 = getelementptr inbounds %struct.node, ptr %5, i64 0, i32 1
%6 = load ptr, ptr %left18, align 8, !tbaa !5
%cmp19 = icmp eq ptr %y.060, %6
%left18. = select i1 %cmp19, ptr %left18, ptr %5
br label %if.end27
if.end27: ; preds = %if.else16, %if.end12
%left18.sink = phi ptr [ @root, %if.end12 ], [ %left18., %if.else16 ]
store ptr %x.055, ptr %left18.sink, align 8, !tbaa !14
%cmp28.not = icmp eq ptr %y.060, %z
br i1 %cmp28.not, label %if.end31, label %if.then29
if.then29: ; preds = %if.end27
%key = getelementptr inbounds %struct.node, ptr %y.060, i64 0, i32 3
%7 = load i32, ptr %key, align 8, !tbaa !13
%key30 = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 3
store i32 %7, ptr %key30, align 8, !tbaa !13
br label %if.end31
if.end31: ; preds = %if.then29, %if.end27
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #4 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !14
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #9
%key = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store i32 %k, ptr %key, align 8, !tbaa !13
%cmp.not34 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call, i8 0, i64 16, i1 false)
br i1 %cmp.not34, label %if.end17, label %while.body.lr.ph
while.body.lr.ph: ; preds = %entry
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
br label %while.body
while.body: ; preds = %while.body.lr.ph, %while.body
%x.035 = phi ptr [ %0, %while.body.lr.ph ], [ %x.1, %while.body ]
%key2 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%1 = load i32, ptr %key2, align 8, !tbaa !13
%cmp3 = icmp sgt i32 %1, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %x.035
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !14
store ptr %x.035, ptr %parent, align 8, !tbaa !16
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else8, label %while.body, !llvm.loop !18
if.else8: ; preds = %while.body
%key10 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%2 = load i32, ptr %key10, align 8, !tbaa !13
%cmp11 = icmp sgt i32 %2, %k
%left13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%spec.select = select i1 %cmp11, ptr %left13, ptr %x.035
br label %if.end17
if.end17: ; preds = %if.else8, %entry
%left13.sink = phi ptr [ @root, %entry ], [ %spec.select, %if.else8 ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !14
ret void
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #4 {
entry:
%cmp.not4 = icmp eq ptr %u, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%u.tr5 = phi ptr [ %2, %if.then ], [ %u, %entry ]
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
tail call void @inorder(ptr noundef %0)
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%1 = load i32, ptr %key, align 8, !tbaa !13
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !15
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #6
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #4 {
entry:
%cmp.not4 = icmp eq ptr %u, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%u.tr5 = phi ptr [ %2, %if.then ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !13
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !5
tail call void @preorder(ptr noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !15
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #4 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #10
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #10
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #10
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !19
%cmp66 = icmp sgt i32 %0, 0
br i1 %cmp66, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.067 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !20
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
i8 100, label %if.then31
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !14
%3 = load i32, ptr %x, align 4, !tbaa !19
%cmp14.i = icmp eq ptr %2, null
br i1 %cmp14.i, label %if.else, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %if.then, %if.end.i
%u.tr15.i = phi ptr [ %u.tr.be.i, %if.end.i ], [ %2, %if.then ]
%key.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 3
%4 = load i32, ptr %key.i, align 8, !tbaa !13
%cmp1.i = icmp eq i32 %4, %3
br i1 %cmp1.i, label %if.then8, label %if.end.i
if.end.i: ; preds = %lor.lhs.false.i
%cmp3.i = icmp sgt i32 %4, %3
%left.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 1
%spec.select.i = select i1 %cmp3.i, ptr %left.i, ptr %u.tr15.i
%u.tr.be.i = load ptr, ptr %spec.select.i, align 8, !tbaa !14
%cmp.i = icmp eq ptr %u.tr.be.i, null
br i1 %cmp.i, label %if.else, label %lor.lhs.false.i
if.then8: ; preds = %lor.lhs.false.i
%puts40 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %if.end.i, %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%5 = load i32, ptr %x, align 4, !tbaa !19
%6 = load ptr, ptr @root, align 8, !tbaa !14
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #9
%key.i41 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store i32 %5, ptr %key.i41, align 8, !tbaa !13
%cmp.not34.i = icmp eq ptr %6, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call.i, i8 0, i64 16, i1 false)
br i1 %cmp.not34.i, label %insert.exit, label %while.body.lr.ph.i
while.body.lr.ph.i: ; preds = %if.then16
%parent.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
br label %while.body.i
while.body.i: ; preds = %while.body.i, %while.body.lr.ph.i
%x.035.i = phi ptr [ %6, %while.body.lr.ph.i ], [ %x.1.i, %while.body.i ]
%key2.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 3
%7 = load i32, ptr %key2.i, align 8, !tbaa !13
%cmp3.i42 = icmp sgt i32 %7, %5
%left4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i42, ptr %left4.i, ptr %x.035.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !14
store ptr %x.035.i, ptr %parent.i, align 8, !tbaa !16
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %insert.exit, label %while.body.i, !llvm.loop !18
insert.exit: ; preds = %while.body.i, %if.then16
%left13.sink.i = phi ptr [ @root, %if.then16 ], [ %x.1.in.i, %while.body.i ]
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !14
br label %for.inc
if.then23: ; preds = %for.body
%8 = load ptr, ptr @root, align 8, !tbaa !14
call void @inorder(ptr noundef %8)
%putchar = call i32 @putchar(i32 10)
%9 = load ptr, ptr @root, align 8, !tbaa !14
call void @preorder(ptr noundef %9)
%putchar39 = call i32 @putchar(i32 10)
br label %for.inc
if.then31: ; preds = %for.body
%call32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%10 = load ptr, ptr @root, align 8, !tbaa !14
%11 = load i32, ptr %x, align 4, !tbaa !19
%cmp14.i44 = icmp eq ptr %10, null
br i1 %cmp14.i44, label %treeSearch.exit56, label %lor.lhs.false.i45
lor.lhs.false.i45: ; preds = %if.then31, %if.end.i49
%u.tr15.i46 = phi ptr [ %u.tr.be.i53, %if.end.i49 ], [ %10, %if.then31 ]
%key.i47 = getelementptr inbounds %struct.node, ptr %u.tr15.i46, i64 0, i32 3
%12 = load i32, ptr %key.i47, align 8, !tbaa !13
%cmp1.i48 = icmp eq i32 %12, %11
br i1 %cmp1.i48, label %treeSearch.exit56, label %if.end.i49
if.end.i49: ; preds = %lor.lhs.false.i45
%cmp3.i50 = icmp sgt i32 %12, %11
%left.i51 = getelementptr inbounds %struct.node, ptr %u.tr15.i46, i64 0, i32 1
%spec.select.i52 = select i1 %cmp3.i50, ptr %left.i51, ptr %u.tr15.i46
%u.tr.be.i53 = load ptr, ptr %spec.select.i52, align 8, !tbaa !14
%cmp.i54 = icmp eq ptr %u.tr.be.i53, null
br i1 %cmp.i54, label %treeSearch.exit56, label %lor.lhs.false.i45
treeSearch.exit56: ; preds = %lor.lhs.false.i45, %if.end.i49, %if.then31
%retval.0.i55 = phi ptr [ null, %if.then31 ], [ %u.tr15.i46, %lor.lhs.false.i45 ], [ null, %if.end.i49 ]
%left.i57 = getelementptr inbounds %struct.node, ptr %retval.0.i55, i64 0, i32 1
%13 = load ptr, ptr %left.i57, align 8, !tbaa !5
%cmp.i58 = icmp eq ptr %13, null
br i1 %cmp.i58, label %if.end8.i, label %lor.lhs.false.i59
lor.lhs.false.i59: ; preds = %treeSearch.exit56
%14 = load ptr, ptr %retval.0.i55, align 8, !tbaa !15
%cmp1.i60 = icmp eq ptr %14, null
br i1 %cmp1.i60, label %if.then10.i, label %while.cond.i.i.i
while.cond.i.i.i: ; preds = %lor.lhs.false.i59, %while.cond.i.i.i
%x.addr.0.i.i.i = phi ptr [ %15, %while.cond.i.i.i ], [ %14, %lor.lhs.false.i59 ]
%left.i.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i.i, i64 0, i32 1
%15 = load ptr, ptr %left.i.i.i, align 8, !tbaa !5
%cmp.not.i.i.i = icmp eq ptr %15, null
br i1 %cmp.not.i.i.i, label %if.end8.i, label %while.cond.i.i.i, !llvm.loop !11
if.end8.i: ; preds = %while.cond.i.i.i, %treeSearch.exit56
%y.0.ph.i = phi ptr [ %retval.0.i55, %treeSearch.exit56 ], [ %x.addr.0.i.i.i, %while.cond.i.i.i ]
%16 = load ptr, ptr %y.0.ph.i, align 8, !tbaa !15
%cmp9.not.i = icmp eq ptr %16, null
br i1 %cmp9.not.i, label %if.end12.i, label %if.then10.i
if.then10.i: ; preds = %if.end8.i, %lor.lhs.false.i59
%y.058.i = phi ptr [ %y.0.ph.i, %if.end8.i ], [ %retval.0.i55, %lor.lhs.false.i59 ]
%x.054.i = phi ptr [ %16, %if.end8.i ], [ %13, %lor.lhs.false.i59 ]
%parent.i61 = getelementptr inbounds %struct.node, ptr %y.058.i, i64 0, i32 2
%17 = load ptr, ptr %parent.i61, align 8, !tbaa !16
%parent11.i = getelementptr inbounds %struct.node, ptr %x.054.i, i64 0, i32 2
store ptr %17, ptr %parent11.i, align 8, !tbaa !16
br label %if.end12.i
if.end12.i: ; preds = %if.then10.i, %if.end8.i
%y.060.i = phi ptr [ %y.058.i, %if.then10.i ], [ %y.0.ph.i, %if.end8.i ]
%x.055.i = phi ptr [ %x.054.i, %if.then10.i ], [ null, %if.end8.i ]
%parent13.i = getelementptr inbounds %struct.node, ptr %y.060.i, i64 0, i32 2
%18 = load ptr, ptr %parent13.i, align 8, !tbaa !16
%cmp14.i62 = icmp eq ptr %18, null
br i1 %cmp14.i62, label %if.end27.i, label %if.else16.i
if.else16.i: ; preds = %if.end12.i
%left18.i = getelementptr inbounds %struct.node, ptr %18, i64 0, i32 1
%19 = load ptr, ptr %left18.i, align 8, !tbaa !5
%cmp19.i = icmp eq ptr %y.060.i, %19
%left18..i = select i1 %cmp19.i, ptr %left18.i, ptr %18
br label %if.end27.i
if.end27.i: ; preds = %if.else16.i, %if.end12.i
%left18.sink.i = phi ptr [ @root, %if.end12.i ], [ %left18..i, %if.else16.i ]
store ptr %x.055.i, ptr %left18.sink.i, align 8, !tbaa !14
%cmp28.not.i = icmp eq ptr %y.060.i, %retval.0.i55
br i1 %cmp28.not.i, label %for.inc, label %if.then29.i
if.then29.i: ; preds = %if.end27.i
%key.i63 = getelementptr inbounds %struct.node, ptr %y.060.i, i64 0, i32 3
%20 = load i32, ptr %key.i63, align 8, !tbaa !13
%key30.i = getelementptr inbounds %struct.node, ptr %retval.0.i55, i64 0, i32 3
store i32 %20, ptr %key30.i, align 8, !tbaa !13
br label %for.inc
for.inc: ; preds = %if.then29.i, %if.end27.i, %for.body, %if.then8, %if.else, %if.then23, %insert.exit
%inc = add nuw nsw i32 %i.067, 1
%21 = load i32, ptr %n, align 4, !tbaa !19
%cmp = icmp slt i32 %inc, %21
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !21
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #10
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #10
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #10
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #7
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #7
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #8
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 = { nofree norecurse nosync nounwind memory(readwrite, argmem: read, inaccessiblemem: none) 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 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nofree 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 #5 = { 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 #6 = { 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 #7 = { nofree nounwind }
attributes #8 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #9 = { nounwind allocsize(0) }
attributes #10 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !7, i64 8}
!6 = !{!"node", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!6, !10, i64 24}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 0}
!16 = !{!6, !7, i64 16}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = !{!10, !10, i64 0}
!20 = !{!8, !8, i64 0}
!21 = distinct !{!21, !12}
|
/*
I used a template program in C.
*/
#include<stdio.h>
#include<stdlib.h>
struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x){
/*my code beginning*/
while ( x->left != NIL ){
x = x->left;
}
return x;
/*my code end*/
}
Node treeMaximum(Node x){
}
Node treeSearch(Node u, int k){ /*find*/
/*my code beginning*/
if ( u == NIL || k == u->key ){
return u;
}
if ( k < u->key ){
return treeSearch(u->left,k);
} else {
return treeSearch(u->right,k);
}
/*my code end*/
}
Node treeSuccessor(Node x){
/*my code beginning*/
Node y;
if ( x->right != NIL ){
return treeMinimum(x->right);
}
y = x->parent;
while ( y != NIL && x == y->right ){
x = y;
y = y->parent;
}
return y;
/*my code end*/
}
Node treeDelete(Node z){ /*delete*/
Node y; // node to be deleted
Node x; // child of y
/*my code beginning*/
if ( z->left == NIL || z->right == NIL ){
y = z;
} else {
y = treeSuccessor(z);
}
if ( y->left != NIL ){
x = y->left;
} else {
x = y->right;
}
if ( x != NIL ){
x->parent = y->parent;
}
if ( y->parent == NIL ){
root = x;
} else if ( y == y->parent->left ){
y->parent->left = x;
} else {
y->parent->right = x;
}
if (y != z){
z->key = y->key;
}
return y;
/*my code end*/
}
void insert(int k){
Node y = NIL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
/*my code beginning*/
while (x!=NIL){
y=x;
if (z->key < x->key){
x=x->left;
} else{
x=x->right;
}
}
z->parent=y;
if (y==NIL){
root = z;
} else if (z->key < y->key){
y->left=z;
} else {
y->right=z;
}
/*my code end*/
}
void inorder(Node u){
/*my code beginning*/
if (u!=NIL){
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
/*my code end*/
}
void preorder(Node u){
/*my code beginning*/
if (u!=NIL){
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
/*my code end*/
}
int main(){
int n, i, x;
char com[20];
scanf("%d", &n);
/*my code beginning*/
root=NIL;
/*my code end*/
for ( i = 0; i < n; i++ ){
scanf("%s", com);
if ( com[0] == 'f' ){
scanf("%d", &x);
Node t = treeSearch(root, x);
if ( t != NIL ) printf("yes\n");
else printf("no\n");
} else if ( com[0] == 'i' ){
scanf("%d", &x);
insert(x);
} else if ( com[0] == 'p' ){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
} else if ( com[0] == 'd' ){
scanf("%d", &x);
treeDelete(treeSearch(root, x));
}
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206744/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206744/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { ptr, ptr, ptr, i32 }
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeMinimum(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%x.addr.0 = phi ptr [ %x, %entry ], [ %0, %while.cond ]
%left = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !11
while.end: ; preds = %while.cond
ret ptr %x.addr.0
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noalias ptr @treeMaximum(ptr nocapture noundef readnone %x) local_unnamed_addr #1 {
entry:
ret ptr undef
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSearch(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #0 {
entry:
%cmp14 = icmp eq ptr %u, null
br i1 %cmp14, label %return, label %lor.lhs.false
lor.lhs.false: ; preds = %entry, %if.end
%u.tr15 = phi ptr [ %u.tr.be, %if.end ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !13
%cmp1 = icmp eq i32 %0, %k
br i1 %cmp1, label %return, label %if.end
if.end: ; preds = %lor.lhs.false
%cmp3 = icmp sgt i32 %0, %k
%left = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 1
%spec.select = select i1 %cmp3, ptr %left, ptr %u.tr15
%u.tr.be = load ptr, ptr %spec.select, align 8, !tbaa !14
%cmp = icmp eq ptr %u.tr.be, null
br i1 %cmp, label %return, label %lor.lhs.false
return: ; preds = %lor.lhs.false, %if.end, %entry
%retval.0 = phi ptr [ null, %entry ], [ null, %if.end ], [ %u.tr15, %lor.lhs.false ]
ret ptr %retval.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSuccessor(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr %x, align 8, !tbaa !15
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%x.addr.0.i = phi ptr [ %1, %while.cond.i ], [ %0, %entry ]
%left.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i, i64 0, i32 1
%1 = load ptr, ptr %left.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %1, null
br i1 %cmp.not.i, label %cleanup, label %while.cond.i, !llvm.loop !11
while.cond: ; preds = %entry, %land.rhs
%x.addr.0 = phi ptr [ %y.0, %land.rhs ], [ %x, %entry ]
%y.0.in = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 2
%y.0 = load ptr, ptr %y.0.in, align 8, !tbaa !16
%cmp2.not = icmp eq ptr %y.0, null
br i1 %cmp2.not, label %cleanup, label %land.rhs
land.rhs: ; preds = %while.cond
%2 = load ptr, ptr %y.0, align 8, !tbaa !15
%cmp4 = icmp eq ptr %x.addr.0, %2
br i1 %cmp4, label %while.cond, label %cleanup, !llvm.loop !17
cleanup: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi ptr [ %y.0, %land.rhs ], [ null, %while.cond ], [ %x.addr.0.i, %while.cond.i ]
ret ptr %retval.0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local ptr @treeDelete(ptr noundef %z) local_unnamed_addr #3 {
entry:
%left = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
%cmp = icmp eq ptr %0, null
br i1 %cmp, label %if.end8, label %lor.lhs.false
lor.lhs.false: ; preds = %entry
%1 = load ptr, ptr %z, align 8, !tbaa !15
%cmp1 = icmp eq ptr %1, null
br i1 %cmp1, label %if.then10, label %while.cond.i.i
while.cond.i.i: ; preds = %lor.lhs.false, %while.cond.i.i
%x.addr.0.i.i = phi ptr [ %2, %while.cond.i.i ], [ %1, %lor.lhs.false ]
%left.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i, i64 0, i32 1
%2 = load ptr, ptr %left.i.i, align 8, !tbaa !5
%cmp.not.i.i = icmp eq ptr %2, null
br i1 %cmp.not.i.i, label %if.end8, label %while.cond.i.i, !llvm.loop !11
if.end8: ; preds = %while.cond.i.i, %entry
%y.0.ph = phi ptr [ %z, %entry ], [ %x.addr.0.i.i, %while.cond.i.i ]
%3 = load ptr, ptr %y.0.ph, align 8, !tbaa !15
%cmp9.not = icmp eq ptr %3, null
br i1 %cmp9.not, label %if.end12, label %if.then10
if.then10: ; preds = %lor.lhs.false, %if.end8
%y.059 = phi ptr [ %y.0.ph, %if.end8 ], [ %z, %lor.lhs.false ]
%x.055 = phi ptr [ %3, %if.end8 ], [ %0, %lor.lhs.false ]
%parent = getelementptr inbounds %struct.node, ptr %y.059, i64 0, i32 2
%4 = load ptr, ptr %parent, align 8, !tbaa !16
%parent11 = getelementptr inbounds %struct.node, ptr %x.055, i64 0, i32 2
store ptr %4, ptr %parent11, align 8, !tbaa !16
br label %if.end12
if.end12: ; preds = %if.then10, %if.end8
%y.061 = phi ptr [ %y.059, %if.then10 ], [ %y.0.ph, %if.end8 ]
%x.056 = phi ptr [ %x.055, %if.then10 ], [ null, %if.end8 ]
%parent13 = getelementptr inbounds %struct.node, ptr %y.061, i64 0, i32 2
%5 = load ptr, ptr %parent13, align 8, !tbaa !16
%cmp14 = icmp eq ptr %5, null
br i1 %cmp14, label %if.end27, label %if.else16
if.else16: ; preds = %if.end12
%left18 = getelementptr inbounds %struct.node, ptr %5, i64 0, i32 1
%6 = load ptr, ptr %left18, align 8, !tbaa !5
%cmp19 = icmp eq ptr %y.061, %6
%left18. = select i1 %cmp19, ptr %left18, ptr %5
br label %if.end27
if.end27: ; preds = %if.else16, %if.end12
%left18.sink = phi ptr [ @root, %if.end12 ], [ %left18., %if.else16 ]
store ptr %x.056, ptr %left18.sink, align 8, !tbaa !14
%cmp28.not = icmp eq ptr %y.061, %z
br i1 %cmp28.not, label %if.end31, label %if.then29
if.then29: ; preds = %if.end27
%key = getelementptr inbounds %struct.node, ptr %y.061, i64 0, i32 3
%7 = load i32, ptr %key, align 8, !tbaa !13
%key30 = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 3
store i32 %7, ptr %key30, align 8, !tbaa !13
br label %if.end31
if.end31: ; preds = %if.then29, %if.end27
ret ptr %y.061
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #4 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !14
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #9
%key = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store i32 %k, ptr %key, align 8, !tbaa !13
%cmp.not34 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call, i8 0, i64 16, i1 false)
br i1 %cmp.not34, label %if.then7, label %while.body
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%key2 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%1 = load i32, ptr %key2, align 8, !tbaa !13
%cmp3 = icmp sgt i32 %1, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %x.035
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !14
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else8, label %while.body, !llvm.loop !18
if.then7: ; preds = %entry
%parent37 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr null, ptr %parent37, align 8, !tbaa !16
br label %if.end17
if.else8: ; preds = %while.body
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr %x.035, ptr %parent, align 8, !tbaa !16
%key10 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%2 = load i32, ptr %key10, align 8, !tbaa !13
%cmp11 = icmp sgt i32 %2, %k
%left13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%spec.select = select i1 %cmp11, ptr %left13, ptr %x.035
br label %if.end17
if.end17: ; preds = %if.else8, %if.then7
%left13.sink = phi ptr [ @root, %if.then7 ], [ %spec.select, %if.else8 ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !14
ret void
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #4 {
entry:
%cmp.not4 = icmp eq ptr %u, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%u.tr5 = phi ptr [ %2, %if.then ], [ %u, %entry ]
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
tail call void @inorder(ptr noundef %0)
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%1 = load i32, ptr %key, align 8, !tbaa !13
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !15
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #6
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #4 {
entry:
%cmp.not4 = icmp eq ptr %u, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%u.tr5 = phi ptr [ %2, %if.then ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !13
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !5
tail call void @preorder(ptr noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !15
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #4 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #10
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #10
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #10
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
store ptr null, ptr @root, align 8, !tbaa !14
%0 = load i32, ptr %n, align 4, !tbaa !19
%cmp67 = icmp sgt i32 %0, 0
br i1 %cmp67, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.068 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !20
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
i8 100, label %if.then31
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !14
%3 = load i32, ptr %x, align 4, !tbaa !19
%cmp14.i = icmp eq ptr %2, null
br i1 %cmp14.i, label %if.else, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %if.then, %if.end.i
%u.tr15.i = phi ptr [ %u.tr.be.i, %if.end.i ], [ %2, %if.then ]
%key.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 3
%4 = load i32, ptr %key.i, align 8, !tbaa !13
%cmp1.i = icmp eq i32 %4, %3
br i1 %cmp1.i, label %if.then8, label %if.end.i
if.end.i: ; preds = %lor.lhs.false.i
%cmp3.i = icmp sgt i32 %4, %3
%left.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 1
%spec.select.i = select i1 %cmp3.i, ptr %left.i, ptr %u.tr15.i
%u.tr.be.i = load ptr, ptr %spec.select.i, align 8, !tbaa !14
%cmp.i = icmp eq ptr %u.tr.be.i, null
br i1 %cmp.i, label %if.else, label %lor.lhs.false.i
if.then8: ; preds = %lor.lhs.false.i
%puts41 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %if.end.i, %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%5 = load i32, ptr %x, align 4, !tbaa !19
%6 = load ptr, ptr @root, align 8, !tbaa !14
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #9
%key.i42 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store i32 %5, ptr %key.i42, align 8, !tbaa !13
%cmp.not34.i = icmp eq ptr %6, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call.i, i8 0, i64 16, i1 false)
br i1 %cmp.not34.i, label %insert.exit, label %while.body.i
while.body.i: ; preds = %if.then16, %while.body.i
%x.035.i = phi ptr [ %x.1.i, %while.body.i ], [ %6, %if.then16 ]
%key2.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 3
%7 = load i32, ptr %key2.i, align 8, !tbaa !13
%cmp3.i43 = icmp sgt i32 %7, %5
%left4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i43, ptr %left4.i, ptr %x.035.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !14
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %insert.exit, label %while.body.i, !llvm.loop !18
insert.exit: ; preds = %while.body.i, %if.then16
%.sink = phi ptr [ null, %if.then16 ], [ %x.035.i, %while.body.i ]
%left13.sink.i = phi ptr [ @root, %if.then16 ], [ %x.1.in.i, %while.body.i ]
%parent37.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
store ptr %.sink, ptr %parent37.i, align 8, !tbaa !16
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !14
br label %for.inc
if.then23: ; preds = %for.body
%8 = load ptr, ptr @root, align 8, !tbaa !14
call void @inorder(ptr noundef %8)
%putchar = call i32 @putchar(i32 10)
%9 = load ptr, ptr @root, align 8, !tbaa !14
call void @preorder(ptr noundef %9)
%putchar40 = call i32 @putchar(i32 10)
br label %for.inc
if.then31: ; preds = %for.body
%call32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%10 = load ptr, ptr @root, align 8, !tbaa !14
%11 = load i32, ptr %x, align 4, !tbaa !19
%cmp14.i45 = icmp eq ptr %10, null
br i1 %cmp14.i45, label %treeSearch.exit57, label %lor.lhs.false.i46
lor.lhs.false.i46: ; preds = %if.then31, %if.end.i50
%u.tr15.i47 = phi ptr [ %u.tr.be.i54, %if.end.i50 ], [ %10, %if.then31 ]
%key.i48 = getelementptr inbounds %struct.node, ptr %u.tr15.i47, i64 0, i32 3
%12 = load i32, ptr %key.i48, align 8, !tbaa !13
%cmp1.i49 = icmp eq i32 %12, %11
br i1 %cmp1.i49, label %treeSearch.exit57, label %if.end.i50
if.end.i50: ; preds = %lor.lhs.false.i46
%cmp3.i51 = icmp sgt i32 %12, %11
%left.i52 = getelementptr inbounds %struct.node, ptr %u.tr15.i47, i64 0, i32 1
%spec.select.i53 = select i1 %cmp3.i51, ptr %left.i52, ptr %u.tr15.i47
%u.tr.be.i54 = load ptr, ptr %spec.select.i53, align 8, !tbaa !14
%cmp.i55 = icmp eq ptr %u.tr.be.i54, null
br i1 %cmp.i55, label %treeSearch.exit57, label %lor.lhs.false.i46
treeSearch.exit57: ; preds = %lor.lhs.false.i46, %if.end.i50, %if.then31
%retval.0.i56 = phi ptr [ null, %if.then31 ], [ %u.tr15.i47, %lor.lhs.false.i46 ], [ null, %if.end.i50 ]
%left.i58 = getelementptr inbounds %struct.node, ptr %retval.0.i56, i64 0, i32 1
%13 = load ptr, ptr %left.i58, align 8, !tbaa !5
%cmp.i59 = icmp eq ptr %13, null
br i1 %cmp.i59, label %if.end8.i, label %lor.lhs.false.i60
lor.lhs.false.i60: ; preds = %treeSearch.exit57
%14 = load ptr, ptr %retval.0.i56, align 8, !tbaa !15
%cmp1.i61 = icmp eq ptr %14, null
br i1 %cmp1.i61, label %if.then10.i, label %while.cond.i.i.i
while.cond.i.i.i: ; preds = %lor.lhs.false.i60, %while.cond.i.i.i
%x.addr.0.i.i.i = phi ptr [ %15, %while.cond.i.i.i ], [ %14, %lor.lhs.false.i60 ]
%left.i.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i.i, i64 0, i32 1
%15 = load ptr, ptr %left.i.i.i, align 8, !tbaa !5
%cmp.not.i.i.i = icmp eq ptr %15, null
br i1 %cmp.not.i.i.i, label %if.end8.i, label %while.cond.i.i.i, !llvm.loop !11
if.end8.i: ; preds = %while.cond.i.i.i, %treeSearch.exit57
%y.0.ph.i = phi ptr [ %retval.0.i56, %treeSearch.exit57 ], [ %x.addr.0.i.i.i, %while.cond.i.i.i ]
%16 = load ptr, ptr %y.0.ph.i, align 8, !tbaa !15
%cmp9.not.i = icmp eq ptr %16, null
br i1 %cmp9.not.i, label %if.end12.i, label %if.then10.i
if.then10.i: ; preds = %if.end8.i, %lor.lhs.false.i60
%y.059.i = phi ptr [ %y.0.ph.i, %if.end8.i ], [ %retval.0.i56, %lor.lhs.false.i60 ]
%x.055.i = phi ptr [ %16, %if.end8.i ], [ %13, %lor.lhs.false.i60 ]
%parent.i62 = getelementptr inbounds %struct.node, ptr %y.059.i, i64 0, i32 2
%17 = load ptr, ptr %parent.i62, align 8, !tbaa !16
%parent11.i = getelementptr inbounds %struct.node, ptr %x.055.i, i64 0, i32 2
store ptr %17, ptr %parent11.i, align 8, !tbaa !16
br label %if.end12.i
if.end12.i: ; preds = %if.then10.i, %if.end8.i
%y.061.i = phi ptr [ %y.059.i, %if.then10.i ], [ %y.0.ph.i, %if.end8.i ]
%x.056.i = phi ptr [ %x.055.i, %if.then10.i ], [ null, %if.end8.i ]
%parent13.i = getelementptr inbounds %struct.node, ptr %y.061.i, i64 0, i32 2
%18 = load ptr, ptr %parent13.i, align 8, !tbaa !16
%cmp14.i63 = icmp eq ptr %18, null
br i1 %cmp14.i63, label %if.end27.i, label %if.else16.i
if.else16.i: ; preds = %if.end12.i
%left18.i = getelementptr inbounds %struct.node, ptr %18, i64 0, i32 1
%19 = load ptr, ptr %left18.i, align 8, !tbaa !5
%cmp19.i = icmp eq ptr %y.061.i, %19
%left18..i = select i1 %cmp19.i, ptr %left18.i, ptr %18
br label %if.end27.i
if.end27.i: ; preds = %if.else16.i, %if.end12.i
%left18.sink.i = phi ptr [ @root, %if.end12.i ], [ %left18..i, %if.else16.i ]
store ptr %x.056.i, ptr %left18.sink.i, align 8, !tbaa !14
%cmp28.not.i = icmp eq ptr %y.061.i, %retval.0.i56
br i1 %cmp28.not.i, label %for.inc, label %if.then29.i
if.then29.i: ; preds = %if.end27.i
%key.i64 = getelementptr inbounds %struct.node, ptr %y.061.i, i64 0, i32 3
%20 = load i32, ptr %key.i64, align 8, !tbaa !13
%key30.i = getelementptr inbounds %struct.node, ptr %retval.0.i56, i64 0, i32 3
store i32 %20, ptr %key30.i, align 8, !tbaa !13
br label %for.inc
for.inc: ; preds = %if.then29.i, %if.end27.i, %for.body, %if.then8, %if.else, %if.then23, %insert.exit
%inc = add nuw nsw i32 %i.068, 1
%21 = load i32, ptr %n, align 4, !tbaa !19
%cmp = icmp slt i32 %inc, %21
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !21
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #10
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #10
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #10
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #7
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #7
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #8
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 nofree norecurse nosync nounwind willreturn memory(none) 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = { nofree 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 #5 = { 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 #6 = { 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 #7 = { nofree nounwind }
attributes #8 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #9 = { nounwind allocsize(0) }
attributes #10 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !7, i64 8}
!6 = !{!"node", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!6, !10, i64 24}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 0}
!16 = !{!6, !7, i64 16}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = !{!10, !10, i64 0}
!20 = !{!8, !8, i64 0}
!21 = distinct !{!21, !12}
|
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct Node{
int key;
struct Node *l, *r, *p;
};
struct Node *root, *NIL;
struct Node * tMin(struct Node *v){
while(v->l != NIL) v = v->l;
return v;
}
struct Node *tSuc(struct Node *v){
struct Node *y;
if(v->r != NIL) return tMin(v->r);
y = v->p;
while(y != NIL && v == y->r){
v = y;
y = y->p;
}
return y;
}
void tDelete(struct Node *z){
struct Node *y; //?????????????±?
struct Node *x; //y??????
// ??????????????????????±???????
if(z->l == NIL || z->r == NIL)y=z;
else y =tSuc(z);
//y??????????±???????
if(y->l != NIL){
x=y->l;
}
else {
x = y->r;
}
if(x != NIL){
x->p = y->p;
}
if(y->p == NIL){
root = x;
}
else {
if(y==y->p->l){
y->p->l=x;
}
else y->p->r = x;
}
if(y != z){
z->key = y->key;
}
free(y);
}
struct Node * find(struct Node *u,int k){
while(u != NIL && k != u->key){
if(k < u->key)u=u->l;
else u=u->r;
}
return u;
}
void insert(int v){
struct Node *y = NIL;
struct Node *x = root;
struct Node *z;
z = (struct Node *)malloc(sizeof(struct Node));
z->key = v;
z->l = NIL;
z->r = NIL;
while(x != NIL){
y = x;
if( z->key < x->key ){
x = x->l;
}
else{
x = x->r;
}
}
z->p = y;
if(y == NIL){
root = z;
}
else if(z->key < y->key){
y->l =z;
}
else{
y->r =z;
}
}
void Iorder(struct Node *u){
if(u == NIL){
return;
}
Iorder(u->l);
printf(" %d", u->key);
Iorder(u->r);
}
void Porder(struct Node *u){
if(u == NIL){
return;
}
printf(" %d", u->key);
Porder(u->l);
Porder(u->r);
}
int main(){
int n,i,v;
struct Node *t;
char *sent = malloc(7);
char *s1 = "insert";
char *s2 = "print";
char *s3 = "delete";
scanf("%d",&n);
for(i = 0;i <n;i++){
scanf("%6s",sent);
if(sent[0] == 'f'){
scanf("%d",&v);
t = find(root,v);
if(t != NIL)printf("yes\n");
else printf("no\n");
}
else if(0==strcmp(sent,s1)){
scanf("%d", &v);
insert(v);
}
else if(0==strcmp(sent,s2)){
Iorder(root);
printf("\n");
Porder(root);
printf("\n");
}
else if(0==strcmp(sent,s3)){
scanf("%d",&v);
tDelete(find(root, v));
}
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206788/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206788/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.Node = type { i32, ptr, ptr, ptr }
@NIL = dso_local local_unnamed_addr global ptr null, align 8
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [7 x i8] c"insert\00", align 1
@.str.2 = private unnamed_addr constant [6 x i8] c"print\00", align 1
@.str.3 = private unnamed_addr constant [7 x i8] c"delete\00", align 1
@.str.4 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.5 = private unnamed_addr constant [4 x i8] c"%6s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.9 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @tMin(ptr noundef readonly %v) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%v.addr.0 = phi ptr [ %v, %entry ], [ %1, %while.cond ]
%l = getelementptr inbounds %struct.Node, ptr %v.addr.0, i64 0, i32 1
%1 = load ptr, ptr %l, align 8, !tbaa !9
%cmp.not = icmp eq ptr %1, %0
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !12
while.end: ; preds = %while.cond
ret ptr %v.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @tSuc(ptr noundef readonly %v) local_unnamed_addr #0 {
entry:
%r = getelementptr inbounds %struct.Node, ptr %v, i64 0, i32 2
%0 = load ptr, ptr %r, align 8, !tbaa !14
%1 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not = icmp eq ptr %0, %1
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%v.addr.0.i = phi ptr [ %2, %while.cond.i ], [ %0, %entry ]
%l.i = getelementptr inbounds %struct.Node, ptr %v.addr.0.i, i64 0, i32 1
%2 = load ptr, ptr %l.i, align 8, !tbaa !9
%cmp.not.i = icmp eq ptr %2, %1
br i1 %cmp.not.i, label %cleanup, label %while.cond.i, !llvm.loop !12
while.cond: ; preds = %entry, %land.rhs
%v.addr.0 = phi ptr [ %y.0, %land.rhs ], [ %v, %entry ]
%y.0.in = getelementptr inbounds %struct.Node, ptr %v.addr.0, i64 0, i32 3
%y.0 = load ptr, ptr %y.0.in, align 8, !tbaa !15
%cmp2.not = icmp eq ptr %y.0, %0
br i1 %cmp2.not, label %cleanup, label %land.rhs
land.rhs: ; preds = %while.cond
%r3 = getelementptr inbounds %struct.Node, ptr %y.0, i64 0, i32 2
%3 = load ptr, ptr %r3, align 8, !tbaa !14
%cmp4 = icmp eq ptr %v.addr.0, %3
br i1 %cmp4, label %while.cond, label %cleanup, !llvm.loop !16
cleanup: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi ptr [ %y.0, %land.rhs ], [ %0, %while.cond ], [ %v.addr.0.i, %while.cond.i ]
ret ptr %retval.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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nounwind uwtable
define dso_local void @tDelete(ptr noundef %z) local_unnamed_addr #2 {
entry:
%l = getelementptr inbounds %struct.Node, ptr %z, i64 0, i32 1
%0 = load ptr, ptr %l, align 8, !tbaa !9
%1 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %0, %1
br i1 %cmp, label %if.end, label %lor.lhs.false
lor.lhs.false: ; preds = %entry
%r = getelementptr inbounds %struct.Node, ptr %z, i64 0, i32 2
%2 = load ptr, ptr %r, align 8, !tbaa !14
%cmp1 = icmp eq ptr %2, %1
br i1 %cmp1, label %if.end, label %while.cond.i.i
while.cond.i.i: ; preds = %lor.lhs.false, %while.cond.i.i
%v.addr.0.i.i = phi ptr [ %3, %while.cond.i.i ], [ %2, %lor.lhs.false ]
%l.i.i = getelementptr inbounds %struct.Node, ptr %v.addr.0.i.i, i64 0, i32 1
%3 = load ptr, ptr %l.i.i, align 8, !tbaa !9
%cmp.not.i.i = icmp eq ptr %3, %1
br i1 %cmp.not.i.i, label %if.else6, label %while.cond.i.i, !llvm.loop !12
if.end: ; preds = %entry, %lor.lhs.false
%cmp3.not = icmp eq ptr %0, %1
br i1 %cmp3.not, label %if.else6, label %if.end8
if.else6: ; preds = %while.cond.i.i, %if.end
%y.057 = phi ptr [ %z, %if.end ], [ %v.addr.0.i.i, %while.cond.i.i ]
%r7 = getelementptr inbounds %struct.Node, ptr %y.057, i64 0, i32 2
%4 = load ptr, ptr %r7, align 8, !tbaa !14
br label %if.end8
if.end8: ; preds = %if.end, %if.else6
%y.056 = phi ptr [ %y.057, %if.else6 ], [ %z, %if.end ]
%x.0 = phi ptr [ %4, %if.else6 ], [ %0, %if.end ]
%cmp9.not = icmp eq ptr %x.0, %1
br i1 %cmp9.not, label %if.end12, label %if.then10
if.then10: ; preds = %if.end8
%p = getelementptr inbounds %struct.Node, ptr %y.056, i64 0, i32 3
%5 = load ptr, ptr %p, align 8, !tbaa !15
%p11 = getelementptr inbounds %struct.Node, ptr %x.0, i64 0, i32 3
store ptr %5, ptr %p11, align 8, !tbaa !15
br label %if.end12
if.end12: ; preds = %if.then10, %if.end8
%p13 = getelementptr inbounds %struct.Node, ptr %y.056, i64 0, i32 3
%6 = load ptr, ptr %p13, align 8, !tbaa !15
%cmp14 = icmp eq ptr %6, %1
br i1 %cmp14, label %if.end27, label %if.else16
if.else16: ; preds = %if.end12
%l18 = getelementptr inbounds %struct.Node, ptr %6, i64 0, i32 1
%7 = load ptr, ptr %l18, align 8, !tbaa !9
%cmp19 = icmp eq ptr %y.056, %7
%r25 = getelementptr inbounds %struct.Node, ptr %6, i64 0, i32 2
%spec.select = select i1 %cmp19, ptr %l18, ptr %r25
br label %if.end27
if.end27: ; preds = %if.else16, %if.end12
%l18.sink = phi ptr [ @root, %if.end12 ], [ %spec.select, %if.else16 ]
store ptr %x.0, ptr %l18.sink, align 8, !tbaa !5
%cmp28.not = icmp eq ptr %y.056, %z
br i1 %cmp28.not, label %if.end31, label %if.then29
if.then29: ; preds = %if.end27
%8 = load i32, ptr %y.056, align 8, !tbaa !17
store i32 %8, ptr %z, align 8, !tbaa !17
br label %if.end31
if.end31: ; preds = %if.then29, %if.end27
tail call void @free(ptr noundef nonnull %y.056) #9
ret void
}
; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @find(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10 = icmp eq ptr %0, %u
br i1 %cmp.not10, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%u.addr.011 = phi ptr [ %u.addr.1, %while.body ], [ %u, %entry ]
%1 = load i32, ptr %u.addr.011, align 8, !tbaa !17
%cmp1.not = icmp eq i32 %1, %k
br i1 %cmp1.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp3 = icmp sgt i32 %1, %k
%l = getelementptr inbounds %struct.Node, ptr %u.addr.011, i64 0, i32 1
%r = getelementptr inbounds %struct.Node, ptr %u.addr.011, i64 0, i32 2
%u.addr.1.in = select i1 %cmp3, ptr %l, ptr %r
%u.addr.1 = load ptr, ptr %u.addr.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %u.addr.1, %0
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !18
while.end: ; preds = %land.rhs, %while.body, %entry
%u.addr.0.lcssa = phi ptr [ %u, %entry ], [ %0, %while.body ], [ %u.addr.011, %land.rhs ]
ret ptr %u.addr.0.lcssa
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %v) local_unnamed_addr #4 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%1 = load ptr, ptr @root, align 8, !tbaa !5
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #10
store i32 %v, ptr %call, align 8, !tbaa !17
%l = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 1
store ptr %0, ptr %l, align 8, !tbaa !9
%r = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 2
store ptr %0, ptr %r, align 8, !tbaa !14
%cmp.not34 = icmp eq ptr %1, %0
br i1 %cmp.not34, label %while.end.thread, label %while.body
while.end.thread: ; preds = %entry
%p37 = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 3
store ptr %0, ptr %p37, align 8, !tbaa !15
br label %if.end17
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %1, %entry ]
%2 = load i32, ptr %x.035, align 8, !tbaa !17
%cmp3 = icmp sgt i32 %2, %v
%l4 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 1
%r5 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 2
%x.1.in = select i1 %cmp3, ptr %l4, ptr %r5
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %x.1, %0
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !19
while.end: ; preds = %while.body
%p = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 3
store ptr %x.035, ptr %p, align 8, !tbaa !15
%cmp6 = icmp eq ptr %x.035, %0
br i1 %cmp6, label %if.end17, label %if.else8
if.else8: ; preds = %while.end
%3 = load i32, ptr %x.035, align 8, !tbaa !17
%cmp11 = icmp sgt i32 %3, %v
br i1 %cmp11, label %if.then12, label %if.else14
if.then12: ; preds = %if.else8
%l13 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 1
br label %if.end17
if.else14: ; preds = %if.else8
%r15 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 2
br label %if.end17
if.end17: ; preds = %while.end, %while.end.thread, %if.then12, %if.else14
%l13.sink = phi ptr [ %l13, %if.then12 ], [ %r15, %if.else14 ], [ @root, %while.end.thread ], [ @root, %while.end ]
store ptr %call, ptr %l13.sink, align 8, !tbaa !5
ret void
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind uwtable
define dso_local void @Iorder(ptr noundef readonly %u) local_unnamed_addr #4 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%l = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 1
%1 = load ptr, ptr %l, align 8, !tbaa !9
tail call void @Iorder(ptr noundef %1)
%2 = load i32, ptr %u.tr5, align 8, !tbaa !17
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %2)
%r = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 2
%3 = load ptr, ptr %r, align 8, !tbaa !14
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #6
; Function Attrs: nofree nounwind uwtable
define dso_local void @Porder(ptr noundef readonly %u) local_unnamed_addr #4 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%1 = load i32, ptr %u.tr5, align 8, !tbaa !17
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%l = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 1
%2 = load ptr, ptr %l, align 8, !tbaa !9
tail call void @Porder(ptr noundef %2)
%r = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 2
%3 = load ptr, ptr %r, align 8, !tbaa !14
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #2 {
entry:
%n = alloca i32, align 4
%v = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #9
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #9
%call = tail call noalias dereferenceable_or_null(7) ptr @malloc(i64 noundef 7) #10
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !20
%cmp69 = icmp sgt i32 %0, 0
br i1 %cmp69, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.070 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.5, ptr noundef %call)
%1 = load i8, ptr %call, align 1, !tbaa !21
%cmp3 = icmp eq i8 %1, 102
br i1 %cmp3, label %if.then, label %if.else12
if.then: ; preds = %for.body
%call5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %v)
%2 = load ptr, ptr @root, align 8, !tbaa !5
%3 = load i32, ptr %v, align 4, !tbaa !20
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10.i = icmp eq ptr %4, %2
br i1 %cmp.not10.i, label %find.exit, label %land.rhs.i
land.rhs.i: ; preds = %if.then, %while.body.i
%u.addr.011.i = phi ptr [ %u.addr.1.i, %while.body.i ], [ %2, %if.then ]
%5 = load i32, ptr %u.addr.011.i, align 8, !tbaa !17
%cmp1.not.i = icmp eq i32 %5, %3
br i1 %cmp1.not.i, label %find.exit, label %while.body.i
while.body.i: ; preds = %land.rhs.i
%cmp3.i = icmp sgt i32 %5, %3
%l.i = getelementptr inbounds %struct.Node, ptr %u.addr.011.i, i64 0, i32 1
%r.i = getelementptr inbounds %struct.Node, ptr %u.addr.011.i, i64 0, i32 2
%u.addr.1.in.i = select i1 %cmp3.i, ptr %l.i, ptr %r.i
%u.addr.1.i = load ptr, ptr %u.addr.1.in.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %u.addr.1.i, %4
br i1 %cmp.not.i, label %if.else, label %land.rhs.i, !llvm.loop !18
find.exit: ; preds = %land.rhs.i, %if.then
%u.addr.0.lcssa.i = phi ptr [ %2, %if.then ], [ %u.addr.011.i, %land.rhs.i ]
%cmp7.not = icmp eq ptr %u.addr.0.lcssa.i, %4
br i1 %cmp7.not, label %if.else, label %if.then9
if.then9: ; preds = %find.exit
%puts42 = call i32 @puts(ptr nonnull dereferenceable(1) @str.9)
br label %for.inc
if.else: ; preds = %while.body.i, %find.exit
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.else12: ; preds = %for.body
%call13 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %call, ptr noundef nonnull dereferenceable(7) @.str.1) #11
%cmp14 = icmp eq i32 %call13, 0
br i1 %cmp14, label %if.then16, label %if.else18
if.then16: ; preds = %if.else12
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %v)
%6 = load i32, ptr %v, align 4, !tbaa !20
%7 = load ptr, ptr @NIL, align 8, !tbaa !5
%8 = load ptr, ptr @root, align 8, !tbaa !5
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #10
store i32 %6, ptr %call.i, align 8, !tbaa !17
%l.i43 = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 1
store ptr %7, ptr %l.i43, align 8, !tbaa !9
%r.i44 = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 2
store ptr %7, ptr %r.i44, align 8, !tbaa !14
%cmp.not34.i = icmp eq ptr %8, %7
br i1 %cmp.not34.i, label %while.end.thread.i, label %while.body.i45
while.end.thread.i: ; preds = %if.then16
%p37.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 3
store ptr %7, ptr %p37.i, align 8, !tbaa !15
br label %insert.exit
while.body.i45: ; preds = %if.then16, %while.body.i45
%x.035.i = phi ptr [ %x.1.i, %while.body.i45 ], [ %8, %if.then16 ]
%9 = load i32, ptr %x.035.i, align 8, !tbaa !17
%cmp3.i46 = icmp sgt i32 %9, %6
%l4.i = getelementptr inbounds %struct.Node, ptr %x.035.i, i64 0, i32 1
%r5.i = getelementptr inbounds %struct.Node, ptr %x.035.i, i64 0, i32 2
%x.1.in.i = select i1 %cmp3.i46, ptr %l4.i, ptr %r5.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !5
%cmp.not.i47 = icmp eq ptr %x.1.i, %7
br i1 %cmp.not.i47, label %while.end.i, label %while.body.i45, !llvm.loop !19
while.end.i: ; preds = %while.body.i45
%p.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 3
store ptr %x.035.i, ptr %p.i, align 8, !tbaa !15
%cmp6.i = icmp eq ptr %x.035.i, %7
%spec.select67 = select i1 %cmp6.i, ptr @root, ptr %x.1.in.i
br label %insert.exit
insert.exit: ; preds = %while.end.i, %while.end.thread.i
%l13.sink.i = phi ptr [ @root, %while.end.thread.i ], [ %spec.select67, %while.end.i ]
store ptr %call.i, ptr %l13.sink.i, align 8, !tbaa !5
br label %for.inc
if.else18: ; preds = %if.else12
%call19 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %call, ptr noundef nonnull dereferenceable(6) @.str.2) #11
%cmp20 = icmp eq i32 %call19, 0
br i1 %cmp20, label %if.then22, label %if.else25
if.then22: ; preds = %if.else18
%10 = load ptr, ptr @root, align 8, !tbaa !5
call void @Iorder(ptr noundef %10)
%putchar = call i32 @putchar(i32 10)
%11 = load ptr, ptr @root, align 8, !tbaa !5
call void @Porder(ptr noundef %11)
%putchar41 = call i32 @putchar(i32 10)
br label %for.inc
if.else25: ; preds = %if.else18
%call26 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %call, ptr noundef nonnull dereferenceable(7) @.str.3) #11
%cmp27 = icmp eq i32 %call26, 0
br i1 %cmp27, label %if.then29, label %for.inc
if.then29: ; preds = %if.else25
%call30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %v)
%12 = load ptr, ptr @root, align 8, !tbaa !5
%13 = load i32, ptr %v, align 4, !tbaa !20
%14 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10.i48 = icmp eq ptr %14, %12
br i1 %cmp.not10.i48, label %find.exit61, label %land.rhs.i49
land.rhs.i49: ; preds = %if.then29, %while.body.i52
%u.addr.011.i50 = phi ptr [ %u.addr.1.i57, %while.body.i52 ], [ %12, %if.then29 ]
%15 = load i32, ptr %u.addr.011.i50, align 8, !tbaa !17
%cmp1.not.i51 = icmp eq i32 %15, %13
br i1 %cmp1.not.i51, label %find.exit61, label %while.body.i52
while.body.i52: ; preds = %land.rhs.i49
%cmp3.i53 = icmp sgt i32 %15, %13
%l.i54 = getelementptr inbounds %struct.Node, ptr %u.addr.011.i50, i64 0, i32 1
%r.i55 = getelementptr inbounds %struct.Node, ptr %u.addr.011.i50, i64 0, i32 2
%u.addr.1.in.i56 = select i1 %cmp3.i53, ptr %l.i54, ptr %r.i55
%u.addr.1.i57 = load ptr, ptr %u.addr.1.in.i56, align 8, !tbaa !5
%cmp.not.i58 = icmp eq ptr %u.addr.1.i57, %14
br i1 %cmp.not.i58, label %find.exit61, label %land.rhs.i49, !llvm.loop !18
find.exit61: ; preds = %land.rhs.i49, %while.body.i52, %if.then29
%u.addr.0.lcssa.i60 = phi ptr [ %12, %if.then29 ], [ %u.addr.011.i50, %land.rhs.i49 ], [ %14, %while.body.i52 ]
%l.i62 = getelementptr inbounds %struct.Node, ptr %u.addr.0.lcssa.i60, i64 0, i32 1
%16 = load ptr, ptr %l.i62, align 8, !tbaa !9
%cmp.i = icmp eq ptr %16, %14
br i1 %cmp.i, label %if.else6.i, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %find.exit61
%r.i63 = getelementptr inbounds %struct.Node, ptr %u.addr.0.lcssa.i60, i64 0, i32 2
%17 = load ptr, ptr %r.i63, align 8, !tbaa !14
%cmp1.i = icmp eq ptr %17, %14
br i1 %cmp1.i, label %if.end8.i, label %while.cond.i.i.i
while.cond.i.i.i: ; preds = %lor.lhs.false.i, %while.cond.i.i.i
%v.addr.0.i.i.i = phi ptr [ %18, %while.cond.i.i.i ], [ %17, %lor.lhs.false.i ]
%l.i.i.i = getelementptr inbounds %struct.Node, ptr %v.addr.0.i.i.i, i64 0, i32 1
%18 = load ptr, ptr %l.i.i.i, align 8, !tbaa !9
%cmp.not.i.i.i = icmp eq ptr %18, %14
br i1 %cmp.not.i.i.i, label %if.else6.i, label %while.cond.i.i.i, !llvm.loop !12
if.else6.i: ; preds = %while.cond.i.i.i, %find.exit61
%y.057.i = phi ptr [ %u.addr.0.lcssa.i60, %find.exit61 ], [ %v.addr.0.i.i.i, %while.cond.i.i.i ]
%r7.i = getelementptr inbounds %struct.Node, ptr %y.057.i, i64 0, i32 2
%19 = load ptr, ptr %r7.i, align 8, !tbaa !14
br label %if.end8.i
if.end8.i: ; preds = %lor.lhs.false.i, %if.else6.i
%y.056.i = phi ptr [ %y.057.i, %if.else6.i ], [ %u.addr.0.lcssa.i60, %lor.lhs.false.i ]
%x.0.i = phi ptr [ %19, %if.else6.i ], [ %16, %lor.lhs.false.i ]
%cmp9.not.i = icmp eq ptr %x.0.i, %14
br i1 %cmp9.not.i, label %if.end12.i, label %if.then10.i
if.then10.i: ; preds = %if.end8.i
%p.i64 = getelementptr inbounds %struct.Node, ptr %y.056.i, i64 0, i32 3
%20 = load ptr, ptr %p.i64, align 8, !tbaa !15
%p11.i = getelementptr inbounds %struct.Node, ptr %x.0.i, i64 0, i32 3
store ptr %20, ptr %p11.i, align 8, !tbaa !15
br label %if.end12.i
if.end12.i: ; preds = %if.then10.i, %if.end8.i
%p13.i = getelementptr inbounds %struct.Node, ptr %y.056.i, i64 0, i32 3
%21 = load ptr, ptr %p13.i, align 8, !tbaa !15
%cmp14.i = icmp eq ptr %21, %14
br i1 %cmp14.i, label %if.end27.i, label %if.else16.i
if.else16.i: ; preds = %if.end12.i
%l18.i = getelementptr inbounds %struct.Node, ptr %21, i64 0, i32 1
%22 = load ptr, ptr %l18.i, align 8, !tbaa !9
%cmp19.i = icmp eq ptr %y.056.i, %22
%r25.i = getelementptr inbounds %struct.Node, ptr %21, i64 0, i32 2
%spec.select.i = select i1 %cmp19.i, ptr %l18.i, ptr %r25.i
br label %if.end27.i
if.end27.i: ; preds = %if.else16.i, %if.end12.i
%l18.sink.i = phi ptr [ @root, %if.end12.i ], [ %spec.select.i, %if.else16.i ]
store ptr %x.0.i, ptr %l18.sink.i, align 8, !tbaa !5
%cmp28.not.i = icmp eq ptr %y.056.i, %u.addr.0.lcssa.i60
br i1 %cmp28.not.i, label %tDelete.exit, label %if.then29.i
if.then29.i: ; preds = %if.end27.i
%23 = load i32, ptr %y.056.i, align 8, !tbaa !17
store i32 %23, ptr %u.addr.0.lcssa.i60, align 8, !tbaa !17
br label %tDelete.exit
tDelete.exit: ; preds = %if.end27.i, %if.then29.i
call void @free(ptr noundef nonnull %y.056.i) #9
br label %for.inc
for.inc: ; preds = %if.else, %if.then9, %if.then22, %tDelete.exit, %if.else25, %insert.exit
%inc = add nuw nsw i32 %i.070, 1
%24 = load i32, ptr %n, align 4, !tbaa !20
%cmp = icmp slt i32 %inc, %24
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !22
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #9
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #6
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #7
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #8
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #8
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 = { 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 = { 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 #4 = { nofree 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 #5 = { 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 #6 = { 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 #7 = { 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 #8 = { nofree nounwind }
attributes #9 = { nounwind }
attributes #10 = { nounwind allocsize(0) }
attributes #11 = { nounwind willreturn memory(read) }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"Node", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !6, i64 16}
!15 = !{!10, !6, i64 24}
!16 = distinct !{!16, !13}
!17 = !{!10, !11, i64 0}
!18 = distinct !{!18, !13}
!19 = distinct !{!19, !13}
!20 = !{!11, !11, i64 0}
!21 = !{!7, !7, i64 0}
!22 = distinct !{!22, !13}
|
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
#define DEBUG
typedef struct node{
struct node* parent;
struct node* left;
struct node* right;
int k;
}Node;
Node* tree;
void insert(int);
void inorder(Node*);
void preorder(Node*);
void delete(Node*);
Node* find(Node*,int);
Node* Minimum(Node*);
Node* Successor(Node*);
int main(){
int m,i,k;
char hairetu[10];
Node* f;
scanf("%d",&m);
for(i=0;i<m;i++){
scanf("%s",hairetu);
if(hairetu[0]=='i'){
scanf("%d",&k);
insert(k);
}
else if(hairetu[0]=='p'){
inorder(tree);
printf("\n");
preorder(tree);
printf("\n");
}
else if(hairetu[0]=='f'){
scanf("%d",&k);
f=find(tree,k);
if(f!=NIL) printf("yes\n");
else printf("no\n");
}
else if(hairetu[0]=='d'){
scanf("%d",&k);
if((f=find(tree,k))!=NIL) delete(f);
}
}
return 0;
}
void insert(int k){
Node* y = NIL;
Node* x = tree;
Node* z;
z=(Node *)malloc(sizeof(Node));
z->k=k;
z->left=NIL;
z->right=NIL;
while(x!=NIL){
y=x;
if(z->k < x->k ){
x = x->left;
}
else{
x = x->right;
}
}
z->parent = y;
if(y==NIL) tree=z;
else if(z->k < y->k) y->left=z;
else y->right=z;
return;
}
void inorder(Node* tree){
if(tree != NIL){
inorder(tree->left);
printf(" %d",tree->k);
inorder(tree->right);
}
return;
}
void preorder(Node* tree){
if(tree != NIL){
printf(" %d",tree->k);
preorder(tree->left);
preorder(tree->right);
}
return;
}
Node* find(Node* tree,int f){
if(tree != NIL){
if(tree->k == f) return tree;
if(tree->k > f) return find(tree->left,f);
else return find(tree->right,f);
}
else return NIL;
}
void delete(Node* z){
Node* y;
Node* x;
if(z->left == NIL || z->right == NIL) y=z;
else y=Successor(z);
if(y->left!=NIL) x = y->left;
else x=y->right;
if(x!=NIL) x->parent = y->parent;
if(y->parent==NIL) tree=x;
else if(y==y->parent->left) y->parent->left=x;
else y->parent->right = x;
if(y!=z){
z->k = y->k;
}
return;
}
Node* Minimum(Node* x){
while(x->left != NIL){
x=x->left;
}
return x;
}
Node* Successor(Node* x){
Node* y;
if(x->right != NIL) return Minimum(x->right);
y = x->parent;
while(y!=NIL && x==y->right){
x=y;
y=y->parent;
}
return y;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206838/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206838/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { ptr, ptr, ptr, i32 }
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@tree = dso_local local_unnamed_addr global ptr null, align 8
@.str.5 = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%m = alloca i32, align 4
%k = alloca i32, align 4
%hairetu = alloca [10 x i8], align 1
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %m) #8
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #8
call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %hairetu) #8
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %m)
%0 = load i32, ptr %m, align 4, !tbaa !5
%cmp74 = icmp sgt i32 %0, 0
br i1 %cmp74, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.075 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %hairetu)
%1 = load i8, ptr %hairetu, align 1, !tbaa !9
switch i8 %1, label %for.inc [
i8 105, label %if.then
i8 112, label %if.then9
i8 102, label %if.then17
i8 100, label %if.then31
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %k)
%2 = load i32, ptr %k, align 4, !tbaa !5
%3 = load ptr, ptr @tree, align 8, !tbaa !10
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #9
%k1.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store i32 %2, ptr %k1.i, align 8, !tbaa !12
%left.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 1
%cmp.not35.i = icmp eq ptr %3, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %left.i, i8 0, i64 16, i1 false)
br i1 %cmp.not35.i, label %insert.exit, label %while.body.i
while.body.i: ; preds = %if.then, %while.body.i
%x.036.i = phi ptr [ %x.1.i, %while.body.i ], [ %3, %if.then ]
%k3.i = getelementptr inbounds %struct.node, ptr %x.036.i, i64 0, i32 3
%4 = load i32, ptr %k3.i, align 8, !tbaa !12
%cmp4.i = icmp sgt i32 %4, %2
%left5.i = getelementptr inbounds %struct.node, ptr %x.036.i, i64 0, i32 1
%right6.i = getelementptr inbounds %struct.node, ptr %x.036.i, i64 0, i32 2
%x.1.in.i = select i1 %cmp4.i, ptr %left5.i, ptr %right6.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !10
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %insert.exit, label %while.body.i, !llvm.loop !14
insert.exit: ; preds = %while.body.i, %if.then
%storemerge = phi ptr [ null, %if.then ], [ %x.036.i, %while.body.i ]
%left14.sink.i = phi ptr [ @tree, %if.then ], [ %x.1.in.i, %while.body.i ]
store ptr %storemerge, ptr %call.i, align 8, !tbaa !16
store ptr %call.i, ptr %left14.sink.i, align 8, !tbaa !10
br label %for.inc
if.then9: ; preds = %for.body
%5 = load ptr, ptr @tree, align 8, !tbaa !10
call void @inorder(ptr noundef %5)
%putchar = call i32 @putchar(i32 10)
%6 = load ptr, ptr @tree, align 8, !tbaa !10
call void @preorder(ptr noundef %6)
%putchar45 = call i32 @putchar(i32 10)
br label %for.inc
if.then17: ; preds = %for.body
%call18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %k)
%7 = load ptr, ptr @tree, align 8, !tbaa !10
%8 = load i32, ptr %k, align 4, !tbaa !5
%cmp.not16.i = icmp eq ptr %7, null
br i1 %cmp.not16.i, label %if.else24, label %if.then.i
if.then.i: ; preds = %if.then17, %if.end.i
%tree.tr17.i = phi ptr [ %tree.tr.be.i, %if.end.i ], [ %7, %if.then17 ]
%k.i = getelementptr inbounds %struct.node, ptr %tree.tr17.i, i64 0, i32 3
%9 = load i32, ptr %k.i, align 8, !tbaa !12
%cmp1.i = icmp eq i32 %9, %8
br i1 %cmp1.i, label %if.then22, label %if.end.i
if.end.i: ; preds = %if.then.i
%cmp4.i46 = icmp sgt i32 %9, %8
%left.i47 = getelementptr inbounds %struct.node, ptr %tree.tr17.i, i64 0, i32 1
%right.i = getelementptr inbounds %struct.node, ptr %tree.tr17.i, i64 0, i32 2
%tree.tr.be.in.i = select i1 %cmp4.i46, ptr %left.i47, ptr %right.i
%tree.tr.be.i = load ptr, ptr %tree.tr.be.in.i, align 8, !tbaa !10
%cmp.not.i48 = icmp eq ptr %tree.tr.be.i, null
br i1 %cmp.not.i48, label %if.else24, label %if.then.i
if.then22: ; preds = %if.then.i
%puts44 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else24: ; preds = %if.end.i, %if.then17
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then31: ; preds = %for.body
%call32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %k)
%10 = load ptr, ptr @tree, align 8, !tbaa !10
%11 = load i32, ptr %k, align 4, !tbaa !5
%cmp.not16.i49 = icmp eq ptr %10, null
br i1 %cmp.not16.i49, label %for.inc, label %if.then.i50
if.then.i50: ; preds = %if.then31, %if.end.i54
%tree.tr17.i51 = phi ptr [ %tree.tr.be.i59, %if.end.i54 ], [ %10, %if.then31 ]
%k.i52 = getelementptr inbounds %struct.node, ptr %tree.tr17.i51, i64 0, i32 3
%12 = load i32, ptr %k.i52, align 8, !tbaa !12
%cmp1.i53 = icmp eq i32 %12, %11
%left.i63 = getelementptr inbounds %struct.node, ptr %tree.tr17.i51, i64 0, i32 1
br i1 %cmp1.i53, label %if.then36, label %if.end.i54
if.end.i54: ; preds = %if.then.i50
%cmp4.i55 = icmp sgt i32 %12, %11
%right.i57 = getelementptr inbounds %struct.node, ptr %tree.tr17.i51, i64 0, i32 2
%tree.tr.be.in.i58 = select i1 %cmp4.i55, ptr %left.i63, ptr %right.i57
%tree.tr.be.i59 = load ptr, ptr %tree.tr.be.in.i58, align 8, !tbaa !10
%cmp.not.i60 = icmp eq ptr %tree.tr.be.i59, null
br i1 %cmp.not.i60, label %for.inc, label %if.then.i50
if.then36: ; preds = %if.then.i50
%k.i52.le = getelementptr inbounds %struct.node, ptr %tree.tr17.i51, i64 0, i32 3
%13 = load ptr, ptr %left.i63, align 8, !tbaa !17
%cmp.i = icmp eq ptr %13, null
br i1 %cmp.i, label %if.end8.i, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %if.then36
%right.i64 = getelementptr inbounds %struct.node, ptr %tree.tr17.i51, i64 0, i32 2
%14 = load ptr, ptr %right.i64, align 8, !tbaa !18
%cmp1.i65 = icmp eq ptr %14, null
br i1 %cmp1.i65, label %if.then10.i, label %while.cond.i.i.i
while.cond.i.i.i: ; preds = %lor.lhs.false.i, %while.cond.i.i.i
%x.addr.0.i.i.i = phi ptr [ %15, %while.cond.i.i.i ], [ %14, %lor.lhs.false.i ]
%left.i.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i.i, i64 0, i32 1
%15 = load ptr, ptr %left.i.i.i, align 8, !tbaa !17
%cmp.not.i.i.i = icmp eq ptr %15, null
br i1 %cmp.not.i.i.i, label %if.end8.i, label %while.cond.i.i.i, !llvm.loop !19
if.end8.i: ; preds = %while.cond.i.i.i, %if.then36
%y.0.ph.i = phi ptr [ %tree.tr17.i51, %if.then36 ], [ %x.addr.0.i.i.i, %while.cond.i.i.i ]
%right7.i = getelementptr inbounds %struct.node, ptr %y.0.ph.i, i64 0, i32 2
%16 = load ptr, ptr %right7.i, align 8, !tbaa !18
%cmp9.not.i = icmp eq ptr %16, null
br i1 %cmp9.not.i, label %if.end12.i, label %if.then10.i
if.then10.i: ; preds = %if.end8.i, %lor.lhs.false.i
%y.058.i = phi ptr [ %y.0.ph.i, %if.end8.i ], [ %tree.tr17.i51, %lor.lhs.false.i ]
%x.054.i = phi ptr [ %16, %if.end8.i ], [ %13, %lor.lhs.false.i ]
%17 = load ptr, ptr %y.058.i, align 8, !tbaa !16
store ptr %17, ptr %x.054.i, align 8, !tbaa !16
br label %if.end12.i
if.end12.i: ; preds = %if.then10.i, %if.end8.i
%y.059.i = phi ptr [ %y.058.i, %if.then10.i ], [ %y.0.ph.i, %if.end8.i ]
%x.055.i = phi ptr [ %x.054.i, %if.then10.i ], [ null, %if.end8.i ]
%18 = load ptr, ptr %y.059.i, align 8, !tbaa !16
%cmp14.i = icmp eq ptr %18, null
br i1 %cmp14.i, label %if.end27.i, label %if.else16.i
if.else16.i: ; preds = %if.end12.i
%left18.i = getelementptr inbounds %struct.node, ptr %18, i64 0, i32 1
%19 = load ptr, ptr %left18.i, align 8, !tbaa !17
%cmp19.i = icmp eq ptr %y.059.i, %19
%right25.i = getelementptr inbounds %struct.node, ptr %18, i64 0, i32 2
%spec.select.i = select i1 %cmp19.i, ptr %left18.i, ptr %right25.i
br label %if.end27.i
if.end27.i: ; preds = %if.else16.i, %if.end12.i
%left18.sink.i = phi ptr [ @tree, %if.end12.i ], [ %spec.select.i, %if.else16.i ]
store ptr %x.055.i, ptr %left18.sink.i, align 8, !tbaa !10
%cmp28.not.i = icmp eq ptr %y.059.i, %tree.tr17.i51
br i1 %cmp28.not.i, label %for.inc, label %if.then29.i
if.then29.i: ; preds = %if.end27.i
%k.i66 = getelementptr inbounds %struct.node, ptr %y.059.i, i64 0, i32 3
%20 = load i32, ptr %k.i66, align 8, !tbaa !12
store i32 %20, ptr %k.i52.le, align 8, !tbaa !12
br label %for.inc
for.inc: ; preds = %if.end.i54, %if.then31, %if.then29.i, %if.end27.i, %for.body, %insert.exit, %if.else24, %if.then22, %if.then9
%inc = add nuw nsw i32 %i.075, 1
%21 = load i32, ptr %m, align 4, !tbaa !5
%cmp = icmp slt i32 %inc, %21
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !20
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %hairetu) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %m) #8
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @tree, align 8, !tbaa !10
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #9
%k1 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store i32 %k, ptr %k1, align 8, !tbaa !12
%left = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 1
%cmp.not35 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %left, i8 0, i64 16, i1 false)
br i1 %cmp.not35, label %if.then8, label %while.body
while.body: ; preds = %entry, %while.body
%x.036 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%k3 = getelementptr inbounds %struct.node, ptr %x.036, i64 0, i32 3
%1 = load i32, ptr %k3, align 8, !tbaa !12
%cmp4 = icmp sgt i32 %1, %k
%left5 = getelementptr inbounds %struct.node, ptr %x.036, i64 0, i32 1
%right6 = getelementptr inbounds %struct.node, ptr %x.036, i64 0, i32 2
%x.1.in = select i1 %cmp4, ptr %left5, ptr %right6
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !10
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else9, label %while.body, !llvm.loop !14
if.then8: ; preds = %entry
store ptr null, ptr %call, align 8, !tbaa !16
br label %if.end18
if.else9: ; preds = %while.body
store ptr %x.036, ptr %call, align 8, !tbaa !16
%k11 = getelementptr inbounds %struct.node, ptr %x.036, i64 0, i32 3
%2 = load i32, ptr %k11, align 8, !tbaa !12
%cmp12 = icmp sgt i32 %2, %k
br i1 %cmp12, label %if.then13, label %if.else15
if.then13: ; preds = %if.else9
%left14 = getelementptr inbounds %struct.node, ptr %x.036, i64 0, i32 1
br label %if.end18
if.else15: ; preds = %if.else9
%right16 = getelementptr inbounds %struct.node, ptr %x.036, i64 0, i32 2
br label %if.end18
if.end18: ; preds = %if.then13, %if.else15, %if.then8
%left14.sink = phi ptr [ %left14, %if.then13 ], [ %right16, %if.else15 ], [ @tree, %if.then8 ]
store ptr %call, ptr %left14.sink, align 8, !tbaa !10
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %tree) local_unnamed_addr #0 {
entry:
%cmp.not4 = icmp eq ptr %tree, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%tree.tr5 = phi ptr [ %2, %if.then ], [ %tree, %entry ]
%left = getelementptr inbounds %struct.node, ptr %tree.tr5, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !17
tail call void @inorder(ptr noundef %0)
%k = getelementptr inbounds %struct.node, ptr %tree.tr5, i64 0, i32 3
%1 = load i32, ptr %k, align 8, !tbaa !12
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %1)
%right = getelementptr inbounds %struct.node, ptr %tree.tr5, i64 0, i32 2
%2 = load ptr, ptr %right, align 8, !tbaa !18
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %tree) local_unnamed_addr #0 {
entry:
%cmp.not4 = icmp eq ptr %tree, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%tree.tr5 = phi ptr [ %2, %if.then ], [ %tree, %entry ]
%k = getelementptr inbounds %struct.node, ptr %tree.tr5, i64 0, i32 3
%0 = load i32, ptr %k, align 8, !tbaa !12
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %tree.tr5, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !17
tail call void @preorder(ptr noundef %1)
%right = getelementptr inbounds %struct.node, ptr %tree.tr5, i64 0, i32 2
%2 = load ptr, ptr %right, align 8, !tbaa !18
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @find(ptr noundef readonly %tree, i32 noundef %f) local_unnamed_addr #3 {
entry:
%cmp.not16 = icmp eq ptr %tree, null
br i1 %cmp.not16, label %return, label %if.then
if.then: ; preds = %entry, %if.end
%tree.tr17 = phi ptr [ %tree.tr.be, %if.end ], [ %tree, %entry ]
%k = getelementptr inbounds %struct.node, ptr %tree.tr17, i64 0, i32 3
%0 = load i32, ptr %k, align 8, !tbaa !12
%cmp1 = icmp eq i32 %0, %f
br i1 %cmp1, label %return, label %if.end
if.end: ; preds = %if.then
%cmp4 = icmp sgt i32 %0, %f
%left = getelementptr inbounds %struct.node, ptr %tree.tr17, i64 0, i32 1
%right = getelementptr inbounds %struct.node, ptr %tree.tr17, i64 0, i32 2
%tree.tr.be.in = select i1 %cmp4, ptr %left, ptr %right
%tree.tr.be = load ptr, ptr %tree.tr.be.in, align 8, !tbaa !10
%cmp.not = icmp eq ptr %tree.tr.be, null
br i1 %cmp.not, label %return, label %if.then
return: ; preds = %if.then, %if.end, %entry
%retval.0 = phi ptr [ null, %entry ], [ null, %if.end ], [ %tree.tr17, %if.then ]
ret ptr %retval.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @delete(ptr noundef %z) local_unnamed_addr #4 {
entry:
%left = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !17
%cmp = icmp eq ptr %0, null
br i1 %cmp, label %if.end8, label %lor.lhs.false
lor.lhs.false: ; preds = %entry
%right = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 2
%1 = load ptr, ptr %right, align 8, !tbaa !18
%cmp1 = icmp eq ptr %1, null
br i1 %cmp1, label %if.then10, label %while.cond.i.i
while.cond.i.i: ; preds = %lor.lhs.false, %while.cond.i.i
%x.addr.0.i.i = phi ptr [ %2, %while.cond.i.i ], [ %1, %lor.lhs.false ]
%left.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i, i64 0, i32 1
%2 = load ptr, ptr %left.i.i, align 8, !tbaa !17
%cmp.not.i.i = icmp eq ptr %2, null
br i1 %cmp.not.i.i, label %if.end8, label %while.cond.i.i, !llvm.loop !19
if.end8: ; preds = %while.cond.i.i, %entry
%y.0.ph = phi ptr [ %z, %entry ], [ %x.addr.0.i.i, %while.cond.i.i ]
%right7 = getelementptr inbounds %struct.node, ptr %y.0.ph, i64 0, i32 2
%3 = load ptr, ptr %right7, align 8, !tbaa !18
%cmp9.not = icmp eq ptr %3, null
br i1 %cmp9.not, label %if.end12, label %if.then10
if.then10: ; preds = %lor.lhs.false, %if.end8
%y.058 = phi ptr [ %y.0.ph, %if.end8 ], [ %z, %lor.lhs.false ]
%x.054 = phi ptr [ %3, %if.end8 ], [ %0, %lor.lhs.false ]
%4 = load ptr, ptr %y.058, align 8, !tbaa !16
store ptr %4, ptr %x.054, align 8, !tbaa !16
br label %if.end12
if.end12: ; preds = %if.then10, %if.end8
%y.059 = phi ptr [ %y.058, %if.then10 ], [ %y.0.ph, %if.end8 ]
%x.055 = phi ptr [ %x.054, %if.then10 ], [ null, %if.end8 ]
%5 = load ptr, ptr %y.059, align 8, !tbaa !16
%cmp14 = icmp eq ptr %5, null
br i1 %cmp14, label %if.end27, label %if.else16
if.else16: ; preds = %if.end12
%left18 = getelementptr inbounds %struct.node, ptr %5, i64 0, i32 1
%6 = load ptr, ptr %left18, align 8, !tbaa !17
%cmp19 = icmp eq ptr %y.059, %6
%right25 = getelementptr inbounds %struct.node, ptr %5, i64 0, i32 2
%spec.select = select i1 %cmp19, ptr %left18, ptr %right25
br label %if.end27
if.end27: ; preds = %if.else16, %if.end12
%left18.sink = phi ptr [ @tree, %if.end12 ], [ %spec.select, %if.else16 ]
store ptr %x.055, ptr %left18.sink, align 8, !tbaa !10
%cmp28.not = icmp eq ptr %y.059, %z
br i1 %cmp28.not, label %if.end31, label %if.then29
if.then29: ; preds = %if.end27
%k = getelementptr inbounds %struct.node, ptr %y.059, i64 0, i32 3
%7 = load i32, ptr %k, align 8, !tbaa !12
%k30 = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 3
store i32 %7, ptr %k30, align 8, !tbaa !12
br label %if.end31
if.end31: ; preds = %if.then29, %if.end27
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @Successor(ptr noundef readonly %x) local_unnamed_addr #3 {
entry:
%right = getelementptr inbounds %struct.node, ptr %x, i64 0, i32 2
%0 = load ptr, ptr %right, align 8, !tbaa !18
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%x.addr.0.i = phi ptr [ %1, %while.cond.i ], [ %0, %entry ]
%left.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i, i64 0, i32 1
%1 = load ptr, ptr %left.i, align 8, !tbaa !17
%cmp.not.i = icmp eq ptr %1, null
br i1 %cmp.not.i, label %cleanup, label %while.cond.i, !llvm.loop !19
while.cond: ; preds = %entry, %land.rhs
%x.addr.0 = phi ptr [ %y.0, %land.rhs ], [ %x, %entry ]
%y.0 = load ptr, ptr %x.addr.0, align 8, !tbaa !16
%cmp2.not = icmp eq ptr %y.0, null
br i1 %cmp2.not, label %cleanup, label %land.rhs
land.rhs: ; preds = %while.cond
%right3 = getelementptr inbounds %struct.node, ptr %y.0, i64 0, i32 2
%2 = load ptr, ptr %right3, align 8, !tbaa !18
%cmp4 = icmp eq ptr %x.addr.0, %2
br i1 %cmp4, label %while.cond, label %cleanup, !llvm.loop !21
cleanup: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi ptr [ %y.0, %land.rhs ], [ null, %while.cond ], [ %x.addr.0.i, %while.cond.i ]
ret ptr %retval.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @Minimum(ptr noundef readonly %x) local_unnamed_addr #3 {
entry:
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%x.addr.0 = phi ptr [ %x, %entry ], [ %0, %while.cond ]
%left = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !17
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !19
while.end: ; preds = %while.cond
ret ptr %x.addr.0
}
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7
attributes #0 = { nofree 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 = { 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 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 #5 = { 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 #6 = { nofree nounwind }
attributes #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind }
attributes #9 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !6, i64 24}
!13 = !{!"node", !11, i64 0, !11, i64 8, !11, i64 16, !6, i64 24}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!13, !11, i64 0}
!17 = !{!13, !11, i64 8}
!18 = !{!13, !11, i64 16}
!19 = distinct !{!19, !15}
!20 = distinct !{!20, !15}
!21 = distinct !{!21, !15}
|
#include<stdio.h>
#include<stdlib.h>
struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x){
while(x -> left != NIL){
x = x -> left;
}
return x;
}
Node treeSearch(Node u, int k){
if(u == NIL || k == u -> key){
return u;
}
if(k < u -> key){
return treeSearch(u -> left,k);
}
else return treeSearch(u -> right,k);
}
Node treeSuccessor(Node x){
Node y;
if(x -> right != NIL){
return treeMinimum(x -> right);
}
y = x -> parent;
while(y != NIL && x == y -> right){
x = y;
y = y -> parent;
}
return y;
}
void treeDelete(Node z){
Node y; // node to be deleted
Node x; // child of y
if(z -> left == NIL || z -> right == NIL){
y = z;
}
else y = treeSuccessor(z);
if(y -> left != NIL){
x = y -> left;
}
else x = y -> right;
if(x != NIL){
x -> parent = y -> parent;
}
if(y -> parent == NIL){
root = x;
}
else if(y == y -> parent -> left)
y -> parent -> left = x;
else y -> parent -> right = x;
if(y != z){
z -> key = y -> key;
}
}
void insert(int k){
Node y = NIL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
while(x != NIL){
y = x;
if(z -> key < x -> key){
x = x -> left;
}
else x = x -> right;
}
z -> parent = y;
if(y == NIL){
root = z;
}
else if(z -> key < y -> key){
y -> left =z;
}
else y -> right = z;
}
void inorder(Node u){
if(u -> left != NIL){
inorder(u -> left);
}
printf(" %d",u -> key);
if(u -> right != NIL){
inorder(u -> right);
}
}
void preorder(Node u){
printf(" %d",u ->key);
if(u -> left != NIL){
preorder(u -> left);
}
if(u -> right != NIL){
preorder(u -> right);
}
}
int main(){
int n, i, x;
char com[20];
scanf("%d", &n);
for ( i = 0; i < n; i++ ){
scanf("%s", com);
if ( com[0] == 'f' ){
scanf("%d", &x);
Node t = treeSearch(root, x);
if ( t != NIL ) printf("yes\n");
else printf("no\n");
} else if ( com[0] == 'i' ){
scanf("%d", &x);
insert(x);
} else if ( com[0] == 'p' ){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
} else if ( com[0] == 'd' ){
scanf("%d", &x);
treeDelete(treeSearch(root, x));
}
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206881/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206881/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { ptr, ptr, ptr, i32 }
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeMinimum(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%x.addr.0 = phi ptr [ %x, %entry ], [ %0, %while.cond ]
%left = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !11
while.end: ; preds = %while.cond
ret ptr %x.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSearch(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #0 {
entry:
%cmp14 = icmp eq ptr %u, null
br i1 %cmp14, label %return, label %lor.lhs.false
lor.lhs.false: ; preds = %entry, %if.end
%u.tr15 = phi ptr [ %u.tr.be, %if.end ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !13
%cmp1 = icmp eq i32 %0, %k
br i1 %cmp1, label %return, label %if.end
if.end: ; preds = %lor.lhs.false
%cmp3 = icmp sgt i32 %0, %k
%left = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 1
%spec.select = select i1 %cmp3, ptr %left, ptr %u.tr15
%u.tr.be = load ptr, ptr %spec.select, align 8, !tbaa !14
%cmp = icmp eq ptr %u.tr.be, null
br i1 %cmp, label %return, label %lor.lhs.false
return: ; preds = %lor.lhs.false, %if.end, %entry
%retval.0 = phi ptr [ null, %entry ], [ null, %if.end ], [ %u.tr15, %lor.lhs.false ]
ret ptr %retval.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSuccessor(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr %x, align 8, !tbaa !15
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%x.addr.0.i = phi ptr [ %1, %while.cond.i ], [ %0, %entry ]
%left.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i, i64 0, i32 1
%1 = load ptr, ptr %left.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %1, null
br i1 %cmp.not.i, label %cleanup, label %while.cond.i, !llvm.loop !11
while.cond: ; preds = %entry, %land.rhs
%x.addr.0 = phi ptr [ %y.0, %land.rhs ], [ %x, %entry ]
%y.0.in = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 2
%y.0 = load ptr, ptr %y.0.in, align 8, !tbaa !16
%cmp2.not = icmp eq ptr %y.0, null
br i1 %cmp2.not, label %cleanup, label %land.rhs
land.rhs: ; preds = %while.cond
%2 = load ptr, ptr %y.0, align 8, !tbaa !15
%cmp4 = icmp eq ptr %x.addr.0, %2
br i1 %cmp4, label %while.cond, label %cleanup, !llvm.loop !17
cleanup: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi ptr [ %y.0, %land.rhs ], [ null, %while.cond ], [ %x.addr.0.i, %while.cond.i ]
ret ptr %retval.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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @treeDelete(ptr noundef %z) local_unnamed_addr #2 {
entry:
%left = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
%cmp = icmp eq ptr %0, null
br i1 %cmp, label %if.end8, label %lor.lhs.false
lor.lhs.false: ; preds = %entry
%1 = load ptr, ptr %z, align 8, !tbaa !15
%cmp1 = icmp eq ptr %1, null
br i1 %cmp1, label %if.then10, label %while.cond.i.i
while.cond.i.i: ; preds = %lor.lhs.false, %while.cond.i.i
%x.addr.0.i.i = phi ptr [ %2, %while.cond.i.i ], [ %1, %lor.lhs.false ]
%left.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i, i64 0, i32 1
%2 = load ptr, ptr %left.i.i, align 8, !tbaa !5
%cmp.not.i.i = icmp eq ptr %2, null
br i1 %cmp.not.i.i, label %if.end8, label %while.cond.i.i, !llvm.loop !11
if.end8: ; preds = %while.cond.i.i, %entry
%y.0.ph = phi ptr [ %z, %entry ], [ %x.addr.0.i.i, %while.cond.i.i ]
%3 = load ptr, ptr %y.0.ph, align 8, !tbaa !15
%cmp9.not = icmp eq ptr %3, null
br i1 %cmp9.not, label %if.end12, label %if.then10
if.then10: ; preds = %lor.lhs.false, %if.end8
%y.058 = phi ptr [ %y.0.ph, %if.end8 ], [ %z, %lor.lhs.false ]
%x.054 = phi ptr [ %3, %if.end8 ], [ %0, %lor.lhs.false ]
%parent = getelementptr inbounds %struct.node, ptr %y.058, i64 0, i32 2
%4 = load ptr, ptr %parent, align 8, !tbaa !16
%parent11 = getelementptr inbounds %struct.node, ptr %x.054, i64 0, i32 2
store ptr %4, ptr %parent11, align 8, !tbaa !16
br label %if.end12
if.end12: ; preds = %if.then10, %if.end8
%y.060 = phi ptr [ %y.058, %if.then10 ], [ %y.0.ph, %if.end8 ]
%x.055 = phi ptr [ %x.054, %if.then10 ], [ null, %if.end8 ]
%parent13 = getelementptr inbounds %struct.node, ptr %y.060, i64 0, i32 2
%5 = load ptr, ptr %parent13, align 8, !tbaa !16
%cmp14 = icmp eq ptr %5, null
br i1 %cmp14, label %if.end27, label %if.else16
if.else16: ; preds = %if.end12
%left18 = getelementptr inbounds %struct.node, ptr %5, i64 0, i32 1
%6 = load ptr, ptr %left18, align 8, !tbaa !5
%cmp19 = icmp eq ptr %y.060, %6
%left18. = select i1 %cmp19, ptr %left18, ptr %5
br label %if.end27
if.end27: ; preds = %if.else16, %if.end12
%left18.sink = phi ptr [ @root, %if.end12 ], [ %left18., %if.else16 ]
store ptr %x.055, ptr %left18.sink, align 8, !tbaa !14
%cmp28.not = icmp eq ptr %y.060, %z
br i1 %cmp28.not, label %if.end31, label %if.then29
if.then29: ; preds = %if.end27
%key = getelementptr inbounds %struct.node, ptr %y.060, i64 0, i32 3
%7 = load i32, ptr %key, align 8, !tbaa !13
%key30 = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 3
store i32 %7, ptr %key30, align 8, !tbaa !13
br label %if.end31
if.end31: ; preds = %if.then29, %if.end27
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !14
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
%key = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store i32 %k, ptr %key, align 8, !tbaa !13
%cmp.not34 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call, i8 0, i64 16, i1 false)
br i1 %cmp.not34, label %if.then7, label %while.body
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%key2 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%1 = load i32, ptr %key2, align 8, !tbaa !13
%cmp3 = icmp sgt i32 %1, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %x.035
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !14
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else8, label %while.body, !llvm.loop !18
if.then7: ; preds = %entry
%parent37 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr null, ptr %parent37, align 8, !tbaa !16
br label %if.end17
if.else8: ; preds = %while.body
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr %x.035, ptr %parent, align 8, !tbaa !16
%key10 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%2 = load i32, ptr %key10, align 8, !tbaa !13
%cmp11 = icmp sgt i32 %2, %k
%left13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%spec.select = select i1 %cmp11, ptr %left13, ptr %x.035
br label %if.end17
if.end17: ; preds = %if.else8, %if.then7
%left13.sink = phi ptr [ @root, %if.then7 ], [ %spec.select, %if.else8 ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !14
ret void
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr nocapture noundef readonly %u) local_unnamed_addr #3 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%u.tr = phi ptr [ %u, %entry ], [ %2, %if.end ]
%left = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @inorder(ptr noundef nonnull %0)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%key = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 3
%1 = load i32, ptr %key, align 8, !tbaa !13
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%2 = load ptr, ptr %u.tr, align 8, !tbaa !15
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr nocapture noundef readonly %u) local_unnamed_addr #3 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%u.tr = phi ptr [ %u, %entry ], [ %2, %if.end ]
%key = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !13
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !5
%cmp.not = icmp eq ptr %1, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @preorder(ptr noundef nonnull %1)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%2 = load ptr, ptr %u.tr, align 8, !tbaa !15
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #3 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #9
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #9
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !19
%cmp66 = icmp sgt i32 %0, 0
br i1 %cmp66, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.067 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !20
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
i8 100, label %if.then31
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !14
%3 = load i32, ptr %x, align 4, !tbaa !19
%cmp14.i = icmp eq ptr %2, null
br i1 %cmp14.i, label %if.else, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %if.then, %if.end.i
%u.tr15.i = phi ptr [ %u.tr.be.i, %if.end.i ], [ %2, %if.then ]
%key.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 3
%4 = load i32, ptr %key.i, align 8, !tbaa !13
%cmp1.i = icmp eq i32 %4, %3
br i1 %cmp1.i, label %if.then8, label %if.end.i
if.end.i: ; preds = %lor.lhs.false.i
%cmp3.i = icmp sgt i32 %4, %3
%left.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 1
%spec.select.i = select i1 %cmp3.i, ptr %left.i, ptr %u.tr15.i
%u.tr.be.i = load ptr, ptr %spec.select.i, align 8, !tbaa !14
%cmp.i = icmp eq ptr %u.tr.be.i, null
br i1 %cmp.i, label %if.else, label %lor.lhs.false.i
if.then8: ; preds = %lor.lhs.false.i
%puts40 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %if.end.i, %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%5 = load i32, ptr %x, align 4, !tbaa !19
%6 = load ptr, ptr @root, align 8, !tbaa !14
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
%key.i41 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store i32 %5, ptr %key.i41, align 8, !tbaa !13
%cmp.not34.i = icmp eq ptr %6, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call.i, i8 0, i64 16, i1 false)
br i1 %cmp.not34.i, label %insert.exit, label %while.body.i
while.body.i: ; preds = %if.then16, %while.body.i
%x.035.i = phi ptr [ %x.1.i, %while.body.i ], [ %6, %if.then16 ]
%key2.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 3
%7 = load i32, ptr %key2.i, align 8, !tbaa !13
%cmp3.i42 = icmp sgt i32 %7, %5
%left4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i42, ptr %left4.i, ptr %x.035.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !14
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %insert.exit, label %while.body.i, !llvm.loop !18
insert.exit: ; preds = %while.body.i, %if.then16
%.sink = phi ptr [ null, %if.then16 ], [ %x.035.i, %while.body.i ]
%left13.sink.i = phi ptr [ @root, %if.then16 ], [ %x.1.in.i, %while.body.i ]
%parent37.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
store ptr %.sink, ptr %parent37.i, align 8, !tbaa !16
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !14
br label %for.inc
if.then23: ; preds = %for.body
%8 = load ptr, ptr @root, align 8, !tbaa !14
call void @inorder(ptr noundef %8)
%putchar = call i32 @putchar(i32 10)
%9 = load ptr, ptr @root, align 8, !tbaa !14
call void @preorder(ptr noundef %9)
%putchar39 = call i32 @putchar(i32 10)
br label %for.inc
if.then31: ; preds = %for.body
%call32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%10 = load ptr, ptr @root, align 8, !tbaa !14
%11 = load i32, ptr %x, align 4, !tbaa !19
%cmp14.i44 = icmp eq ptr %10, null
br i1 %cmp14.i44, label %treeSearch.exit56, label %lor.lhs.false.i45
lor.lhs.false.i45: ; preds = %if.then31, %if.end.i49
%u.tr15.i46 = phi ptr [ %u.tr.be.i53, %if.end.i49 ], [ %10, %if.then31 ]
%key.i47 = getelementptr inbounds %struct.node, ptr %u.tr15.i46, i64 0, i32 3
%12 = load i32, ptr %key.i47, align 8, !tbaa !13
%cmp1.i48 = icmp eq i32 %12, %11
br i1 %cmp1.i48, label %treeSearch.exit56, label %if.end.i49
if.end.i49: ; preds = %lor.lhs.false.i45
%cmp3.i50 = icmp sgt i32 %12, %11
%left.i51 = getelementptr inbounds %struct.node, ptr %u.tr15.i46, i64 0, i32 1
%spec.select.i52 = select i1 %cmp3.i50, ptr %left.i51, ptr %u.tr15.i46
%u.tr.be.i53 = load ptr, ptr %spec.select.i52, align 8, !tbaa !14
%cmp.i54 = icmp eq ptr %u.tr.be.i53, null
br i1 %cmp.i54, label %treeSearch.exit56, label %lor.lhs.false.i45
treeSearch.exit56: ; preds = %lor.lhs.false.i45, %if.end.i49, %if.then31
%retval.0.i55 = phi ptr [ null, %if.then31 ], [ %u.tr15.i46, %lor.lhs.false.i45 ], [ null, %if.end.i49 ]
%left.i57 = getelementptr inbounds %struct.node, ptr %retval.0.i55, i64 0, i32 1
%13 = load ptr, ptr %left.i57, align 8, !tbaa !5
%cmp.i58 = icmp eq ptr %13, null
br i1 %cmp.i58, label %if.end8.i, label %lor.lhs.false.i59
lor.lhs.false.i59: ; preds = %treeSearch.exit56
%14 = load ptr, ptr %retval.0.i55, align 8, !tbaa !15
%cmp1.i60 = icmp eq ptr %14, null
br i1 %cmp1.i60, label %if.then10.i, label %while.cond.i.i.i
while.cond.i.i.i: ; preds = %lor.lhs.false.i59, %while.cond.i.i.i
%x.addr.0.i.i.i = phi ptr [ %15, %while.cond.i.i.i ], [ %14, %lor.lhs.false.i59 ]
%left.i.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i.i, i64 0, i32 1
%15 = load ptr, ptr %left.i.i.i, align 8, !tbaa !5
%cmp.not.i.i.i = icmp eq ptr %15, null
br i1 %cmp.not.i.i.i, label %if.end8.i, label %while.cond.i.i.i, !llvm.loop !11
if.end8.i: ; preds = %while.cond.i.i.i, %treeSearch.exit56
%y.0.ph.i = phi ptr [ %retval.0.i55, %treeSearch.exit56 ], [ %x.addr.0.i.i.i, %while.cond.i.i.i ]
%16 = load ptr, ptr %y.0.ph.i, align 8, !tbaa !15
%cmp9.not.i = icmp eq ptr %16, null
br i1 %cmp9.not.i, label %if.end12.i, label %if.then10.i
if.then10.i: ; preds = %if.end8.i, %lor.lhs.false.i59
%y.058.i = phi ptr [ %y.0.ph.i, %if.end8.i ], [ %retval.0.i55, %lor.lhs.false.i59 ]
%x.054.i = phi ptr [ %16, %if.end8.i ], [ %13, %lor.lhs.false.i59 ]
%parent.i61 = getelementptr inbounds %struct.node, ptr %y.058.i, i64 0, i32 2
%17 = load ptr, ptr %parent.i61, align 8, !tbaa !16
%parent11.i = getelementptr inbounds %struct.node, ptr %x.054.i, i64 0, i32 2
store ptr %17, ptr %parent11.i, align 8, !tbaa !16
br label %if.end12.i
if.end12.i: ; preds = %if.then10.i, %if.end8.i
%y.060.i = phi ptr [ %y.058.i, %if.then10.i ], [ %y.0.ph.i, %if.end8.i ]
%x.055.i = phi ptr [ %x.054.i, %if.then10.i ], [ null, %if.end8.i ]
%parent13.i = getelementptr inbounds %struct.node, ptr %y.060.i, i64 0, i32 2
%18 = load ptr, ptr %parent13.i, align 8, !tbaa !16
%cmp14.i62 = icmp eq ptr %18, null
br i1 %cmp14.i62, label %if.end27.i, label %if.else16.i
if.else16.i: ; preds = %if.end12.i
%left18.i = getelementptr inbounds %struct.node, ptr %18, i64 0, i32 1
%19 = load ptr, ptr %left18.i, align 8, !tbaa !5
%cmp19.i = icmp eq ptr %y.060.i, %19
%left18..i = select i1 %cmp19.i, ptr %left18.i, ptr %18
br label %if.end27.i
if.end27.i: ; preds = %if.else16.i, %if.end12.i
%left18.sink.i = phi ptr [ @root, %if.end12.i ], [ %left18..i, %if.else16.i ]
store ptr %x.055.i, ptr %left18.sink.i, align 8, !tbaa !14
%cmp28.not.i = icmp eq ptr %y.060.i, %retval.0.i55
br i1 %cmp28.not.i, label %for.inc, label %if.then29.i
if.then29.i: ; preds = %if.end27.i
%key.i63 = getelementptr inbounds %struct.node, ptr %y.060.i, i64 0, i32 3
%20 = load i32, ptr %key.i63, align 8, !tbaa !13
%key30.i = getelementptr inbounds %struct.node, ptr %retval.0.i55, i64 0, i32 3
store i32 %20, ptr %key30.i, align 8, !tbaa !13
br label %for.inc
for.inc: ; preds = %if.then29.i, %if.end27.i, %for.body, %if.then8, %if.else, %if.then23, %insert.exit
%inc = add nuw nsw i32 %i.067, 1
%21 = load i32, ptr %n, align 4, !tbaa !19
%cmp = icmp slt i32 %inc, %21
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !21
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #9
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = { nofree 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 = { 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 #5 = { 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 #6 = { nofree nounwind }
attributes #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !7, i64 8}
!6 = !{!"node", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!6, !10, i64 24}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 0}
!16 = !{!6, !7, i64 16}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = !{!10, !10, i64 0}
!20 = !{!8, !8, i64 0}
!21 = distinct !{!21, !12}
|
#include<stdio.h>
#include<stdlib.h>
struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x){
while(x->left != NIL){
x = x->left;
}
return x;
}
Node treeSearch(Node u, int k){
if(u == NIL || k == u->key){
return u;
}
if(k < u->key){
return treeSearch(u->left,k);
}else{
return treeSearch(u->right,k);
}
while(u != NIL && k != u->key){
if(k < u->key){
u = u->left;
}else{
u = u->right;
}
}
return u;
}
Node treeSuccessor(Node x){
Node y;
if(x->right != NIL){
return treeMinimum(x->right);
}
y = x->parent;
while(y != NIL && x == y->right){
x = y;
y = y->parent;
}
return y;
}
void treeDelete(Node z){
Node y;
Node x;
if(z->left == NIL || z->right == NIL){
y = z;
}else{
y = treeSuccessor(z);
}
if(y->left != NIL){
x = y->left;
}else{
x = y->right;
}
if(x != NIL){
x->parent = y->parent;
}
if(y->parent == NIL){
root = x;
}else if(y == y->parent->left){
y->parent->left = x;
}else{
y->parent->right = x;
}
if(y != z){
z->key = y->key;
z = y;
}
}
void insert(int k){
Node y = NIL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
while(x != NIL){
y = x;
if(z->key < x->key){
x = x->left;
}else{
x = x->right;
}
}
z->parent = y;
if(y == NIL){
root = z;
}else if(z->key < y->key){
y->left = z;
}else{
y->right = z;
}
}
void inorder(Node u){
if(u->left != NIL){
inorder(u->left);
}
printf(" %d",u->key);
if(u->right != NIL){
inorder(u->right);
}
}
void preorder(Node u){
printf(" %d",u->key);
if(u->left != NIL){
preorder(u->left);
}
if(u->right != NIL){
preorder(u->right);
}
}
int main(){
int n, i, x;
char com[20];
scanf("%d", &n);
for ( i = 0; i < n; i++ ){
scanf("%s", com);
if ( com[0] == 'f' ){
scanf("%d", &x);
Node t = treeSearch(root, x);
if ( t != NIL ) printf("yes\n");
else printf("no\n");
} else if ( com[0] == 'i' ){
scanf("%d", &x);
insert(x);
} else if ( com[0] == 'p' ){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
} else if ( com[0] == 'd' ){
scanf("%d", &x);
treeDelete(treeSearch(root, x));
}
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206924/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206924/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { ptr, ptr, ptr, i32 }
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeMinimum(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%x.addr.0 = phi ptr [ %x, %entry ], [ %0, %while.cond ]
%left = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !11
while.end: ; preds = %while.cond
ret ptr %x.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSearch(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #0 {
entry:
%cmp14 = icmp eq ptr %u, null
br i1 %cmp14, label %return, label %lor.lhs.false
lor.lhs.false: ; preds = %entry, %if.end
%u.tr15 = phi ptr [ %u.tr.be, %if.end ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !13
%cmp1 = icmp eq i32 %0, %k
br i1 %cmp1, label %return, label %if.end
if.end: ; preds = %lor.lhs.false
%cmp3 = icmp sgt i32 %0, %k
%left = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 1
%spec.select = select i1 %cmp3, ptr %left, ptr %u.tr15
%u.tr.be = load ptr, ptr %spec.select, align 8, !tbaa !14
%cmp = icmp eq ptr %u.tr.be, null
br i1 %cmp, label %return, label %lor.lhs.false
return: ; preds = %lor.lhs.false, %if.end, %entry
%retval.0 = phi ptr [ null, %entry ], [ null, %if.end ], [ %u.tr15, %lor.lhs.false ]
ret ptr %retval.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSuccessor(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr %x, align 8, !tbaa !15
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%x.addr.0.i = phi ptr [ %1, %while.cond.i ], [ %0, %entry ]
%left.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i, i64 0, i32 1
%1 = load ptr, ptr %left.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %1, null
br i1 %cmp.not.i, label %cleanup, label %while.cond.i, !llvm.loop !11
while.cond: ; preds = %entry, %land.rhs
%x.addr.0 = phi ptr [ %y.0, %land.rhs ], [ %x, %entry ]
%y.0.in = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 2
%y.0 = load ptr, ptr %y.0.in, align 8, !tbaa !16
%cmp2.not = icmp eq ptr %y.0, null
br i1 %cmp2.not, label %cleanup, label %land.rhs
land.rhs: ; preds = %while.cond
%2 = load ptr, ptr %y.0, align 8, !tbaa !15
%cmp4 = icmp eq ptr %x.addr.0, %2
br i1 %cmp4, label %while.cond, label %cleanup, !llvm.loop !17
cleanup: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi ptr [ %y.0, %land.rhs ], [ null, %while.cond ], [ %x.addr.0.i, %while.cond.i ]
ret ptr %retval.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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @treeDelete(ptr noundef %z) local_unnamed_addr #2 {
entry:
%left = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
%cmp = icmp eq ptr %0, null
br i1 %cmp, label %if.end8, label %lor.lhs.false
lor.lhs.false: ; preds = %entry
%1 = load ptr, ptr %z, align 8, !tbaa !15
%cmp1 = icmp eq ptr %1, null
br i1 %cmp1, label %if.then10, label %while.cond.i.i
while.cond.i.i: ; preds = %lor.lhs.false, %while.cond.i.i
%x.addr.0.i.i = phi ptr [ %2, %while.cond.i.i ], [ %1, %lor.lhs.false ]
%left.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i, i64 0, i32 1
%2 = load ptr, ptr %left.i.i, align 8, !tbaa !5
%cmp.not.i.i = icmp eq ptr %2, null
br i1 %cmp.not.i.i, label %if.end8, label %while.cond.i.i, !llvm.loop !11
if.end8: ; preds = %while.cond.i.i, %entry
%y.0.ph = phi ptr [ %z, %entry ], [ %x.addr.0.i.i, %while.cond.i.i ]
%3 = load ptr, ptr %y.0.ph, align 8, !tbaa !15
%cmp9.not = icmp eq ptr %3, null
br i1 %cmp9.not, label %if.end12, label %if.then10
if.then10: ; preds = %lor.lhs.false, %if.end8
%y.059 = phi ptr [ %y.0.ph, %if.end8 ], [ %z, %lor.lhs.false ]
%x.055 = phi ptr [ %3, %if.end8 ], [ %0, %lor.lhs.false ]
%parent = getelementptr inbounds %struct.node, ptr %y.059, i64 0, i32 2
%4 = load ptr, ptr %parent, align 8, !tbaa !16
%parent11 = getelementptr inbounds %struct.node, ptr %x.055, i64 0, i32 2
store ptr %4, ptr %parent11, align 8, !tbaa !16
br label %if.end12
if.end12: ; preds = %if.then10, %if.end8
%y.061 = phi ptr [ %y.059, %if.then10 ], [ %y.0.ph, %if.end8 ]
%x.056 = phi ptr [ %x.055, %if.then10 ], [ null, %if.end8 ]
%parent13 = getelementptr inbounds %struct.node, ptr %y.061, i64 0, i32 2
%5 = load ptr, ptr %parent13, align 8, !tbaa !16
%cmp14 = icmp eq ptr %5, null
br i1 %cmp14, label %if.end27, label %if.else16
if.else16: ; preds = %if.end12
%left18 = getelementptr inbounds %struct.node, ptr %5, i64 0, i32 1
%6 = load ptr, ptr %left18, align 8, !tbaa !5
%cmp19 = icmp eq ptr %y.061, %6
%left18. = select i1 %cmp19, ptr %left18, ptr %5
br label %if.end27
if.end27: ; preds = %if.else16, %if.end12
%left18.sink = phi ptr [ @root, %if.end12 ], [ %left18., %if.else16 ]
store ptr %x.056, ptr %left18.sink, align 8, !tbaa !14
%cmp28.not = icmp eq ptr %y.061, %z
br i1 %cmp28.not, label %if.end31, label %if.then29
if.then29: ; preds = %if.end27
%key = getelementptr inbounds %struct.node, ptr %y.061, i64 0, i32 3
%7 = load i32, ptr %key, align 8, !tbaa !13
%key30 = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 3
store i32 %7, ptr %key30, align 8, !tbaa !13
br label %if.end31
if.end31: ; preds = %if.then29, %if.end27
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !14
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
%key = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store i32 %k, ptr %key, align 8, !tbaa !13
%cmp.not34 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call, i8 0, i64 16, i1 false)
br i1 %cmp.not34, label %if.then7, label %while.body
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%key2 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%1 = load i32, ptr %key2, align 8, !tbaa !13
%cmp3 = icmp sgt i32 %1, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %x.035
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !14
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else8, label %while.body, !llvm.loop !18
if.then7: ; preds = %entry
%parent37 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr null, ptr %parent37, align 8, !tbaa !16
br label %if.end17
if.else8: ; preds = %while.body
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr %x.035, ptr %parent, align 8, !tbaa !16
%key10 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%2 = load i32, ptr %key10, align 8, !tbaa !13
%cmp11 = icmp sgt i32 %2, %k
%left13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%spec.select = select i1 %cmp11, ptr %left13, ptr %x.035
br label %if.end17
if.end17: ; preds = %if.else8, %if.then7
%left13.sink = phi ptr [ @root, %if.then7 ], [ %spec.select, %if.else8 ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !14
ret void
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr nocapture noundef readonly %u) local_unnamed_addr #3 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%u.tr = phi ptr [ %u, %entry ], [ %2, %if.end ]
%left = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @inorder(ptr noundef nonnull %0)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%key = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 3
%1 = load i32, ptr %key, align 8, !tbaa !13
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%2 = load ptr, ptr %u.tr, align 8, !tbaa !15
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr nocapture noundef readonly %u) local_unnamed_addr #3 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%u.tr = phi ptr [ %u, %entry ], [ %2, %if.end ]
%key = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !13
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !5
%cmp.not = icmp eq ptr %1, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @preorder(ptr noundef nonnull %1)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%2 = load ptr, ptr %u.tr, align 8, !tbaa !15
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #3 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #9
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #9
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !19
%cmp66 = icmp sgt i32 %0, 0
br i1 %cmp66, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.067 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !20
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
i8 100, label %if.then31
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !14
%3 = load i32, ptr %x, align 4, !tbaa !19
%cmp14.i = icmp eq ptr %2, null
br i1 %cmp14.i, label %if.else, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %if.then, %if.end.i
%u.tr15.i = phi ptr [ %u.tr.be.i, %if.end.i ], [ %2, %if.then ]
%key.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 3
%4 = load i32, ptr %key.i, align 8, !tbaa !13
%cmp1.i = icmp eq i32 %4, %3
br i1 %cmp1.i, label %if.then8, label %if.end.i
if.end.i: ; preds = %lor.lhs.false.i
%cmp3.i = icmp sgt i32 %4, %3
%left.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 1
%spec.select.i = select i1 %cmp3.i, ptr %left.i, ptr %u.tr15.i
%u.tr.be.i = load ptr, ptr %spec.select.i, align 8, !tbaa !14
%cmp.i = icmp eq ptr %u.tr.be.i, null
br i1 %cmp.i, label %if.else, label %lor.lhs.false.i
if.then8: ; preds = %lor.lhs.false.i
%puts40 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %if.end.i, %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%5 = load i32, ptr %x, align 4, !tbaa !19
%6 = load ptr, ptr @root, align 8, !tbaa !14
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
%key.i41 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store i32 %5, ptr %key.i41, align 8, !tbaa !13
%cmp.not34.i = icmp eq ptr %6, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call.i, i8 0, i64 16, i1 false)
br i1 %cmp.not34.i, label %insert.exit, label %while.body.i
while.body.i: ; preds = %if.then16, %while.body.i
%x.035.i = phi ptr [ %x.1.i, %while.body.i ], [ %6, %if.then16 ]
%key2.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 3
%7 = load i32, ptr %key2.i, align 8, !tbaa !13
%cmp3.i42 = icmp sgt i32 %7, %5
%left4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i42, ptr %left4.i, ptr %x.035.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !14
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %insert.exit, label %while.body.i, !llvm.loop !18
insert.exit: ; preds = %while.body.i, %if.then16
%.sink = phi ptr [ null, %if.then16 ], [ %x.035.i, %while.body.i ]
%left13.sink.i = phi ptr [ @root, %if.then16 ], [ %x.1.in.i, %while.body.i ]
%parent37.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
store ptr %.sink, ptr %parent37.i, align 8, !tbaa !16
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !14
br label %for.inc
if.then23: ; preds = %for.body
%8 = load ptr, ptr @root, align 8, !tbaa !14
call void @inorder(ptr noundef %8)
%putchar = call i32 @putchar(i32 10)
%9 = load ptr, ptr @root, align 8, !tbaa !14
call void @preorder(ptr noundef %9)
%putchar39 = call i32 @putchar(i32 10)
br label %for.inc
if.then31: ; preds = %for.body
%call32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%10 = load ptr, ptr @root, align 8, !tbaa !14
%11 = load i32, ptr %x, align 4, !tbaa !19
%cmp14.i44 = icmp eq ptr %10, null
br i1 %cmp14.i44, label %treeSearch.exit56, label %lor.lhs.false.i45
lor.lhs.false.i45: ; preds = %if.then31, %if.end.i49
%u.tr15.i46 = phi ptr [ %u.tr.be.i53, %if.end.i49 ], [ %10, %if.then31 ]
%key.i47 = getelementptr inbounds %struct.node, ptr %u.tr15.i46, i64 0, i32 3
%12 = load i32, ptr %key.i47, align 8, !tbaa !13
%cmp1.i48 = icmp eq i32 %12, %11
br i1 %cmp1.i48, label %treeSearch.exit56, label %if.end.i49
if.end.i49: ; preds = %lor.lhs.false.i45
%cmp3.i50 = icmp sgt i32 %12, %11
%left.i51 = getelementptr inbounds %struct.node, ptr %u.tr15.i46, i64 0, i32 1
%spec.select.i52 = select i1 %cmp3.i50, ptr %left.i51, ptr %u.tr15.i46
%u.tr.be.i53 = load ptr, ptr %spec.select.i52, align 8, !tbaa !14
%cmp.i54 = icmp eq ptr %u.tr.be.i53, null
br i1 %cmp.i54, label %treeSearch.exit56, label %lor.lhs.false.i45
treeSearch.exit56: ; preds = %lor.lhs.false.i45, %if.end.i49, %if.then31
%retval.0.i55 = phi ptr [ null, %if.then31 ], [ %u.tr15.i46, %lor.lhs.false.i45 ], [ null, %if.end.i49 ]
%left.i57 = getelementptr inbounds %struct.node, ptr %retval.0.i55, i64 0, i32 1
%13 = load ptr, ptr %left.i57, align 8, !tbaa !5
%cmp.i58 = icmp eq ptr %13, null
br i1 %cmp.i58, label %if.end8.i, label %lor.lhs.false.i59
lor.lhs.false.i59: ; preds = %treeSearch.exit56
%14 = load ptr, ptr %retval.0.i55, align 8, !tbaa !15
%cmp1.i60 = icmp eq ptr %14, null
br i1 %cmp1.i60, label %if.then10.i, label %while.cond.i.i.i
while.cond.i.i.i: ; preds = %lor.lhs.false.i59, %while.cond.i.i.i
%x.addr.0.i.i.i = phi ptr [ %15, %while.cond.i.i.i ], [ %14, %lor.lhs.false.i59 ]
%left.i.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i.i, i64 0, i32 1
%15 = load ptr, ptr %left.i.i.i, align 8, !tbaa !5
%cmp.not.i.i.i = icmp eq ptr %15, null
br i1 %cmp.not.i.i.i, label %if.end8.i, label %while.cond.i.i.i, !llvm.loop !11
if.end8.i: ; preds = %while.cond.i.i.i, %treeSearch.exit56
%y.0.ph.i = phi ptr [ %retval.0.i55, %treeSearch.exit56 ], [ %x.addr.0.i.i.i, %while.cond.i.i.i ]
%16 = load ptr, ptr %y.0.ph.i, align 8, !tbaa !15
%cmp9.not.i = icmp eq ptr %16, null
br i1 %cmp9.not.i, label %if.end12.i, label %if.then10.i
if.then10.i: ; preds = %if.end8.i, %lor.lhs.false.i59
%y.059.i = phi ptr [ %y.0.ph.i, %if.end8.i ], [ %retval.0.i55, %lor.lhs.false.i59 ]
%x.055.i = phi ptr [ %16, %if.end8.i ], [ %13, %lor.lhs.false.i59 ]
%parent.i61 = getelementptr inbounds %struct.node, ptr %y.059.i, i64 0, i32 2
%17 = load ptr, ptr %parent.i61, align 8, !tbaa !16
%parent11.i = getelementptr inbounds %struct.node, ptr %x.055.i, i64 0, i32 2
store ptr %17, ptr %parent11.i, align 8, !tbaa !16
br label %if.end12.i
if.end12.i: ; preds = %if.then10.i, %if.end8.i
%y.061.i = phi ptr [ %y.059.i, %if.then10.i ], [ %y.0.ph.i, %if.end8.i ]
%x.056.i = phi ptr [ %x.055.i, %if.then10.i ], [ null, %if.end8.i ]
%parent13.i = getelementptr inbounds %struct.node, ptr %y.061.i, i64 0, i32 2
%18 = load ptr, ptr %parent13.i, align 8, !tbaa !16
%cmp14.i62 = icmp eq ptr %18, null
br i1 %cmp14.i62, label %if.end27.i, label %if.else16.i
if.else16.i: ; preds = %if.end12.i
%left18.i = getelementptr inbounds %struct.node, ptr %18, i64 0, i32 1
%19 = load ptr, ptr %left18.i, align 8, !tbaa !5
%cmp19.i = icmp eq ptr %y.061.i, %19
%left18..i = select i1 %cmp19.i, ptr %left18.i, ptr %18
br label %if.end27.i
if.end27.i: ; preds = %if.else16.i, %if.end12.i
%left18.sink.i = phi ptr [ @root, %if.end12.i ], [ %left18..i, %if.else16.i ]
store ptr %x.056.i, ptr %left18.sink.i, align 8, !tbaa !14
%cmp28.not.i = icmp eq ptr %y.061.i, %retval.0.i55
br i1 %cmp28.not.i, label %for.inc, label %if.then29.i
if.then29.i: ; preds = %if.end27.i
%key.i63 = getelementptr inbounds %struct.node, ptr %y.061.i, i64 0, i32 3
%20 = load i32, ptr %key.i63, align 8, !tbaa !13
%key30.i = getelementptr inbounds %struct.node, ptr %retval.0.i55, i64 0, i32 3
store i32 %20, ptr %key30.i, align 8, !tbaa !13
br label %for.inc
for.inc: ; preds = %if.then29.i, %if.end27.i, %for.body, %if.then8, %if.else, %if.then23, %insert.exit
%inc = add nuw nsw i32 %i.067, 1
%21 = load i32, ptr %n, align 4, !tbaa !19
%cmp = icmp slt i32 %inc, %21
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !21
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #9
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = { nofree 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 = { 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 #5 = { 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 #6 = { nofree nounwind }
attributes #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !7, i64 8}
!6 = !{!"node", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!6, !10, i64 24}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 0}
!16 = !{!6, !7, i64 16}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = !{!10, !10, i64 0}
!20 = !{!8, !8, i64 0}
!21 = distinct !{!21, !12}
|
#include<stdio.h>
#include<stdlib.h>
struct node{
struct node *r;
struct node *l;
struct node *p;
int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node minimum(Node x){
while(x->l != NIL)
x = x->l;
return x;
}
Node search(Node u, int k){
if(u == NIL || u->key == k)
return u;
else if(u->key > k)
return search(u->l, k);
else if(u->key < k)
return search(u->r, k);
}
Node successor(Node x){
Node y;
if(x->r != NIL)
return minimum(x->r);
y = x->p;
while(y != NIL && x == y->r){
x = y;
y = y->p;
}
return y;
}
void delete(Node z){
Node y;
Node x;
if(z->l == NIL || z->r == NIL)
y = z;
else
y = successor(z);
if(y->l != NIL)
x = y->l;
else
x = y->r;
if(x != NIL)
x->p = y->p;
if(y->p == NIL)
root = x;
else if(y == y->p->l)
y->p->l = x;
else
y->p->r = x;
if(y != z)
z->key = y->key;
}
void insert(int k){
Node y = NIL;
Node x = root;
Node z;
z = (Node)malloc(sizeof(struct node));
z->key = k;
z->l = NIL;
z->r = NIL;
while(x != NIL){
y = x;
if(z->key < x->key)
x = x->l;
else
x = x->r;
}
z->p = y;
if(y == NIL)
root = z;
else if(z->key < y->key)
y->l = z;
else
y->r = z;
}
void inorder(Node u){
if(u->l != NIL)
inorder(u->l);
printf(" %d",u->key);
if(u->r != NIL)
inorder(u->r);
}
void preorder(Node u){
printf(" %d",u->key);
if(u->l != NIL)
preorder(u->l);
if(u->r != NIL)
preorder(u->r);
}
int main(){
int n, i, x;
char com[20];
Node t;
scanf("%d", &n);
for ( i = 0; i < n; i++ ){
scanf("%s", com);
if ( com[0] == 'f' ){
scanf("%d", &x);
t = search(root, x);
if ( t != NIL ) printf("yes\n");
else printf("no\n");
} else if ( com[0] == 'i' ){
scanf("%d", &x);
insert(x);
} else if ( com[0] == 'p' ){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
} else if ( com[0] == 'd' ){
scanf("%d", &x);
delete(search(root, x));
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_206968/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_206968/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { ptr, ptr, ptr, i32 }
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @minimum(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%x.addr.0 = phi ptr [ %x, %entry ], [ %0, %while.cond ]
%l = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 1
%0 = load ptr, ptr %l, align 8, !tbaa !5
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !11
while.end: ; preds = %while.cond
ret ptr %x.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @search(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #0 {
entry:
%cmp22 = icmp eq ptr %u, null
br i1 %cmp22, label %if.end11, label %lor.lhs.false
lor.lhs.false: ; preds = %entry, %tailrecurse.backedge
%u.tr23 = phi ptr [ %u.tr.be, %tailrecurse.backedge ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr23, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !13
%cmp1 = icmp eq i32 %0, %k
br i1 %cmp1, label %if.end11, label %if.else
if.else: ; preds = %lor.lhs.false
%cmp3 = icmp sgt i32 %0, %k
br i1 %cmp3, label %if.then4, label %if.else5
if.then4: ; preds = %if.else
%l = getelementptr inbounds %struct.node, ptr %u.tr23, i64 0, i32 1
br label %tailrecurse.backedge
tailrecurse.backedge: ; preds = %if.else5, %if.then4
%u.tr.be.in = phi ptr [ %l, %if.then4 ], [ %u.tr23, %if.else5 ]
%u.tr.be = load ptr, ptr %u.tr.be.in, align 8, !tbaa !14
%cmp = icmp eq ptr %u.tr.be, null
br i1 %cmp, label %if.end11, label %lor.lhs.false
if.else5: ; preds = %if.else
%cmp7 = icmp slt i32 %0, %k
br i1 %cmp7, label %tailrecurse.backedge, label %if.end11
if.end11: ; preds = %if.else5, %lor.lhs.false, %tailrecurse.backedge, %entry
%retval.0 = phi ptr [ null, %entry ], [ null, %tailrecurse.backedge ], [ %u.tr23, %lor.lhs.false ], [ undef, %if.else5 ]
ret ptr %retval.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @successor(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr %x, align 8, !tbaa !15
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%x.addr.0.i = phi ptr [ %1, %while.cond.i ], [ %0, %entry ]
%l.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i, i64 0, i32 1
%1 = load ptr, ptr %l.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %1, null
br i1 %cmp.not.i, label %cleanup, label %while.cond.i, !llvm.loop !11
while.cond: ; preds = %entry, %land.rhs
%x.addr.0 = phi ptr [ %y.0, %land.rhs ], [ %x, %entry ]
%y.0.in = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 2
%y.0 = load ptr, ptr %y.0.in, align 8, !tbaa !16
%cmp2.not = icmp eq ptr %y.0, null
br i1 %cmp2.not, label %cleanup, label %land.rhs
land.rhs: ; preds = %while.cond
%2 = load ptr, ptr %y.0, align 8, !tbaa !15
%cmp4 = icmp eq ptr %x.addr.0, %2
br i1 %cmp4, label %while.cond, label %cleanup, !llvm.loop !17
cleanup: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi ptr [ %y.0, %land.rhs ], [ null, %while.cond ], [ %x.addr.0.i, %while.cond.i ]
ret ptr %retval.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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @delete(ptr noundef %z) local_unnamed_addr #2 {
entry:
%l = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 1
%0 = load ptr, ptr %l, align 8, !tbaa !5
%cmp = icmp eq ptr %0, null
br i1 %cmp, label %if.end8, label %lor.lhs.false
lor.lhs.false: ; preds = %entry
%1 = load ptr, ptr %z, align 8, !tbaa !15
%cmp1 = icmp eq ptr %1, null
br i1 %cmp1, label %if.then10, label %while.cond.i.i
while.cond.i.i: ; preds = %lor.lhs.false, %while.cond.i.i
%x.addr.0.i.i = phi ptr [ %2, %while.cond.i.i ], [ %1, %lor.lhs.false ]
%l.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i, i64 0, i32 1
%2 = load ptr, ptr %l.i.i, align 8, !tbaa !5
%cmp.not.i.i = icmp eq ptr %2, null
br i1 %cmp.not.i.i, label %if.end8, label %while.cond.i.i, !llvm.loop !11
if.end8: ; preds = %while.cond.i.i, %entry
%y.0.ph = phi ptr [ %z, %entry ], [ %x.addr.0.i.i, %while.cond.i.i ]
%3 = load ptr, ptr %y.0.ph, align 8, !tbaa !15
%cmp9.not = icmp eq ptr %3, null
br i1 %cmp9.not, label %if.end12, label %if.then10
if.then10: ; preds = %lor.lhs.false, %if.end8
%y.058 = phi ptr [ %y.0.ph, %if.end8 ], [ %z, %lor.lhs.false ]
%x.054 = phi ptr [ %3, %if.end8 ], [ %0, %lor.lhs.false ]
%p = getelementptr inbounds %struct.node, ptr %y.058, i64 0, i32 2
%4 = load ptr, ptr %p, align 8, !tbaa !16
%p11 = getelementptr inbounds %struct.node, ptr %x.054, i64 0, i32 2
store ptr %4, ptr %p11, align 8, !tbaa !16
br label %if.end12
if.end12: ; preds = %if.then10, %if.end8
%y.060 = phi ptr [ %y.058, %if.then10 ], [ %y.0.ph, %if.end8 ]
%x.055 = phi ptr [ %x.054, %if.then10 ], [ null, %if.end8 ]
%p13 = getelementptr inbounds %struct.node, ptr %y.060, i64 0, i32 2
%5 = load ptr, ptr %p13, align 8, !tbaa !16
%cmp14 = icmp eq ptr %5, null
br i1 %cmp14, label %if.end27, label %if.else16
if.else16: ; preds = %if.end12
%l18 = getelementptr inbounds %struct.node, ptr %5, i64 0, i32 1
%6 = load ptr, ptr %l18, align 8, !tbaa !5
%cmp19 = icmp eq ptr %y.060, %6
%l18. = select i1 %cmp19, ptr %l18, ptr %5
br label %if.end27
if.end27: ; preds = %if.else16, %if.end12
%l18.sink = phi ptr [ @root, %if.end12 ], [ %l18., %if.else16 ]
store ptr %x.055, ptr %l18.sink, align 8, !tbaa !14
%cmp28.not = icmp eq ptr %y.060, %z
br i1 %cmp28.not, label %if.end31, label %if.then29
if.then29: ; preds = %if.end27
%key = getelementptr inbounds %struct.node, ptr %y.060, i64 0, i32 3
%7 = load i32, ptr %key, align 8, !tbaa !13
%key30 = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 3
store i32 %7, ptr %key30, align 8, !tbaa !13
br label %if.end31
if.end31: ; preds = %if.then29, %if.end27
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !14
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
%key = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store i32 %k, ptr %key, align 8, !tbaa !13
%cmp.not34 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call, i8 0, i64 16, i1 false)
br i1 %cmp.not34, label %if.then7, label %while.body
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%key2 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%1 = load i32, ptr %key2, align 8, !tbaa !13
%cmp3 = icmp sgt i32 %1, %k
%l4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %l4, ptr %x.035
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !14
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else8, label %while.body, !llvm.loop !18
if.then7: ; preds = %entry
%p37 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr null, ptr %p37, align 8, !tbaa !16
br label %if.end17
if.else8: ; preds = %while.body
%p = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr %x.035, ptr %p, align 8, !tbaa !16
%key10 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%2 = load i32, ptr %key10, align 8, !tbaa !13
%cmp11 = icmp sgt i32 %2, %k
%l13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%spec.select = select i1 %cmp11, ptr %l13, ptr %x.035
br label %if.end17
if.end17: ; preds = %if.else8, %if.then7
%l13.sink = phi ptr [ @root, %if.then7 ], [ %spec.select, %if.else8 ]
store ptr %call, ptr %l13.sink, align 8, !tbaa !14
ret void
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr nocapture noundef readonly %u) local_unnamed_addr #3 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%u.tr = phi ptr [ %u, %entry ], [ %2, %if.end ]
%l = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 1
%0 = load ptr, ptr %l, align 8, !tbaa !5
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @inorder(ptr noundef nonnull %0)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%key = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 3
%1 = load i32, ptr %key, align 8, !tbaa !13
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%2 = load ptr, ptr %u.tr, align 8, !tbaa !15
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr nocapture noundef readonly %u) local_unnamed_addr #3 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%u.tr = phi ptr [ %u, %entry ], [ %2, %if.end ]
%key = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !13
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%l = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 1
%1 = load ptr, ptr %l, align 8, !tbaa !5
%cmp.not = icmp eq ptr %1, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @preorder(ptr noundef nonnull %1)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%2 = load ptr, ptr %u.tr, align 8, !tbaa !15
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #3 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #9
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #9
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !19
%cmp74 = icmp sgt i32 %0, 0
br i1 %cmp74, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.075 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !20
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
i8 100, label %if.then31
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !14
%3 = load i32, ptr %x, align 4, !tbaa !19
%cmp22.i = icmp eq ptr %2, null
br i1 %cmp22.i, label %if.else, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %if.then, %tailrecurse.backedge.i
%u.tr23.i = phi ptr [ %u.tr.be.i, %tailrecurse.backedge.i ], [ %2, %if.then ]
%key.i = getelementptr inbounds %struct.node, ptr %u.tr23.i, i64 0, i32 3
%4 = load i32, ptr %key.i, align 8, !tbaa !13
%cmp1.i = icmp eq i32 %4, %3
br i1 %cmp1.i, label %if.then8, label %if.else.i
if.else.i: ; preds = %lor.lhs.false.i
%cmp3.i = icmp sgt i32 %4, %3
br i1 %cmp3.i, label %if.then4.i, label %if.else5.i
if.then4.i: ; preds = %if.else.i
%l.i = getelementptr inbounds %struct.node, ptr %u.tr23.i, i64 0, i32 1
br label %tailrecurse.backedge.i
tailrecurse.backedge.i: ; preds = %if.else5.i, %if.then4.i
%u.tr.be.in.i = phi ptr [ %l.i, %if.then4.i ], [ %u.tr23.i, %if.else5.i ]
%u.tr.be.i = load ptr, ptr %u.tr.be.in.i, align 8, !tbaa !14
%cmp.i = icmp eq ptr %u.tr.be.i, null
br i1 %cmp.i, label %if.else, label %lor.lhs.false.i
if.else5.i: ; preds = %if.else.i
%cmp7.i = icmp slt i32 %4, %3
br i1 %cmp7.i, label %tailrecurse.backedge.i, label %if.else
if.then8: ; preds = %lor.lhs.false.i
%puts40 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %tailrecurse.backedge.i, %if.else5.i, %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%5 = load i32, ptr %x, align 4, !tbaa !19
%6 = load ptr, ptr @root, align 8, !tbaa !14
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
%key.i41 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store i32 %5, ptr %key.i41, align 8, !tbaa !13
%cmp.not34.i = icmp eq ptr %6, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call.i, i8 0, i64 16, i1 false)
br i1 %cmp.not34.i, label %insert.exit, label %while.body.i
while.body.i: ; preds = %if.then16, %while.body.i
%x.035.i = phi ptr [ %x.1.i, %while.body.i ], [ %6, %if.then16 ]
%key2.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 3
%7 = load i32, ptr %key2.i, align 8, !tbaa !13
%cmp3.i42 = icmp sgt i32 %7, %5
%l4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i42, ptr %l4.i, ptr %x.035.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !14
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %insert.exit, label %while.body.i, !llvm.loop !18
insert.exit: ; preds = %while.body.i, %if.then16
%.sink = phi ptr [ null, %if.then16 ], [ %x.035.i, %while.body.i ]
%l13.sink.i = phi ptr [ @root, %if.then16 ], [ %x.1.in.i, %while.body.i ]
%p37.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
store ptr %.sink, ptr %p37.i, align 8, !tbaa !16
store ptr %call.i, ptr %l13.sink.i, align 8, !tbaa !14
br label %for.inc
if.then23: ; preds = %for.body
%8 = load ptr, ptr @root, align 8, !tbaa !14
call void @inorder(ptr noundef %8)
%putchar = call i32 @putchar(i32 10)
%9 = load ptr, ptr @root, align 8, !tbaa !14
call void @preorder(ptr noundef %9)
%putchar39 = call i32 @putchar(i32 10)
br label %for.inc
if.then31: ; preds = %for.body
%call32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%10 = load ptr, ptr @root, align 8, !tbaa !14
%11 = load i32, ptr %x, align 4, !tbaa !19
%cmp22.i43 = icmp eq ptr %10, null
br i1 %cmp22.i43, label %search.exit59, label %lor.lhs.false.i44
lor.lhs.false.i44: ; preds = %if.then31, %tailrecurse.backedge.i53
%u.tr23.i45 = phi ptr [ %u.tr.be.i55, %tailrecurse.backedge.i53 ], [ %10, %if.then31 ]
%key.i46 = getelementptr inbounds %struct.node, ptr %u.tr23.i45, i64 0, i32 3
%12 = load i32, ptr %key.i46, align 8, !tbaa !13
%cmp1.i47 = icmp eq i32 %12, %11
br i1 %cmp1.i47, label %search.exit59, label %if.else.i48
if.else.i48: ; preds = %lor.lhs.false.i44
%cmp3.i49 = icmp sgt i32 %12, %11
br i1 %cmp3.i49, label %if.then4.i57, label %if.else5.i50
if.then4.i57: ; preds = %if.else.i48
%l.i58 = getelementptr inbounds %struct.node, ptr %u.tr23.i45, i64 0, i32 1
br label %tailrecurse.backedge.i53
tailrecurse.backedge.i53: ; preds = %if.else5.i50, %if.then4.i57
%u.tr.be.in.i54 = phi ptr [ %l.i58, %if.then4.i57 ], [ %u.tr23.i45, %if.else5.i50 ]
%u.tr.be.i55 = load ptr, ptr %u.tr.be.in.i54, align 8, !tbaa !14
%cmp.i56 = icmp eq ptr %u.tr.be.i55, null
br i1 %cmp.i56, label %search.exit59, label %lor.lhs.false.i44
if.else5.i50: ; preds = %if.else.i48
%cmp7.i51 = icmp slt i32 %12, %11
br i1 %cmp7.i51, label %tailrecurse.backedge.i53, label %search.exit59
search.exit59: ; preds = %lor.lhs.false.i44, %tailrecurse.backedge.i53, %if.else5.i50, %if.then31
%retval.0.i52 = phi ptr [ null, %if.then31 ], [ undef, %if.else5.i50 ], [ %u.tr23.i45, %lor.lhs.false.i44 ], [ null, %tailrecurse.backedge.i53 ]
%l.i60 = getelementptr inbounds %struct.node, ptr %retval.0.i52, i64 0, i32 1
%13 = load ptr, ptr %l.i60, align 8, !tbaa !5
%cmp.i61 = icmp eq ptr %13, null
br i1 %cmp.i61, label %if.end8.i, label %lor.lhs.false.i62
lor.lhs.false.i62: ; preds = %search.exit59
%14 = load ptr, ptr %retval.0.i52, align 8, !tbaa !15
%cmp1.i63 = icmp eq ptr %14, null
br i1 %cmp1.i63, label %if.then10.i, label %while.cond.i.i.i
while.cond.i.i.i: ; preds = %lor.lhs.false.i62, %while.cond.i.i.i
%x.addr.0.i.i.i = phi ptr [ %15, %while.cond.i.i.i ], [ %14, %lor.lhs.false.i62 ]
%l.i.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i.i, i64 0, i32 1
%15 = load ptr, ptr %l.i.i.i, align 8, !tbaa !5
%cmp.not.i.i.i = icmp eq ptr %15, null
br i1 %cmp.not.i.i.i, label %if.end8.i, label %while.cond.i.i.i, !llvm.loop !11
if.end8.i: ; preds = %while.cond.i.i.i, %search.exit59
%y.0.ph.i = phi ptr [ %retval.0.i52, %search.exit59 ], [ %x.addr.0.i.i.i, %while.cond.i.i.i ]
%16 = load ptr, ptr %y.0.ph.i, align 8, !tbaa !15
%cmp9.not.i = icmp eq ptr %16, null
br i1 %cmp9.not.i, label %if.end12.i, label %if.then10.i
if.then10.i: ; preds = %if.end8.i, %lor.lhs.false.i62
%y.058.i = phi ptr [ %y.0.ph.i, %if.end8.i ], [ %retval.0.i52, %lor.lhs.false.i62 ]
%x.054.i = phi ptr [ %16, %if.end8.i ], [ %13, %lor.lhs.false.i62 ]
%p.i64 = getelementptr inbounds %struct.node, ptr %y.058.i, i64 0, i32 2
%17 = load ptr, ptr %p.i64, align 8, !tbaa !16
%p11.i = getelementptr inbounds %struct.node, ptr %x.054.i, i64 0, i32 2
store ptr %17, ptr %p11.i, align 8, !tbaa !16
br label %if.end12.i
if.end12.i: ; preds = %if.then10.i, %if.end8.i
%y.060.i = phi ptr [ %y.058.i, %if.then10.i ], [ %y.0.ph.i, %if.end8.i ]
%x.055.i = phi ptr [ %x.054.i, %if.then10.i ], [ null, %if.end8.i ]
%p13.i = getelementptr inbounds %struct.node, ptr %y.060.i, i64 0, i32 2
%18 = load ptr, ptr %p13.i, align 8, !tbaa !16
%cmp14.i = icmp eq ptr %18, null
br i1 %cmp14.i, label %if.end27.i, label %if.else16.i
if.else16.i: ; preds = %if.end12.i
%l18.i = getelementptr inbounds %struct.node, ptr %18, i64 0, i32 1
%19 = load ptr, ptr %l18.i, align 8, !tbaa !5
%cmp19.i = icmp eq ptr %y.060.i, %19
%l18..i = select i1 %cmp19.i, ptr %l18.i, ptr %18
br label %if.end27.i
if.end27.i: ; preds = %if.else16.i, %if.end12.i
%l18.sink.i = phi ptr [ @root, %if.end12.i ], [ %l18..i, %if.else16.i ]
store ptr %x.055.i, ptr %l18.sink.i, align 8, !tbaa !14
%cmp28.not.i = icmp eq ptr %y.060.i, %retval.0.i52
br i1 %cmp28.not.i, label %for.inc, label %if.then29.i
if.then29.i: ; preds = %if.end27.i
%key.i65 = getelementptr inbounds %struct.node, ptr %y.060.i, i64 0, i32 3
%20 = load i32, ptr %key.i65, align 8, !tbaa !13
%key30.i = getelementptr inbounds %struct.node, ptr %retval.0.i52, i64 0, i32 3
store i32 %20, ptr %key30.i, align 8, !tbaa !13
br label %for.inc
for.inc: ; preds = %if.then29.i, %if.end27.i, %for.body, %if.else, %if.then8, %if.then23, %insert.exit
%inc = add nuw nsw i32 %i.075, 1
%21 = load i32, ptr %n, align 4, !tbaa !19
%cmp = icmp slt i32 %inc, %21
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !21
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #9
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = { nofree 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 = { 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 #5 = { 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 #6 = { nofree nounwind }
attributes #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !7, i64 8}
!6 = !{!"node", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!6, !10, i64 24}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 0}
!16 = !{!6, !7, i64 16}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = !{!10, !10, i64 0}
!20 = !{!8, !8, i64 0}
!21 = distinct !{!21, !12}
|
#include<stdio.h>
#include<stdlib.h>
struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
void insert(int);
void inorder(Node);
void preorder(Node);
Node treeSearch(Node,int);
Node treeMinimum(Node);
Node treeSuccessor(Node);
void treeDelete(Node);
int main(){
int n, i, x;
char com[20];
scanf("%d",&n);
for (i=0;i<n;i++){
scanf("%s",com);
if(com[0]=='f'){
scanf("%d",&x);
Node t = treeSearch(root, x);
if (t!=NIL) printf("yes\n");
else printf("no\n");
}
else if(com[0]=='i'){
scanf("%d",&x);
insert(x);
}
else if(com[0]=='p'){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}
else if(com[0]=='d'){
scanf("%d",&x);
treeDelete(treeSearch(root,x));
}
}
return 0;
}
void insert(int k){
Node y = NIL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
while(x!=NIL){
y=x;
if(z->key < x->key) x=x->left;
else x=x->right;
}
z->parent=y;
if(y==NIL) root=z;
else if(z->key < y->key) y->left=z;
else y->right=z;
}
void inorder(Node u){
if(u!=NIL){
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
}
void preorder(Node u){
if(u!=NIL){
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
}
Node treeSearch(Node u, int k){
if(u==NIL || k==u->key) return u;
if(k<u->key) return treeSearch(u->left,k);
else return treeSearch(u->right,k);
}
Node treeMinimum(Node x){
while(x->left!=NIL) x=x->left;
return x;
}
Node treeSuccessor(Node x){
Node y;
if(x->right!=NIL) return treeMinimum(x->right);
y=x->parent;
while(y!=NIL && x==y->right){
x=y;
y=y->parent;
}
return y;
}
void treeDelete(Node z){
Node y;
Node x;
if(z->left==NIL || z->right==NIL) y=z;
else y=treeSuccessor(z);
if(y->left!=NIL) x=y->left;
else x=y->right;
if(x!=NIL) x->parent=y->parent;
if(y->parent==NIL) root=x;
else if(y==y->parent->left) y->parent->left=x;
else y->parent->right=x;
if(y!=z) z->key=y->key;
free(y);
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207017/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207017/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { ptr, ptr, ptr, i32 }
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str.5 = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #9
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #9
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%cmp66 = icmp sgt i32 %0, 0
br i1 %cmp66, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.067 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !9
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
i8 100, label %if.then31
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !10
%3 = load i32, ptr %x, align 4, !tbaa !5
%cmp14.i = icmp eq ptr %2, null
br i1 %cmp14.i, label %if.else, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %if.then, %if.end.i
%u.tr15.i = phi ptr [ %u.tr.be.i, %if.end.i ], [ %2, %if.then ]
%key.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 3
%4 = load i32, ptr %key.i, align 8, !tbaa !12
%cmp1.i = icmp eq i32 %4, %3
br i1 %cmp1.i, label %if.then8, label %if.end.i
if.end.i: ; preds = %lor.lhs.false.i
%cmp3.i = icmp sgt i32 %4, %3
%left.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 1
%spec.select.i = select i1 %cmp3.i, ptr %left.i, ptr %u.tr15.i
%u.tr.be.i = load ptr, ptr %spec.select.i, align 8, !tbaa !10
%cmp.i = icmp eq ptr %u.tr.be.i, null
br i1 %cmp.i, label %if.else, label %lor.lhs.false.i
if.then8: ; preds = %lor.lhs.false.i
%puts40 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %if.end.i, %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x)
%5 = load i32, ptr %x, align 4, !tbaa !5
%6 = load ptr, ptr @root, align 8, !tbaa !10
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #10
%key.i41 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store i32 %5, ptr %key.i41, align 8, !tbaa !12
%cmp.not34.i = icmp eq ptr %6, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call.i, i8 0, i64 16, i1 false)
br i1 %cmp.not34.i, label %insert.exit, label %while.body.i
while.body.i: ; preds = %if.then16, %while.body.i
%x.035.i = phi ptr [ %x.1.i, %while.body.i ], [ %6, %if.then16 ]
%key2.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 3
%7 = load i32, ptr %key2.i, align 8, !tbaa !12
%cmp3.i42 = icmp sgt i32 %7, %5
%left4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i42, ptr %left4.i, ptr %x.035.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !10
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %insert.exit, label %while.body.i, !llvm.loop !14
insert.exit: ; preds = %while.body.i, %if.then16
%.sink = phi ptr [ null, %if.then16 ], [ %x.035.i, %while.body.i ]
%left13.sink.i = phi ptr [ @root, %if.then16 ], [ %x.1.in.i, %while.body.i ]
%parent37.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
store ptr %.sink, ptr %parent37.i, align 8, !tbaa !16
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !10
br label %for.inc
if.then23: ; preds = %for.body
%8 = load ptr, ptr @root, align 8, !tbaa !10
call void @inorder(ptr noundef %8)
%putchar = call i32 @putchar(i32 10)
%9 = load ptr, ptr @root, align 8, !tbaa !10
call void @preorder(ptr noundef %9)
%putchar39 = call i32 @putchar(i32 10)
br label %for.inc
if.then31: ; preds = %for.body
%call32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x)
%10 = load ptr, ptr @root, align 8, !tbaa !10
%11 = load i32, ptr %x, align 4, !tbaa !5
%cmp14.i44 = icmp eq ptr %10, null
br i1 %cmp14.i44, label %treeSearch.exit56, label %lor.lhs.false.i45
lor.lhs.false.i45: ; preds = %if.then31, %if.end.i49
%u.tr15.i46 = phi ptr [ %u.tr.be.i53, %if.end.i49 ], [ %10, %if.then31 ]
%key.i47 = getelementptr inbounds %struct.node, ptr %u.tr15.i46, i64 0, i32 3
%12 = load i32, ptr %key.i47, align 8, !tbaa !12
%cmp1.i48 = icmp eq i32 %12, %11
br i1 %cmp1.i48, label %treeSearch.exit56, label %if.end.i49
if.end.i49: ; preds = %lor.lhs.false.i45
%cmp3.i50 = icmp sgt i32 %12, %11
%left.i51 = getelementptr inbounds %struct.node, ptr %u.tr15.i46, i64 0, i32 1
%spec.select.i52 = select i1 %cmp3.i50, ptr %left.i51, ptr %u.tr15.i46
%u.tr.be.i53 = load ptr, ptr %spec.select.i52, align 8, !tbaa !10
%cmp.i54 = icmp eq ptr %u.tr.be.i53, null
br i1 %cmp.i54, label %treeSearch.exit56, label %lor.lhs.false.i45
treeSearch.exit56: ; preds = %lor.lhs.false.i45, %if.end.i49, %if.then31
%retval.0.i55 = phi ptr [ null, %if.then31 ], [ %u.tr15.i46, %lor.lhs.false.i45 ], [ null, %if.end.i49 ]
%left.i57 = getelementptr inbounds %struct.node, ptr %retval.0.i55, i64 0, i32 1
%13 = load ptr, ptr %left.i57, align 8, !tbaa !17
%cmp.i58 = icmp eq ptr %13, null
br i1 %cmp.i58, label %if.end8.i, label %lor.lhs.false.i59
lor.lhs.false.i59: ; preds = %treeSearch.exit56
%14 = load ptr, ptr %retval.0.i55, align 8, !tbaa !18
%cmp1.i60 = icmp eq ptr %14, null
br i1 %cmp1.i60, label %if.then10.i, label %while.cond.i.i.i
while.cond.i.i.i: ; preds = %lor.lhs.false.i59, %while.cond.i.i.i
%x.addr.0.i.i.i = phi ptr [ %15, %while.cond.i.i.i ], [ %14, %lor.lhs.false.i59 ]
%left.i.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i.i, i64 0, i32 1
%15 = load ptr, ptr %left.i.i.i, align 8, !tbaa !17
%cmp.not.i.i.i = icmp eq ptr %15, null
br i1 %cmp.not.i.i.i, label %if.end8.i, label %while.cond.i.i.i, !llvm.loop !19
if.end8.i: ; preds = %while.cond.i.i.i, %treeSearch.exit56
%y.0.ph.i = phi ptr [ %retval.0.i55, %treeSearch.exit56 ], [ %x.addr.0.i.i.i, %while.cond.i.i.i ]
%16 = load ptr, ptr %y.0.ph.i, align 8, !tbaa !18
%cmp9.not.i = icmp eq ptr %16, null
br i1 %cmp9.not.i, label %if.end12.i, label %if.then10.i
if.then10.i: ; preds = %if.end8.i, %lor.lhs.false.i59
%y.059.i = phi ptr [ %y.0.ph.i, %if.end8.i ], [ %retval.0.i55, %lor.lhs.false.i59 ]
%x.055.i = phi ptr [ %16, %if.end8.i ], [ %13, %lor.lhs.false.i59 ]
%parent.i61 = getelementptr inbounds %struct.node, ptr %y.059.i, i64 0, i32 2
%17 = load ptr, ptr %parent.i61, align 8, !tbaa !16
%parent11.i = getelementptr inbounds %struct.node, ptr %x.055.i, i64 0, i32 2
store ptr %17, ptr %parent11.i, align 8, !tbaa !16
br label %if.end12.i
if.end12.i: ; preds = %if.then10.i, %if.end8.i
%y.061.i = phi ptr [ %y.059.i, %if.then10.i ], [ %y.0.ph.i, %if.end8.i ]
%x.056.i = phi ptr [ %x.055.i, %if.then10.i ], [ null, %if.end8.i ]
%parent13.i = getelementptr inbounds %struct.node, ptr %y.061.i, i64 0, i32 2
%18 = load ptr, ptr %parent13.i, align 8, !tbaa !16
%cmp14.i62 = icmp eq ptr %18, null
br i1 %cmp14.i62, label %if.end27.i, label %if.else16.i
if.else16.i: ; preds = %if.end12.i
%left18.i = getelementptr inbounds %struct.node, ptr %18, i64 0, i32 1
%19 = load ptr, ptr %left18.i, align 8, !tbaa !17
%cmp19.i = icmp eq ptr %y.061.i, %19
%left18..i = select i1 %cmp19.i, ptr %left18.i, ptr %18
br label %if.end27.i
if.end27.i: ; preds = %if.else16.i, %if.end12.i
%left18.sink.i = phi ptr [ @root, %if.end12.i ], [ %left18..i, %if.else16.i ]
store ptr %x.056.i, ptr %left18.sink.i, align 8, !tbaa !10
%cmp28.not.i = icmp eq ptr %y.061.i, %retval.0.i55
br i1 %cmp28.not.i, label %treeDelete.exit, label %if.then29.i
if.then29.i: ; preds = %if.end27.i
%key.i63 = getelementptr inbounds %struct.node, ptr %y.061.i, i64 0, i32 3
%20 = load i32, ptr %key.i63, align 8, !tbaa !12
%key30.i = getelementptr inbounds %struct.node, ptr %retval.0.i55, i64 0, i32 3
store i32 %20, ptr %key30.i, align 8, !tbaa !12
br label %treeDelete.exit
treeDelete.exit: ; preds = %if.end27.i, %if.then29.i
call void @free(ptr noundef nonnull %y.061.i) #9
br label %for.inc
for.inc: ; preds = %for.body, %if.then8, %if.else, %if.then23, %treeDelete.exit, %insert.exit
%inc = add nuw nsw i32 %i.067, 1
%21 = load i32, ptr %n, align 4, !tbaa !5
%cmp = icmp slt i32 %inc, %21
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !20
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #9
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSearch(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #3 {
entry:
%cmp14 = icmp eq ptr %u, null
br i1 %cmp14, label %return, label %lor.lhs.false
lor.lhs.false: ; preds = %entry, %if.end
%u.tr15 = phi ptr [ %u.tr.be, %if.end ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !12
%cmp1 = icmp eq i32 %0, %k
br i1 %cmp1, label %return, label %if.end
if.end: ; preds = %lor.lhs.false
%cmp3 = icmp sgt i32 %0, %k
%left = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 1
%spec.select = select i1 %cmp3, ptr %left, ptr %u.tr15
%u.tr.be = load ptr, ptr %spec.select, align 8, !tbaa !10
%cmp = icmp eq ptr %u.tr.be, null
br i1 %cmp, label %return, label %lor.lhs.false
return: ; preds = %lor.lhs.false, %if.end, %entry
%retval.0 = phi ptr [ null, %entry ], [ null, %if.end ], [ %u.tr15, %lor.lhs.false ]
ret ptr %retval.0
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #4 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !10
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #10
%key = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store i32 %k, ptr %key, align 8, !tbaa !12
%cmp.not34 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call, i8 0, i64 16, i1 false)
br i1 %cmp.not34, label %if.then7, label %while.body
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%key2 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%1 = load i32, ptr %key2, align 8, !tbaa !12
%cmp3 = icmp sgt i32 %1, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %x.035
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !10
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else8, label %while.body, !llvm.loop !14
if.then7: ; preds = %entry
%parent37 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr null, ptr %parent37, align 8, !tbaa !16
br label %if.end17
if.else8: ; preds = %while.body
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr %x.035, ptr %parent, align 8, !tbaa !16
%key10 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%2 = load i32, ptr %key10, align 8, !tbaa !12
%cmp11 = icmp sgt i32 %2, %k
%left13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%spec.select = select i1 %cmp11, ptr %left13, ptr %x.035
br label %if.end17
if.end17: ; preds = %if.else8, %if.then7
%left13.sink = phi ptr [ @root, %if.then7 ], [ %spec.select, %if.else8 ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !10
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #4 {
entry:
%cmp.not4 = icmp eq ptr %u, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%u.tr5 = phi ptr [ %2, %if.then ], [ %u, %entry ]
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !17
tail call void @inorder(ptr noundef %0)
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%1 = load i32, ptr %key, align 8, !tbaa !12
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !18
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #4 {
entry:
%cmp.not4 = icmp eq ptr %u, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%u.tr5 = phi ptr [ %2, %if.then ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !12
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !17
tail call void @preorder(ptr noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !18
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nounwind uwtable
define dso_local void @treeDelete(ptr noundef %z) local_unnamed_addr #0 {
entry:
%left = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !17
%cmp = icmp eq ptr %0, null
br i1 %cmp, label %if.end8, label %lor.lhs.false
lor.lhs.false: ; preds = %entry
%1 = load ptr, ptr %z, align 8, !tbaa !18
%cmp1 = icmp eq ptr %1, null
br i1 %cmp1, label %if.then10, label %while.cond.i.i
while.cond.i.i: ; preds = %lor.lhs.false, %while.cond.i.i
%x.addr.0.i.i = phi ptr [ %2, %while.cond.i.i ], [ %1, %lor.lhs.false ]
%left.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i, i64 0, i32 1
%2 = load ptr, ptr %left.i.i, align 8, !tbaa !17
%cmp.not.i.i = icmp eq ptr %2, null
br i1 %cmp.not.i.i, label %if.end8, label %while.cond.i.i, !llvm.loop !19
if.end8: ; preds = %while.cond.i.i, %entry
%y.0.ph = phi ptr [ %z, %entry ], [ %x.addr.0.i.i, %while.cond.i.i ]
%3 = load ptr, ptr %y.0.ph, align 8, !tbaa !18
%cmp9.not = icmp eq ptr %3, null
br i1 %cmp9.not, label %if.end12, label %if.then10
if.then10: ; preds = %lor.lhs.false, %if.end8
%y.059 = phi ptr [ %y.0.ph, %if.end8 ], [ %z, %lor.lhs.false ]
%x.055 = phi ptr [ %3, %if.end8 ], [ %0, %lor.lhs.false ]
%parent = getelementptr inbounds %struct.node, ptr %y.059, i64 0, i32 2
%4 = load ptr, ptr %parent, align 8, !tbaa !16
%parent11 = getelementptr inbounds %struct.node, ptr %x.055, i64 0, i32 2
store ptr %4, ptr %parent11, align 8, !tbaa !16
br label %if.end12
if.end12: ; preds = %if.then10, %if.end8
%y.061 = phi ptr [ %y.059, %if.then10 ], [ %y.0.ph, %if.end8 ]
%x.056 = phi ptr [ %x.055, %if.then10 ], [ null, %if.end8 ]
%parent13 = getelementptr inbounds %struct.node, ptr %y.061, i64 0, i32 2
%5 = load ptr, ptr %parent13, align 8, !tbaa !16
%cmp14 = icmp eq ptr %5, null
br i1 %cmp14, label %if.end27, label %if.else16
if.else16: ; preds = %if.end12
%left18 = getelementptr inbounds %struct.node, ptr %5, i64 0, i32 1
%6 = load ptr, ptr %left18, align 8, !tbaa !17
%cmp19 = icmp eq ptr %y.061, %6
%left18. = select i1 %cmp19, ptr %left18, ptr %5
br label %if.end27
if.end27: ; preds = %if.else16, %if.end12
%left18.sink = phi ptr [ @root, %if.end12 ], [ %left18., %if.else16 ]
store ptr %x.056, ptr %left18.sink, align 8, !tbaa !10
%cmp28.not = icmp eq ptr %y.061, %z
br i1 %cmp28.not, label %if.end31, label %if.then29
if.then29: ; preds = %if.end27
%key = getelementptr inbounds %struct.node, ptr %y.061, i64 0, i32 3
%7 = load i32, ptr %key, align 8, !tbaa !12
%key30 = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 3
store i32 %7, ptr %key30, align 8, !tbaa !12
br label %if.end31
if.end31: ; preds = %if.then29, %if.end27
tail call void @free(ptr noundef nonnull %y.061) #9
ret void
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeMinimum(ptr noundef readonly %x) local_unnamed_addr #3 {
entry:
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%x.addr.0 = phi ptr [ %x, %entry ], [ %0, %while.cond ]
%left = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !17
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !19
while.end: ; preds = %while.cond
ret ptr %x.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSuccessor(ptr noundef readonly %x) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr %x, align 8, !tbaa !18
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%x.addr.0.i = phi ptr [ %1, %while.cond.i ], [ %0, %entry ]
%left.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i, i64 0, i32 1
%1 = load ptr, ptr %left.i, align 8, !tbaa !17
%cmp.not.i = icmp eq ptr %1, null
br i1 %cmp.not.i, label %cleanup, label %while.cond.i, !llvm.loop !19
while.cond: ; preds = %entry, %land.rhs
%x.addr.0 = phi ptr [ %y.0, %land.rhs ], [ %x, %entry ]
%y.0.in = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 2
%y.0 = load ptr, ptr %y.0.in, align 8, !tbaa !16
%cmp2.not = icmp eq ptr %y.0, null
br i1 %cmp2.not, label %cleanup, label %land.rhs
land.rhs: ; preds = %while.cond
%2 = load ptr, ptr %y.0, align 8, !tbaa !18
%cmp4 = icmp eq ptr %x.addr.0, %2
br i1 %cmp4, label %while.cond, label %cleanup, !llvm.loop !21
cleanup: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi ptr [ %y.0, %land.rhs ], [ null, %while.cond ], [ %x.addr.0.i, %while.cond.i ]
ret ptr %retval.0
}
; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #7
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #7
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #8
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 = { 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 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 = { nofree 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 #5 = { 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 #6 = { 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 #7 = { nofree nounwind }
attributes #8 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #9 = { nounwind }
attributes #10 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !6, i64 24}
!13 = !{!"node", !11, i64 0, !11, i64 8, !11, i64 16, !6, i64 24}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!13, !11, i64 16}
!17 = !{!13, !11, i64 8}
!18 = !{!13, !11, i64 0}
!19 = distinct !{!19, !15}
!20 = distinct !{!20, !15}
!21 = distinct !{!21, !15}
|
#include <stdio.h>
#include <stdlib.h>
struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x){
while(x->left != NIL)
x = x->left;
return x;
}
Node treeMaximum(Node x){
while(x->right != NIL)
x = x->right;
return x;
}
Node treeSearch(Node u, int k){
if(u == NIL || k == u->key)
return u;
if(k < u->key)
return treeSearch(u->left,k);
else
return treeSearch(u->right,k);
}
Node treeSuccessor(Node x){
Node y;
if(x->right != NIL)
return treeMinimum(x->right);
y = x->parent;
while(y != NIL && x == y->right) {
x = y;
y = y->parent;
}
return y;
}
void treeDelete(Node z){
Node y; // node to be deleted
Node x; // child of y
if(z->left == NIL || z->right == NIL)
y = z;
else
y = treeSuccessor(z);
if(y->left != NIL)
x = y->left;
else
x = y->right;
if(x != NIL)
x->parent = y->parent;
if(y->parent == NIL)
root = x;
else if(y == y->parent->left)
y->parent->left = x;
else y->parent->right = x;
if(y != z)
z->key = y->key;
}
void insert(int k){
Node y = NIL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
y = NIL;
x = root;
while(x != NIL) {
y = x;
if(z->key < x->key)
x = x->left;
else
x = x->right;
}
z->parent = y;
if(y == NIL)
root = z;
else if(z->key < y->key)
y->left = z;
else
y->right = z;
}
void inorder(Node u){
if(u == NIL)
return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(Node u){
if(u == NIL)
return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
int main(){
int n, i, x;
char com[20];
scanf("%d", &n);
for ( i = 0; i < n; i++ ){
scanf("%s", com);
if ( com[0] == 'f' ){
scanf("%d", &x);
Node t = treeSearch(root, x);
if ( t != NIL ) printf("yes\n");
else printf("no\n");
} else if ( com[0] == 'i' ){
scanf("%d", &x);
insert(x);
} else if ( com[0] == 'p' ){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
} else if ( com[0] == 'd' ){
scanf("%d", &x);
treeDelete(treeSearch(root, x));
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207060/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207060/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { ptr, ptr, ptr, i32 }
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeMinimum(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%x.addr.0 = phi ptr [ %x, %entry ], [ %0, %while.cond ]
%left = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !11
while.end: ; preds = %while.cond
ret ptr %x.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeMaximum(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%x.addr.0 = phi ptr [ %x, %entry ], [ %0, %while.cond ]
%0 = load ptr, ptr %x.addr.0, align 8, !tbaa !13
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !14
while.end: ; preds = %while.cond
ret ptr %x.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSearch(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #0 {
entry:
%cmp14 = icmp eq ptr %u, null
br i1 %cmp14, label %return, label %lor.lhs.false
lor.lhs.false: ; preds = %entry, %if.end
%u.tr15 = phi ptr [ %u.tr.be, %if.end ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !15
%cmp1 = icmp eq i32 %0, %k
br i1 %cmp1, label %return, label %if.end
if.end: ; preds = %lor.lhs.false
%cmp3 = icmp sgt i32 %0, %k
%left = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 1
%spec.select = select i1 %cmp3, ptr %left, ptr %u.tr15
%u.tr.be = load ptr, ptr %spec.select, align 8, !tbaa !16
%cmp = icmp eq ptr %u.tr.be, null
br i1 %cmp, label %return, label %lor.lhs.false
return: ; preds = %lor.lhs.false, %if.end, %entry
%retval.0 = phi ptr [ null, %entry ], [ null, %if.end ], [ %u.tr15, %lor.lhs.false ]
ret ptr %retval.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSuccessor(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr %x, align 8, !tbaa !13
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%x.addr.0.i = phi ptr [ %1, %while.cond.i ], [ %0, %entry ]
%left.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i, i64 0, i32 1
%1 = load ptr, ptr %left.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %1, null
br i1 %cmp.not.i, label %cleanup, label %while.cond.i, !llvm.loop !11
while.cond: ; preds = %entry, %land.rhs
%x.addr.0 = phi ptr [ %y.0, %land.rhs ], [ %x, %entry ]
%y.0.in = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 2
%y.0 = load ptr, ptr %y.0.in, align 8, !tbaa !17
%cmp2.not = icmp eq ptr %y.0, null
br i1 %cmp2.not, label %cleanup, label %land.rhs
land.rhs: ; preds = %while.cond
%2 = load ptr, ptr %y.0, align 8, !tbaa !13
%cmp4 = icmp eq ptr %x.addr.0, %2
br i1 %cmp4, label %while.cond, label %cleanup, !llvm.loop !18
cleanup: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi ptr [ %y.0, %land.rhs ], [ null, %while.cond ], [ %x.addr.0.i, %while.cond.i ]
ret ptr %retval.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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @treeDelete(ptr noundef %z) local_unnamed_addr #2 {
entry:
%left = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
%cmp = icmp eq ptr %0, null
br i1 %cmp, label %if.end8, label %lor.lhs.false
lor.lhs.false: ; preds = %entry
%1 = load ptr, ptr %z, align 8, !tbaa !13
%cmp1 = icmp eq ptr %1, null
br i1 %cmp1, label %if.then10, label %while.cond.i.i
while.cond.i.i: ; preds = %lor.lhs.false, %while.cond.i.i
%x.addr.0.i.i = phi ptr [ %2, %while.cond.i.i ], [ %1, %lor.lhs.false ]
%left.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i, i64 0, i32 1
%2 = load ptr, ptr %left.i.i, align 8, !tbaa !5
%cmp.not.i.i = icmp eq ptr %2, null
br i1 %cmp.not.i.i, label %if.end8, label %while.cond.i.i, !llvm.loop !11
if.end8: ; preds = %while.cond.i.i, %entry
%y.0.ph = phi ptr [ %z, %entry ], [ %x.addr.0.i.i, %while.cond.i.i ]
%3 = load ptr, ptr %y.0.ph, align 8, !tbaa !13
%cmp9.not = icmp eq ptr %3, null
br i1 %cmp9.not, label %if.end12, label %if.then10
if.then10: ; preds = %lor.lhs.false, %if.end8
%y.058 = phi ptr [ %y.0.ph, %if.end8 ], [ %z, %lor.lhs.false ]
%x.054 = phi ptr [ %3, %if.end8 ], [ %0, %lor.lhs.false ]
%parent = getelementptr inbounds %struct.node, ptr %y.058, i64 0, i32 2
%4 = load ptr, ptr %parent, align 8, !tbaa !17
%parent11 = getelementptr inbounds %struct.node, ptr %x.054, i64 0, i32 2
store ptr %4, ptr %parent11, align 8, !tbaa !17
br label %if.end12
if.end12: ; preds = %if.then10, %if.end8
%y.060 = phi ptr [ %y.058, %if.then10 ], [ %y.0.ph, %if.end8 ]
%x.055 = phi ptr [ %x.054, %if.then10 ], [ null, %if.end8 ]
%parent13 = getelementptr inbounds %struct.node, ptr %y.060, i64 0, i32 2
%5 = load ptr, ptr %parent13, align 8, !tbaa !17
%cmp14 = icmp eq ptr %5, null
br i1 %cmp14, label %if.end27, label %if.else16
if.else16: ; preds = %if.end12
%left18 = getelementptr inbounds %struct.node, ptr %5, i64 0, i32 1
%6 = load ptr, ptr %left18, align 8, !tbaa !5
%cmp19 = icmp eq ptr %y.060, %6
%left18. = select i1 %cmp19, ptr %left18, ptr %5
br label %if.end27
if.end27: ; preds = %if.else16, %if.end12
%left18.sink = phi ptr [ @root, %if.end12 ], [ %left18., %if.else16 ]
store ptr %x.055, ptr %left18.sink, align 8, !tbaa !16
%cmp28.not = icmp eq ptr %y.060, %z
br i1 %cmp28.not, label %if.end31, label %if.then29
if.then29: ; preds = %if.end27
%key = getelementptr inbounds %struct.node, ptr %y.060, i64 0, i32 3
%7 = load i32, ptr %key, align 8, !tbaa !15
%key30 = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 3
store i32 %7, ptr %key30, align 8, !tbaa !15
br label %if.end31
if.end31: ; preds = %if.then29, %if.end27
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #3 {
entry:
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
%key = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store i32 %k, ptr %key, align 8, !tbaa !15
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call, i8 0, i64 16, i1 false)
%x.034 = load ptr, ptr @root, align 8, !tbaa !16
%cmp.not35 = icmp eq ptr %x.034, null
br i1 %cmp.not35, label %if.then7, label %while.body
while.body: ; preds = %entry, %while.body
%x.036 = phi ptr [ %x.0, %while.body ], [ %x.034, %entry ]
%key2 = getelementptr inbounds %struct.node, ptr %x.036, i64 0, i32 3
%0 = load i32, ptr %key2, align 8, !tbaa !15
%cmp3 = icmp sgt i32 %0, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.036, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %x.036
%x.0 = load ptr, ptr %x.1.in, align 8, !tbaa !16
%cmp.not = icmp eq ptr %x.0, null
br i1 %cmp.not, label %if.else8, label %while.body, !llvm.loop !19
if.then7: ; preds = %entry
%parent38 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr null, ptr %parent38, align 8, !tbaa !17
br label %if.end17
if.else8: ; preds = %while.body
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr %x.036, ptr %parent, align 8, !tbaa !17
%key10 = getelementptr inbounds %struct.node, ptr %x.036, i64 0, i32 3
%1 = load i32, ptr %key10, align 8, !tbaa !15
%cmp11 = icmp sgt i32 %1, %k
%left13 = getelementptr inbounds %struct.node, ptr %x.036, i64 0, i32 1
%spec.select = select i1 %cmp11, ptr %left13, ptr %x.036
br label %if.end17
if.end17: ; preds = %if.else8, %if.then7
%left13.sink = phi ptr [ @root, %if.then7 ], [ %spec.select, %if.else8 ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !16
ret void
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #3 {
entry:
%cmp4 = icmp eq ptr %u, null
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %2, %if.end ], [ %u, %entry ]
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
tail call void @inorder(ptr noundef %0)
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%1 = load i32, ptr %key, align 8, !tbaa !15
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !13
%cmp = icmp eq ptr %2, null
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #3 {
entry:
%cmp4 = icmp eq ptr %u, null
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %2, %if.end ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !15
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !5
tail call void @preorder(ptr noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !13
%cmp = icmp eq ptr %2, null
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #3 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #9
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #9
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !20
%cmp66 = icmp sgt i32 %0, 0
br i1 %cmp66, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.067 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !21
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
i8 100, label %if.then31
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !16
%3 = load i32, ptr %x, align 4, !tbaa !20
%cmp14.i = icmp eq ptr %2, null
br i1 %cmp14.i, label %if.else, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %if.then, %if.end.i
%u.tr15.i = phi ptr [ %u.tr.be.i, %if.end.i ], [ %2, %if.then ]
%key.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 3
%4 = load i32, ptr %key.i, align 8, !tbaa !15
%cmp1.i = icmp eq i32 %4, %3
br i1 %cmp1.i, label %if.then8, label %if.end.i
if.end.i: ; preds = %lor.lhs.false.i
%cmp3.i = icmp sgt i32 %4, %3
%left.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 1
%spec.select.i = select i1 %cmp3.i, ptr %left.i, ptr %u.tr15.i
%u.tr.be.i = load ptr, ptr %spec.select.i, align 8, !tbaa !16
%cmp.i = icmp eq ptr %u.tr.be.i, null
br i1 %cmp.i, label %if.else, label %lor.lhs.false.i
if.then8: ; preds = %lor.lhs.false.i
%puts40 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %if.end.i, %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%5 = load i32, ptr %x, align 4, !tbaa !20
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
%key.i41 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store i32 %5, ptr %key.i41, align 8, !tbaa !15
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call.i, i8 0, i64 16, i1 false)
%x.034.i = load ptr, ptr @root, align 8, !tbaa !16
%cmp.not35.i = icmp eq ptr %x.034.i, null
br i1 %cmp.not35.i, label %insert.exit, label %while.body.i
while.body.i: ; preds = %if.then16, %while.body.i
%x.036.i = phi ptr [ %x.0.i, %while.body.i ], [ %x.034.i, %if.then16 ]
%key2.i = getelementptr inbounds %struct.node, ptr %x.036.i, i64 0, i32 3
%6 = load i32, ptr %key2.i, align 8, !tbaa !15
%cmp3.i42 = icmp sgt i32 %6, %5
%left4.i = getelementptr inbounds %struct.node, ptr %x.036.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i42, ptr %left4.i, ptr %x.036.i
%x.0.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !16
%cmp.not.i = icmp eq ptr %x.0.i, null
br i1 %cmp.not.i, label %insert.exit, label %while.body.i, !llvm.loop !19
insert.exit: ; preds = %while.body.i, %if.then16
%.sink = phi ptr [ null, %if.then16 ], [ %x.036.i, %while.body.i ]
%left13.sink.i = phi ptr [ @root, %if.then16 ], [ %x.1.in.i, %while.body.i ]
%parent38.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
store ptr %.sink, ptr %parent38.i, align 8, !tbaa !17
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !16
br label %for.inc
if.then23: ; preds = %for.body
%7 = load ptr, ptr @root, align 8, !tbaa !16
call void @inorder(ptr noundef %7)
%putchar = call i32 @putchar(i32 10)
%8 = load ptr, ptr @root, align 8, !tbaa !16
call void @preorder(ptr noundef %8)
%putchar39 = call i32 @putchar(i32 10)
br label %for.inc
if.then31: ; preds = %for.body
%call32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%9 = load ptr, ptr @root, align 8, !tbaa !16
%10 = load i32, ptr %x, align 4, !tbaa !20
%cmp14.i44 = icmp eq ptr %9, null
br i1 %cmp14.i44, label %treeSearch.exit56, label %lor.lhs.false.i45
lor.lhs.false.i45: ; preds = %if.then31, %if.end.i49
%u.tr15.i46 = phi ptr [ %u.tr.be.i53, %if.end.i49 ], [ %9, %if.then31 ]
%key.i47 = getelementptr inbounds %struct.node, ptr %u.tr15.i46, i64 0, i32 3
%11 = load i32, ptr %key.i47, align 8, !tbaa !15
%cmp1.i48 = icmp eq i32 %11, %10
br i1 %cmp1.i48, label %treeSearch.exit56, label %if.end.i49
if.end.i49: ; preds = %lor.lhs.false.i45
%cmp3.i50 = icmp sgt i32 %11, %10
%left.i51 = getelementptr inbounds %struct.node, ptr %u.tr15.i46, i64 0, i32 1
%spec.select.i52 = select i1 %cmp3.i50, ptr %left.i51, ptr %u.tr15.i46
%u.tr.be.i53 = load ptr, ptr %spec.select.i52, align 8, !tbaa !16
%cmp.i54 = icmp eq ptr %u.tr.be.i53, null
br i1 %cmp.i54, label %treeSearch.exit56, label %lor.lhs.false.i45
treeSearch.exit56: ; preds = %lor.lhs.false.i45, %if.end.i49, %if.then31
%retval.0.i55 = phi ptr [ null, %if.then31 ], [ %u.tr15.i46, %lor.lhs.false.i45 ], [ null, %if.end.i49 ]
%left.i57 = getelementptr inbounds %struct.node, ptr %retval.0.i55, i64 0, i32 1
%12 = load ptr, ptr %left.i57, align 8, !tbaa !5
%cmp.i58 = icmp eq ptr %12, null
br i1 %cmp.i58, label %if.end8.i, label %lor.lhs.false.i59
lor.lhs.false.i59: ; preds = %treeSearch.exit56
%13 = load ptr, ptr %retval.0.i55, align 8, !tbaa !13
%cmp1.i60 = icmp eq ptr %13, null
br i1 %cmp1.i60, label %if.then10.i, label %while.cond.i.i.i
while.cond.i.i.i: ; preds = %lor.lhs.false.i59, %while.cond.i.i.i
%x.addr.0.i.i.i = phi ptr [ %14, %while.cond.i.i.i ], [ %13, %lor.lhs.false.i59 ]
%left.i.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i.i, i64 0, i32 1
%14 = load ptr, ptr %left.i.i.i, align 8, !tbaa !5
%cmp.not.i.i.i = icmp eq ptr %14, null
br i1 %cmp.not.i.i.i, label %if.end8.i, label %while.cond.i.i.i, !llvm.loop !11
if.end8.i: ; preds = %while.cond.i.i.i, %treeSearch.exit56
%y.0.ph.i = phi ptr [ %retval.0.i55, %treeSearch.exit56 ], [ %x.addr.0.i.i.i, %while.cond.i.i.i ]
%15 = load ptr, ptr %y.0.ph.i, align 8, !tbaa !13
%cmp9.not.i = icmp eq ptr %15, null
br i1 %cmp9.not.i, label %if.end12.i, label %if.then10.i
if.then10.i: ; preds = %if.end8.i, %lor.lhs.false.i59
%y.058.i = phi ptr [ %y.0.ph.i, %if.end8.i ], [ %retval.0.i55, %lor.lhs.false.i59 ]
%x.054.i = phi ptr [ %15, %if.end8.i ], [ %12, %lor.lhs.false.i59 ]
%parent.i61 = getelementptr inbounds %struct.node, ptr %y.058.i, i64 0, i32 2
%16 = load ptr, ptr %parent.i61, align 8, !tbaa !17
%parent11.i = getelementptr inbounds %struct.node, ptr %x.054.i, i64 0, i32 2
store ptr %16, ptr %parent11.i, align 8, !tbaa !17
br label %if.end12.i
if.end12.i: ; preds = %if.then10.i, %if.end8.i
%y.060.i = phi ptr [ %y.058.i, %if.then10.i ], [ %y.0.ph.i, %if.end8.i ]
%x.055.i = phi ptr [ %x.054.i, %if.then10.i ], [ null, %if.end8.i ]
%parent13.i = getelementptr inbounds %struct.node, ptr %y.060.i, i64 0, i32 2
%17 = load ptr, ptr %parent13.i, align 8, !tbaa !17
%cmp14.i62 = icmp eq ptr %17, null
br i1 %cmp14.i62, label %if.end27.i, label %if.else16.i
if.else16.i: ; preds = %if.end12.i
%left18.i = getelementptr inbounds %struct.node, ptr %17, i64 0, i32 1
%18 = load ptr, ptr %left18.i, align 8, !tbaa !5
%cmp19.i = icmp eq ptr %y.060.i, %18
%left18..i = select i1 %cmp19.i, ptr %left18.i, ptr %17
br label %if.end27.i
if.end27.i: ; preds = %if.else16.i, %if.end12.i
%left18.sink.i = phi ptr [ @root, %if.end12.i ], [ %left18..i, %if.else16.i ]
store ptr %x.055.i, ptr %left18.sink.i, align 8, !tbaa !16
%cmp28.not.i = icmp eq ptr %y.060.i, %retval.0.i55
br i1 %cmp28.not.i, label %for.inc, label %if.then29.i
if.then29.i: ; preds = %if.end27.i
%key.i63 = getelementptr inbounds %struct.node, ptr %y.060.i, i64 0, i32 3
%19 = load i32, ptr %key.i63, align 8, !tbaa !15
%key30.i = getelementptr inbounds %struct.node, ptr %retval.0.i55, i64 0, i32 3
store i32 %19, ptr %key30.i, align 8, !tbaa !15
br label %for.inc
for.inc: ; preds = %if.then29.i, %if.end27.i, %for.body, %if.then8, %if.else, %if.then23, %insert.exit
%inc = add nuw nsw i32 %i.067, 1
%20 = load i32, ptr %n, align 4, !tbaa !20
%cmp = icmp slt i32 %inc, %20
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !22
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #9
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = { nofree 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 = { 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 #5 = { 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 #6 = { nofree nounwind }
attributes #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !7, i64 8}
!6 = !{!"node", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!6, !7, i64 0}
!14 = distinct !{!14, !12}
!15 = !{!6, !10, i64 24}
!16 = !{!7, !7, i64 0}
!17 = !{!6, !7, i64 16}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = !{!10, !10, i64 0}
!21 = !{!8, !8, i64 0}
!22 = distinct !{!22, !12}
|
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define N 200001
#define MAX 1000
struct node_t {
int key;
struct node_t *pare;
struct node_t *left;
struct node_t *right;
};
typedef struct node_t Node;
Node *tree_insert(Node *top, Node *z) {
Node *y, *x;
x = top;
y = NULL;
while (x != NULL) {
y = x;
if (z->key < x->key) { x = x->left;}
else { x = x->right;}
}
z->pare = y;
if (y == NULL) { top = z;}
else if (z->key < y->key) {y->left = z; }
else {y->right = z;}
return top;
}
Node *tree_find(Node *node, int key) {
if (node == NULL){return NULL;}
if (node->key == key){return node;}
if (key < node->key){return tree_find(node->left, key);}
return tree_find(node->right, key);
}
Node *tree_minimum(Node *x) {
while (x->left != NULL) {x = x->left;}
return x;
}
Node *tree_successor(Node *x) {
Node *y;
if (x->right != NULL) {return tree_minimum(x->right);}
y = x->pare;
while (y != NULL && x == y->right) {
x = y;
y = y->pare;
}
return y;
}
Node *tree_delete(Node *top, Node *z) {
Node *y, *x;
if (z->left == NULL || z->right == NULL) {y = z;}
else {y = tree_successor(z);}
if (z->left != NULL) {x = y->left;}
else {x = y->right;}
if (x != NULL) {x->pare = y->pare;}
if (y->pare == NULL) {top = x;}
else if (y == y->pare->left) {y->pare->left = x;}
else {y->pare->right = x;}
if (y != z) {z->key = y->key;}
return top;
}
void inorder_walk(Node *node) {
if (node->left != NULL) {inorder_walk(node->left);}
printf(" %d", node->key);
if (node->right != NULL) {inorder_walk(node->right);}
}
void preorder_walk(Node *node) {
printf(" %d", node->key);
if (node->left != NULL) {preorder_walk(node->left);}
if (node->right != NULL) { preorder_walk(node->right);}
}
int main(void) {
char c[20];
int i,n, key;
Node *top = NULL, *p;
scanf("%d ", &n);
for (i = 0; i < n; i++) {
scanf("%s %d ", c, &key);
if (c[0] == 'i') {
p = malloc(sizeof(Node));
p->key = key;
p->pare = p->left = p->right = NULL;
top = tree_insert(top, p);
}
else if (c[0] == 'f') {
puts(tree_find(top, key) != NULL ? "yes" : "no");
}
else if (c[0] == 'd') {
p = tree_find(top, key);
if (p != NULL) {top = tree_delete(top, p);}
}
else {
inorder_walk(top);
putchar('\n');
preorder_walk(top);
putchar('\n');
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207103/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207103/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node_t = type { i32, ptr, ptr, ptr }
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d \00", align 1
@.str.2 = private unnamed_addr constant [7 x i8] c"%s %d \00", align 1
@.str.3 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
@.str.4 = private unnamed_addr constant [3 x i8] c"no\00", align 1
@stdout = external local_unnamed_addr global ptr, align 8
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local ptr @tree_insert(ptr noundef %top, ptr noundef %z) local_unnamed_addr #0 {
entry:
%cmp.not29 = icmp eq ptr %top, null
br i1 %cmp.not29, label %while.end.thread, label %while.body.lr.ph
while.end.thread: ; preds = %entry
%pare32 = getelementptr inbounds %struct.node_t, ptr %z, i64 0, i32 1
store ptr null, ptr %pare32, align 8, !tbaa !5
br label %if.end14
while.body.lr.ph: ; preds = %entry
%0 = load i32, ptr %z, align 8, !tbaa !11
br label %while.body
while.body: ; preds = %while.body.lr.ph, %while.body
%x.030 = phi ptr [ %top, %while.body.lr.ph ], [ %x.1, %while.body ]
%1 = load i32, ptr %x.030, align 8, !tbaa !11
%cmp2 = icmp slt i32 %0, %1
%left = getelementptr inbounds %struct.node_t, ptr %x.030, i64 0, i32 2
%right = getelementptr inbounds %struct.node_t, ptr %x.030, i64 0, i32 3
%x.1.in = select i1 %cmp2, ptr %left, ptr %right
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !12
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else5, label %while.body, !llvm.loop !13
if.else5: ; preds = %while.body
%pare = getelementptr inbounds %struct.node_t, ptr %z, i64 0, i32 1
store ptr %x.030, ptr %pare, align 8, !tbaa !5
%2 = load i32, ptr %z, align 8, !tbaa !11
%3 = load i32, ptr %x.030, align 8, !tbaa !11
%cmp8 = icmp slt i32 %2, %3
br i1 %cmp8, label %if.then9, label %if.else11
if.then9: ; preds = %if.else5
%left10 = getelementptr inbounds %struct.node_t, ptr %x.030, i64 0, i32 2
store ptr %z, ptr %left10, align 8, !tbaa !15
br label %if.end14
if.else11: ; preds = %if.else5
%right12 = getelementptr inbounds %struct.node_t, ptr %x.030, i64 0, i32 3
store ptr %z, ptr %right12, align 8, !tbaa !16
br label %if.end14
if.end14: ; preds = %while.end.thread, %if.then9, %if.else11
%top.addr.0 = phi ptr [ %top, %if.then9 ], [ %top, %if.else11 ], [ %z, %while.end.thread ]
ret ptr %top.addr.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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @tree_find(ptr noundef readonly %node, i32 noundef %key) local_unnamed_addr #2 {
entry:
%cmp18 = icmp eq ptr %node, null
br i1 %cmp18, label %return, label %if.end
if.end: ; preds = %entry, %if.end4
%node.tr19 = phi ptr [ %node.tr.be, %if.end4 ], [ %node, %entry ]
%0 = load i32, ptr %node.tr19, align 8, !tbaa !11
%cmp2 = icmp eq i32 %0, %key
br i1 %cmp2, label %return, label %if.end4
if.end4: ; preds = %if.end
%cmp6 = icmp sgt i32 %0, %key
%left = getelementptr inbounds %struct.node_t, ptr %node.tr19, i64 0, i32 2
%right = getelementptr inbounds %struct.node_t, ptr %node.tr19, i64 0, i32 3
%node.tr.be.in = select i1 %cmp6, ptr %left, ptr %right
%node.tr.be = load ptr, ptr %node.tr.be.in, align 8, !tbaa !12
%cmp = icmp eq ptr %node.tr.be, null
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end4, %if.end, %entry
%retval.0 = phi ptr [ null, %entry ], [ %node.tr19, %if.end ], [ null, %if.end4 ]
ret ptr %retval.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @tree_minimum(ptr noundef readonly %x) local_unnamed_addr #2 {
entry:
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%x.addr.0 = phi ptr [ %x, %entry ], [ %0, %while.cond ]
%left = getelementptr inbounds %struct.node_t, ptr %x.addr.0, i64 0, i32 2
%0 = load ptr, ptr %left, align 8, !tbaa !15
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !17
while.end: ; preds = %while.cond
ret ptr %x.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @tree_successor(ptr noundef readonly %x) local_unnamed_addr #2 {
entry:
%right = getelementptr inbounds %struct.node_t, ptr %x, i64 0, i32 3
%0 = load ptr, ptr %right, align 8, !tbaa !16
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%x.addr.0.i = phi ptr [ %1, %while.cond.i ], [ %0, %entry ]
%left.i = getelementptr inbounds %struct.node_t, ptr %x.addr.0.i, i64 0, i32 2
%1 = load ptr, ptr %left.i, align 8, !tbaa !15
%cmp.not.i = icmp eq ptr %1, null
br i1 %cmp.not.i, label %cleanup, label %while.cond.i, !llvm.loop !17
while.cond: ; preds = %entry, %land.rhs
%x.addr.0 = phi ptr [ %y.0, %land.rhs ], [ %x, %entry ]
%y.0.in = getelementptr inbounds %struct.node_t, ptr %x.addr.0, i64 0, i32 1
%y.0 = load ptr, ptr %y.0.in, align 8, !tbaa !5
%cmp2.not = icmp eq ptr %y.0, null
br i1 %cmp2.not, label %cleanup, label %land.rhs
land.rhs: ; preds = %while.cond
%right3 = getelementptr inbounds %struct.node_t, ptr %y.0, i64 0, i32 3
%2 = load ptr, ptr %right3, align 8, !tbaa !16
%cmp4 = icmp eq ptr %x.addr.0, %2
br i1 %cmp4, label %while.cond, label %cleanup, !llvm.loop !18
cleanup: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi ptr [ %y.0, %land.rhs ], [ null, %while.cond ], [ %x.addr.0.i, %while.cond.i ]
ret ptr %retval.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local ptr @tree_delete(ptr noundef readnone %top, ptr noundef %z) local_unnamed_addr #0 {
entry:
%left = getelementptr inbounds %struct.node_t, ptr %z, i64 0, i32 2
%0 = load ptr, ptr %left, align 8, !tbaa !15
%cmp = icmp eq ptr %0, null
br i1 %cmp, label %if.end, label %lor.lhs.false
lor.lhs.false: ; preds = %entry
%right = getelementptr inbounds %struct.node_t, ptr %z, i64 0, i32 3
%1 = load ptr, ptr %right, align 8, !tbaa !16
%cmp1 = icmp eq ptr %1, null
br i1 %cmp1, label %if.end, label %while.cond.i.i
while.cond.i.i: ; preds = %lor.lhs.false, %while.cond.i.i
%x.addr.0.i.i = phi ptr [ %2, %while.cond.i.i ], [ %1, %lor.lhs.false ]
%left.i.i = getelementptr inbounds %struct.node_t, ptr %x.addr.0.i.i, i64 0, i32 2
%2 = load ptr, ptr %left.i.i, align 8, !tbaa !15
%cmp.not.i.i = icmp eq ptr %2, null
br i1 %cmp.not.i.i, label %if.end, label %while.cond.i.i, !llvm.loop !17
if.end: ; preds = %while.cond.i.i, %entry, %lor.lhs.false
%y.0 = phi ptr [ %z, %lor.lhs.false ], [ %z, %entry ], [ %x.addr.0.i.i, %while.cond.i.i ]
%left5 = getelementptr inbounds %struct.node_t, ptr %y.0, i64 0, i32 2
%right7 = getelementptr inbounds %struct.node_t, ptr %y.0, i64 0, i32 3
%x.0.in = select i1 %cmp, ptr %right7, ptr %left5
%x.0 = load ptr, ptr %x.0.in, align 8, !tbaa !12
%cmp9.not = icmp eq ptr %x.0, null
br i1 %cmp9.not, label %if.end12, label %if.then10
if.then10: ; preds = %if.end
%pare = getelementptr inbounds %struct.node_t, ptr %y.0, i64 0, i32 1
%3 = load ptr, ptr %pare, align 8, !tbaa !5
%pare11 = getelementptr inbounds %struct.node_t, ptr %x.0, i64 0, i32 1
store ptr %3, ptr %pare11, align 8, !tbaa !5
br label %if.end12
if.end12: ; preds = %if.then10, %if.end
%pare13 = getelementptr inbounds %struct.node_t, ptr %y.0, i64 0, i32 1
%4 = load ptr, ptr %pare13, align 8, !tbaa !5
%cmp14 = icmp eq ptr %4, null
br i1 %cmp14, label %if.end27, label %if.else16
if.else16: ; preds = %if.end12
%left18 = getelementptr inbounds %struct.node_t, ptr %4, i64 0, i32 2
%5 = load ptr, ptr %left18, align 8, !tbaa !15
%cmp19 = icmp eq ptr %y.0, %5
%right25 = getelementptr inbounds %struct.node_t, ptr %4, i64 0, i32 3
%left18.sink = select i1 %cmp19, ptr %left18, ptr %right25
store ptr %x.0, ptr %left18.sink, align 8, !tbaa !12
br label %if.end27
if.end27: ; preds = %if.else16, %if.end12
%top.addr.0 = phi ptr [ %x.0, %if.end12 ], [ %top, %if.else16 ]
%cmp28.not = icmp eq ptr %y.0, %z
br i1 %cmp28.not, label %if.end31, label %if.then29
if.then29: ; preds = %if.end27
%6 = load i32, ptr %y.0, align 8, !tbaa !11
store i32 %6, ptr %z, align 8, !tbaa !11
br label %if.end31
if.end31: ; preds = %if.then29, %if.end27
ret ptr %top.addr.0
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder_walk(ptr nocapture noundef readonly %node) local_unnamed_addr #3 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%node.tr = phi ptr [ %node, %entry ], [ %2, %if.end ]
%left = getelementptr inbounds %struct.node_t, ptr %node.tr, i64 0, i32 2
%0 = load ptr, ptr %left, align 8, !tbaa !15
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @inorder_walk(ptr noundef nonnull %0)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%1 = load i32, ptr %node.tr, align 8, !tbaa !11
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%right = getelementptr inbounds %struct.node_t, ptr %node.tr, i64 0, i32 3
%2 = load ptr, ptr %right, align 8, !tbaa !16
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder_walk(ptr nocapture noundef readonly %node) local_unnamed_addr #3 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%node.tr = phi ptr [ %node, %entry ], [ %2, %if.end ]
%0 = load i32, ptr %node.tr, align 8, !tbaa !11
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%left = getelementptr inbounds %struct.node_t, ptr %node.tr, i64 0, i32 2
%1 = load ptr, ptr %left, align 8, !tbaa !15
%cmp.not = icmp eq ptr %1, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @preorder_walk(ptr noundef nonnull %1)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%right = getelementptr inbounds %struct.node_t, ptr %node.tr, i64 0, i32 3
%2 = load ptr, ptr %right, align 8, !tbaa !16
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #3 {
entry:
%c = alloca [20 x i8], align 16
%n = alloca i32, align 4
%key = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %c) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %key) #7
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !19
%cmp71 = icmp sgt i32 %0, 0
br i1 %cmp71, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%top.073 = phi ptr [ %top.1, %for.inc ], [ null, %entry ]
%i.072 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %c, ptr noundef nonnull %key)
%1 = load i8, ptr %c, align 16, !tbaa !20
switch i8 %1, label %if.else27 [
i8 105, label %if.then
i8 102, label %if.then11
i8 100, label %if.then21
]
if.then: ; preds = %for.body
%call4 = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
%2 = load i32, ptr %key, align 4, !tbaa !19
store i32 %2, ptr %call4, align 8, !tbaa !11
%pare = getelementptr inbounds %struct.node_t, ptr %call4, i64 0, i32 1
%cmp.not29.i = icmp eq ptr %top.073, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %pare, i8 0, i64 24, i1 false)
br i1 %cmp.not29.i, label %for.inc, label %while.body.i
while.body.i: ; preds = %if.then, %while.body.i
%x.030.i = phi ptr [ %x.1.i, %while.body.i ], [ %top.073, %if.then ]
%3 = load i32, ptr %x.030.i, align 8, !tbaa !11
%cmp2.i = icmp slt i32 %2, %3
%left.i = getelementptr inbounds %struct.node_t, ptr %x.030.i, i64 0, i32 2
%right.i = getelementptr inbounds %struct.node_t, ptr %x.030.i, i64 0, i32 3
%x.1.in.i = select i1 %cmp2.i, ptr %left.i, ptr %right.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !12
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %if.else5.i, label %while.body.i, !llvm.loop !13
if.else5.i: ; preds = %while.body.i
store ptr %x.030.i, ptr %pare, align 8, !tbaa !5
br i1 %cmp2.i, label %if.then9.i, label %if.else11.i
if.then9.i: ; preds = %if.else5.i
store ptr %call4, ptr %left.i, align 8, !tbaa !15
br label %for.inc
if.else11.i: ; preds = %if.else5.i
store ptr %call4, ptr %right.i, align 8, !tbaa !16
br label %for.inc
if.then11: ; preds = %for.body
%4 = load i32, ptr %key, align 4, !tbaa !19
%cmp18.i = icmp eq ptr %top.073, null
br i1 %cmp18.i, label %tree_find.exit, label %if.end.i
if.end.i: ; preds = %if.then11, %if.end4.i
%node.tr19.i = phi ptr [ %node.tr.be.i, %if.end4.i ], [ %top.073, %if.then11 ]
%5 = load i32, ptr %node.tr19.i, align 8, !tbaa !11
%cmp2.i45 = icmp eq i32 %5, %4
br i1 %cmp2.i45, label %tree_find.exit, label %if.end4.i
if.end4.i: ; preds = %if.end.i
%cmp6.i = icmp sgt i32 %5, %4
%left.i46 = getelementptr inbounds %struct.node_t, ptr %node.tr19.i, i64 0, i32 2
%right.i47 = getelementptr inbounds %struct.node_t, ptr %node.tr19.i, i64 0, i32 3
%node.tr.be.in.i = select i1 %cmp6.i, ptr %left.i46, ptr %right.i47
%node.tr.be.i = load ptr, ptr %node.tr.be.in.i, align 8, !tbaa !12
%cmp.i = icmp eq ptr %node.tr.be.i, null
br i1 %cmp.i, label %tree_find.exit, label %if.end.i
tree_find.exit: ; preds = %if.end.i, %if.end4.i, %if.then11
%retval.0.i = phi ptr [ @.str.4, %if.then11 ], [ @.str.4, %if.end4.i ], [ @.str.3, %if.end.i ]
%call15 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %retval.0.i)
br label %for.inc
if.then21: ; preds = %for.body
%6 = load i32, ptr %key, align 4, !tbaa !19
%cmp18.i48 = icmp eq ptr %top.073, null
br i1 %cmp18.i48, label %for.inc, label %if.end.i49
if.end.i49: ; preds = %if.then21, %if.end4.i52
%node.tr19.i50 = phi ptr [ %node.tr.be.i57, %if.end4.i52 ], [ %top.073, %if.then21 ]
%7 = load i32, ptr %node.tr19.i50, align 8, !tbaa !11
%cmp2.i51 = icmp eq i32 %7, %6
br i1 %cmp2.i51, label %if.then25, label %if.end4.i52
if.end4.i52: ; preds = %if.end.i49
%cmp6.i53 = icmp sgt i32 %7, %6
%left.i54 = getelementptr inbounds %struct.node_t, ptr %node.tr19.i50, i64 0, i32 2
%right.i55 = getelementptr inbounds %struct.node_t, ptr %node.tr19.i50, i64 0, i32 3
%node.tr.be.in.i56 = select i1 %cmp6.i53, ptr %left.i54, ptr %right.i55
%node.tr.be.i57 = load ptr, ptr %node.tr.be.in.i56, align 8, !tbaa !12
%cmp.i58 = icmp eq ptr %node.tr.be.i57, null
br i1 %cmp.i58, label %for.inc, label %if.end.i49
if.then25: ; preds = %if.end.i49
%left.i61 = getelementptr inbounds %struct.node_t, ptr %node.tr19.i50, i64 0, i32 2
%8 = load ptr, ptr %left.i61, align 8, !tbaa !15
%cmp.i62 = icmp eq ptr %8, null
br i1 %cmp.i62, label %if.end.i64, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %if.then25
%right.i63 = getelementptr inbounds %struct.node_t, ptr %node.tr19.i50, i64 0, i32 3
%9 = load ptr, ptr %right.i63, align 8, !tbaa !16
%cmp1.i = icmp eq ptr %9, null
br i1 %cmp1.i, label %if.end.i64, label %while.cond.i.i.i
while.cond.i.i.i: ; preds = %lor.lhs.false.i, %while.cond.i.i.i
%x.addr.0.i.i.i = phi ptr [ %10, %while.cond.i.i.i ], [ %9, %lor.lhs.false.i ]
%left.i.i.i = getelementptr inbounds %struct.node_t, ptr %x.addr.0.i.i.i, i64 0, i32 2
%10 = load ptr, ptr %left.i.i.i, align 8, !tbaa !15
%cmp.not.i.i.i = icmp eq ptr %10, null
br i1 %cmp.not.i.i.i, label %if.end.i64, label %while.cond.i.i.i, !llvm.loop !17
if.end.i64: ; preds = %while.cond.i.i.i, %lor.lhs.false.i, %if.then25
%y.0.i = phi ptr [ %node.tr19.i50, %lor.lhs.false.i ], [ %node.tr19.i50, %if.then25 ], [ %x.addr.0.i.i.i, %while.cond.i.i.i ]
%left5.i = getelementptr inbounds %struct.node_t, ptr %y.0.i, i64 0, i32 2
%right7.i = getelementptr inbounds %struct.node_t, ptr %y.0.i, i64 0, i32 3
%x.0.in.i = select i1 %cmp.i62, ptr %right7.i, ptr %left5.i
%x.0.i = load ptr, ptr %x.0.in.i, align 8, !tbaa !12
%cmp9.not.i = icmp eq ptr %x.0.i, null
br i1 %cmp9.not.i, label %if.end12.i, label %if.then10.i
if.then10.i: ; preds = %if.end.i64
%pare.i65 = getelementptr inbounds %struct.node_t, ptr %y.0.i, i64 0, i32 1
%11 = load ptr, ptr %pare.i65, align 8, !tbaa !5
%pare11.i = getelementptr inbounds %struct.node_t, ptr %x.0.i, i64 0, i32 1
store ptr %11, ptr %pare11.i, align 8, !tbaa !5
br label %if.end12.i
if.end12.i: ; preds = %if.then10.i, %if.end.i64
%pare13.i = getelementptr inbounds %struct.node_t, ptr %y.0.i, i64 0, i32 1
%12 = load ptr, ptr %pare13.i, align 8, !tbaa !5
%cmp14.i = icmp eq ptr %12, null
br i1 %cmp14.i, label %if.end27.i, label %if.else16.i
if.else16.i: ; preds = %if.end12.i
%left18.i = getelementptr inbounds %struct.node_t, ptr %12, i64 0, i32 2
%13 = load ptr, ptr %left18.i, align 8, !tbaa !15
%cmp19.i = icmp eq ptr %y.0.i, %13
%right25.i = getelementptr inbounds %struct.node_t, ptr %12, i64 0, i32 3
%left18.sink.i = select i1 %cmp19.i, ptr %left18.i, ptr %right25.i
store ptr %x.0.i, ptr %left18.sink.i, align 8, !tbaa !12
br label %if.end27.i
if.end27.i: ; preds = %if.else16.i, %if.end12.i
%top.addr.0.i66 = phi ptr [ %x.0.i, %if.end12.i ], [ %top.073, %if.else16.i ]
%cmp28.not.i = icmp eq ptr %y.0.i, %node.tr19.i50
br i1 %cmp28.not.i, label %for.inc, label %if.then29.i
if.then29.i: ; preds = %if.end27.i
%14 = load i32, ptr %y.0.i, align 8, !tbaa !11
store i32 %14, ptr %node.tr19.i50, align 8, !tbaa !11
br label %for.inc
if.else27: ; preds = %for.body
call void @inorder_walk(ptr noundef %top.073)
%15 = load ptr, ptr @stdout, align 8, !tbaa !12
%call.i = call i32 @putc(i32 noundef 10, ptr noundef %15)
call void @preorder_walk(ptr noundef %top.073)
%16 = load ptr, ptr @stdout, align 8, !tbaa !12
%call.i67 = call i32 @putc(i32 noundef 10, ptr noundef %16)
br label %for.inc
for.inc: ; preds = %if.end4.i52, %if.then, %if.then21, %if.then29.i, %if.end27.i, %if.else11.i, %if.then9.i, %if.else27, %tree_find.exit
%top.1 = phi ptr [ %top.073, %tree_find.exit ], [ %top.073, %if.else27 ], [ %top.073, %if.then9.i ], [ %top.073, %if.else11.i ], [ %top.addr.0.i66, %if.end27.i ], [ %top.addr.0.i66, %if.then29.i ], [ null, %if.then21 ], [ %call4, %if.then ], [ %top.073, %if.end4.i52 ]
%inc = add nuw nsw i32 %i.072, 1
%17 = load i32, ptr %n, align 4, !tbaa !19
%cmp = icmp slt i32 %inc, %17
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !21
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %key) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #7
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %c) #7
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #4
; Function Attrs: nofree nounwind
declare noundef i32 @putc(i32 noundef, ptr nocapture noundef) local_unnamed_addr #4
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6
attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 = { nofree 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 = { 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 #5 = { 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind }
attributes #8 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !10, i64 8}
!6 = !{!"node_t", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!10, !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!6, !10, i64 16}
!16 = !{!6, !10, i64 24}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = !{!7, !7, i64 0}
!20 = !{!8, !8, i64 0}
!21 = distinct !{!21, !14}
|
#include<stdio.h>
#include<stdlib.h>
struct node{
int key;
struct node *p;
struct node *l;
struct node *r;
};
typedef struct node *NodePointer;
NodePointer r,NIL;
NodePointer getMinimum(NodePointer x){
while(x->l != NIL){
x = x->l;
}
return x;
}
NodePointer find(NodePointer x,int k){
while(x != NIL && k != x->key){
if(k < x->key){
x = x->l;
}else{
x = x->r;
}
}
return x;
}
NodePointer getSuccessor(NodePointer x){
NodePointer k;
if(x->r != NIL){
return getMinimum(x->r);
}
k = x->p;
while(k != NIL && x ==k->r){
x = k;
k = k->p;
}
return k;
}
void delete(NodePointer z){
NodePointer x;
NodePointer y;
if(z->l == NIL || z->r == NIL){
y = z;
}else{
y = getSuccessor(z);
}
if(y->l != NIL){
x = y->l;
}else{
x = y->r;
}
if(x != NIL){
x->p = y->p;
}
if(y->p == NIL){
r = x;
}else{
if(y == y->p->l){
y->p->l = x;
}else{
y->p->r = x;
}
}
if(y != z){
z->key = y->key;
}
}
void insert(int k){
NodePointer y = NIL;
NodePointer x = r;
NodePointer z = (NodePointer)malloc(sizeof(struct node));
z->key = k;
z->l = NIL;
z->r = NIL;
while(x != NIL){
y = x;
if(z->key < x->key){
x = x->l;
}else{
x = x->r;
}
}
z->p = y;
if(y == NIL){
r = z;
}else if(z->key < y->key){
y->l = z;
}else{
y->r = z;
}
}
void inorder(NodePointer u){
if(u == NIL){
return;
}
inorder(u->l);
printf(" %d",u->key);
inorder(u->r);
}
void preorder(NodePointer u){
if(u == NIL){
return;
}
printf(" %d",u->key);
preorder(u->l);
preorder(u->r);
}
void print(){
inorder(r);
puts("");
preorder(r);
puts("");
}
int main(){
int n,i,j,z,k;
char s[10];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",s);
if(s[0] == 'f'){
scanf("%d",&k);
NodePointer t = find(r,k);
if(t == NIL)printf("no\n");
else printf("yes\n");
}else if(s[0] == 'i'){
scanf("%d",&z);
insert(z);
}else if(s[0] == 'd'){
scanf("%d",&z);
delete(find(r,z));
}else{
print();
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207147/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207147/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { i32, ptr, ptr, ptr }
@NIL = dso_local local_unnamed_addr global ptr null, align 8
@r = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.3 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [4 x i8] c"yes\00", align 1
@str.6 = private unnamed_addr constant [3 x i8] c"no\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @getMinimum(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%x.addr.0 = phi ptr [ %x, %entry ], [ %1, %while.cond ]
%l = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 2
%1 = load ptr, ptr %l, align 8, !tbaa !9
%cmp.not = icmp eq ptr %1, %0
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !12
while.end: ; preds = %while.cond
ret ptr %x.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @find(ptr noundef readonly %x, i32 noundef %k) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10 = icmp eq ptr %0, %x
br i1 %cmp.not10, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%x.addr.011 = phi ptr [ %x.addr.1, %while.body ], [ %x, %entry ]
%1 = load i32, ptr %x.addr.011, align 8, !tbaa !14
%cmp1.not = icmp eq i32 %1, %k
br i1 %cmp1.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp3 = icmp sgt i32 %1, %k
%l = getelementptr inbounds %struct.node, ptr %x.addr.011, i64 0, i32 2
%r = getelementptr inbounds %struct.node, ptr %x.addr.011, i64 0, i32 3
%x.addr.1.in = select i1 %cmp3, ptr %l, ptr %r
%x.addr.1 = load ptr, ptr %x.addr.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %x.addr.1, %0
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !15
while.end: ; preds = %land.rhs, %while.body, %entry
%x.addr.0.lcssa = phi ptr [ %x, %entry ], [ %0, %while.body ], [ %x.addr.011, %land.rhs ]
ret ptr %x.addr.0.lcssa
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @getSuccessor(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
%r = getelementptr inbounds %struct.node, ptr %x, i64 0, i32 3
%0 = load ptr, ptr %r, align 8, !tbaa !16
%1 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not = icmp eq ptr %0, %1
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%x.addr.0.i = phi ptr [ %2, %while.cond.i ], [ %0, %entry ]
%l.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i, i64 0, i32 2
%2 = load ptr, ptr %l.i, align 8, !tbaa !9
%cmp.not.i = icmp eq ptr %2, %1
br i1 %cmp.not.i, label %cleanup, label %while.cond.i, !llvm.loop !12
while.cond: ; preds = %entry, %land.rhs
%x.addr.0 = phi ptr [ %k.0, %land.rhs ], [ %x, %entry ]
%k.0.in = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 1
%k.0 = load ptr, ptr %k.0.in, align 8, !tbaa !17
%cmp2.not = icmp eq ptr %k.0, %0
br i1 %cmp2.not, label %cleanup, label %land.rhs
land.rhs: ; preds = %while.cond
%r3 = getelementptr inbounds %struct.node, ptr %k.0, i64 0, i32 3
%3 = load ptr, ptr %r3, align 8, !tbaa !16
%cmp4 = icmp eq ptr %x.addr.0, %3
br i1 %cmp4, label %while.cond, label %cleanup, !llvm.loop !18
cleanup: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi ptr [ %k.0, %land.rhs ], [ %0, %while.cond ], [ %x.addr.0.i, %while.cond.i ]
ret ptr %retval.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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @delete(ptr noundef %z) local_unnamed_addr #2 {
entry:
%l = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 2
%0 = load ptr, ptr %l, align 8, !tbaa !9
%1 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %0, %1
br i1 %cmp, label %if.end, label %lor.lhs.false
lor.lhs.false: ; preds = %entry
%r = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 3
%2 = load ptr, ptr %r, align 8, !tbaa !16
%cmp1 = icmp eq ptr %2, %1
br i1 %cmp1, label %if.end, label %while.cond.i.i
while.cond.i.i: ; preds = %lor.lhs.false, %while.cond.i.i
%x.addr.0.i.i = phi ptr [ %3, %while.cond.i.i ], [ %2, %lor.lhs.false ]
%l.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i, i64 0, i32 2
%3 = load ptr, ptr %l.i.i, align 8, !tbaa !9
%cmp.not.i.i = icmp eq ptr %3, %1
br i1 %cmp.not.i.i, label %if.else6, label %while.cond.i.i, !llvm.loop !12
if.end: ; preds = %entry, %lor.lhs.false
%cmp3.not = icmp eq ptr %0, %1
br i1 %cmp3.not, label %if.else6, label %if.end8
if.else6: ; preds = %while.cond.i.i, %if.end
%y.056 = phi ptr [ %z, %if.end ], [ %x.addr.0.i.i, %while.cond.i.i ]
%r7 = getelementptr inbounds %struct.node, ptr %y.056, i64 0, i32 3
%4 = load ptr, ptr %r7, align 8, !tbaa !16
br label %if.end8
if.end8: ; preds = %if.end, %if.else6
%y.055 = phi ptr [ %y.056, %if.else6 ], [ %z, %if.end ]
%x.0 = phi ptr [ %4, %if.else6 ], [ %0, %if.end ]
%cmp9.not = icmp eq ptr %x.0, %1
br i1 %cmp9.not, label %if.end12, label %if.then10
if.then10: ; preds = %if.end8
%p = getelementptr inbounds %struct.node, ptr %y.055, i64 0, i32 1
%5 = load ptr, ptr %p, align 8, !tbaa !17
%p11 = getelementptr inbounds %struct.node, ptr %x.0, i64 0, i32 1
store ptr %5, ptr %p11, align 8, !tbaa !17
br label %if.end12
if.end12: ; preds = %if.then10, %if.end8
%p13 = getelementptr inbounds %struct.node, ptr %y.055, i64 0, i32 1
%6 = load ptr, ptr %p13, align 8, !tbaa !17
%cmp14 = icmp eq ptr %6, %1
br i1 %cmp14, label %if.end27, label %if.else16
if.else16: ; preds = %if.end12
%l18 = getelementptr inbounds %struct.node, ptr %6, i64 0, i32 2
%7 = load ptr, ptr %l18, align 8, !tbaa !9
%cmp19 = icmp eq ptr %y.055, %7
%r25 = getelementptr inbounds %struct.node, ptr %6, i64 0, i32 3
%spec.select = select i1 %cmp19, ptr %l18, ptr %r25
br label %if.end27
if.end27: ; preds = %if.else16, %if.end12
%l18.sink = phi ptr [ @r, %if.end12 ], [ %spec.select, %if.else16 ]
store ptr %x.0, ptr %l18.sink, align 8, !tbaa !5
%cmp28.not = icmp eq ptr %y.055, %z
br i1 %cmp28.not, label %if.end31, label %if.then29
if.then29: ; preds = %if.end27
%8 = load i32, ptr %y.055, align 8, !tbaa !14
store i32 %8, ptr %z, align 8, !tbaa !14
br label %if.end31
if.end31: ; preds = %if.then29, %if.end27
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%1 = load ptr, ptr @r, align 8, !tbaa !5
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
store i32 %k, ptr %call, align 8, !tbaa !14
%l = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr %0, ptr %l, align 8, !tbaa !9
%r = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store ptr %0, ptr %r, align 8, !tbaa !16
%cmp.not34 = icmp eq ptr %1, %0
br i1 %cmp.not34, label %while.end.thread, label %while.body
while.end.thread: ; preds = %entry
%p37 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 1
store ptr %0, ptr %p37, align 8, !tbaa !17
br label %if.end17
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %1, %entry ]
%2 = load i32, ptr %x.035, align 8, !tbaa !14
%cmp3 = icmp sgt i32 %2, %k
%l4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 2
%r5 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%x.1.in = select i1 %cmp3, ptr %l4, ptr %r5
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %x.1, %0
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !19
while.end: ; preds = %while.body
%p = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 1
store ptr %x.035, ptr %p, align 8, !tbaa !17
%cmp6 = icmp eq ptr %x.035, %0
br i1 %cmp6, label %if.end17, label %if.else8
if.else8: ; preds = %while.end
%3 = load i32, ptr %x.035, align 8, !tbaa !14
%cmp11 = icmp sgt i32 %3, %k
br i1 %cmp11, label %if.then12, label %if.else14
if.then12: ; preds = %if.else8
%l13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 2
br label %if.end17
if.else14: ; preds = %if.else8
%r15 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
br label %if.end17
if.end17: ; preds = %while.end, %while.end.thread, %if.then12, %if.else14
%l13.sink = phi ptr [ %l13, %if.then12 ], [ %r15, %if.else14 ], [ @r, %while.end.thread ], [ @r, %while.end ]
store ptr %call, ptr %l13.sink, align 8, !tbaa !5
ret void
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%l = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 2
%1 = load ptr, ptr %l, align 8, !tbaa !9
tail call void @inorder(ptr noundef %1)
%2 = load i32, ptr %u.tr5, align 8, !tbaa !14
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %2)
%r = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%3 = load ptr, ptr %r, align 8, !tbaa !16
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%1 = load i32, ptr %u.tr5, align 8, !tbaa !14
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%l = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 2
%2 = load ptr, ptr %l, align 8, !tbaa !9
tail call void @preorder(ptr noundef %2)
%r = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%3 = load ptr, ptr %r, align 8, !tbaa !16
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @print() local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr @r, align 8, !tbaa !5
tail call void @inorder(ptr noundef %0)
%putchar = tail call i32 @putchar(i32 10)
%1 = load ptr, ptr @r, align 8, !tbaa !5
tail call void @preorder(ptr noundef %1)
%putchar2 = tail call i32 @putchar(i32 10)
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #5
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #3 {
entry:
%n = alloca i32, align 4
%z = alloca i32, align 4
%k = alloca i32, align 4
%s = alloca [10 x i8], align 1
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #8
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %z) #8
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #8
call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %s) #8
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !20
%cmp58 = icmp sgt i32 %0, 0
br i1 %cmp58, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.059 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %s)
%1 = load i8, ptr %s, align 1, !tbaa !21
switch i8 %1, label %if.else26 [
i8 102, label %if.then
i8 105, label %if.then16
i8 100, label %if.then23
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %k)
%2 = load ptr, ptr @r, align 8, !tbaa !5
%3 = load i32, ptr %k, align 4, !tbaa !20
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10.i = icmp eq ptr %4, %2
br i1 %cmp.not10.i, label %find.exit, label %land.rhs.i
land.rhs.i: ; preds = %if.then, %while.body.i
%x.addr.011.i = phi ptr [ %x.addr.1.i, %while.body.i ], [ %2, %if.then ]
%5 = load i32, ptr %x.addr.011.i, align 8, !tbaa !14
%cmp1.not.i = icmp eq i32 %5, %3
br i1 %cmp1.not.i, label %find.exit, label %while.body.i
while.body.i: ; preds = %land.rhs.i
%cmp3.i = icmp sgt i32 %5, %3
%l.i = getelementptr inbounds %struct.node, ptr %x.addr.011.i, i64 0, i32 2
%r.i = getelementptr inbounds %struct.node, ptr %x.addr.011.i, i64 0, i32 3
%x.addr.1.in.i = select i1 %cmp3.i, ptr %l.i, ptr %r.i
%x.addr.1.i = load ptr, ptr %x.addr.1.in.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %x.addr.1.i, %4
br i1 %cmp.not.i, label %if.then8, label %land.rhs.i, !llvm.loop !15
find.exit: ; preds = %land.rhs.i, %if.then
%x.addr.0.lcssa.i = phi ptr [ %2, %if.then ], [ %x.addr.011.i, %land.rhs.i ]
%cmp6 = icmp eq ptr %x.addr.0.lcssa.i, %4
br i1 %cmp6, label %if.then8, label %if.else
if.then8: ; preds = %while.body.i, %find.exit
%puts31 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %find.exit
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %z)
%6 = load i32, ptr %z, align 4, !tbaa !20
%7 = load ptr, ptr @NIL, align 8, !tbaa !5
%8 = load ptr, ptr @r, align 8, !tbaa !5
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
store i32 %6, ptr %call.i, align 8, !tbaa !14
%l.i32 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
store ptr %7, ptr %l.i32, align 8, !tbaa !9
%r.i33 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store ptr %7, ptr %r.i33, align 8, !tbaa !16
%cmp.not34.i = icmp eq ptr %8, %7
br i1 %cmp.not34.i, label %while.end.thread.i, label %while.body.i34
while.end.thread.i: ; preds = %if.then16
%p37.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 1
store ptr %7, ptr %p37.i, align 8, !tbaa !17
br label %insert.exit
while.body.i34: ; preds = %if.then16, %while.body.i34
%x.035.i = phi ptr [ %x.1.i, %while.body.i34 ], [ %8, %if.then16 ]
%9 = load i32, ptr %x.035.i, align 8, !tbaa !14
%cmp3.i35 = icmp sgt i32 %9, %6
%l4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 2
%r5.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 3
%x.1.in.i = select i1 %cmp3.i35, ptr %l4.i, ptr %r5.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !5
%cmp.not.i36 = icmp eq ptr %x.1.i, %7
br i1 %cmp.not.i36, label %while.end.i, label %while.body.i34, !llvm.loop !19
while.end.i: ; preds = %while.body.i34
%p.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 1
store ptr %x.035.i, ptr %p.i, align 8, !tbaa !17
%cmp6.i = icmp eq ptr %x.035.i, %7
%spec.select56 = select i1 %cmp6.i, ptr @r, ptr %x.1.in.i
br label %insert.exit
insert.exit: ; preds = %while.end.i, %while.end.thread.i
%l13.sink.i = phi ptr [ @r, %while.end.thread.i ], [ %spec.select56, %while.end.i ]
store ptr %call.i, ptr %l13.sink.i, align 8, !tbaa !5
br label %for.inc
if.then23: ; preds = %for.body
%call24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %z)
%10 = load ptr, ptr @r, align 8, !tbaa !5
%11 = load i32, ptr %z, align 4, !tbaa !20
%12 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10.i37 = icmp eq ptr %12, %10
br i1 %cmp.not10.i37, label %find.exit50, label %land.rhs.i38
land.rhs.i38: ; preds = %if.then23, %while.body.i41
%x.addr.011.i39 = phi ptr [ %x.addr.1.i46, %while.body.i41 ], [ %10, %if.then23 ]
%13 = load i32, ptr %x.addr.011.i39, align 8, !tbaa !14
%cmp1.not.i40 = icmp eq i32 %13, %11
br i1 %cmp1.not.i40, label %find.exit50, label %while.body.i41
while.body.i41: ; preds = %land.rhs.i38
%cmp3.i42 = icmp sgt i32 %13, %11
%l.i43 = getelementptr inbounds %struct.node, ptr %x.addr.011.i39, i64 0, i32 2
%r.i44 = getelementptr inbounds %struct.node, ptr %x.addr.011.i39, i64 0, i32 3
%x.addr.1.in.i45 = select i1 %cmp3.i42, ptr %l.i43, ptr %r.i44
%x.addr.1.i46 = load ptr, ptr %x.addr.1.in.i45, align 8, !tbaa !5
%cmp.not.i47 = icmp eq ptr %x.addr.1.i46, %12
br i1 %cmp.not.i47, label %find.exit50, label %land.rhs.i38, !llvm.loop !15
find.exit50: ; preds = %land.rhs.i38, %while.body.i41, %if.then23
%x.addr.0.lcssa.i49 = phi ptr [ %10, %if.then23 ], [ %x.addr.011.i39, %land.rhs.i38 ], [ %12, %while.body.i41 ]
%l.i51 = getelementptr inbounds %struct.node, ptr %x.addr.0.lcssa.i49, i64 0, i32 2
%14 = load ptr, ptr %l.i51, align 8, !tbaa !9
%cmp.i = icmp eq ptr %14, %12
br i1 %cmp.i, label %if.else6.i, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %find.exit50
%r.i52 = getelementptr inbounds %struct.node, ptr %x.addr.0.lcssa.i49, i64 0, i32 3
%15 = load ptr, ptr %r.i52, align 8, !tbaa !16
%cmp1.i = icmp eq ptr %15, %12
br i1 %cmp1.i, label %if.end8.i, label %while.cond.i.i.i
while.cond.i.i.i: ; preds = %lor.lhs.false.i, %while.cond.i.i.i
%x.addr.0.i.i.i = phi ptr [ %16, %while.cond.i.i.i ], [ %15, %lor.lhs.false.i ]
%l.i.i.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i.i.i, i64 0, i32 2
%16 = load ptr, ptr %l.i.i.i, align 8, !tbaa !9
%cmp.not.i.i.i = icmp eq ptr %16, %12
br i1 %cmp.not.i.i.i, label %if.else6.i, label %while.cond.i.i.i, !llvm.loop !12
if.else6.i: ; preds = %while.cond.i.i.i, %find.exit50
%y.056.i = phi ptr [ %x.addr.0.lcssa.i49, %find.exit50 ], [ %x.addr.0.i.i.i, %while.cond.i.i.i ]
%r7.i = getelementptr inbounds %struct.node, ptr %y.056.i, i64 0, i32 3
%17 = load ptr, ptr %r7.i, align 8, !tbaa !16
br label %if.end8.i
if.end8.i: ; preds = %lor.lhs.false.i, %if.else6.i
%y.055.i = phi ptr [ %y.056.i, %if.else6.i ], [ %x.addr.0.lcssa.i49, %lor.lhs.false.i ]
%x.0.i = phi ptr [ %17, %if.else6.i ], [ %14, %lor.lhs.false.i ]
%cmp9.not.i = icmp eq ptr %x.0.i, %12
br i1 %cmp9.not.i, label %if.end12.i, label %if.then10.i
if.then10.i: ; preds = %if.end8.i
%p.i53 = getelementptr inbounds %struct.node, ptr %y.055.i, i64 0, i32 1
%18 = load ptr, ptr %p.i53, align 8, !tbaa !17
%p11.i = getelementptr inbounds %struct.node, ptr %x.0.i, i64 0, i32 1
store ptr %18, ptr %p11.i, align 8, !tbaa !17
br label %if.end12.i
if.end12.i: ; preds = %if.then10.i, %if.end8.i
%p13.i = getelementptr inbounds %struct.node, ptr %y.055.i, i64 0, i32 1
%19 = load ptr, ptr %p13.i, align 8, !tbaa !17
%cmp14.i = icmp eq ptr %19, %12
br i1 %cmp14.i, label %if.end27.i, label %if.else16.i
if.else16.i: ; preds = %if.end12.i
%l18.i = getelementptr inbounds %struct.node, ptr %19, i64 0, i32 2
%20 = load ptr, ptr %l18.i, align 8, !tbaa !9
%cmp19.i = icmp eq ptr %y.055.i, %20
%r25.i = getelementptr inbounds %struct.node, ptr %19, i64 0, i32 3
%spec.select.i = select i1 %cmp19.i, ptr %l18.i, ptr %r25.i
br label %if.end27.i
if.end27.i: ; preds = %if.else16.i, %if.end12.i
%l18.sink.i = phi ptr [ @r, %if.end12.i ], [ %spec.select.i, %if.else16.i ]
store ptr %x.0.i, ptr %l18.sink.i, align 8, !tbaa !5
%cmp28.not.i = icmp eq ptr %y.055.i, %x.addr.0.lcssa.i49
br i1 %cmp28.not.i, label %for.inc, label %if.then29.i
if.then29.i: ; preds = %if.end27.i
%21 = load i32, ptr %y.055.i, align 8, !tbaa !14
store i32 %21, ptr %x.addr.0.lcssa.i49, align 8, !tbaa !14
br label %for.inc
if.else26: ; preds = %for.body
%22 = load ptr, ptr @r, align 8, !tbaa !5
call void @inorder(ptr noundef %22)
%putchar.i = call i32 @putchar(i32 10)
%23 = load ptr, ptr @r, align 8, !tbaa !5
call void @preorder(ptr noundef %23)
%putchar2.i = call i32 @putchar(i32 10)
br label %for.inc
for.inc: ; preds = %if.then29.i, %if.end27.i, %if.then8, %if.else, %if.else26, %insert.exit
%inc = add nuw nsw i32 %i.059, 1
%24 = load i32, ptr %n, align 4, !tbaa !20
%cmp = icmp slt i32 %inc, %24
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !22
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %s) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %z) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #8
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = { nofree 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 = { 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 #5 = { 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 #6 = { nofree nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 16}
!10 = !{!"node", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !11, i64 0}
!15 = distinct !{!15, !13}
!16 = !{!10, !6, i64 24}
!17 = !{!10, !6, i64 8}
!18 = distinct !{!18, !13}
!19 = distinct !{!19, !13}
!20 = !{!11, !11, i64 0}
!21 = !{!7, !7, i64 0}
!22 = distinct !{!22, !13}
|
#include<stdio.h>
#include<stdlib.h>
struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node treeSearch(Node u, int k){
Node n;
if(u->key == k) return u;
else if(u->key > k){
if(u->left != NIL){
n = treeSearch(u->left,k);
if(n!=NIL) return n;
}
}
else if(u->key < k){
if(u->right != NIL){
n = treeSearch(u->right,k);
if(n!=NIL) return n;
}
}
return NIL;
}
void treeDelete(Node z){
Node y; // node to be deleted
Node x; // child of y
if(z->left == NIL && z->right == NIL){
if(z->parent->left == z) z->parent->left = NIL;
else z->parent->right = NIL;
free(z);
}
else if(z->left == NIL && z->right != NIL){
if(z->parent->left == z) z->parent->left = z->right;
else z->parent->right = z->right;
z->right->parent=z->parent;
free(z);
}
else if(z->left != NIL && z->right == NIL){
if(z->parent->left == z) z->parent->left = z->left;
else z->parent->right = z->left;
z->left->parent=z->parent;
free(z);
}
else{
for(y = z->right ; y->left!=NIL ; y = y->left){}
z->key = y->key;
treeDelete(y);
}
}
void insert(int k){
Node y = NIL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
while(x != NIL){
y=x;
if(z->key < x->key) x = x->left;
else x = x->right;
}
z->parent = y;
if(y == NIL) root = z;
else if(z->key < y->key) y->left = z;
else y->right = z;
}
void inorder(Node u){
if(u->left != NIL) inorder(u->left);
printf(" %d",u->key);
if(u->right != NIL) inorder(u->right);
}
void preorder(Node u){
printf(" %d",u->key);
if(u->left != NIL) preorder(u->left);
if(u->right != NIL) preorder(u->right);
}
int main(){
int n, i, x;
char com[20];
scanf("%d", &n);
for ( i = 0; i < n; i++ ){
scanf("%s", com);
if ( com[0] == 'f' ){
scanf("%d", &x);
Node t = treeSearch(root, x);
if ( t != NIL ) printf("yes\n");
else printf("no\n");
} else if ( com[0] == 'i' ){
scanf("%d", &x);
insert(x);
} else if ( com[0] == 'p' ){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
} else if ( com[0] == 'd' ){
scanf("%d", &x);
treeDelete(treeSearch(root, x));
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207190/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207190/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { ptr, ptr, ptr, i32 }
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSearch(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #0 {
entry:
%key = getelementptr inbounds %struct.node, ptr %u, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !5
%cmp = icmp eq i32 %0, %k
br i1 %cmp, label %cleanup, label %if.else
if.else: ; preds = %entry
%cmp2 = icmp sgt i32 %0, %k
br i1 %cmp2, label %if.then3, label %if.else10
if.then3: ; preds = %if.else
%left = getelementptr inbounds %struct.node, ptr %u, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !11
%cmp4.not = icmp eq ptr %1, null
br i1 %cmp4.not, label %if.end24, label %if.then5
if.then5: ; preds = %if.then3
%call = tail call ptr @treeSearch(ptr noundef nonnull %1, i32 noundef %k)
%cmp7.not = icmp eq ptr %call, null
br i1 %cmp7.not, label %if.end24, label %cleanup
if.else10: ; preds = %if.else
%cmp12 = icmp slt i32 %0, %k
br i1 %cmp12, label %if.then13, label %if.end24
if.then13: ; preds = %if.else10
%2 = load ptr, ptr %u, align 8, !tbaa !12
%cmp14.not = icmp eq ptr %2, null
br i1 %cmp14.not, label %if.end24, label %if.then15
if.then15: ; preds = %if.then13
%call17 = tail call ptr @treeSearch(ptr noundef nonnull %2, i32 noundef %k)
%cmp18.not = icmp eq ptr %call17, null
br i1 %cmp18.not, label %if.end24, label %cleanup
if.end24: ; preds = %if.then5, %if.then3, %if.then13, %if.then15, %if.else10
br label %cleanup
cleanup: ; preds = %if.then15, %if.then5, %entry, %if.end24
%retval.0 = phi ptr [ null, %if.end24 ], [ %u, %entry ], [ %call, %if.then5 ], [ %call17, %if.then15 ]
ret ptr %retval.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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nounwind uwtable
define dso_local void @treeDelete(ptr noundef %z) local_unnamed_addr #2 {
entry:
%left.phi.trans.insert = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 1
%.pre111 = load ptr, ptr %left.phi.trans.insert, align 8, !tbaa !11
%cmp119 = icmp eq ptr %.pre111, null
br i1 %cmp119, label %land.lhs.true, label %land.lhs.true34
land.lhs.true: ; preds = %for.end, %entry
%z.tr.lcssa = phi ptr [ %y.0, %for.end ], [ %z, %entry ]
%0 = load ptr, ptr %z.tr.lcssa, align 8, !tbaa !12
%cmp1 = icmp eq ptr %0, null
%parent = getelementptr inbounds %struct.node, ptr %z.tr.lcssa, i64 0, i32 2
%1 = load ptr, ptr %parent, align 8, !tbaa !13
%left2 = getelementptr inbounds %struct.node, ptr %1, i64 0, i32 1
%2 = load ptr, ptr %left2, align 8, !tbaa !11
%cmp3 = icmp eq ptr %2, %z.tr.lcssa
br i1 %cmp1, label %if.then, label %if.then15
if.then: ; preds = %land.lhs.true
%left2. = select i1 %cmp3, ptr %left2, ptr %1
store ptr null, ptr %left2., align 8, !tbaa !14
br label %if.end61
if.then15: ; preds = %land.lhs.true
br i1 %cmp3, label %if.then19, label %if.else23
if.then19: ; preds = %if.then15
store ptr %0, ptr %left2, align 8, !tbaa !11
br label %if.end27
if.else23: ; preds = %if.then15
store ptr %0, ptr %1, align 8, !tbaa !12
%.pre110 = load ptr, ptr %z.tr.lcssa, align 8, !tbaa !12
br label %if.end27
if.end27: ; preds = %if.else23, %if.then19
%3 = phi ptr [ %.pre110, %if.else23 ], [ %0, %if.then19 ]
%parent30 = getelementptr inbounds %struct.node, ptr %3, i64 0, i32 2
store ptr %1, ptr %parent30, align 8, !tbaa !13
br label %if.end61
land.lhs.true34: ; preds = %entry
%4 = load ptr, ptr %z, align 8, !tbaa !12
%cmp36 = icmp eq ptr %4, null
br i1 %cmp36, label %if.then37, label %for.cond
if.then37: ; preds = %land.lhs.true34
%parent38 = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 2
%5 = load ptr, ptr %parent38, align 8, !tbaa !13
%left39 = getelementptr inbounds %struct.node, ptr %5, i64 0, i32 1
%6 = load ptr, ptr %left39, align 8, !tbaa !11
%cmp40 = icmp eq ptr %6, %z
br i1 %cmp40, label %if.then41, label %if.else45
if.then41: ; preds = %if.then37
%left.le = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 1
store ptr %.pre111, ptr %left39, align 8, !tbaa !11
%.pre = load ptr, ptr %left.le, align 8, !tbaa !11
br label %if.end49
if.else45: ; preds = %if.then37
store ptr %.pre111, ptr %5, align 8, !tbaa !12
br label %if.end49
if.end49: ; preds = %if.else45, %if.then41
%7 = phi ptr [ %.pre111, %if.else45 ], [ %.pre, %if.then41 ]
%parent52 = getelementptr inbounds %struct.node, ptr %7, i64 0, i32 2
store ptr %5, ptr %parent52, align 8, !tbaa !13
br label %if.end61
for.cond: ; preds = %land.lhs.true34, %for.cond
%y.0 = phi ptr [ %8, %for.cond ], [ %4, %land.lhs.true34 ]
%left55 = getelementptr inbounds %struct.node, ptr %y.0, i64 0, i32 1
%8 = load ptr, ptr %left55, align 8, !tbaa !11
%cmp56.not = icmp eq ptr %8, null
br i1 %cmp56.not, label %for.end, label %for.cond, !llvm.loop !15
for.end: ; preds = %for.cond
%key = getelementptr inbounds %struct.node, ptr %y.0, i64 0, i32 3
%9 = load i32, ptr %key, align 8, !tbaa !5
%key58 = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 3
store i32 %9, ptr %key58, align 8, !tbaa !5
br label %land.lhs.true
if.end61: ; preds = %if.end27, %if.end49, %if.then
%z.tr117 = phi ptr [ %z.tr.lcssa, %if.end27 ], [ %z, %if.end49 ], [ %z.tr.lcssa, %if.then ]
tail call void @free(ptr noundef nonnull %z.tr117) #9
ret void
}
; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #4 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !14
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #10
%key = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store i32 %k, ptr %key, align 8, !tbaa !5
%cmp.not34 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call, i8 0, i64 16, i1 false)
br i1 %cmp.not34, label %if.then7, label %while.body
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%key2 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%1 = load i32, ptr %key2, align 8, !tbaa !5
%cmp3 = icmp sgt i32 %1, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %x.035
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !14
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else8, label %while.body, !llvm.loop !17
if.then7: ; preds = %entry
%parent37 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr null, ptr %parent37, align 8, !tbaa !13
br label %if.end17
if.else8: ; preds = %while.body
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr %x.035, ptr %parent, align 8, !tbaa !13
%key10 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%2 = load i32, ptr %key10, align 8, !tbaa !5
%cmp11 = icmp sgt i32 %2, %k
%left13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%spec.select = select i1 %cmp11, ptr %left13, ptr %x.035
br label %if.end17
if.end17: ; preds = %if.else8, %if.then7
%left13.sink = phi ptr [ @root, %if.then7 ], [ %spec.select, %if.else8 ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !14
ret void
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr nocapture noundef readonly %u) local_unnamed_addr #4 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%u.tr = phi ptr [ %u, %entry ], [ %2, %if.end ]
%left = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !11
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @inorder(ptr noundef nonnull %0)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%key = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 3
%1 = load i32, ptr %key, align 8, !tbaa !5
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%2 = load ptr, ptr %u.tr, align 8, !tbaa !12
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #6
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr nocapture noundef readonly %u) local_unnamed_addr #4 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%u.tr = phi ptr [ %u, %entry ], [ %2, %if.end ]
%key = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !5
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !11
%cmp.not = icmp eq ptr %1, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @preorder(ptr noundef nonnull %1)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%2 = load ptr, ptr %u.tr, align 8, !tbaa !12
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #2 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #9
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #9
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !18
%cmp54 = icmp sgt i32 %0, 0
br i1 %cmp54, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.055 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !19
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
i8 100, label %if.then31
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !14
%3 = load i32, ptr %x, align 4, !tbaa !18
%call5 = call ptr @treeSearch(ptr noundef %2, i32 noundef %3)
%cmp6.not = icmp eq ptr %call5, null
br i1 %cmp6.not, label %if.else, label %if.then8
if.then8: ; preds = %if.then
%puts40 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%4 = load i32, ptr %x, align 4, !tbaa !18
%5 = load ptr, ptr @root, align 8, !tbaa !14
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #10
%key.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store i32 %4, ptr %key.i, align 8, !tbaa !5
%cmp.not34.i = icmp eq ptr %5, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call.i, i8 0, i64 16, i1 false)
br i1 %cmp.not34.i, label %insert.exit, label %while.body.i
while.body.i: ; preds = %if.then16, %while.body.i
%x.035.i = phi ptr [ %x.1.i, %while.body.i ], [ %5, %if.then16 ]
%key2.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 3
%6 = load i32, ptr %key2.i, align 8, !tbaa !5
%cmp3.i = icmp sgt i32 %6, %4
%left4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i, ptr %left4.i, ptr %x.035.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !14
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %insert.exit, label %while.body.i, !llvm.loop !17
insert.exit: ; preds = %while.body.i, %if.then16
%.sink = phi ptr [ null, %if.then16 ], [ %x.035.i, %while.body.i ]
%left13.sink.i = phi ptr [ @root, %if.then16 ], [ %x.1.in.i, %while.body.i ]
%parent37.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
store ptr %.sink, ptr %parent37.i, align 8, !tbaa !13
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !14
br label %for.inc
if.then23: ; preds = %for.body
%7 = load ptr, ptr @root, align 8, !tbaa !14
call void @inorder(ptr noundef %7)
%putchar = call i32 @putchar(i32 10)
%8 = load ptr, ptr @root, align 8, !tbaa !14
call void @preorder(ptr noundef %8)
%putchar39 = call i32 @putchar(i32 10)
br label %for.inc
if.then31: ; preds = %for.body
%call32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%9 = load ptr, ptr @root, align 8, !tbaa !14
%10 = load i32, ptr %x, align 4, !tbaa !18
%call33 = call ptr @treeSearch(ptr noundef %9, i32 noundef %10)
%left.phi.trans.insert.i = getelementptr inbounds %struct.node, ptr %call33, i64 0, i32 1
%.pre111.i = load ptr, ptr %left.phi.trans.insert.i, align 8, !tbaa !11
%cmp.i47 = icmp eq ptr %.pre111.i, null
br i1 %cmp.i47, label %land.lhs.true.i, label %land.lhs.true34.i.lr.ph
land.lhs.true34.i.lr.ph: ; preds = %if.then31
%11 = load ptr, ptr %call33, align 8, !tbaa !12
%cmp36.i.us = icmp eq ptr %11, null
br i1 %cmp36.i.us, label %if.then37.i.split.us, label %for.cond.i.us
for.cond.i.us: ; preds = %land.lhs.true34.i.lr.ph, %for.cond.i.us
%y.0.i.us = phi ptr [ %12, %for.cond.i.us ], [ %11, %land.lhs.true34.i.lr.ph ]
%left55.i.us = getelementptr inbounds %struct.node, ptr %y.0.i.us, i64 0, i32 1
%12 = load ptr, ptr %left55.i.us, align 8, !tbaa !11
%cmp56.not.i.us = icmp eq ptr %12, null
br i1 %cmp56.not.i.us, label %for.end.i.us, label %for.cond.i.us, !llvm.loop !15
for.end.i.us: ; preds = %for.cond.i.us
%key.i41.us = getelementptr inbounds %struct.node, ptr %y.0.i.us, i64 0, i32 3
%13 = load i32, ptr %key.i41.us, align 8, !tbaa !5
%key58.i.us = getelementptr inbounds %struct.node, ptr %call33, i64 0, i32 3
store i32 %13, ptr %key58.i.us, align 8, !tbaa !5
br label %land.lhs.true.i
if.then37.i.split.us: ; preds = %land.lhs.true34.i.lr.ph
%parent38.i = getelementptr inbounds %struct.node, ptr %call33, i64 0, i32 2
%14 = load ptr, ptr %parent38.i, align 8, !tbaa !13
%left39.i = getelementptr inbounds %struct.node, ptr %14, i64 0, i32 1
%15 = load ptr, ptr %left39.i, align 8, !tbaa !11
%cmp40.i = icmp eq ptr %15, %call33
br i1 %cmp40.i, label %if.then41.i, label %if.else45.i
land.lhs.true.i: ; preds = %for.end.i.us, %if.then31
%z.tr.i.lcssa = phi ptr [ %y.0.i.us, %for.end.i.us ], [ %call33, %if.then31 ]
%16 = load ptr, ptr %z.tr.i.lcssa, align 8, !tbaa !12
%cmp1.i = icmp eq ptr %16, null
%parent.i42 = getelementptr inbounds %struct.node, ptr %z.tr.i.lcssa, i64 0, i32 2
%17 = load ptr, ptr %parent.i42, align 8, !tbaa !13
%left2.i = getelementptr inbounds %struct.node, ptr %17, i64 0, i32 1
%18 = load ptr, ptr %left2.i, align 8, !tbaa !11
%cmp3.i43 = icmp eq ptr %18, %z.tr.i.lcssa
br i1 %cmp1.i, label %if.then.i, label %if.then15.i
if.then.i: ; preds = %land.lhs.true.i
%left2..i = select i1 %cmp3.i43, ptr %left2.i, ptr %17
store ptr null, ptr %left2..i, align 8, !tbaa !14
br label %treeDelete.exit
if.then15.i: ; preds = %land.lhs.true.i
br i1 %cmp3.i43, label %if.then19.i, label %if.else23.i
if.then19.i: ; preds = %if.then15.i
store ptr %16, ptr %left2.i, align 8, !tbaa !11
br label %if.end27.i
if.else23.i: ; preds = %if.then15.i
store ptr %16, ptr %17, align 8, !tbaa !12
%.pre110.i = load ptr, ptr %z.tr.i.lcssa, align 8, !tbaa !12
br label %if.end27.i
if.end27.i: ; preds = %if.else23.i, %if.then19.i
%19 = phi ptr [ %.pre110.i, %if.else23.i ], [ %16, %if.then19.i ]
%parent30.i = getelementptr inbounds %struct.node, ptr %19, i64 0, i32 2
store ptr %17, ptr %parent30.i, align 8, !tbaa !13
br label %treeDelete.exit
if.then41.i: ; preds = %if.then37.i.split.us
store ptr %.pre111.i, ptr %left39.i, align 8, !tbaa !11
%.pre.i = load ptr, ptr %left.phi.trans.insert.i, align 8, !tbaa !11
br label %if.end49.i
if.else45.i: ; preds = %if.then37.i.split.us
store ptr %.pre111.i, ptr %14, align 8, !tbaa !12
br label %if.end49.i
if.end49.i: ; preds = %if.else45.i, %if.then41.i
%20 = phi ptr [ %.pre111.i, %if.else45.i ], [ %.pre.i, %if.then41.i ]
%parent52.i = getelementptr inbounds %struct.node, ptr %20, i64 0, i32 2
store ptr %14, ptr %parent52.i, align 8, !tbaa !13
br label %treeDelete.exit
treeDelete.exit: ; preds = %if.then.i, %if.end27.i, %if.end49.i
%z.tr.i45 = phi ptr [ %z.tr.i.lcssa, %if.then.i ], [ %z.tr.i.lcssa, %if.end27.i ], [ %call33, %if.end49.i ]
call void @free(ptr noundef nonnull %z.tr.i45) #9
br label %for.inc
for.inc: ; preds = %for.body, %if.then8, %if.else, %if.then23, %treeDelete.exit, %insert.exit
%inc = add nuw nsw i32 %i.055, 1
%21 = load i32, ptr %n, align 4, !tbaa !18
%cmp = icmp slt i32 %inc, %21
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !20
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #9
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #7
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #7
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #8
attributes #0 = { nofree nosync nounwind memory(read, inaccessiblemem: none) 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 = { 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 = { 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 #4 = { nofree 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 #5 = { 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 #6 = { 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 #7 = { nofree nounwind }
attributes #8 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #9 = { nounwind }
attributes #10 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !10, i64 24}
!6 = !{!"node", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !7, i64 16}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = !{!10, !10, i64 0}
!19 = !{!8, !8, i64 0}
!20 = distinct !{!20, !16}
|
#include <stdio.h>
#define nn 500000
typedef struct nnode_tbl{
int k;
int p;
int l;
int r;
} nnode;
const int nil=-1;
nnode t[nn];
int root;
int room;
int ix;
int tmin(int u){
while (t[u].l!=nil)u=t[u].l;
return u;
}
int find(int u, int k){
while (u!=nil && k!=t[u].k){
if (k<t[u].k)u=t[u].l;
else u=t[u].r;
}
return u;
}
int trees(int u){
if (t[u].r!=nil){
return tmin(t[u].r);
}
int y=t[u].p;
while (y!=nil && u==t[y].r){
u=y;
y=t[y].p;
}
return y;
}
void delete(int z){
int y;
int x;
if (t[z].l == nil || t[z].r == nil)y = z;
else y = trees(z);
if (t[y].l!=nil)x=t[y].l;
else{
x=t[y].r;
}
if (x!=nil) t[x].p=t[y].p;
if (t[y].p == nil)root=x;
else{
if (y==t[t[y].p].l){
t[t[y].p].l=x;
}
else{
t[t[y].p].r=x;
}
}
if (y!=z)t[z].k=t[y].k;
t[y].r=room;
room=y;
}
void insert(int k){
int z;
int y = nil;
int x = root;
if (room==nil) z=ix++;
else{
z=room;
room=t[room].r;
}
t[z].k=k;
t[z].l=nil;
t[z].r=nil;
while (x!=nil){
y=x;
if (t[z].k<t[x].k)x=t[x].l;
else x = t[x].r;
}
t[z].p=y;
if (y==nil)root=z;
else{
if (t[z].k<t[y].k)t[y].l=z;
else t[y].r = z;
}
}
void inorder(int u){
if (u==nil)return;
inorder(t[u].l);
printf(" %d", t[u].k);
inorder(t[u].r);
}
void preorder(int u){
if (u == nil) return;
printf(" %d", t[u].k);
preorder(t[u].l);
preorder(t[u].r);
}
int main(int argc, char** argv){
char com[8];
int n;
int x;
int i;
root=nil;
room=-1;
ix=0;
scanf("%d", &n);
for (i=0 ; i<n; i++){
scanf("%s", com);
switch (com[0]){
case 'd':
scanf("%d", &x);
delete(find(root, x));
break;
case 'f':
scanf("%d", &x);
printf("%s\n", find(root, x) != nil ? "yes" : "no");
break;
case 'i':
scanf("%d", &x);
insert(x);
break;
case 'p':
default:
inorder(root);
printf("\n");
preorder(root);
printf("\n");
break;
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207233/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207233/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.nnode_tbl = type { i32, i32, i32, i32 }
@nil = dso_local local_unnamed_addr constant i32 -1, align 4
@t = dso_local local_unnamed_addr global [500000 x %struct.nnode_tbl] zeroinitializer, align 16
@root = dso_local local_unnamed_addr global i32 0, align 4
@room = dso_local local_unnamed_addr global i32 0, align 4
@ix = dso_local local_unnamed_addr global i32 0, align 4
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.4 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
@.str.5 = private unnamed_addr constant [3 x i8] c"no\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local i32 @tmin(i32 noundef %u) local_unnamed_addr #0 {
entry:
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%u.addr.0 = phi i32 [ %u, %entry ], [ %0, %while.cond ]
%idxprom = sext i32 %u.addr.0 to i64
%l = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom, i32 2
%0 = load i32, ptr %l, align 8, !tbaa !5
%cmp.not = icmp eq i32 %0, -1
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !10
while.end: ; preds = %while.cond
ret i32 %u.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local i32 @find(i32 noundef %u, i32 noundef %k) local_unnamed_addr #1 {
entry:
%cmp.not17 = icmp eq i32 %u, -1
br i1 %cmp.not17, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%u.addr.018 = phi i32 [ %u.addr.1, %while.body ], [ %u, %entry ]
%idxprom = sext i32 %u.addr.018 to i64
%arrayidx = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom
%0 = load i32, ptr %arrayidx, align 16, !tbaa !12
%cmp2.not = icmp eq i32 %0, %k
br i1 %cmp2.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp6 = icmp sgt i32 %0, %k
%l = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom, i32 2
%r = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom, i32 3
%u.addr.1.in = select i1 %cmp6, ptr %l, ptr %r
%u.addr.1 = load i32, ptr %u.addr.1.in, align 4, !tbaa !13
%cmp.not = icmp eq i32 %u.addr.1, -1
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !14
while.end: ; preds = %land.rhs, %while.body, %entry
%u.addr.0.lcssa = phi i32 [ -1, %entry ], [ -1, %while.body ], [ %u.addr.018, %land.rhs ]
ret i32 %u.addr.0.lcssa
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local i32 @trees(i32 noundef %u) local_unnamed_addr #0 {
entry:
%idxprom = sext i32 %u to i64
%r = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom, i32 3
%0 = load i32, ptr %r, align 4, !tbaa !15
%cmp.not = icmp eq i32 %0, -1
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%u.addr.0.i = phi i32 [ %1, %while.cond.i ], [ %0, %entry ]
%idxprom.i = sext i32 %u.addr.0.i to i64
%l.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom.i, i32 2
%1 = load i32, ptr %l.i, align 8, !tbaa !5
%cmp.not.i = icmp eq i32 %1, -1
br i1 %cmp.not.i, label %return, label %while.cond.i, !llvm.loop !10
while.cond: ; preds = %entry, %land.rhs
%u.addr.0 = phi i32 [ %y.0, %land.rhs ], [ %u, %entry ]
%idxprom.pn = phi i64 [ %idxprom7, %land.rhs ], [ %idxprom, %entry ]
%y.0.in = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom.pn, i32 1
%y.0 = load i32, ptr %y.0.in, align 4, !tbaa !16
%cmp6.not = icmp eq i32 %y.0, -1
br i1 %cmp6.not, label %return, label %land.rhs
land.rhs: ; preds = %while.cond
%idxprom7 = sext i32 %y.0 to i64
%r9 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom7, i32 3
%2 = load i32, ptr %r9, align 4, !tbaa !15
%cmp10 = icmp eq i32 %u.addr.0, %2
br i1 %cmp10, label %while.cond, label %return, !llvm.loop !17
return: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi i32 [ %y.0, %land.rhs ], [ -1, %while.cond ], [ %u.addr.0.i, %while.cond.i ]
ret i32 %retval.0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: read, inaccessiblemem: none) uwtable
define dso_local void @delete(i32 noundef %z) local_unnamed_addr #3 {
entry:
%idxprom = sext i32 %z to i64
%arrayidx = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom
%l = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom, i32 2
%0 = load i32, ptr %l, align 8, !tbaa !5
%cmp = icmp eq i32 %0, -1
br i1 %cmp, label %if.end16, label %lor.lhs.false
lor.lhs.false: ; preds = %entry
%r = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom, i32 3
%1 = load i32, ptr %r, align 4, !tbaa !15
%cmp3 = icmp eq i32 %1, -1
br i1 %cmp3, label %if.end, label %while.cond.i.i
while.cond.i.i: ; preds = %lor.lhs.false, %while.cond.i.i
%u.addr.0.i.i = phi i32 [ %2, %while.cond.i.i ], [ %1, %lor.lhs.false ]
%idxprom.i.i = sext i32 %u.addr.0.i.i to i64
%l.i.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom.i.i, i32 2
%2 = load i32, ptr %l.i.i, align 8, !tbaa !5
%cmp.not.i.i = icmp eq i32 %2, -1
br i1 %cmp.not.i.i, label %if.end16, label %while.cond.i.i, !llvm.loop !10
if.end: ; preds = %lor.lhs.false
%arrayidx5 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom
br label %if.then18
if.end16: ; preds = %while.cond.i.i, %entry
%idxprom4.pre-phi.ph = phi i64 [ %idxprom, %entry ], [ %idxprom.i.i, %while.cond.i.i ]
%y.0.ph = phi i32 [ %z, %entry ], [ %u.addr.0.i.i, %while.cond.i.i ]
%arrayidx593 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom4.pre-phi.ph
%r15 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom4.pre-phi.ph, i32 3
%3 = load i32, ptr %r15, align 4, !tbaa !15
%cmp17.not = icmp eq i32 %3, -1
br i1 %cmp17.not, label %if.end24, label %if.then18
if.then18: ; preds = %if.end, %if.end16
%arrayidx5101 = phi ptr [ %arrayidx593, %if.end16 ], [ %arrayidx5, %if.end ]
%y.098 = phi i32 [ %y.0.ph, %if.end16 ], [ %z, %if.end ]
%idxprom4.pre-phi95 = phi i64 [ %idxprom4.pre-phi.ph, %if.end16 ], [ %idxprom, %if.end ]
%x.089 = phi i32 [ %3, %if.end16 ], [ %0, %if.end ]
%p = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom4.pre-phi95, i32 1
%4 = load i32, ptr %p, align 4, !tbaa !16
%idxprom21 = sext i32 %x.089 to i64
%p23 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom21, i32 1
store i32 %4, ptr %p23, align 4, !tbaa !16
br label %if.end24
if.end24: ; preds = %if.then18, %if.end16
%arrayidx5102 = phi ptr [ %arrayidx5101, %if.then18 ], [ %arrayidx593, %if.end16 ]
%y.099 = phi i32 [ %y.098, %if.then18 ], [ %y.0.ph, %if.end16 ]
%idxprom4.pre-phi96 = phi i64 [ %idxprom4.pre-phi95, %if.then18 ], [ %idxprom4.pre-phi.ph, %if.end16 ]
%x.090 = phi i32 [ %x.089, %if.then18 ], [ -1, %if.end16 ]
%p27 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom4.pre-phi96, i32 1
%5 = load i32, ptr %p27, align 4, !tbaa !16
%cmp28 = icmp eq i32 %5, -1
br i1 %cmp28, label %if.then29, label %if.else30
if.then29: ; preds = %if.end24
store i32 %x.090, ptr @root, align 4, !tbaa !13
br label %if.end53
if.else30: ; preds = %if.end24
%idxprom34 = sext i32 %5 to i64
%l36 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom34, i32 2
%6 = load i32, ptr %l36, align 8, !tbaa !5
%cmp37 = icmp eq i32 %y.099, %6
br i1 %cmp37, label %if.then38, label %if.else45
if.then38: ; preds = %if.else30
store i32 %x.090, ptr %l36, align 8, !tbaa !5
br label %if.end53
if.else45: ; preds = %if.else30
%r51 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom34, i32 3
store i32 %x.090, ptr %r51, align 4, !tbaa !15
br label %if.end53
if.end53: ; preds = %if.then38, %if.else45, %if.then29
%cmp54.not = icmp eq i32 %y.099, %z
br i1 %cmp54.not, label %if.end61, label %if.then55
if.then55: ; preds = %if.end53
%7 = load i32, ptr %arrayidx5102, align 16, !tbaa !12
store i32 %7, ptr %arrayidx, align 16, !tbaa !12
br label %if.end61
if.end61: ; preds = %if.then55, %if.end53
%8 = load i32, ptr @room, align 4, !tbaa !13
%r64 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom4.pre-phi96, i32 3
store i32 %8, ptr %r64, align 4, !tbaa !15
store i32 %y.099, ptr @room, align 4, !tbaa !13
ret void
}
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: read, inaccessiblemem: none) uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #3 {
entry:
%0 = load i32, ptr @root, align 4, !tbaa !13
%1 = load i32, ptr @room, align 4, !tbaa !13
%cmp = icmp eq i32 %1, -1
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
%2 = load i32, ptr @ix, align 4, !tbaa !13
%inc = add nsw i32 %2, 1
store i32 %inc, ptr @ix, align 4, !tbaa !13
%.pre = sext i32 %2 to i64
br label %if.end
if.else: ; preds = %entry
%idxprom = sext i32 %1 to i64
%r = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom, i32 3
%3 = load i32, ptr %r, align 4, !tbaa !15
store i32 %3, ptr @room, align 4, !tbaa !13
br label %if.end
if.end: ; preds = %if.else, %if.then
%idxprom1.pre-phi = phi i64 [ %idxprom, %if.else ], [ %.pre, %if.then ]
%z.0 = phi i32 [ %1, %if.else ], [ %2, %if.then ]
%arrayidx2 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom1.pre-phi
store i32 %k, ptr %arrayidx2, align 16, !tbaa !12
%l = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom1.pre-phi, i32 2
store i32 -1, ptr %l, align 8, !tbaa !5
%r8 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom1.pre-phi, i32 3
store i32 -1, ptr %r8, align 4, !tbaa !15
%cmp9.not64 = icmp eq i32 %0, -1
br i1 %cmp9.not64, label %if.then29, label %while.body
while.body: ; preds = %if.end, %while.body
%x.065 = phi i32 [ %x.1, %while.body ], [ %0, %if.end ]
%idxprom13 = sext i32 %x.065 to i64
%arrayidx14 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom13
%4 = load i32, ptr %arrayidx14, align 16, !tbaa !12
%cmp16 = icmp sgt i32 %4, %k
%l20 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom13, i32 2
%r24 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom13, i32 3
%x.1.in = select i1 %cmp16, ptr %l20, ptr %r24
%x.1 = load i32, ptr %x.1.in, align 4, !tbaa !13
%cmp9.not = icmp eq i32 %x.1, -1
br i1 %cmp9.not, label %if.else30, label %while.body, !llvm.loop !18
if.then29: ; preds = %if.end
%p67 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom1.pre-phi, i32 1
store i32 -1, ptr %p67, align 4, !tbaa !16
store i32 %z.0, ptr @root, align 4, !tbaa !13
br label %if.end47
if.else30: ; preds = %while.body
%p = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom1.pre-phi, i32 1
store i32 %x.065, ptr %p, align 4, !tbaa !16
%idxprom34 = sext i32 %x.065 to i64
%arrayidx35 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom34
%5 = load i32, ptr %arrayidx35, align 16, !tbaa !12
%cmp37 = icmp sgt i32 %5, %k
br i1 %cmp37, label %if.then38, label %if.else42
if.then38: ; preds = %if.else30
%l41 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom34, i32 2
store i32 %z.0, ptr %l41, align 8, !tbaa !5
br label %if.end47
if.else42: ; preds = %if.else30
%r45 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom34, i32 3
store i32 %z.0, ptr %r45, align 4, !tbaa !15
br label %if.end47
if.end47: ; preds = %if.then38, %if.else42, %if.then29
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(i32 noundef %u) local_unnamed_addr #4 {
entry:
%cmp8 = icmp eq i32 %u, -1
br i1 %cmp8, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr9 = phi i32 [ %2, %if.end ], [ %u, %entry ]
%idxprom = sext i32 %u.tr9 to i64
%arrayidx = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom
%l = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom, i32 2
%0 = load i32, ptr %l, align 8, !tbaa !5
tail call void @inorder(i32 noundef %0)
%1 = load i32, ptr %arrayidx, align 16, !tbaa !12
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%r = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom, i32 3
%2 = load i32, ptr %r, align 4, !tbaa !15
%cmp = icmp eq i32 %2, -1
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(i32 noundef %u) local_unnamed_addr #4 {
entry:
%cmp8 = icmp eq i32 %u, -1
br i1 %cmp8, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr9 = phi i32 [ %2, %if.end ], [ %u, %entry ]
%idxprom = sext i32 %u.tr9 to i64
%arrayidx = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom
%0 = load i32, ptr %arrayidx, align 16, !tbaa !12
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%l = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom, i32 2
%1 = load i32, ptr %l, align 8, !tbaa !5
tail call void @preorder(i32 noundef %1)
%r = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom, i32 3
%2 = load i32, ptr %r, align 4, !tbaa !15
%cmp = icmp eq i32 %2, -1
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main(i32 noundef %argc, ptr nocapture noundef readnone %argv) local_unnamed_addr #4 {
entry:
%com = alloca [8 x i8], align 1
%n = alloca i32, align 4
%x = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %com) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #7
store i32 -1, ptr @root, align 4, !tbaa !13
store i32 -1, ptr @room, align 4, !tbaa !13
store i32 0, ptr @ix, align 4, !tbaa !13
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !13
%cmp51 = icmp sgt i32 %0, 0
br i1 %cmp51, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.052 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 1, !tbaa !19
%conv = sext i8 %1 to i32
switch i32 %conv, label %sw.default [
i32 100, label %sw.bb
i32 102, label %sw.bb4
i32 105, label %sw.bb10
]
sw.bb: ; preds = %for.body
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load i32, ptr @root, align 4, !tbaa !13
%3 = load i32, ptr %x, align 4, !tbaa !13
%cmp.not17.i = icmp eq i32 %2, -1
br i1 %cmp.not17.i, label %find.exit, label %land.rhs.i
land.rhs.i: ; preds = %sw.bb, %while.body.i
%u.addr.018.i = phi i32 [ %u.addr.1.i, %while.body.i ], [ %2, %sw.bb ]
%idxprom.i = sext i32 %u.addr.018.i to i64
%arrayidx.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom.i
%4 = load i32, ptr %arrayidx.i, align 16, !tbaa !12
%cmp2.not.i = icmp eq i32 %4, %3
br i1 %cmp2.not.i, label %find.exit, label %while.body.i
while.body.i: ; preds = %land.rhs.i
%cmp6.i = icmp sgt i32 %4, %3
%l.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom.i, i32 2
%r.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom.i, i32 3
%u.addr.1.in.i = select i1 %cmp6.i, ptr %l.i, ptr %r.i
%u.addr.1.i = load i32, ptr %u.addr.1.in.i, align 4, !tbaa !13
%cmp.not.i = icmp eq i32 %u.addr.1.i, -1
br i1 %cmp.not.i, label %find.exit, label %land.rhs.i, !llvm.loop !14
find.exit: ; preds = %land.rhs.i, %while.body.i, %sw.bb
%u.addr.0.lcssa.i = phi i32 [ -1, %sw.bb ], [ %u.addr.018.i, %land.rhs.i ], [ -1, %while.body.i ]
%idxprom.i17 = sext i32 %u.addr.0.lcssa.i to i64
%arrayidx.i18 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom.i17
%l.i19 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom.i17, i32 2
%5 = load i32, ptr %l.i19, align 8, !tbaa !5
%cmp.i = icmp eq i32 %5, -1
br i1 %cmp.i, label %if.end16.i, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %find.exit
%r.i20 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom.i17, i32 3
%6 = load i32, ptr %r.i20, align 4, !tbaa !15
%cmp3.i = icmp eq i32 %6, -1
br i1 %cmp3.i, label %if.then18.i, label %while.cond.i.i.i
while.cond.i.i.i: ; preds = %lor.lhs.false.i, %while.cond.i.i.i
%u.addr.0.i.i.i = phi i32 [ %7, %while.cond.i.i.i ], [ %6, %lor.lhs.false.i ]
%idxprom.i.i.i = sext i32 %u.addr.0.i.i.i to i64
%l.i.i.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom.i.i.i, i32 2
%7 = load i32, ptr %l.i.i.i, align 8, !tbaa !5
%cmp.not.i.i.i = icmp eq i32 %7, -1
br i1 %cmp.not.i.i.i, label %if.end16.i, label %while.cond.i.i.i, !llvm.loop !10
if.end16.i: ; preds = %while.cond.i.i.i, %find.exit
%idxprom4.pre-phi.ph.i = phi i64 [ %idxprom.i17, %find.exit ], [ %idxprom.i.i.i, %while.cond.i.i.i ]
%y.0.ph.i = phi i32 [ %u.addr.0.lcssa.i, %find.exit ], [ %u.addr.0.i.i.i, %while.cond.i.i.i ]
%arrayidx593.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom4.pre-phi.ph.i
%r15.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom4.pre-phi.ph.i, i32 3
%8 = load i32, ptr %r15.i, align 4, !tbaa !15
%cmp17.not.i = icmp eq i32 %8, -1
br i1 %cmp17.not.i, label %if.end24.i, label %if.then18.i
if.then18.i: ; preds = %lor.lhs.false.i, %if.end16.i
%arrayidx5101.i = phi ptr [ %arrayidx593.i, %if.end16.i ], [ %arrayidx.i18, %lor.lhs.false.i ]
%y.098.i = phi i32 [ %y.0.ph.i, %if.end16.i ], [ %u.addr.0.lcssa.i, %lor.lhs.false.i ]
%idxprom4.pre-phi95.i = phi i64 [ %idxprom4.pre-phi.ph.i, %if.end16.i ], [ %idxprom.i17, %lor.lhs.false.i ]
%x.089.i = phi i32 [ %8, %if.end16.i ], [ %5, %lor.lhs.false.i ]
%p.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom4.pre-phi95.i, i32 1
%9 = load i32, ptr %p.i, align 4, !tbaa !16
%idxprom21.i = sext i32 %x.089.i to i64
%p23.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom21.i, i32 1
store i32 %9, ptr %p23.i, align 4, !tbaa !16
br label %if.end24.i
if.end24.i: ; preds = %if.then18.i, %if.end16.i
%arrayidx5102.i = phi ptr [ %arrayidx5101.i, %if.then18.i ], [ %arrayidx593.i, %if.end16.i ]
%y.099.i = phi i32 [ %y.098.i, %if.then18.i ], [ %y.0.ph.i, %if.end16.i ]
%idxprom4.pre-phi96.i = phi i64 [ %idxprom4.pre-phi95.i, %if.then18.i ], [ %idxprom4.pre-phi.ph.i, %if.end16.i ]
%x.090.i = phi i32 [ %x.089.i, %if.then18.i ], [ -1, %if.end16.i ]
%p27.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom4.pre-phi96.i, i32 1
%10 = load i32, ptr %p27.i, align 4, !tbaa !16
%cmp28.i = icmp eq i32 %10, -1
br i1 %cmp28.i, label %if.then29.i, label %if.else30.i
if.then29.i: ; preds = %if.end24.i
store i32 %x.090.i, ptr @root, align 4, !tbaa !13
br label %if.end53.i
if.else30.i: ; preds = %if.end24.i
%idxprom34.i = sext i32 %10 to i64
%l36.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom34.i, i32 2
%11 = load i32, ptr %l36.i, align 8, !tbaa !5
%cmp37.i = icmp eq i32 %y.099.i, %11
br i1 %cmp37.i, label %if.then38.i, label %if.else45.i
if.then38.i: ; preds = %if.else30.i
store i32 %x.090.i, ptr %l36.i, align 8, !tbaa !5
br label %if.end53.i
if.else45.i: ; preds = %if.else30.i
%r51.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom34.i, i32 3
store i32 %x.090.i, ptr %r51.i, align 4, !tbaa !15
br label %if.end53.i
if.end53.i: ; preds = %if.else45.i, %if.then38.i, %if.then29.i
%cmp54.not.i = icmp eq i32 %y.099.i, %u.addr.0.lcssa.i
br i1 %cmp54.not.i, label %delete.exit, label %if.then55.i
if.then55.i: ; preds = %if.end53.i
%12 = load i32, ptr %arrayidx5102.i, align 16, !tbaa !12
store i32 %12, ptr %arrayidx.i18, align 16, !tbaa !12
br label %delete.exit
delete.exit: ; preds = %if.end53.i, %if.then55.i
%13 = load i32, ptr @room, align 4, !tbaa !13
%r64.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom4.pre-phi96.i, i32 3
store i32 %13, ptr %r64.i, align 4, !tbaa !15
store i32 %y.099.i, ptr @room, align 4, !tbaa !13
br label %for.inc
sw.bb4: ; preds = %for.body
%call5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%14 = load i32, ptr @root, align 4, !tbaa !13
%15 = load i32, ptr %x, align 4, !tbaa !13
%cmp.not17.i21 = icmp eq i32 %14, -1
br i1 %cmp.not17.i21, label %find.exit35, label %land.rhs.i22
land.rhs.i22: ; preds = %sw.bb4, %while.body.i27
%u.addr.018.i23 = phi i32 [ %u.addr.1.i32, %while.body.i27 ], [ %14, %sw.bb4 ]
%idxprom.i24 = sext i32 %u.addr.018.i23 to i64
%arrayidx.i25 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom.i24
%16 = load i32, ptr %arrayidx.i25, align 16, !tbaa !12
%cmp2.not.i26 = icmp eq i32 %16, %15
br i1 %cmp2.not.i26, label %find.exit35, label %while.body.i27
while.body.i27: ; preds = %land.rhs.i22
%cmp6.i28 = icmp sgt i32 %16, %15
%l.i29 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom.i24, i32 2
%r.i30 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom.i24, i32 3
%u.addr.1.in.i31 = select i1 %cmp6.i28, ptr %l.i29, ptr %r.i30
%u.addr.1.i32 = load i32, ptr %u.addr.1.in.i31, align 4, !tbaa !13
%cmp.not.i33 = icmp eq i32 %u.addr.1.i32, -1
br i1 %cmp.not.i33, label %find.exit35, label %land.rhs.i22, !llvm.loop !14
find.exit35: ; preds = %while.body.i27, %land.rhs.i22, %sw.bb4
%17 = phi ptr [ @.str.5, %sw.bb4 ], [ @.str.5, %while.body.i27 ], [ @.str.4, %land.rhs.i22 ]
%puts = call i32 @puts(ptr nonnull dereferenceable(1) %17)
br label %for.inc
sw.bb10: ; preds = %for.body
%call11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%18 = load i32, ptr %x, align 4, !tbaa !13
%19 = load i32, ptr @root, align 4, !tbaa !13
%20 = load i32, ptr @room, align 4, !tbaa !13
%cmp.i36 = icmp eq i32 %20, -1
br i1 %cmp.i36, label %if.then.i, label %if.else.i
if.then.i: ; preds = %sw.bb10
%21 = load i32, ptr @ix, align 4, !tbaa !13
%inc.i = add nsw i32 %21, 1
store i32 %inc.i, ptr @ix, align 4, !tbaa !13
%.pre.i = sext i32 %21 to i64
br label %if.end.i39
if.else.i: ; preds = %sw.bb10
%idxprom.i37 = sext i32 %20 to i64
%r.i38 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom.i37, i32 3
%22 = load i32, ptr %r.i38, align 4, !tbaa !15
store i32 %22, ptr @room, align 4, !tbaa !13
br label %if.end.i39
if.end.i39: ; preds = %if.else.i, %if.then.i
%idxprom1.pre-phi.i = phi i64 [ %idxprom.i37, %if.else.i ], [ %.pre.i, %if.then.i ]
%z.0.i = phi i32 [ %20, %if.else.i ], [ %21, %if.then.i ]
%arrayidx2.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom1.pre-phi.i
store i32 %18, ptr %arrayidx2.i, align 16, !tbaa !12
%l.i40 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom1.pre-phi.i, i32 2
store i32 -1, ptr %l.i40, align 8, !tbaa !5
%r8.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom1.pre-phi.i, i32 3
store i32 -1, ptr %r8.i, align 4, !tbaa !15
%cmp9.not64.i = icmp eq i32 %19, -1
br i1 %cmp9.not64.i, label %if.then29.i47, label %while.body.i41
while.body.i41: ; preds = %if.end.i39, %while.body.i41
%x.065.i = phi i32 [ %x.1.i, %while.body.i41 ], [ %19, %if.end.i39 ]
%idxprom13.i = sext i32 %x.065.i to i64
%arrayidx14.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom13.i
%23 = load i32, ptr %arrayidx14.i, align 16, !tbaa !12
%cmp16.i = icmp sgt i32 %23, %18
%l20.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom13.i, i32 2
%r24.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom13.i, i32 3
%x.1.in.i = select i1 %cmp16.i, ptr %l20.i, ptr %r24.i
%x.1.i = load i32, ptr %x.1.in.i, align 4, !tbaa !13
%cmp9.not.i = icmp eq i32 %x.1.i, -1
br i1 %cmp9.not.i, label %if.else30.i42, label %while.body.i41, !llvm.loop !18
if.then29.i47: ; preds = %if.end.i39
%p67.i = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom1.pre-phi.i, i32 1
store i32 -1, ptr %p67.i, align 4, !tbaa !16
store i32 %z.0.i, ptr @root, align 4, !tbaa !13
br label %for.inc
if.else30.i42: ; preds = %while.body.i41
%p.i43 = getelementptr inbounds [500000 x %struct.nnode_tbl], ptr @t, i64 0, i64 %idxprom1.pre-phi.i, i32 1
store i32 %x.065.i, ptr %p.i43, align 4, !tbaa !16
br i1 %cmp16.i, label %if.then38.i46, label %if.else42.i
if.then38.i46: ; preds = %if.else30.i42
store i32 %z.0.i, ptr %l20.i, align 8, !tbaa !5
br label %for.inc
if.else42.i: ; preds = %if.else30.i42
store i32 %z.0.i, ptr %r24.i, align 4, !tbaa !15
br label %for.inc
sw.default: ; preds = %for.body
%24 = load i32, ptr @root, align 4, !tbaa !13
call void @inorder(i32 noundef %24)
%putchar = call i32 @putchar(i32 10)
%25 = load i32, ptr @root, align 4, !tbaa !13
call void @preorder(i32 noundef %25)
%putchar16 = call i32 @putchar(i32 10)
br label %for.inc
for.inc: ; preds = %if.else42.i, %if.then38.i46, %if.then29.i47, %delete.exit, %find.exit35, %sw.default
%inc = add nuw nsw i32 %i.052, 1
%26 = load i32, ptr %n, align 4, !tbaa !13
%cmp = icmp slt i32 %inc, %26
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !20
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #7
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %com) #7
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: none, inaccessiblemem: none) 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 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nofree norecurse nosync nounwind memory(readwrite, argmem: read, inaccessiblemem: none) 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 = { nofree 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 #5 = { 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 #6 = { nofree nounwind }
attributes #7 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !7, i64 8}
!6 = !{!"nnode_tbl", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!6, !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !11}
!15 = !{!6, !7, i64 12}
!16 = !{!6, !7, i64 4}
!17 = distinct !{!17, !11}
!18 = distinct !{!18, !11}
!19 = !{!8, !8, i64 0}
!20 = distinct !{!20, !11}
|
#include <stdio.h>
#include <string.h>
int main(){
char s[11];
char t[12];
int n;
scanf("%s%s",s,t);
n = strlen(s);
for(int i=0;i<n;i++){
if(s[i]!=t[i]){
printf("No\n");
return 0;
}
}
printf("Yes\n");
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207284/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207284/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [5 x i8] c"%s%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"No\00", align 1
@str.3 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca [11 x i8], align 1
%t = alloca [12 x i8], align 1
call void @llvm.lifetime.start.p0(i64 11, ptr nonnull %s) #5
call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %t) #5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s, ptr noundef nonnull %t)
%call3 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %s) #6
%conv = trunc i64 %call3 to i32
%cmp.not20 = icmp sgt i32 %conv, 0
br i1 %cmp.not20, label %for.body.preheader, label %cleanup13
for.body.preheader: ; preds = %entry
%wide.trip.count = and i64 %call3, 4294967295
br label %for.body
for.cond: ; preds = %for.body
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
br i1 %exitcond.not, label %cleanup13, label %for.body, !llvm.loop !5
for.body: ; preds = %for.body.preheader, %for.cond
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.cond ]
%arrayidx = getelementptr inbounds [11 x i8], ptr %s, i64 0, i64 %indvars.iv
%0 = load i8, ptr %arrayidx, align 1, !tbaa !7
%arrayidx7 = getelementptr inbounds [12 x i8], ptr %t, i64 0, i64 %indvars.iv
%1 = load i8, ptr %arrayidx7, align 1, !tbaa !7
%cmp9.not = icmp eq i8 %0, %1
br i1 %cmp9.not, label %for.cond, label %cleanup13
cleanup13: ; preds = %for.cond, %for.body, %entry
%str.sink = phi ptr [ @str.3, %entry ], [ @str, %for.body ], [ @str.3, %for.cond ]
%puts = call i32 @puts(ptr nonnull dereferenceable(1) %str.sink)
call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %t) #5
call void @llvm.lifetime.end.p0(i64 11, ptr nonnull %s) #5
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #4
attributes #0 = { nofree 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 = { 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 = { 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 #4 = { nofree nounwind }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
int main() {
char s[15], t[15];
scanf("%s %s", s, t);
bool ok = 1;
for (int i = 0; i < strlen(s); i++) {
if (s[i] != t[i]) ok = 0;
}
if (ok) printf("Yes\n");
else printf("No\n");
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207327/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207327/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%s %s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"No\00", align 1
@str.3 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca [15 x i8], align 1
%t = alloca [15 x i8], align 1
call void @llvm.lifetime.start.p0(i64 15, ptr nonnull %s) #5
call void @llvm.lifetime.start.p0(i64 15, ptr nonnull %t) #5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s, ptr noundef nonnull %t)
%call3 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %s) #6
%cmp19.not = icmp eq i64 %call3, 0
br i1 %cmp19.not, label %if.end14, label %iter.check
iter.check: ; preds = %entry
%min.iters.check = icmp ult i64 %call3, 8
br i1 %min.iters.check, label %for.body.preheader, label %vector.main.loop.iter.check
vector.main.loop.iter.check: ; preds = %iter.check
%min.iters.check25 = icmp ult i64 %call3, 32
br i1 %min.iters.check25, label %vec.epilog.ph, label %vector.ph
vector.ph: ; preds = %vector.main.loop.iter.check
%n.vec = and i64 %call3, -32
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%vec.phi = phi <16 x i8> [ <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>, %vector.ph ], [ %6, %vector.body ]
%vec.phi26 = phi <16 x i8> [ <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>, %vector.ph ], [ %7, %vector.body ]
%0 = getelementptr inbounds [15 x i8], ptr %s, i64 0, i64 %index
%wide.load = load <16 x i8>, ptr %0, align 1, !tbaa !5
%1 = getelementptr inbounds i8, ptr %0, i64 16
%wide.load27 = load <16 x i8>, ptr %1, align 1, !tbaa !5
%2 = getelementptr inbounds [15 x i8], ptr %t, i64 0, i64 %index
%wide.load28 = load <16 x i8>, ptr %2, align 1, !tbaa !5
%3 = getelementptr inbounds i8, ptr %2, i64 16
%wide.load29 = load <16 x i8>, ptr %3, align 1, !tbaa !5
%4 = icmp eq <16 x i8> %wide.load, %wide.load28
%5 = icmp eq <16 x i8> %wide.load27, %wide.load29
%6 = select <16 x i1> %4, <16 x i8> %vec.phi, <16 x i8> zeroinitializer
%7 = select <16 x i1> %5, <16 x i8> %vec.phi26, <16 x i8> zeroinitializer
%index.next = add nuw i64 %index, 32
%8 = icmp eq i64 %index.next, %n.vec
br i1 %8, label %middle.block, label %vector.body, !llvm.loop !8
middle.block: ; preds = %vector.body
%rdx.select.cmp.not = icmp ne <16 x i8> %6, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%rdx.select.cmp3043 = icmp ne <16 x i8> %7, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%rdx.select.cmp30 = select <16 x i1> %rdx.select.cmp.not, <16 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <16 x i1> %rdx.select.cmp3043
%9 = bitcast <16 x i1> %rdx.select.cmp30 to i16
%.not = icmp eq i16 %9, 0
%rdx.select31 = zext i1 %.not to i8
%cmp.n = icmp eq i64 %call3, %n.vec
br i1 %cmp.n, label %for.cond.cleanup, label %vec.epilog.iter.check
vec.epilog.iter.check: ; preds = %middle.block
%n.vec.remaining = and i64 %call3, 24
%min.epilog.iters.check = icmp eq i64 %n.vec.remaining, 0
br i1 %min.epilog.iters.check, label %for.body.preheader, label %vec.epilog.ph
vec.epilog.ph: ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
%bc.merge.rdx = phi i8 [ 1, %vector.main.loop.iter.check ], [ %rdx.select31, %vec.epilog.iter.check ]
%vec.epilog.resume.val = phi i64 [ 0, %vector.main.loop.iter.check ], [ %n.vec, %vec.epilog.iter.check ]
%n.vec33 = and i64 %call3, -8
%minmax.ident.splatinsert = insertelement <8 x i8> poison, i8 %bc.merge.rdx, i64 0
%minmax.ident.splat = shufflevector <8 x i8> %minmax.ident.splatinsert, <8 x i8> poison, <8 x i32> zeroinitializer
br label %vec.epilog.vector.body
vec.epilog.vector.body: ; preds = %vec.epilog.vector.body, %vec.epilog.ph
%index35 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next39, %vec.epilog.vector.body ]
%vec.phi36 = phi <8 x i8> [ %minmax.ident.splat, %vec.epilog.ph ], [ %13, %vec.epilog.vector.body ]
%10 = getelementptr inbounds [15 x i8], ptr %s, i64 0, i64 %index35
%wide.load37 = load <8 x i8>, ptr %10, align 1, !tbaa !5
%11 = getelementptr inbounds [15 x i8], ptr %t, i64 0, i64 %index35
%wide.load38 = load <8 x i8>, ptr %11, align 1, !tbaa !5
%12 = icmp eq <8 x i8> %wide.load37, %wide.load38
%13 = select <8 x i1> %12, <8 x i8> %vec.phi36, <8 x i8> zeroinitializer
%index.next39 = add nuw i64 %index35, 8
%14 = icmp eq i64 %index.next39, %n.vec33
br i1 %14, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !12
vec.epilog.middle.block: ; preds = %vec.epilog.vector.body
%.scalar = bitcast <8 x i8> %13 to i64
%.not44 = icmp eq i64 %.scalar, 72340172838076673
%rdx.select41 = zext i1 %.not44 to i8
%cmp.n34 = icmp eq i64 %call3, %n.vec33
br i1 %cmp.n34, label %for.cond.cleanup, label %for.body.preheader
for.body.preheader: ; preds = %iter.check, %vec.epilog.iter.check, %vec.epilog.middle.block
%indvars.iv.ph = phi i64 [ 0, %iter.check ], [ %n.vec, %vec.epilog.iter.check ], [ %n.vec33, %vec.epilog.middle.block ]
%ok.020.ph = phi i8 [ 1, %iter.check ], [ %rdx.select31, %vec.epilog.iter.check ], [ %rdx.select41, %vec.epilog.middle.block ]
br label %for.body
for.cond.cleanup: ; preds = %for.body, %vec.epilog.middle.block, %middle.block
%spec.select.lcssa = phi i8 [ %rdx.select31, %middle.block ], [ %rdx.select41, %vec.epilog.middle.block ], [ %spec.select, %for.body ]
%15 = and i8 %spec.select.lcssa, 1
%16 = icmp eq i8 %15, 0
%spec.select24 = select i1 %16, ptr @str, ptr @str.3
br label %if.end14
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader ]
%ok.020 = phi i8 [ %spec.select, %for.body ], [ %ok.020.ph, %for.body.preheader ]
%arrayidx = getelementptr inbounds [15 x i8], ptr %s, i64 0, i64 %indvars.iv
%17 = load i8, ptr %arrayidx, align 1, !tbaa !5
%arrayidx7 = getelementptr inbounds [15 x i8], ptr %t, i64 0, i64 %indvars.iv
%18 = load i8, ptr %arrayidx7, align 1, !tbaa !5
%cmp9.not = icmp eq i8 %17, %18
%spec.select = select i1 %cmp9.not, i8 %ok.020, i8 0
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %call3
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body, !llvm.loop !13
if.end14: ; preds = %for.cond.cleanup, %entry
%str.sink = phi ptr [ @str.3, %entry ], [ %spec.select24, %for.cond.cleanup ]
%puts = call i32 @puts(ptr nonnull dereferenceable(1) %str.sink)
call void @llvm.lifetime.end.p0(i64 15, ptr nonnull %t) #5
call void @llvm.lifetime.end.p0(i64 15, ptr nonnull %s) #5
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #4
attributes #0 = { nofree 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 = { 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 = { 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 #4 = { nofree nounwind }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9, !10, !11}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !9, !10, !11}
!13 = distinct !{!13, !9, !11, !10}
|
#include <stdio.h>
int main(void){
char s[15], t[15];
scanf("%s", s);
scanf("%s", t);
//printf("%lu\n", sizeof(s));
int flag = 0;
int i = 0;
while(s[i] != '\0'){
//printf("%c\n", s[i]);
//printf("%c\n", t[i]);
if(s[i] != t[i]) flag = 1;
//printf("%d\n", i);
i++;
}
if(flag) puts("No");
else puts("Yes");
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207378/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207378/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"No\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca [15 x i8], align 1
%t = alloca [15 x i8], align 1
call void @llvm.lifetime.start.p0(i64 15, ptr nonnull %s) #3
call void @llvm.lifetime.start.p0(i64 15, ptr nonnull %t) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s)
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %t)
%0 = load i8, ptr %s, align 1, !tbaa !5
%cmp.not19 = icmp eq i8 %0, 0
br i1 %cmp.not19, label %if.else, label %while.body
while.body: ; preds = %entry, %while.body
%indvars.iv = phi i64 [ %indvars.iv.next, %while.body ], [ 0, %entry ]
%1 = phi i8 [ %3, %while.body ], [ %0, %entry ]
%flag.020 = phi i32 [ %spec.select, %while.body ], [ 0, %entry ]
%arrayidx8 = getelementptr inbounds [15 x i8], ptr %t, i64 0, i64 %indvars.iv
%2 = load i8, ptr %arrayidx8, align 1, !tbaa !5
%cmp10.not = icmp eq i8 %1, %2
%spec.select = select i1 %cmp10.not, i32 %flag.020, i32 1
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%arrayidx = getelementptr inbounds [15 x i8], ptr %s, i64 0, i64 %indvars.iv.next
%3 = load i8, ptr %arrayidx, align 1, !tbaa !5
%cmp.not = icmp eq i8 %3, 0
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !8
while.end: ; preds = %while.body
%4 = icmp eq i32 %spec.select, 0
br i1 %4, label %if.else, label %if.end15
if.else: ; preds = %entry, %while.end
br label %if.end15
if.end15: ; preds = %while.end, %if.else
%.str.2.sink = phi ptr [ @.str.2, %if.else ], [ @.str.1, %while.end ]
%call14 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.2.sink)
call void @llvm.lifetime.end.p0(i64 15, ptr nonnull %t) #3
call void @llvm.lifetime.end.p0(i64 15, ptr nonnull %s) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
|
#include<stdio.h>
int main() {
char S[100], T[100];
int i = 0;
int result = 0;
scanf("%s", S);
scanf("%s", T);
while(S[i] != '\0'){
if(S[i] != T[i]){
printf("No");
result = 1;
break;
}
i++;
}
if(result == 0){
printf("Yes");
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207420/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207420/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"No\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%S = alloca [100 x i8], align 16
%T = alloca [100 x i8], align 16
call void @llvm.lifetime.start.p0(i64 100, ptr nonnull %S) #3
call void @llvm.lifetime.start.p0(i64 100, ptr nonnull %T) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %S)
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %T)
%0 = load i8, ptr %S, align 16, !tbaa !5
%cmp.not21 = icmp eq i8 %0, 0
br i1 %cmp.not21, label %if.end17, label %while.body
while.cond: ; preds = %while.body
%indvars.iv.next = add nuw i64 %indvars.iv, 1
%arrayidx = getelementptr inbounds [100 x i8], ptr %S, i64 0, i64 %indvars.iv.next
%1 = load i8, ptr %arrayidx, align 1, !tbaa !5
%cmp.not = icmp eq i8 %1, 0
br i1 %cmp.not, label %if.end17, label %while.body, !llvm.loop !8
while.body: ; preds = %entry, %while.cond
%indvars.iv = phi i64 [ %indvars.iv.next, %while.cond ], [ 0, %entry ]
%2 = phi i8 [ %1, %while.cond ], [ %0, %entry ]
%arrayidx8 = getelementptr inbounds [100 x i8], ptr %T, i64 0, i64 %indvars.iv
%3 = load i8, ptr %arrayidx8, align 1, !tbaa !5
%cmp10.not = icmp eq i8 %2, %3
br i1 %cmp10.not, label %while.cond, label %if.end17
if.end17: ; preds = %while.cond, %while.body, %entry
%.str.1.sink = phi ptr [ @.str.2, %entry ], [ @.str.1, %while.body ], [ @.str.2, %while.cond ]
%call12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.1.sink)
call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %T) #3
call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %S) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
|
#include <stdio.h>
#include <string.h>
int main() {
char S[11],T[12];
long len_S,len_T;
scanf("%s",S);
scanf("%s",T);
len_S = strlen(S);
len_T = strlen(T);
if (strncmp(S,T,len_S) == 0){
printf("Yes\n");
}else{
printf("No\n");
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207464/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207464/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"No\00", align 1
@str.3 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%S = alloca [11 x i8], align 1
%T = alloca [12 x i8], align 1
call void @llvm.lifetime.start.p0(i64 11, ptr nonnull %S) #5
call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %T) #5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %S)
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %T)
%call4 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %S) #6
%call9 = call i32 @strncmp(ptr noundef nonnull %S, ptr noundef nonnull %T, i64 noundef %call4) #6
%cmp = icmp eq i32 %call9, 0
%str.3.str = select i1 %cmp, ptr @str.3, ptr @str
%puts = call i32 @puts(ptr nonnull dereferenceable(1) %str.3.str)
call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %T) #5
call void @llvm.lifetime.end.p0(i64 11, ptr nonnull %S) #5
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strncmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #4
attributes #0 = { nofree 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 = { 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 = { 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 #4 = { nofree nounwind }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
|
#include<stdio.h>
int main(void){
char S[11];
char T[11];
int i,a,b;
scanf("%s",S);
scanf("%s",T);
a=0;
b=0;
for(i=0;S[i]!='\0';i++){
if(S[i]!=T[i]){
a=1;
}
if(S[i+1]!=T[i+1]){
b=1;
}
if(S[i+1]==T[i+1]){
b=0;
}
}
if(a==0&&b==1){
printf("Yes");
}else{
printf("No");
}
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207507/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207507/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"No\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%S = alloca [11 x i8], align 1
%T = alloca [11 x i8], align 1
call void @llvm.lifetime.start.p0(i64 11, ptr nonnull %S) #3
call void @llvm.lifetime.start.p0(i64 11, ptr nonnull %T) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %S)
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %T)
%0 = load i8, ptr %S, align 1, !tbaa !5
%cmp.not50 = icmp eq i8 %0, 0
br i1 %cmp.not50, label %if.else, label %for.body
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
%1 = phi i8 [ %3, %for.body ], [ %0, %entry ]
%a.052 = phi i32 [ %spec.select, %for.body ], [ 0, %entry ]
%arrayidx8 = getelementptr inbounds [11 x i8], ptr %T, i64 0, i64 %indvars.iv
%2 = load i8, ptr %arrayidx8, align 1, !tbaa !5
%cmp10.not = icmp eq i8 %1, %2
%spec.select = select i1 %cmp10.not, i32 %a.052, i32 1
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%arrayidx = getelementptr inbounds [11 x i8], ptr %S, i64 0, i64 %indvars.iv.next
%3 = load i8, ptr %arrayidx, align 1, !tbaa !5
%cmp.not = icmp eq i8 %3, 0
br i1 %cmp.not, label %for.end, label %for.body, !llvm.loop !8
for.end: ; preds = %for.body
%idxprom12.le = and i64 %indvars.iv.next, 4294967295
%arrayidx13.le = getelementptr inbounds [11 x i8], ptr %S, i64 0, i64 %idxprom12.le
%4 = load i8, ptr %arrayidx13.le, align 1, !tbaa !5
%arrayidx17.le = getelementptr inbounds [11 x i8], ptr %T, i64 0, i64 %idxprom12.le
%5 = load i8, ptr %arrayidx17.le, align 1, !tbaa !5
%cmp19.not.le = icmp ne i8 %4, %5
%6 = icmp eq i32 %spec.select, 0
%7 = select i1 %6, i1 %cmp19.not.le, i1 false
br i1 %7, label %if.end42, label %if.else
if.else: ; preds = %entry, %for.end
br label %if.end42
if.end42: ; preds = %for.end, %if.else
%.str.2.sink = phi ptr [ @.str.2, %if.else ], [ @.str.1, %for.end ]
%call41 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.2.sink)
call void @llvm.lifetime.end.p0(i64 11, ptr nonnull %T) #3
call void @llvm.lifetime.end.p0(i64 11, ptr nonnull %S) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
|
#include<stdio.h>
int main()
{
char s[12];
char t[12];
int i;
int flagone=1;
int flagtwo=0;
scanf("%s",s);
scanf("%s",t);
for(i=0;s[i]!='\0';i++){
if(s[i]!=t[i]){flagone=0;break;}
}
if(flagone==1){
if(t[i]!='\0'){flagtwo=1;}
}
if(flagtwo==1){
printf("Yes");
}else{
printf("No");
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207550/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207550/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"No\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca [12 x i8], align 1
%t = alloca [12 x i8], align 1
call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %s) #3
call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %t) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s)
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %t)
%0 = load i8, ptr %s, align 1, !tbaa !5
%cmp.not34 = icmp eq i8 %0, 0
br i1 %cmp.not34, label %if.then14, label %for.body
for.cond: ; preds = %for.body
%indvars.iv.next = add nuw i64 %indvars.iv, 1
%arrayidx = getelementptr inbounds [12 x i8], ptr %s, i64 0, i64 %indvars.iv.next
%1 = load i8, ptr %arrayidx, align 1, !tbaa !5
%cmp.not = icmp eq i8 %1, 0
br i1 %cmp.not, label %if.then14, label %for.body, !llvm.loop !8
for.body: ; preds = %entry, %for.cond
%indvars.iv = phi i64 [ %indvars.iv.next, %for.cond ], [ 0, %entry ]
%2 = phi i8 [ %1, %for.cond ], [ %0, %entry ]
%arrayidx8 = getelementptr inbounds [12 x i8], ptr %t, i64 0, i64 %indvars.iv
%3 = load i8, ptr %arrayidx8, align 1, !tbaa !5
%cmp10.not = icmp eq i8 %2, %3
br i1 %cmp10.not, label %for.cond, label %if.else
if.then14: ; preds = %for.cond, %entry
%idxprom.lcssa = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.cond ]
%arrayidx16 = getelementptr inbounds [12 x i8], ptr %t, i64 0, i64 %idxprom.lcssa
%4 = load i8, ptr %arrayidx16, align 1, !tbaa !5
%cmp18.not.not = icmp eq i8 %4, 0
br i1 %cmp18.not.not, label %if.else, label %if.end28
if.else: ; preds = %for.body, %if.then14
br label %if.end28
if.end28: ; preds = %if.then14, %if.else
%.str.2.sink = phi ptr [ @.str.2, %if.else ], [ @.str.1, %if.then14 ]
%call27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.2.sink)
call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %t) #3
call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %s) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
|
#include<stdio.h>
#include<string.h>
int main(){
int i, j, n, m, flag=0;
char s[11], t[12];
scanf("%s", s);
scanf("%s", t);
n = strlen(s);
m = strlen(t);
for(i=0; i<n; i++){
if(s[i]!=t[i]){
flag = 1;
}
}
if(m-n!=1){
flag = 1;
}
if(flag==0){
printf("Yes");
}else{
printf("No");
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207608/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207608/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"No\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca [11 x i8], align 1
%t = alloca [12 x i8], align 1
call void @llvm.lifetime.start.p0(i64 11, ptr nonnull %s) #4
call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %t) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s)
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %t)
%call4 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %s) #5
%conv = trunc i64 %call4 to i32
%call6 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %t) #5
%cmp31 = icmp sgt i32 %conv, 0
br i1 %cmp31, label %for.body.preheader, label %for.end
for.body.preheader: ; preds = %entry
%wide.trip.count = and i64 %call4, 4294967295
%min.iters.check = icmp ult i64 %wide.trip.count, 8
br i1 %min.iters.check, label %for.body.preheader42, label %vector.ph
vector.ph: ; preds = %for.body.preheader
%n.mod.vf = and i64 %call4, 7
%n.vec = sub nsw i64 %wide.trip.count, %n.mod.vf
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %6, %vector.body ]
%vec.phi35 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %7, %vector.body ]
%0 = getelementptr inbounds [11 x i8], ptr %s, i64 0, i64 %index
%wide.load = load <4 x i8>, ptr %0, align 1, !tbaa !5
%1 = getelementptr inbounds i8, ptr %0, i64 4
%wide.load36 = load <4 x i8>, ptr %1, align 1, !tbaa !5
%2 = getelementptr inbounds [12 x i8], ptr %t, i64 0, i64 %index
%wide.load37 = load <4 x i8>, ptr %2, align 1, !tbaa !5
%3 = getelementptr inbounds i8, ptr %2, i64 4
%wide.load38 = load <4 x i8>, ptr %3, align 1, !tbaa !5
%4 = icmp eq <4 x i8> %wide.load, %wide.load37
%5 = icmp eq <4 x i8> %wide.load36, %wide.load38
%6 = select <4 x i1> %4, <4 x i32> %vec.phi, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
%7 = select <4 x i1> %5, <4 x i32> %vec.phi35, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
%index.next = add nuw i64 %index, 8
%8 = icmp eq i64 %index.next, %n.vec
br i1 %8, label %middle.block, label %vector.body, !llvm.loop !8
middle.block: ; preds = %vector.body
%rdx.select.cmp.not = icmp ne <4 x i32> %6, zeroinitializer
%rdx.select.cmp3941 = icmp ne <4 x i32> %7, zeroinitializer
%rdx.select.cmp39 = select <4 x i1> %rdx.select.cmp.not, <4 x i1> <i1 true, i1 true, i1 true, i1 true>, <4 x i1> %rdx.select.cmp3941
%9 = bitcast <4 x i1> %rdx.select.cmp39 to i4
%.not = icmp ne i4 %9, 0
%rdx.select40 = zext i1 %.not to i32
%cmp.n = icmp eq i64 %n.mod.vf, 0
br i1 %cmp.n, label %for.end.loopexit, label %for.body.preheader42
for.body.preheader42: ; preds = %for.body.preheader, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.body.preheader ], [ %n.vec, %middle.block ]
%flag.033.ph = phi i32 [ 0, %for.body.preheader ], [ %rdx.select40, %middle.block ]
br label %for.body
for.body: ; preds = %for.body.preheader42, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader42 ]
%flag.033 = phi i32 [ %spec.select, %for.body ], [ %flag.033.ph, %for.body.preheader42 ]
%arrayidx = getelementptr inbounds [11 x i8], ptr %s, i64 0, i64 %indvars.iv
%10 = load i8, ptr %arrayidx, align 1, !tbaa !5
%arrayidx11 = getelementptr inbounds [12 x i8], ptr %t, i64 0, i64 %indvars.iv
%11 = load i8, ptr %arrayidx11, align 1, !tbaa !5
%cmp13.not = icmp eq i8 %10, %11
%spec.select = select i1 %cmp13.not, i32 %flag.033, i32 1
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
br i1 %exitcond.not, label %for.end.loopexit, label %for.body, !llvm.loop !12
for.end.loopexit: ; preds = %for.body, %middle.block
%spec.select.lcssa = phi i32 [ %rdx.select40, %middle.block ], [ %spec.select, %for.body ]
%12 = icmp eq i32 %spec.select.lcssa, 0
br label %for.end
for.end: ; preds = %for.end.loopexit, %entry
%flag.0.lcssa = phi i1 [ true, %entry ], [ %12, %for.end.loopexit ]
%conv7 = trunc i64 %call6 to i32
%sub = sub nsw i32 %conv7, %conv
%cmp15.not = icmp eq i32 %sub, 1
%cmp19 = select i1 %cmp15.not, i1 %flag.0.lcssa, i1 false
%.str.1..str.2 = select i1 %cmp19, ptr @.str.1, ptr @.str.2
%call23 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.1..str.2)
call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %t) #4
call void @llvm.lifetime.end.p0(i64 11, ptr nonnull %s) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = { 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 #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9, !10, !11}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !9, !11, !10}
|
#include <stdio.h>
char S[20],T[20];
int main()
{
//変数宣言
int can=0;
int i=0;
//初期入力
scanf("%s",S);
scanf("%s",T);
while(can==0)
{
if(S[i] == '\0')
{
if(T[i]!='\0' && T[i+1]=='\0')
{
can = 1;
}
else
{
can = -1;
}
}
else if(S[i] != T[i])
{
can = -1;
}
else
{
i++;
}
}
//最終出力
if(can == 1)
{
printf("Yes\n");
}else
{
printf("No\n");
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207666/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207666/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@S = dso_local global [20 x i8] zeroinitializer, align 16
@T = dso_local global [20 x i8] zeroinitializer, align 16
@str = private unnamed_addr constant [3 x i8] c"No\00", align 1
@str.3 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @S)
%call1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @T)
br label %while.cond.outer
while.cond.outer: ; preds = %if.else15, %entry
%can.0.ph = phi i32 [ %spec.select, %if.else15 ], [ 0, %entry ]
%i.0.ph = phi i32 [ %spec.select42, %if.else15 ], [ 0, %entry ]
%idxprom = zext i32 %i.0.ph to i64
%arrayidx = getelementptr inbounds [20 x i8], ptr @S, i64 0, i64 %idxprom
%arrayidx5 = getelementptr inbounds [20 x i8], ptr @T, i64 0, i64 %idxprom
%add = add nuw nsw i32 %i.0.ph, 1
%idxprom9 = zext i32 %add to i64
%arrayidx10 = getelementptr inbounds [20 x i8], ptr @T, i64 0, i64 %idxprom9
br label %while.cond
while.cond: ; preds = %while.cond.backedge, %while.cond.outer
%can.0 = phi i32 [ %can.0.ph, %while.cond.outer ], [ %can.0.be, %while.cond.backedge ]
switch i32 %can.0, label %if.end34.loopexit43 [
i32 0, label %while.body
i32 1, label %if.end34
]
while.body: ; preds = %while.cond
%0 = load i8, ptr %arrayidx, align 1, !tbaa !5
%cmp2 = icmp eq i8 %0, 0
%1 = load i8, ptr %arrayidx5, align 1, !tbaa !5
br i1 %cmp2, label %if.then, label %if.else15
if.then: ; preds = %while.body
%cmp7.not = icmp eq i8 %1, 0
br i1 %cmp7.not, label %if.else, label %land.lhs.true
land.lhs.true: ; preds = %if.then
%2 = load i8, ptr %arrayidx10, align 1, !tbaa !5
%cmp12 = icmp eq i8 %2, 0
br i1 %cmp12, label %while.cond.backedge, label %if.else
while.cond.backedge: ; preds = %land.lhs.true, %if.else
%can.0.be = phi i32 [ -1, %if.else ], [ 1, %land.lhs.true ]
br label %while.cond, !llvm.loop !8
if.else: ; preds = %land.lhs.true, %if.then
br label %while.cond.backedge
if.else15: ; preds = %while.body
%cmp22.not = icmp ne i8 %0, %1
%spec.select = sext i1 %cmp22.not to i32
%not.cmp22.not = xor i1 %cmp22.not, true
%inc = zext i1 %not.cmp22.not to i32
%spec.select42 = add nuw nsw i32 %i.0.ph, %inc
br label %while.cond.outer, !llvm.loop !8
if.end34.loopexit43: ; preds = %while.cond
br label %if.end34
if.end34: ; preds = %while.cond, %if.end34.loopexit43
%str.sink = phi ptr [ @str, %if.end34.loopexit43 ], [ @str.3, %while.cond ]
%puts = tail call i32 @puts(ptr nonnull dereferenceable(1) %str.sink)
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2
attributes #0 = { nofree 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 = { 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 #2 = { nofree 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
|
#include <stdio.h>
int main(void){
char s[12],t[12];
scanf("%s",s);
scanf("%s",t);
int i=0;
while(s[i]!='\0'){
if(s[i]!=t[i]){
printf("No\n");
return 0;
}
i++;
}
printf("Yes\n");
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207730/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207730/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
@str.3 = private unnamed_addr constant [3 x i8] c"No\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca [12 x i8], align 1
%t = alloca [12 x i8], align 1
call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %s) #4
call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %t) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s)
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %t)
%0 = load i8, ptr %s, align 1, !tbaa !5
%cmp.not20 = icmp eq i8 %0, 0
br i1 %cmp.not20, label %cleanup, label %while.body
while.cond: ; preds = %while.body
%indvars.iv.next = add nuw i64 %indvars.iv, 1
%arrayidx = getelementptr inbounds [12 x i8], ptr %s, i64 0, i64 %indvars.iv.next
%1 = load i8, ptr %arrayidx, align 1, !tbaa !5
%cmp.not = icmp eq i8 %1, 0
br i1 %cmp.not, label %cleanup, label %while.body, !llvm.loop !8
while.body: ; preds = %entry, %while.cond
%indvars.iv = phi i64 [ %indvars.iv.next, %while.cond ], [ 0, %entry ]
%2 = phi i8 [ %1, %while.cond ], [ %0, %entry ]
%arrayidx8 = getelementptr inbounds [12 x i8], ptr %t, i64 0, i64 %indvars.iv
%3 = load i8, ptr %arrayidx8, align 1, !tbaa !5
%cmp10.not = icmp eq i8 %2, %3
br i1 %cmp10.not, label %while.cond, label %cleanup
cleanup: ; preds = %while.cond, %while.body, %entry
%str.sink = phi ptr [ @str, %entry ], [ @str.3, %while.body ], [ @str, %while.cond ]
%puts = call i32 @puts(ptr nonnull dereferenceable(1) %str.sink)
call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %t) #4
call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %s) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
attributes #0 = { nofree 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 = { 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 = { nofree nounwind }
attributes #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
|
// Aizu Vol0 0038: Poker Hand
// 2017.7.30
#include <stdio.h>
#include <stdlib.h>
#define MAX 14
int main()
{
int card[MAX+3];
int max;
int i, j, d[5];
while (scanf("%d,%d,%d,%d,%d", &d[0], &d[1], &d[2], &d[3], &d[4]) == 5) {
for (i = 1; i <= MAX; i++) card[i] = 0;
max = 0;
for (i = 0; i < 5; i++) {
if (++card[d[i]] > max) max = card[d[i]];
if (d[i] == 1) card[14] = 1;
}
if (max == 4) {
puts("four card");
goto DONE;
}
if (max == 3) {
for (i = 1; i < MAX; i++) {
if (card[i] == 2) {
puts("full house");
goto DONE;
}
}
}
if (max == 1) {
for (i = 1; i <= 10; i++) {
for (j = 0; ; j++) {
if (j >= 5) {
puts("straight");
goto DONE;
}
if (card[i + j] != 1) break;
}
}
}
if (max == 3) {
puts("three card");
goto DONE;
}
if (max == 2) {
for (i = 1; card[i] < 2; i++);
for (j = i + 1; j < MAX; j++) {
if (card[j] == 2) {
puts("two pair");
goto DONE;
}
}
puts("one pair");
goto DONE;
}
puts("null");
DONE:;
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207781/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207781/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [15 x i8] c"%d,%d,%d,%d,%d\00", align 1
@.str.1 = private unnamed_addr constant [10 x i8] c"four card\00", align 1
@.str.2 = private unnamed_addr constant [11 x i8] c"full house\00", align 1
@.str.3 = private unnamed_addr constant [9 x i8] c"straight\00", align 1
@.str.4 = private unnamed_addr constant [11 x i8] c"three card\00", align 1
@.str.5 = private unnamed_addr constant [9 x i8] c"two pair\00", align 1
@.str.6 = private unnamed_addr constant [9 x i8] c"one pair\00", align 1
@.str.7 = private unnamed_addr constant [5 x i8] c"null\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%card = alloca [17 x i32], align 16
%d = alloca [5 x i32], align 16
call void @llvm.lifetime.start.p0(i64 68, ptr nonnull %card) #4
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %d) #4
%arrayidx1 = getelementptr inbounds [5 x i32], ptr %d, i64 0, i64 1
%arrayidx2 = getelementptr inbounds [5 x i32], ptr %d, i64 0, i64 2
%arrayidx3 = getelementptr inbounds [5 x i32], ptr %d, i64 0, i64 3
%arrayidx4 = getelementptr inbounds [5 x i32], ptr %d, i64 0, i64 4
%call132 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %d, ptr noundef nonnull %arrayidx1, ptr noundef nonnull %arrayidx2, ptr noundef nonnull %arrayidx3, ptr noundef nonnull %arrayidx4)
%cmp133 = icmp eq i32 %call132, 5
br i1 %cmp133, label %for.cond.preheader.lr.ph, label %while.end
for.cond.preheader.lr.ph: ; preds = %entry
%arrayidx24 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 14
%scevgep = getelementptr inbounds i8, ptr %card, i64 4
%arrayidx59.1140.phi.trans.insert = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 2
%arrayidx59.1 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 2
%arrayidx59.2143.phi.trans.insert = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 3
%arrayidx59.2 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 3
%arrayidx59.3 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 4
%arrayidx59.4 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 5
%arrayidx59.1.1 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 3
%arrayidx59.3146.phi.trans.insert = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 4
%arrayidx59.2.1 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 4
%arrayidx59.3.1 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 5
%arrayidx59.4.1 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 6
%arrayidx59.1.2 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 4
%arrayidx59.4149.phi.trans.insert = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 5
%arrayidx59.2.2 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 5
%arrayidx59.3.2 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 6
%arrayidx59.4.2 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 7
%arrayidx59.1.3 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 5
%arrayidx59.5.phi.trans.insert = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 6
%arrayidx59.2.3 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 6
%arrayidx59.3.3 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 7
%arrayidx59.4.3 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 8
%arrayidx59.1.4 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 6
%arrayidx59.6.phi.trans.insert = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 7
%arrayidx59.2.4 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 7
%arrayidx59.3.4 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 8
%arrayidx59.4.4 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 9
%arrayidx59.1.5 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 7
%arrayidx59.7.phi.trans.insert = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 8
%arrayidx59.2.5 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 8
%arrayidx59.3.5 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 9
%arrayidx59.4.5 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 10
%arrayidx59.1.6 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 8
%arrayidx59.8.phi.trans.insert = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 9
%arrayidx59.2.6 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 9
%arrayidx59.3.6 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 10
%arrayidx59.4.6 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 11
%arrayidx59.1.7 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 9
%arrayidx59.9.phi.trans.insert = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 10
%arrayidx59.2.7 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 10
%arrayidx59.3.7 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 11
%arrayidx59.4.7 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 12
%arrayidx59.1.8 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 10
%arrayidx59.2.8 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 11
%arrayidx59.3.8 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 12
%arrayidx59.4.8 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 13
%arrayidx59.1.9 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 11
%arrayidx59.2.9 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 12
%arrayidx59.3.9 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 13
%arrayidx39.8 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 9
%arrayidx39.12 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 13
br label %for.cond.preheader
for.cond.preheader: ; preds = %for.cond.preheader.lr.ph, %DONE
call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(56) %scevgep, i8 0, i64 56, i1 false), !tbaa !5
%0 = load i32, ptr %d, align 16, !tbaa !5
%idxprom12 = sext i32 %0 to i64
%arrayidx13 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 %idxprom12
%1 = load i32, ptr %arrayidx13, align 4, !tbaa !5
%inc14 = add nsw i32 %1, 1
store i32 %inc14, ptr %arrayidx13, align 4, !tbaa !5
%cmp15.not = icmp slt i32 %1, 0
%spec.select = select i1 %cmp15.not, i32 0, i32 %inc14
%cmp22 = icmp eq i32 %0, 1
br i1 %cmp22, label %if.then23, label %for.inc26
if.then23: ; preds = %for.cond.preheader
store i32 1, ptr %arrayidx24, align 8, !tbaa !5
br label %for.inc26
for.inc26: ; preds = %for.cond.preheader, %if.then23
%2 = load i32, ptr %arrayidx1, align 4, !tbaa !5
%idxprom12.1 = sext i32 %2 to i64
%arrayidx13.1 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 %idxprom12.1
%3 = load i32, ptr %arrayidx13.1, align 4, !tbaa !5
%inc14.1 = add nsw i32 %3, 1
store i32 %inc14.1, ptr %arrayidx13.1, align 4, !tbaa !5
%cmp15.not.1 = icmp slt i32 %3, %spec.select
%spec.select.1 = select i1 %cmp15.not.1, i32 %spec.select, i32 %inc14.1
%cmp22.1 = icmp eq i32 %2, 1
br i1 %cmp22.1, label %if.then23.1, label %for.inc26.1
if.then23.1: ; preds = %for.inc26
store i32 1, ptr %arrayidx24, align 8, !tbaa !5
br label %for.inc26.1
for.inc26.1: ; preds = %if.then23.1, %for.inc26
%4 = load i32, ptr %arrayidx2, align 8, !tbaa !5
%idxprom12.2 = sext i32 %4 to i64
%arrayidx13.2 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 %idxprom12.2
%5 = load i32, ptr %arrayidx13.2, align 4, !tbaa !5
%inc14.2 = add nsw i32 %5, 1
store i32 %inc14.2, ptr %arrayidx13.2, align 4, !tbaa !5
%cmp15.not.2 = icmp slt i32 %5, %spec.select.1
%spec.select.2 = select i1 %cmp15.not.2, i32 %spec.select.1, i32 %inc14.2
%cmp22.2 = icmp eq i32 %4, 1
br i1 %cmp22.2, label %if.then23.2, label %for.inc26.2
if.then23.2: ; preds = %for.inc26.1
store i32 1, ptr %arrayidx24, align 8, !tbaa !5
br label %for.inc26.2
for.inc26.2: ; preds = %if.then23.2, %for.inc26.1
%6 = load i32, ptr %arrayidx3, align 4, !tbaa !5
%idxprom12.3 = sext i32 %6 to i64
%arrayidx13.3 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 %idxprom12.3
%7 = load i32, ptr %arrayidx13.3, align 4, !tbaa !5
%inc14.3 = add nsw i32 %7, 1
store i32 %inc14.3, ptr %arrayidx13.3, align 4, !tbaa !5
%cmp15.not.3 = icmp slt i32 %7, %spec.select.2
%spec.select.3 = select i1 %cmp15.not.3, i32 %spec.select.2, i32 %inc14.3
%cmp22.3 = icmp eq i32 %6, 1
br i1 %cmp22.3, label %if.then23.3, label %for.inc26.3
if.then23.3: ; preds = %for.inc26.2
store i32 1, ptr %arrayidx24, align 8, !tbaa !5
br label %for.inc26.3
for.inc26.3: ; preds = %if.then23.3, %for.inc26.2
%8 = load i32, ptr %arrayidx4, align 16, !tbaa !5
%idxprom12.4 = sext i32 %8 to i64
%arrayidx13.4 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 %idxprom12.4
%9 = load i32, ptr %arrayidx13.4, align 4, !tbaa !5
%inc14.4 = add nsw i32 %9, 1
store i32 %inc14.4, ptr %arrayidx13.4, align 4, !tbaa !5
%cmp15.not.4 = icmp slt i32 %9, %spec.select.3
%spec.select.4 = select i1 %cmp15.not.4, i32 %spec.select.3, i32 %inc14.4
%cmp22.4 = icmp eq i32 %8, 1
br i1 %cmp22.4, label %if.then23.4, label %for.inc26.4
if.then23.4: ; preds = %for.inc26.3
store i32 1, ptr %arrayidx24, align 8, !tbaa !5
br label %for.inc26.4
for.inc26.4: ; preds = %if.then23.4, %for.inc26.3
switch i32 %spec.select.4, label %if.end98 [
i32 4, label %DONE
i32 3, label %for.body37.preheader
i32 1, label %for.cond53.preheader.preheader
i32 2, label %for.cond76
]
for.body37.preheader: ; preds = %for.inc26.4
%10 = load <8 x i32>, ptr %scevgep, align 4
%.fr = freeze <8 x i32> %10
%11 = icmp eq <8 x i32> %.fr, <i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2>
%12 = load <4 x i32>, ptr %arrayidx39.8, align 4
%.fr228 = freeze <4 x i32> %12
%13 = icmp eq <4 x i32> %.fr228, <i32 2, i32 2, i32 2, i32 2>
%14 = load i32, ptr %arrayidx39.12, align 4
%cmp40.12 = icmp eq i32 %14, 2
%15 = bitcast <8 x i1> %11 to i8
%16 = icmp ne i8 %15, 0
%17 = bitcast <4 x i1> %13 to i4
%18 = icmp ne i4 %17, 0
%op.rdx = or i1 %16, %18
%op.rdx227 = select i1 %op.rdx, i1 true, i1 %cmp40.12
%.str.2..str.4 = select i1 %op.rdx227, ptr @.str.2, ptr @.str.4
br label %DONE
for.cond53.preheader.preheader: ; preds = %for.inc26.4
%19 = load i32, ptr %scevgep, align 4, !tbaa !5
%cmp60.not = icmp eq i32 %19, 1
br i1 %cmp60.not, label %for.cond53, label %for.inc66
for.cond53: ; preds = %for.cond53.preheader.preheader
%20 = load i32, ptr %arrayidx59.1, align 8, !tbaa !5
%cmp60.not.1 = icmp eq i32 %20, 1
br i1 %cmp60.not.1, label %for.cond53.1, label %for.inc66.1
for.cond53.1: ; preds = %for.cond53
%21 = load i32, ptr %arrayidx59.2, align 4, !tbaa !5
%cmp60.not.2 = icmp eq i32 %21, 1
%22 = load i32, ptr %arrayidx59.3, align 16
%cmp60.not.3 = icmp eq i32 %22, 1
%or.cond204 = select i1 %cmp60.not.2, i1 %cmp60.not.3, i1 false
%23 = load i32, ptr %arrayidx59.4, align 4
%cmp60.not.4 = icmp eq i32 %23, 1
%or.cond205 = select i1 %or.cond204, i1 %cmp60.not.4, i1 false
br i1 %or.cond205, label %DONE, label %for.cond53.1142
for.inc66: ; preds = %for.cond53.preheader.preheader
%.pre = load i32, ptr %arrayidx59.1140.phi.trans.insert, align 8, !tbaa !5
%cmp60.not.1141 = icmp eq i32 %.pre, 1
br i1 %cmp60.not.1141, label %for.cond53.1142, label %for.inc66.1
for.cond53.1142: ; preds = %for.cond53.1, %for.inc66
%24 = load i32, ptr %arrayidx59.1.1, align 4, !tbaa !5
%cmp60.not.1.1 = icmp eq i32 %24, 1
br i1 %cmp60.not.1.1, label %for.cond53.1.1, label %for.inc66.2
for.cond53.1.1: ; preds = %for.cond53.1142
%25 = load i32, ptr %arrayidx59.2.1, align 16, !tbaa !5
%cmp60.not.2.1 = icmp eq i32 %25, 1
%26 = load i32, ptr %arrayidx59.3.1, align 4
%cmp60.not.3.1 = icmp eq i32 %26, 1
%or.cond206 = select i1 %cmp60.not.2.1, i1 %cmp60.not.3.1, i1 false
%27 = load i32, ptr %arrayidx59.4.1, align 8
%cmp60.not.4.1 = icmp eq i32 %27, 1
%or.cond207 = select i1 %or.cond206, i1 %cmp60.not.4.1, i1 false
br i1 %or.cond207, label %DONE, label %for.cond53.2145
for.inc66.1: ; preds = %for.cond53, %for.inc66
%.pre156 = load i32, ptr %arrayidx59.2143.phi.trans.insert, align 4, !tbaa !5
%cmp60.not.2144 = icmp eq i32 %.pre156, 1
br i1 %cmp60.not.2144, label %for.cond53.2145, label %for.inc66.2
for.cond53.2145: ; preds = %for.cond53.1.1, %for.inc66.1
%28 = load i32, ptr %arrayidx59.1.2, align 16, !tbaa !5
%cmp60.not.1.2 = icmp eq i32 %28, 1
br i1 %cmp60.not.1.2, label %for.cond53.1.2, label %for.inc66.3
for.cond53.1.2: ; preds = %for.cond53.2145
%29 = load i32, ptr %arrayidx59.2.2, align 4, !tbaa !5
%cmp60.not.2.2 = icmp eq i32 %29, 1
%30 = load i32, ptr %arrayidx59.3.2, align 8
%cmp60.not.3.2 = icmp eq i32 %30, 1
%or.cond208 = select i1 %cmp60.not.2.2, i1 %cmp60.not.3.2, i1 false
%31 = load i32, ptr %arrayidx59.4.2, align 4
%cmp60.not.4.2 = icmp eq i32 %31, 1
%or.cond209 = select i1 %or.cond208, i1 %cmp60.not.4.2, i1 false
br i1 %or.cond209, label %DONE, label %for.cond53.3148
for.inc66.2: ; preds = %for.cond53.1142, %for.inc66.1
%.pre157 = load i32, ptr %arrayidx59.3146.phi.trans.insert, align 16, !tbaa !5
%cmp60.not.3147 = icmp eq i32 %.pre157, 1
br i1 %cmp60.not.3147, label %for.cond53.3148, label %for.inc66.3
for.cond53.3148: ; preds = %for.cond53.1.2, %for.inc66.2
%32 = load i32, ptr %arrayidx59.1.3, align 4, !tbaa !5
%cmp60.not.1.3 = icmp eq i32 %32, 1
br i1 %cmp60.not.1.3, label %for.cond53.1.3, label %for.inc66.4
for.cond53.1.3: ; preds = %for.cond53.3148
%33 = load i32, ptr %arrayidx59.2.3, align 8, !tbaa !5
%cmp60.not.2.3 = icmp eq i32 %33, 1
%34 = load i32, ptr %arrayidx59.3.3, align 4
%cmp60.not.3.3 = icmp eq i32 %34, 1
%or.cond210 = select i1 %cmp60.not.2.3, i1 %cmp60.not.3.3, i1 false
%35 = load i32, ptr %arrayidx59.4.3, align 16
%cmp60.not.4.3 = icmp eq i32 %35, 1
%or.cond211 = select i1 %or.cond210, i1 %cmp60.not.4.3, i1 false
br i1 %or.cond211, label %DONE, label %for.cond53.4151
for.inc66.3: ; preds = %for.cond53.2145, %for.inc66.2
%.pre158 = load i32, ptr %arrayidx59.4149.phi.trans.insert, align 4, !tbaa !5
%cmp60.not.4150 = icmp eq i32 %.pre158, 1
br i1 %cmp60.not.4150, label %for.cond53.4151, label %for.inc66.4
for.cond53.4151: ; preds = %for.cond53.1.3, %for.inc66.3
%36 = load i32, ptr %arrayidx59.1.4, align 8, !tbaa !5
%cmp60.not.1.4 = icmp eq i32 %36, 1
br i1 %cmp60.not.1.4, label %for.cond53.1.4, label %for.inc66.5
for.cond53.1.4: ; preds = %for.cond53.4151
%37 = load i32, ptr %arrayidx59.2.4, align 4, !tbaa !5
%cmp60.not.2.4 = icmp eq i32 %37, 1
%38 = load i32, ptr %arrayidx59.3.4, align 16
%cmp60.not.3.4 = icmp eq i32 %38, 1
%or.cond212 = select i1 %cmp60.not.2.4, i1 %cmp60.not.3.4, i1 false
%39 = load i32, ptr %arrayidx59.4.4, align 4
%cmp60.not.4.4 = icmp eq i32 %39, 1
%or.cond213 = select i1 %or.cond212, i1 %cmp60.not.4.4, i1 false
br i1 %or.cond213, label %DONE, label %for.cond53.5
for.inc66.4: ; preds = %for.cond53.3148, %for.inc66.3
%.pre159 = load i32, ptr %arrayidx59.5.phi.trans.insert, align 8, !tbaa !5
%cmp60.not.5 = icmp eq i32 %.pre159, 1
br i1 %cmp60.not.5, label %for.cond53.5, label %for.inc66.5
for.cond53.5: ; preds = %for.cond53.1.4, %for.inc66.4
%40 = load i32, ptr %arrayidx59.1.5, align 4, !tbaa !5
%cmp60.not.1.5 = icmp eq i32 %40, 1
br i1 %cmp60.not.1.5, label %for.cond53.1.5, label %for.inc66.6
for.cond53.1.5: ; preds = %for.cond53.5
%41 = load i32, ptr %arrayidx59.2.5, align 16, !tbaa !5
%cmp60.not.2.5 = icmp eq i32 %41, 1
%42 = load i32, ptr %arrayidx59.3.5, align 4
%cmp60.not.3.5 = icmp eq i32 %42, 1
%or.cond214 = select i1 %cmp60.not.2.5, i1 %cmp60.not.3.5, i1 false
%43 = load i32, ptr %arrayidx59.4.5, align 8
%cmp60.not.4.5 = icmp eq i32 %43, 1
%or.cond215 = select i1 %or.cond214, i1 %cmp60.not.4.5, i1 false
br i1 %or.cond215, label %DONE, label %for.cond53.6
for.inc66.5: ; preds = %for.cond53.4151, %for.inc66.4
%.pre160 = load i32, ptr %arrayidx59.6.phi.trans.insert, align 4, !tbaa !5
%cmp60.not.6 = icmp eq i32 %.pre160, 1
br i1 %cmp60.not.6, label %for.cond53.6, label %for.inc66.6
for.cond53.6: ; preds = %for.cond53.1.5, %for.inc66.5
%44 = load i32, ptr %arrayidx59.1.6, align 16, !tbaa !5
%cmp60.not.1.6 = icmp eq i32 %44, 1
br i1 %cmp60.not.1.6, label %for.cond53.1.6, label %for.inc66.7
for.cond53.1.6: ; preds = %for.cond53.6
%45 = load i32, ptr %arrayidx59.2.6, align 4, !tbaa !5
%cmp60.not.2.6 = icmp eq i32 %45, 1
%46 = load i32, ptr %arrayidx59.3.6, align 8
%cmp60.not.3.6 = icmp eq i32 %46, 1
%or.cond216 = select i1 %cmp60.not.2.6, i1 %cmp60.not.3.6, i1 false
%47 = load i32, ptr %arrayidx59.4.6, align 4
%cmp60.not.4.6 = icmp eq i32 %47, 1
%or.cond217 = select i1 %or.cond216, i1 %cmp60.not.4.6, i1 false
br i1 %or.cond217, label %DONE, label %for.cond53.7
for.inc66.6: ; preds = %for.cond53.5, %for.inc66.5
%.pre161 = load i32, ptr %arrayidx59.7.phi.trans.insert, align 16, !tbaa !5
%cmp60.not.7 = icmp eq i32 %.pre161, 1
br i1 %cmp60.not.7, label %for.cond53.7, label %for.inc66.7
for.cond53.7: ; preds = %for.cond53.1.6, %for.inc66.6
%48 = load i32, ptr %arrayidx59.1.7, align 4, !tbaa !5
%cmp60.not.1.7 = icmp eq i32 %48, 1
br i1 %cmp60.not.1.7, label %for.cond53.1.7, label %for.inc66.8
for.cond53.1.7: ; preds = %for.cond53.7
%49 = load i32, ptr %arrayidx59.2.7, align 8, !tbaa !5
%cmp60.not.2.7 = icmp eq i32 %49, 1
%50 = load i32, ptr %arrayidx59.3.7, align 4
%cmp60.not.3.7 = icmp eq i32 %50, 1
%or.cond218 = select i1 %cmp60.not.2.7, i1 %cmp60.not.3.7, i1 false
%51 = load i32, ptr %arrayidx59.4.7, align 16
%cmp60.not.4.7 = icmp eq i32 %51, 1
%or.cond219 = select i1 %or.cond218, i1 %cmp60.not.4.7, i1 false
br i1 %or.cond219, label %DONE, label %for.cond53.8
for.inc66.7: ; preds = %for.cond53.6, %for.inc66.6
%.pre162 = load i32, ptr %arrayidx59.8.phi.trans.insert, align 4, !tbaa !5
%cmp60.not.8 = icmp eq i32 %.pre162, 1
br i1 %cmp60.not.8, label %for.cond53.8, label %for.inc66.8
for.cond53.8: ; preds = %for.cond53.1.7, %for.inc66.7
%52 = load i32, ptr %arrayidx59.1.8, align 8, !tbaa !5
%cmp60.not.1.8 = icmp eq i32 %52, 1
br i1 %cmp60.not.1.8, label %for.cond53.1.8, label %if.end98
for.cond53.1.8: ; preds = %for.cond53.8
%53 = load i32, ptr %arrayidx59.2.8, align 4, !tbaa !5
%cmp60.not.2.8 = icmp eq i32 %53, 1
%54 = load i32, ptr %arrayidx59.3.8, align 16
%cmp60.not.3.8 = icmp eq i32 %54, 1
%or.cond220 = select i1 %cmp60.not.2.8, i1 %cmp60.not.3.8, i1 false
%55 = load i32, ptr %arrayidx59.4.8, align 4
%cmp60.not.4.8 = icmp eq i32 %55, 1
%or.cond221 = select i1 %or.cond220, i1 %cmp60.not.4.8, i1 false
br i1 %or.cond221, label %DONE, label %for.cond53.9
for.inc66.8: ; preds = %for.cond53.7, %for.inc66.7
%.pre163 = load i32, ptr %arrayidx59.9.phi.trans.insert, align 8, !tbaa !5
%cmp60.not.9 = icmp eq i32 %.pre163, 1
%56 = load i32, ptr %arrayidx59.1.9, align 4
%cmp60.not.1.9 = icmp eq i32 %56, 1
%or.cond222 = select i1 %cmp60.not.9, i1 %cmp60.not.1.9, i1 false
br i1 %or.cond222, label %for.cond53.1.9, label %if.end98
for.cond53.9: ; preds = %for.cond53.1.8
%.old = load i32, ptr %arrayidx59.1.9, align 4, !tbaa !5
%cmp60.not.1.9.old = icmp eq i32 %.old, 1
br i1 %cmp60.not.1.9.old, label %for.cond53.1.9, label %if.end98
for.cond53.1.9: ; preds = %for.inc66.8, %for.cond53.9
%57 = load i32, ptr %arrayidx59.2.9, align 16, !tbaa !5
%cmp60.not.2.9 = icmp eq i32 %57, 1
%58 = load i32, ptr %arrayidx59.3.9, align 4
%cmp60.not.3.9 = icmp eq i32 %58, 1
%or.cond224 = select i1 %cmp60.not.2.9, i1 %cmp60.not.3.9, i1 false
%59 = load i32, ptr %arrayidx24, align 8
%cmp60.not.4.9 = icmp eq i32 %59, 1
%or.cond226 = select i1 %or.cond224, i1 %cmp60.not.4.9, i1 false
br i1 %or.cond226, label %DONE, label %if.end98
for.cond76: ; preds = %for.inc26.4, %for.cond76
%indvars.iv = phi i64 [ %indvars.iv.next, %for.cond76 ], [ 1, %for.inc26.4 ]
%arrayidx78 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 %indvars.iv
%60 = load i32, ptr %arrayidx78, align 4, !tbaa !5
%cmp79 = icmp slt i32 %60, 2
%indvars.iv.next = add nuw i64 %indvars.iv, 1
br i1 %cmp79, label %for.cond76, label %for.cond85, !llvm.loop !9
for.cond85: ; preds = %for.cond76, %for.body87
%indvars.iv153 = phi i64 [ %indvars.iv.next154, %for.body87 ], [ %indvars.iv, %for.cond76 ]
%cmp86 = icmp ult i64 %indvars.iv153, 13
br i1 %cmp86, label %for.body87, label %DONE
for.body87: ; preds = %for.cond85
%indvars.iv.next154 = add nuw nsw i64 %indvars.iv153, 1
%arrayidx89 = getelementptr inbounds [17 x i32], ptr %card, i64 0, i64 %indvars.iv.next154
%61 = load i32, ptr %arrayidx89, align 4, !tbaa !5
%cmp90 = icmp eq i32 %61, 2
br i1 %cmp90, label %DONE, label %for.cond85, !llvm.loop !11
if.end98: ; preds = %for.inc26.4, %for.cond53.8, %for.cond53.1.9, %for.cond53.9, %for.inc66.8
br label %DONE
DONE: ; preds = %for.cond85, %for.body87, %for.cond53.1, %for.cond53.1.1, %for.cond53.1.2, %for.cond53.1.3, %for.cond53.1.4, %for.cond53.1.5, %for.cond53.1.6, %for.cond53.1.7, %for.cond53.1.8, %for.cond53.1.9, %for.body37.preheader, %for.inc26.4, %if.end98
%.str.7.sink = phi ptr [ @.str.7, %if.end98 ], [ @.str.1, %for.inc26.4 ], [ %.str.2..str.4, %for.body37.preheader ], [ @.str.3, %for.cond53.1.9 ], [ @.str.3, %for.cond53.1.8 ], [ @.str.3, %for.cond53.1.7 ], [ @.str.3, %for.cond53.1.6 ], [ @.str.3, %for.cond53.1.5 ], [ @.str.3, %for.cond53.1.4 ], [ @.str.3, %for.cond53.1.3 ], [ @.str.3, %for.cond53.1.2 ], [ @.str.3, %for.cond53.1.1 ], [ @.str.3, %for.cond53.1 ], [ @.str.5, %for.body87 ], [ @.str.6, %for.cond85 ]
%call99 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.7.sink)
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %d, ptr noundef nonnull %arrayidx1, ptr noundef nonnull %arrayidx2, ptr noundef nonnull %arrayidx3, ptr noundef nonnull %arrayidx4)
%cmp = icmp eq i32 %call, 5
br i1 %cmp, label %for.cond.preheader, label %while.end, !llvm.loop !12
while.end: ; preds = %DONE, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %d) #4
call void @llvm.lifetime.end.p0(i64 68, ptr nonnull %card) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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) #3
attributes #0 = { nofree 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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
|
#include <stdio.h>
void sort(int array[], const int size) {
int i, last, sorted = size;
while(sorted) {
last = 0;
for(i = 0; i < sorted - 1; ++i) {
if(array[i] > array[i + 1]) {
int temp = array[i];
array[i] = array[i + 1];
array[i + 1] = temp;
last = i + 1;
}
}
sorted = last;
}
}
int main() {
int pair;
int three_card;
int four_card;
int straight;
int flag;
int continue_sum;
int prev;
int temp;
int input[5];
int i;
while(scanf("%d", &input[0]) != EOF) {
for(i = 1; i < 5; i++)
scanf(",%d", &input[i]);
pair = three_card = four_card = straight = flag = 0;
prev = -1;
sort(input, 5);
for(i = 0; i < 5; i++) {
if(prev == input[i]) {
if(flag && three_card) {
four_card++;
three_card--;
}
else if (flag) {
three_card++;
pair--;
}
else
pair++;
flag = 1;
}
else if(input[i] - prev == 1) {
straight++;
flag = 0;
}
else
flag = 0;
prev = input[i];
}
if(pair == 2)
printf("two pair\n");
else if(pair == 1) {
if(three_card)
printf("full house\n");
else
printf("one pair\n");
}
else if(four_card)
printf("four card\n");
else if(three_card)
printf("three card\n");
else if(straight == 4)
printf("straight\n");
else if(straight == 3) {
if(input[0] == 1 && input[4] == 13) {
if(input[1] == 2 && input[3] != 12)
printf("straight\n");
else if(input[1] != 2 && input[3] == 12)
printf("straight\n");
else
printf("null\n");
}
else printf("null\n");
}
else
printf("null\n");
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207824/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207824/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c",%d\00", align 1
@str.10 = private unnamed_addr constant [5 x i8] c"null\00", align 1
@str.13 = private unnamed_addr constant [9 x i8] c"straight\00", align 1
@str.14 = private unnamed_addr constant [11 x i8] c"three card\00", align 1
@str.15 = private unnamed_addr constant [10 x i8] c"four card\00", align 1
@str.16 = private unnamed_addr constant [9 x i8] c"one pair\00", align 1
@str.17 = private unnamed_addr constant [11 x i8] c"full house\00", align 1
@str.18 = private unnamed_addr constant [9 x i8] c"two pair\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @sort(ptr nocapture noundef %array, i32 noundef %size) local_unnamed_addr #0 {
entry:
%tobool.not33 = icmp eq i32 %size, 0
br i1 %tobool.not33, label %while.end, label %for.cond.preheader
while.cond.loopexit.unr-lcssa: ; preds = %for.inc.1, %for.body.preheader
%last.1.lcssa.ph = phi i32 [ undef, %for.body.preheader ], [ %last.1.1, %for.inc.1 ]
%.unr = phi i32 [ %.pre, %for.body.preheader ], [ %9, %for.inc.1 ]
%indvars.iv.unr = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next.1, %for.inc.1 ]
%last.031.unr = phi i32 [ 0, %for.body.preheader ], [ %last.1.1, %for.inc.1 ]
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br i1 %lcmp.mod.not, label %while.cond.loopexit, label %for.body.epil
for.body.epil: ; preds = %while.cond.loopexit.unr-lcssa
%indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.unr, 1
%arrayidx2.epil = getelementptr inbounds i32, ptr %array, i64 %indvars.iv.next.epil
%0 = load i32, ptr %arrayidx2.epil, align 4, !tbaa !5
%cmp3.epil = icmp sgt i32 %.unr, %0
br i1 %cmp3.epil, label %if.then.epil, label %while.cond.loopexit
if.then.epil: ; preds = %for.body.epil
%arrayidx.epil = getelementptr inbounds i32, ptr %array, i64 %indvars.iv.unr
store i32 %0, ptr %arrayidx.epil, align 4, !tbaa !5
store i32 %.unr, ptr %arrayidx2.epil, align 4, !tbaa !5
%1 = trunc i64 %indvars.iv.next.epil to i32
br label %while.cond.loopexit
while.cond.loopexit: ; preds = %for.body.epil, %if.then.epil, %while.cond.loopexit.unr-lcssa
%last.1.lcssa = phi i32 [ %last.1.lcssa.ph, %while.cond.loopexit.unr-lcssa ], [ %1, %if.then.epil ], [ %last.031.unr, %for.body.epil ]
%tobool.not = icmp eq i32 %last.1.lcssa, 0
br i1 %tobool.not, label %while.end, label %for.cond.preheader, !llvm.loop !9
for.cond.preheader: ; preds = %entry, %while.cond.loopexit
%sorted.034 = phi i32 [ %last.1.lcssa, %while.cond.loopexit ], [ %size, %entry ]
%cmp30 = icmp sgt i32 %sorted.034, 1
br i1 %cmp30, label %for.body.preheader, label %while.end
for.body.preheader: ; preds = %for.cond.preheader
%sub = add i32 %sorted.034, -1
%wide.trip.count = zext i32 %sub to i64
%.pre = load i32, ptr %array, align 4, !tbaa !5
%xtraiter = and i64 %wide.trip.count, 1
%2 = icmp eq i32 %sub, 1
br i1 %2, label %while.cond.loopexit.unr-lcssa, label %for.body.preheader.new
for.body.preheader.new: ; preds = %for.body.preheader
%unroll_iter = and i64 %wide.trip.count, 4294967294
br label %for.body
for.body: ; preds = %for.inc.1, %for.body.preheader.new
%3 = phi i32 [ %.pre, %for.body.preheader.new ], [ %9, %for.inc.1 ]
%indvars.iv = phi i64 [ 0, %for.body.preheader.new ], [ %indvars.iv.next.1, %for.inc.1 ]
%last.031 = phi i32 [ 0, %for.body.preheader.new ], [ %last.1.1, %for.inc.1 ]
%niter = phi i64 [ 0, %for.body.preheader.new ], [ %niter.next.1, %for.inc.1 ]
%indvars.iv.next = or i64 %indvars.iv, 1
%arrayidx2 = getelementptr inbounds i32, ptr %array, i64 %indvars.iv.next
%4 = load i32, ptr %arrayidx2, align 4, !tbaa !5
%cmp3 = icmp sgt i32 %3, %4
br i1 %cmp3, label %if.then, label %for.inc
if.then: ; preds = %for.body
%arrayidx = getelementptr inbounds i32, ptr %array, i64 %indvars.iv
store i32 %4, ptr %arrayidx, align 4, !tbaa !5
store i32 %3, ptr %arrayidx2, align 4, !tbaa !5
%5 = trunc i64 %indvars.iv.next to i32
br label %for.inc
for.inc: ; preds = %for.body, %if.then
%6 = phi i32 [ %3, %if.then ], [ %4, %for.body ]
%last.1 = phi i32 [ %5, %if.then ], [ %last.031, %for.body ]
%indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
%arrayidx2.1 = getelementptr inbounds i32, ptr %array, i64 %indvars.iv.next.1
%7 = load i32, ptr %arrayidx2.1, align 4, !tbaa !5
%cmp3.1 = icmp sgt i32 %6, %7
br i1 %cmp3.1, label %if.then.1, label %for.inc.1
if.then.1: ; preds = %for.inc
%arrayidx.1 = getelementptr inbounds i32, ptr %array, i64 %indvars.iv.next
store i32 %7, ptr %arrayidx.1, align 4, !tbaa !5
store i32 %6, ptr %arrayidx2.1, align 4, !tbaa !5
%8 = trunc i64 %indvars.iv.next.1 to i32
br label %for.inc.1
for.inc.1: ; preds = %if.then.1, %for.inc
%9 = phi i32 [ %6, %if.then.1 ], [ %7, %for.inc ]
%last.1.1 = phi i32 [ %8, %if.then.1 ], [ %last.1, %for.inc ]
%niter.next.1 = add i64 %niter, 2
%niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
br i1 %niter.ncmp.1, label %while.cond.loopexit.unr-lcssa, label %for.body, !llvm.loop !11
while.end: ; preds = %while.cond.loopexit, %for.cond.preheader, %entry
ret void
}
; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #2 {
entry:
%input = alloca [5 x i32], align 16
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %input) #5
%call137 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %input)
%cmp.not138 = icmp eq i32 %call137, -1
br i1 %cmp.not138, label %while.end, label %for.cond.preheader.lr.ph
for.cond.preheader.lr.ph: ; preds = %entry
%arrayidx64 = getelementptr inbounds [5 x i32], ptr %input, i64 0, i64 4
%arrayidx67 = getelementptr inbounds [5 x i32], ptr %input, i64 0, i64 1
%arrayidx70 = getelementptr inbounds [5 x i32], ptr %input, i64 0, i64 3
%arrayidx2.1 = getelementptr inbounds [5 x i32], ptr %input, i64 0, i64 2
br label %for.cond.preheader
for.cond.preheader: ; preds = %for.cond.preheader.lr.ph, %if.end96
%call3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %arrayidx67)
%call3.1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %arrayidx2.1)
%call3.2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %arrayidx70)
%call3.3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %arrayidx64)
br label %for.cond.preheader.i
while.cond.loopexit.i.unr-lcssa: ; preds = %for.inc.i.1, %for.body.preheader.i
%last.1.i.lcssa.ph = phi i32 [ undef, %for.body.preheader.i ], [ %last.1.i.1, %for.inc.i.1 ]
%.unr = phi i32 [ %.pre141, %for.body.preheader.i ], [ %9, %for.inc.i.1 ]
%indvars.iv.i.unr = phi i64 [ 0, %for.body.preheader.i ], [ %indvars.iv.next.i.1, %for.inc.i.1 ]
%last.031.i.unr = phi i32 [ 0, %for.body.preheader.i ], [ %last.1.i.1, %for.inc.i.1 ]
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br i1 %lcmp.mod.not, label %while.cond.loopexit.i, label %for.body.i.epil
for.body.i.epil: ; preds = %while.cond.loopexit.i.unr-lcssa
%indvars.iv.next.i.epil = add nuw nsw i64 %indvars.iv.i.unr, 1
%arrayidx2.i.epil = getelementptr inbounds i32, ptr %input, i64 %indvars.iv.next.i.epil
%0 = load i32, ptr %arrayidx2.i.epil, align 4, !tbaa !5
%cmp3.i.epil = icmp sgt i32 %.unr, %0
br i1 %cmp3.i.epil, label %if.then.i.epil, label %while.cond.loopexit.i
if.then.i.epil: ; preds = %for.body.i.epil
%arrayidx.i.epil = getelementptr inbounds i32, ptr %input, i64 %indvars.iv.i.unr
store i32 %0, ptr %arrayidx.i.epil, align 4, !tbaa !5
store i32 %.unr, ptr %arrayidx2.i.epil, align 4, !tbaa !5
%1 = trunc i64 %indvars.iv.next.i.epil to i32
br label %while.cond.loopexit.i
while.cond.loopexit.i: ; preds = %for.body.i.epil, %if.then.i.epil, %while.cond.loopexit.i.unr-lcssa
%last.1.i.lcssa = phi i32 [ %last.1.i.lcssa.ph, %while.cond.loopexit.i.unr-lcssa ], [ %1, %if.then.i.epil ], [ %last.031.i.unr, %for.body.i.epil ]
%tobool.not.i = icmp eq i32 %last.1.i.lcssa, 0
br i1 %tobool.not.i, label %while.cond.loopexit.i.sort.exit_crit_edge, label %for.cond.preheader.i, !llvm.loop !9
while.cond.loopexit.i.sort.exit_crit_edge: ; preds = %while.cond.loopexit.i
%.pre = load i32, ptr %input, align 16, !tbaa !5
br label %sort.exit
for.cond.preheader.i: ; preds = %for.cond.preheader, %while.cond.loopexit.i
%sorted.034.i = phi i32 [ %last.1.i.lcssa, %while.cond.loopexit.i ], [ 5, %for.cond.preheader ]
%cmp30.i = icmp sgt i32 %sorted.034.i, 1
%.pre141 = load i32, ptr %input, align 16, !tbaa !5
br i1 %cmp30.i, label %for.body.preheader.i, label %sort.exit
for.body.preheader.i: ; preds = %for.cond.preheader.i
%sub.i = add i32 %sorted.034.i, -1
%wide.trip.count.i = zext i32 %sub.i to i64
%xtraiter = and i64 %wide.trip.count.i, 1
%2 = icmp eq i32 %sub.i, 1
br i1 %2, label %while.cond.loopexit.i.unr-lcssa, label %for.body.preheader.i.new
for.body.preheader.i.new: ; preds = %for.body.preheader.i
%unroll_iter = and i64 %wide.trip.count.i, 4294967294
br label %for.body.i
for.body.i: ; preds = %for.inc.i.1, %for.body.preheader.i.new
%3 = phi i32 [ %.pre141, %for.body.preheader.i.new ], [ %9, %for.inc.i.1 ]
%indvars.iv.i = phi i64 [ 0, %for.body.preheader.i.new ], [ %indvars.iv.next.i.1, %for.inc.i.1 ]
%last.031.i = phi i32 [ 0, %for.body.preheader.i.new ], [ %last.1.i.1, %for.inc.i.1 ]
%niter = phi i64 [ 0, %for.body.preheader.i.new ], [ %niter.next.1, %for.inc.i.1 ]
%indvars.iv.next.i = or i64 %indvars.iv.i, 1
%arrayidx2.i = getelementptr inbounds i32, ptr %input, i64 %indvars.iv.next.i
%4 = load i32, ptr %arrayidx2.i, align 4, !tbaa !5
%cmp3.i = icmp sgt i32 %3, %4
br i1 %cmp3.i, label %if.then.i, label %for.inc.i
if.then.i: ; preds = %for.body.i
%arrayidx.i = getelementptr inbounds i32, ptr %input, i64 %indvars.iv.i
store i32 %4, ptr %arrayidx.i, align 8, !tbaa !5
store i32 %3, ptr %arrayidx2.i, align 4, !tbaa !5
%5 = trunc i64 %indvars.iv.next.i to i32
br label %for.inc.i
for.inc.i: ; preds = %if.then.i, %for.body.i
%6 = phi i32 [ %3, %if.then.i ], [ %4, %for.body.i ]
%last.1.i = phi i32 [ %5, %if.then.i ], [ %last.031.i, %for.body.i ]
%indvars.iv.next.i.1 = add nuw nsw i64 %indvars.iv.i, 2
%arrayidx2.i.1 = getelementptr inbounds i32, ptr %input, i64 %indvars.iv.next.i.1
%7 = load i32, ptr %arrayidx2.i.1, align 8, !tbaa !5
%cmp3.i.1 = icmp sgt i32 %6, %7
br i1 %cmp3.i.1, label %if.then.i.1, label %for.inc.i.1
if.then.i.1: ; preds = %for.inc.i
%arrayidx.i.1 = getelementptr inbounds i32, ptr %input, i64 %indvars.iv.next.i
store i32 %7, ptr %arrayidx.i.1, align 4, !tbaa !5
store i32 %6, ptr %arrayidx2.i.1, align 8, !tbaa !5
%8 = trunc i64 %indvars.iv.next.i.1 to i32
br label %for.inc.i.1
for.inc.i.1: ; preds = %if.then.i.1, %for.inc.i
%9 = phi i32 [ %6, %if.then.i.1 ], [ %7, %for.inc.i ]
%last.1.i.1 = phi i32 [ %8, %if.then.i.1 ], [ %last.1.i, %for.inc.i ]
%niter.next.1 = add i64 %niter, 2
%niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
br i1 %niter.ncmp.1, label %while.cond.loopexit.i.unr-lcssa, label %for.body.i, !llvm.loop !11
sort.exit: ; preds = %for.cond.preheader.i, %while.cond.loopexit.i.sort.exit_crit_edge
%10 = phi i32 [ %.pre, %while.cond.loopexit.i.sort.exit_crit_edge ], [ %.pre141, %for.cond.preheader.i ]
%cmp9.not = icmp eq i32 %10, -1
br i1 %cmp9.not, label %if.end28, label %if.end28.thread
if.end28: ; preds = %sort.exit
%11 = load i32, ptr %arrayidx67, align 4, !tbaa !5
%cmp9.1 = icmp eq i32 %10, %11
br i1 %cmp9.1, label %if.end28.1, label %if.else20.1
if.end28.thread: ; preds = %sort.exit
%cmp23 = icmp eq i32 %10, 0
%inc25 = zext i1 %cmp23 to i32
%12 = load i32, ptr %arrayidx67, align 4, !tbaa !5
%cmp9.1144 = icmp eq i32 %10, %12
br i1 %cmp9.1144, label %if.end28.1, label %if.else20.1
if.else20.1: ; preds = %if.end28.thread, %if.end28
%13 = phi i32 [ %12, %if.end28.thread ], [ %11, %if.end28 ]
%flag.1148 = phi i32 [ 0, %if.end28.thread ], [ 1, %if.end28 ]
%straight.1145 = phi i32 [ %inc25, %if.end28.thread ], [ 0, %if.end28 ]
%sub.1 = sub nsw i32 %13, %10
%cmp23.1 = icmp eq i32 %sub.1, 1
%inc25.1 = zext i1 %cmp23.1 to i32
%spec.select.1 = add nuw nsw i32 %straight.1145, %inc25.1
br label %if.end28.1
if.end28.1: ; preds = %if.end28, %if.end28.thread, %if.else20.1
%cmp9.1149 = phi i1 [ false, %if.else20.1 ], [ true, %if.end28.thread ], [ true, %if.end28 ]
%14 = phi i32 [ %13, %if.else20.1 ], [ %12, %if.end28.thread ], [ %11, %if.end28 ]
%straight.1.1 = phi i32 [ %spec.select.1, %if.else20.1 ], [ %inc25, %if.end28.thread ], [ 0, %if.end28 ]
%tobool10.2 = phi i1 [ false, %if.else20.1 ], [ false, %if.end28.thread ], [ true, %if.end28 ]
%three_card.2.1 = phi i32 [ 0, %if.else20.1 ], [ 0, %if.end28.thread ], [ 1, %if.end28 ]
%pair.2.1 = phi i32 [ %flag.1148, %if.else20.1 ], [ 1, %if.end28.thread ], [ 0, %if.end28 ]
%15 = load i32, ptr %arrayidx2.1, align 8, !tbaa !5
%cmp9.2 = icmp eq i32 %14, %15
br i1 %cmp9.2, label %if.then.2, label %if.else20.2
if.else20.2: ; preds = %if.end28.1
%sub.2 = sub nsw i32 %15, %14
%cmp23.2 = icmp eq i32 %sub.2, 1
%inc25.2 = zext i1 %cmp23.2 to i32
%spec.select.2 = add nuw nsw i32 %straight.1.1, %inc25.2
br label %if.end28.2
if.then.2: ; preds = %if.end28.1
%or.cond.2 = and i1 %cmp9.1149, %tobool10.2
br i1 %or.cond.2, label %if.then11.2, label %if.else.2
if.else.2: ; preds = %if.then.2
br i1 %cmp9.1149, label %if.then14.2, label %if.else17.2
if.else17.2: ; preds = %if.else.2
%inc18.2 = add nuw nsw i32 %pair.2.1, 1
br label %if.end28.2
if.then14.2: ; preds = %if.else.2
%inc15.2 = add nuw nsw i32 %three_card.2.1, 1
%dec16.2 = add nsw i32 %pair.2.1, -1
br label %if.end28.2
if.then11.2: ; preds = %if.then.2
%dec.2 = add nsw i32 %three_card.2.1, -1
br label %if.end28.2
if.end28.2: ; preds = %if.then11.2, %if.then14.2, %if.else17.2, %if.else20.2
%four_card.2.2 = phi i32 [ 1, %if.then11.2 ], [ 0, %if.then14.2 ], [ 0, %if.else17.2 ], [ 0, %if.else20.2 ]
%straight.1.2 = phi i32 [ %straight.1.1, %if.then11.2 ], [ %straight.1.1, %if.then14.2 ], [ %straight.1.1, %if.else17.2 ], [ %spec.select.2, %if.else20.2 ]
%three_card.2.2 = phi i32 [ %dec.2, %if.then11.2 ], [ %inc15.2, %if.then14.2 ], [ %three_card.2.1, %if.else17.2 ], [ %three_card.2.1, %if.else20.2 ]
%pair.2.2 = phi i32 [ %pair.2.1, %if.then11.2 ], [ %dec16.2, %if.then14.2 ], [ %inc18.2, %if.else17.2 ], [ %pair.2.1, %if.else20.2 ]
%16 = load i32, ptr %arrayidx70, align 4
%cmp9.3 = icmp eq i32 %15, %16
br i1 %cmp9.3, label %if.then.3, label %if.else20.3
if.else20.3: ; preds = %if.end28.2
%sub.3 = sub nsw i32 %16, %15
%cmp23.3 = icmp eq i32 %sub.3, 1
%inc25.3 = zext i1 %cmp23.3 to i32
%spec.select.3 = add nuw nsw i32 %straight.1.2, %inc25.3
br label %if.end28.3
if.then.3: ; preds = %if.end28.2
%tobool10.3 = icmp ne i32 %three_card.2.2, 0
%or.cond.3 = select i1 %cmp9.2, i1 %tobool10.3, i1 false
br i1 %or.cond.3, label %if.then11.3, label %if.else.3
if.else.3: ; preds = %if.then.3
br i1 %cmp9.2, label %if.then14.3, label %if.else17.3
if.else17.3: ; preds = %if.else.3
%inc18.3 = add nsw i32 %pair.2.2, 1
br label %if.end28.3
if.then14.3: ; preds = %if.else.3
%inc15.3 = add nsw i32 %three_card.2.2, 1
%dec16.3 = add nsw i32 %pair.2.2, -1
br label %if.end28.3
if.then11.3: ; preds = %if.then.3
%inc12.3 = add nuw nsw i32 %four_card.2.2, 1
%dec.3 = add nsw i32 %three_card.2.2, -1
br label %if.end28.3
if.end28.3: ; preds = %if.then11.3, %if.then14.3, %if.else17.3, %if.else20.3
%four_card.2.3 = phi i32 [ %inc12.3, %if.then11.3 ], [ %four_card.2.2, %if.then14.3 ], [ %four_card.2.2, %if.else17.3 ], [ %four_card.2.2, %if.else20.3 ]
%straight.1.3 = phi i32 [ %straight.1.2, %if.then11.3 ], [ %straight.1.2, %if.then14.3 ], [ %straight.1.2, %if.else17.3 ], [ %spec.select.3, %if.else20.3 ]
%three_card.2.3 = phi i32 [ %dec.3, %if.then11.3 ], [ %inc15.3, %if.then14.3 ], [ %three_card.2.2, %if.else17.3 ], [ %three_card.2.2, %if.else20.3 ]
%pair.2.3 = phi i32 [ %pair.2.2, %if.then11.3 ], [ %dec16.3, %if.then14.3 ], [ %inc18.3, %if.else17.3 ], [ %pair.2.2, %if.else20.3 ]
%17 = load i32, ptr %arrayidx64, align 16
%cmp9.4 = icmp eq i32 %16, %17
br i1 %cmp9.4, label %if.then.4, label %if.else20.4
if.else20.4: ; preds = %if.end28.3
%sub.4 = sub nsw i32 %17, %16
%cmp23.4 = icmp eq i32 %sub.4, 1
%inc25.4 = zext i1 %cmp23.4 to i32
%spec.select.4 = add nuw nsw i32 %straight.1.3, %inc25.4
br label %if.end28.4
if.then.4: ; preds = %if.end28.3
%tobool10.4 = icmp ne i32 %three_card.2.3, 0
%or.cond.4 = select i1 %cmp9.3, i1 %tobool10.4, i1 false
br i1 %or.cond.4, label %if.then11.4, label %if.else.4
if.else.4: ; preds = %if.then.4
br i1 %cmp9.3, label %if.then14.4, label %if.else17.4
if.else17.4: ; preds = %if.else.4
%inc18.4 = add nsw i32 %pair.2.3, 1
br label %if.end28.4
if.then14.4: ; preds = %if.else.4
%inc15.4 = add nsw i32 %three_card.2.3, 1
%dec16.4 = add nsw i32 %pair.2.3, -1
br label %if.end28.4
if.then11.4: ; preds = %if.then.4
%dec.4 = add nsw i32 %three_card.2.3, -1
br label %if.end28.4
if.end28.4: ; preds = %if.then11.4, %if.then14.4, %if.else17.4, %if.else20.4
%four_card.2.4 = phi i32 [ 1, %if.then11.4 ], [ %four_card.2.3, %if.then14.4 ], [ %four_card.2.3, %if.else17.4 ], [ %four_card.2.3, %if.else20.4 ]
%straight.1.4 = phi i32 [ %straight.1.3, %if.then11.4 ], [ %straight.1.3, %if.then14.4 ], [ %straight.1.3, %if.else17.4 ], [ %spec.select.4, %if.else20.4 ]
%three_card.2.4 = phi i32 [ %dec.4, %if.then11.4 ], [ %inc15.4, %if.then14.4 ], [ %three_card.2.3, %if.else17.4 ], [ %three_card.2.3, %if.else20.4 ]
%pair.2.4 = phi i32 [ %pair.2.3, %if.then11.4 ], [ %dec16.4, %if.then14.4 ], [ %inc18.4, %if.else17.4 ], [ %pair.2.3, %if.else20.4 ]
switch i32 %pair.2.4, label %if.else46 [
i32 2, label %if.end96
i32 1, label %if.then39
]
if.then39: ; preds = %if.end28.4
%tobool40.not = icmp eq i32 %three_card.2.4, 0
%str.16.str.17 = select i1 %tobool40.not, ptr @str.16, ptr @str.17
br label %if.end96
if.else46: ; preds = %if.end28.4
%tobool47.not = icmp eq i32 %four_card.2.4, 0
br i1 %tobool47.not, label %if.else50, label %if.end96
if.else50: ; preds = %if.else46
%tobool51.not = icmp eq i32 %three_card.2.4, 0
br i1 %tobool51.not, label %if.else54, label %if.end96
if.else54: ; preds = %if.else50
switch i32 %straight.1.4, label %if.else89 [
i32 4, label %if.end96
i32 3, label %if.then60
]
if.then60: ; preds = %if.else54
%cmp62 = icmp eq i32 %10, 1
%cmp65 = icmp eq i32 %17, 13
%or.cond97 = and i1 %cmp62, %cmp65
br i1 %or.cond97, label %if.then66, label %if.end96
if.then66: ; preds = %if.then60
%cmp68 = icmp eq i32 %14, 2
%cmp71 = icmp ne i32 %16, 12
%or.cond98 = and i1 %cmp68, %cmp71
br i1 %or.cond98, label %if.end96, label %if.else74
if.else74: ; preds = %if.then66
%cmp76 = icmp ne i32 %14, 2
%cmp79 = icmp eq i32 %16, 12
%or.cond99 = and i1 %cmp76, %cmp79
%str.11.str.10 = select i1 %or.cond99, ptr @str.13, ptr @str.10
br label %if.end96
if.else89: ; preds = %if.else54
br label %if.end96
if.end96: ; preds = %if.then60, %if.else74, %if.then66, %if.else54, %if.else50, %if.else46, %if.then39, %if.end28.4, %if.else89
%str.16.sink = phi ptr [ @str.10, %if.else89 ], [ @str.18, %if.end28.4 ], [ %str.16.str.17, %if.then39 ], [ @str.15, %if.else46 ], [ @str.14, %if.else50 ], [ @str.13, %if.else54 ], [ @str.13, %if.then66 ], [ %str.11.str.10, %if.else74 ], [ @str.10, %if.then60 ]
%puts126 = call i32 @puts(ptr nonnull dereferenceable(1) %str.16.sink)
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %input)
%cmp.not = icmp eq i32 %call, -1
br i1 %cmp.not, label %while.end, label %for.cond.preheader, !llvm.loop !12
while.end: ; preds = %if.end96, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %input) #5
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #4
attributes #0 = { nofree norecurse nosync nounwind memory(argmem: 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree 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 = { 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 #4 = { nofree nounwind }
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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
|
#include <stdio.h>
#include <math.h>
int main(void){
int ans=-1,i,K,a[1000001];
scanf("%d",&K);
a[1]=7%K;
for(i=2;i<=K;i++){
a[i] = (a[i-1]*10 + 7) % K;
}
for(i=1;i<=K;i++){
if(a[i]==0){
ans = i;
break;
}
}
printf("%d\n",ans);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207882/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207882/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%K = alloca i32, align 4
%a = alloca [1000001 x i32], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %K) #3
call void @llvm.lifetime.start.p0(i64 4000004, ptr nonnull %a) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %K)
%0 = load i32, ptr %K, align 4, !tbaa !5
%rem = srem i32 7, %0
%arrayidx = getelementptr inbounds [1000001 x i32], ptr %a, i64 0, i64 1
store i32 %rem, ptr %arrayidx, align 4, !tbaa !5
%cmp.not22 = icmp slt i32 %0, 2
br i1 %cmp.not22, label %for.cond5.preheader, label %for.body.preheader
for.body.preheader: ; preds = %entry
%1 = add nuw i32 %0, 1
%wide.trip.count = zext i32 %1 to i64
%xtraiter = and i64 %wide.trip.count, 1
%2 = icmp eq i32 %1, 3
br i1 %2, label %for.cond5.preheader.loopexit.unr-lcssa, label %for.body.preheader.new
for.body.preheader.new: ; preds = %for.body.preheader
%3 = and i64 %wide.trip.count, 4294967294
%4 = add nsw i64 %3, -4
br label %for.body
for.cond5.preheader.loopexit.unr-lcssa: ; preds = %for.body, %for.body.preheader
%.unr = phi i32 [ %rem, %for.body.preheader ], [ %rem2.1, %for.body ]
%indvars.iv.unr = phi i64 [ 2, %for.body.preheader ], [ %indvars.iv.next.1, %for.body ]
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br i1 %lcmp.mod.not, label %for.cond5.preheader, label %for.body.epil
for.body.epil: ; preds = %for.cond5.preheader.loopexit.unr-lcssa
%mul.epil = mul nsw i32 %.unr, 10
%add.epil = add nsw i32 %mul.epil, 7
%rem2.epil = srem i32 %add.epil, %0
%arrayidx4.epil = getelementptr inbounds [1000001 x i32], ptr %a, i64 0, i64 %indvars.iv.unr
store i32 %rem2.epil, ptr %arrayidx4.epil, align 4, !tbaa !5
br label %for.cond5.preheader
for.cond5.preheader: ; preds = %for.body.epil, %for.cond5.preheader.loopexit.unr-lcssa, %entry
%cmp6.not24 = icmp slt i32 %0, 1
br i1 %cmp6.not24, label %for.end13, label %for.body7.preheader
for.body7.preheader: ; preds = %for.cond5.preheader
%5 = add nuw i32 %0, 1
%wide.trip.count32 = zext i32 %5 to i64
br label %for.body7
for.body: ; preds = %for.body, %for.body.preheader.new
%6 = phi i32 [ %rem, %for.body.preheader.new ], [ %rem2.1, %for.body ]
%indvars.iv = phi i64 [ 2, %for.body.preheader.new ], [ %indvars.iv.next.1, %for.body ]
%niter = phi i64 [ 0, %for.body.preheader.new ], [ %niter.next.1, %for.body ]
%mul = mul nsw i32 %6, 10
%add = add nsw i32 %mul, 7
%rem2 = srem i32 %add, %0
%arrayidx4 = getelementptr inbounds [1000001 x i32], ptr %a, i64 0, i64 %indvars.iv
store i32 %rem2, ptr %arrayidx4, align 8, !tbaa !5
%indvars.iv.next = or i64 %indvars.iv, 1
%mul.1 = mul nsw i32 %rem2, 10
%add.1 = add nsw i32 %mul.1, 7
%rem2.1 = srem i32 %add.1, %0
%arrayidx4.1 = getelementptr inbounds [1000001 x i32], ptr %a, i64 0, i64 %indvars.iv.next
store i32 %rem2.1, ptr %arrayidx4.1, align 4, !tbaa !5
%indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
%niter.next.1 = add i64 %niter, 2
%niter.ncmp.1 = icmp eq i64 %niter, %4
br i1 %niter.ncmp.1, label %for.cond5.preheader.loopexit.unr-lcssa, label %for.body, !llvm.loop !9
for.body7: ; preds = %for.body7.preheader, %for.inc11
%indvars.iv29 = phi i64 [ 1, %for.body7.preheader ], [ %indvars.iv.next30, %for.inc11 ]
%arrayidx9 = getelementptr inbounds [1000001 x i32], ptr %a, i64 0, i64 %indvars.iv29
%7 = load i32, ptr %arrayidx9, align 4, !tbaa !5
%cmp10 = icmp eq i32 %7, 0
br i1 %cmp10, label %for.end13.loopexit.split.loop.exit, label %for.inc11
for.inc11: ; preds = %for.body7
%indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
%exitcond33.not = icmp eq i64 %indvars.iv.next30, %wide.trip.count32
br i1 %exitcond33.not, label %for.end13, label %for.body7, !llvm.loop !11
for.end13.loopexit.split.loop.exit: ; preds = %for.body7
%8 = trunc i64 %indvars.iv29 to i32
br label %for.end13
for.end13: ; preds = %for.inc11, %for.end13.loopexit.split.loop.exit, %for.cond5.preheader
%ans.0 = phi i32 [ -1, %for.cond5.preheader ], [ %8, %for.end13.loopexit.split.loop.exit ], [ -1, %for.inc11 ]
%call14 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %ans.0)
call void @llvm.lifetime.end.p0(i64 4000004, ptr nonnull %a) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %K) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
|
#include<stdio.h>
int main(){
long long n,i,k,a=7;
scanf("%lld",&k);
for(i=0;i<k;i++){
if(a%k==0){
printf("%lld\n",i+1);
return 0;
}
a=a%k;
a=a*10+7;
}
printf("-1\n");
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_207969/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_207969/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [5 x i8] c"%lld\00", align 1
@.str.1 = private unnamed_addr constant [6 x i8] c"%lld\0A\00", align 1
@str = private unnamed_addr constant [3 x i8] c"-1\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%k = alloca i64, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %k) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %k)
%0 = load i64, ptr %k, align 8, !tbaa !5
%cmp14 = icmp sgt i64 %0, 0
br i1 %cmp14, label %for.body, label %for.end
for.body: ; preds = %entry, %if.end
%a.016 = phi i64 [ %add4, %if.end ], [ 7, %entry ]
%i.015 = phi i64 [ %inc, %if.end ], [ 0, %entry ]
%rem = srem i64 %a.016, %0
%cmp1 = icmp eq i64 %rem, 0
br i1 %cmp1, label %if.then, label %if.end
if.then: ; preds = %for.body
%add = add nuw nsw i64 %i.015, 1
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %add)
br label %cleanup
if.end: ; preds = %for.body
%mul = mul nsw i64 %rem, 10
%add4 = add nsw i64 %mul, 7
%inc = add nuw nsw i64 %i.015, 1
%exitcond.not = icmp eq i64 %inc, %0
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !9
for.end: ; preds = %if.end, %entry
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %cleanup
cleanup: ; preds = %for.end, %if.then
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %k) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
attributes #0 = { nofree 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 = { 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 = { nofree nounwind }
attributes #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
#include<stdio.h>
void quicksort(int i,int j,int *A);
int partition(int i,int j,int a,int *A);
int pivot(int i,int j,int *A);
void swap(int i,int j,int *A);
int main(void){
int N,K,i;
long total = 0;
int h[200009];
scanf("%d %d\n",&N,&K );
for(i=0; i<N; i++){
scanf("%d",&h[i] );
}
quicksort(0,N-1,h);
for(i=0;i<N-K;i++ ){
total += h[i];
}
printf("%ld\n",total );
return 0;
}
void quicksort(int i,int j,int *A){
int a,pv,k;
pv = pivot(i,j,A);
if(pv != -1){
a = A[pv];
k = partition(i,j,a,A);
quicksort(i,k-1,A);
quicksort(k,j,A);
}
}
int partition(int i,int j,int a,int *A){
int l,r,k;
l = i;
r = j;
while(1){
while(A[l] < a) l++;
while(A[r] >= a) r--;
if(l <= r){
swap(l, r, A);
l++;
r--;
}else break;
}
k = l;
return k;
}
int pivot(int i,int j,int *A){
int pv,k;
k = i+1;
while(k<=j && A[i] == A[k]) k++;
if(k > j) pv = -1;
else if(A[i] >= A[k]) pv = i;
else pv = k;
return pv;
}
void swap(int i,int j,int *A){
int tmp;
tmp = A[i];
A[i] = A[j];
A[j] = tmp;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208010/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208010/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [5 x i8] c"%ld\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%N = alloca i32, align 4
%K = alloca i32, align 4
%h = alloca [200009 x i32], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #8
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %K) #8
call void @llvm.lifetime.start.p0(i64 800036, ptr nonnull %h) #8
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N, ptr noundef nonnull %K)
%0 = load i32, ptr %N, align 4, !tbaa !5
%cmp18 = icmp sgt i32 %0, 0
br i1 %cmp18, label %for.body, label %for.end
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
%arrayidx = getelementptr inbounds [200009 x i32], ptr %h, i64 0, i64 %indvars.iv
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %arrayidx)
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%1 = load i32, ptr %N, align 4, !tbaa !5
%2 = sext i32 %1 to i64
%cmp = icmp slt i64 %indvars.iv.next, %2
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !9
for.end: ; preds = %for.body, %entry
%.lcssa = phi i32 [ %0, %entry ], [ %1, %for.body ]
%sub = add nsw i32 %.lcssa, -1
call void @quicksort(i32 noundef 0, i32 noundef %sub, ptr noundef nonnull %h)
%3 = load i32, ptr %K, align 4, !tbaa !5
%sub3 = sub nsw i32 %.lcssa, %3
%cmp420 = icmp sgt i32 %sub3, 0
br i1 %cmp420, label %for.body5.preheader, label %for.end10
for.body5.preheader: ; preds = %for.end
%wide.trip.count = zext i32 %sub3 to i64
%min.iters.check = icmp ult i32 %sub3, 4
br i1 %min.iters.check, label %for.body5.preheader33, label %vector.ph
vector.ph: ; preds = %for.body5.preheader
%n.vec = and i64 %wide.trip.count, 4294967292
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%vec.phi = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %8, %vector.body ]
%vec.phi31 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %9, %vector.body ]
%4 = getelementptr inbounds [200009 x i32], ptr %h, i64 0, i64 %index
%wide.load = load <2 x i32>, ptr %4, align 16, !tbaa !5
%5 = getelementptr inbounds i32, ptr %4, i64 2
%wide.load32 = load <2 x i32>, ptr %5, align 8, !tbaa !5
%6 = sext <2 x i32> %wide.load to <2 x i64>
%7 = sext <2 x i32> %wide.load32 to <2 x i64>
%8 = add <2 x i64> %vec.phi, %6
%9 = add <2 x i64> %vec.phi31, %7
%index.next = add nuw i64 %index, 4
%10 = icmp eq i64 %index.next, %n.vec
br i1 %10, label %middle.block, label %vector.body, !llvm.loop !11
middle.block: ; preds = %vector.body
%bin.rdx = add <2 x i64> %9, %8
%11 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count
br i1 %cmp.n, label %for.end10, label %for.body5.preheader33
for.body5.preheader33: ; preds = %for.body5.preheader, %middle.block
%indvars.iv26.ph = phi i64 [ 0, %for.body5.preheader ], [ %n.vec, %middle.block ]
%total.022.ph = phi i64 [ 0, %for.body5.preheader ], [ %11, %middle.block ]
br label %for.body5
for.body5: ; preds = %for.body5.preheader33, %for.body5
%indvars.iv26 = phi i64 [ %indvars.iv.next27, %for.body5 ], [ %indvars.iv26.ph, %for.body5.preheader33 ]
%total.022 = phi i64 [ %add, %for.body5 ], [ %total.022.ph, %for.body5.preheader33 ]
%arrayidx7 = getelementptr inbounds [200009 x i32], ptr %h, i64 0, i64 %indvars.iv26
%12 = load i32, ptr %arrayidx7, align 4, !tbaa !5
%conv = sext i32 %12 to i64
%add = add nsw i64 %total.022, %conv
%indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
%exitcond.not = icmp eq i64 %indvars.iv.next27, %wide.trip.count
br i1 %exitcond.not, label %for.end10, label %for.body5, !llvm.loop !14
for.end10: ; preds = %for.body5, %middle.block, %for.end
%total.0.lcssa = phi i64 [ 0, %for.end ], [ %11, %middle.block ], [ %add, %for.body5 ]
%call11 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %total.0.lcssa)
call void @llvm.lifetime.end.p0(i64 800036, ptr nonnull %h) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %K) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #8
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @quicksort(i32 noundef %i, i32 noundef %j, ptr nocapture noundef %A) local_unnamed_addr #3 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %partition.exit, %entry
%i.tr = phi i32 [ %i, %entry ], [ %9, %partition.exit ]
%idxprom.i = sext i32 %i.tr to i64
%arrayidx.i = getelementptr inbounds i32, ptr %A, i64 %idxprom.i
%smax.i = tail call i32 @llvm.smax.i32(i32 %j, i32 %i.tr)
%wide.trip.count.i = sext i32 %smax.i to i64
br label %while.cond.i
while.cond.i: ; preds = %land.rhs.i, %tailrecurse
%indvars.iv.i = phi i64 [ %indvars.iv.next.i, %land.rhs.i ], [ %idxprom.i, %tailrecurse ]
%exitcond.not.i = icmp eq i64 %indvars.iv.i, %wide.trip.count.i
br i1 %exitcond.not.i, label %if.end, label %land.rhs.i
land.rhs.i: ; preds = %while.cond.i
%indvars.iv.next.i = add nsw i64 %indvars.iv.i, 1
%0 = load i32, ptr %arrayidx.i, align 4, !tbaa !5
%arrayidx2.i = getelementptr inbounds i32, ptr %A, i64 %indvars.iv.next.i
%1 = load i32, ptr %arrayidx2.i, align 4, !tbaa !5
%cmp3.i = icmp eq i32 %0, %1
br i1 %cmp3.i, label %while.cond.i, label %pivot.exit, !llvm.loop !15
pivot.exit: ; preds = %land.rhs.i
%2 = trunc i64 %indvars.iv.next.i to i32
%sext.i = shl i64 %indvars.iv.next.i, 32
%idxprom7.i = ashr exact i64 %sext.i, 32
%arrayidx8.i = getelementptr inbounds i32, ptr %A, i64 %idxprom7.i
%3 = load i32, ptr %arrayidx8.i, align 4, !tbaa !5
%cmp9.not.i = icmp slt i32 %0, %3
%k.0.i.i = select i1 %cmp9.not.i, i32 %2, i32 %i.tr
%cmp.not = icmp eq i32 %k.0.i.i, -1
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %pivot.exit
%idxprom = sext i32 %k.0.i.i to i64
%arrayidx = getelementptr inbounds i32, ptr %A, i64 %idxprom
%4 = load i32, ptr %arrayidx, align 4, !tbaa !5
br label %while.cond.i12
while.cond.i12: ; preds = %if.then.i, %if.then
%r.0.i = phi i32 [ %j, %if.then ], [ %dec11.i, %if.then.i ]
%l.0.i = phi i32 [ %i.tr, %if.then ], [ %inc10.i, %if.then.i ]
%5 = sext i32 %l.0.i to i64
br label %while.cond1.i
while.cond1.i: ; preds = %while.cond1.i, %while.cond.i12
%indvars.iv.i13 = phi i64 [ %indvars.iv.next.i15, %while.cond1.i ], [ %5, %while.cond.i12 ]
%arrayidx.i14 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv.i13
%6 = load i32, ptr %arrayidx.i14, align 4, !tbaa !5
%cmp.i = icmp slt i32 %6, %4
%indvars.iv.next.i15 = add i64 %indvars.iv.i13, 1
br i1 %cmp.i, label %while.cond1.i, label %while.cond3.preheader.i, !llvm.loop !16
while.cond3.preheader.i: ; preds = %while.cond1.i
%arrayidx.i14.le = getelementptr inbounds i32, ptr %A, i64 %indvars.iv.i13
%7 = sext i32 %r.0.i to i64
br label %while.cond3.i
while.cond3.i: ; preds = %while.cond3.i, %while.cond3.preheader.i
%indvars.iv28.i = phi i64 [ %indvars.iv.next29.i, %while.cond3.i ], [ %7, %while.cond3.preheader.i ]
%arrayidx5.i = getelementptr inbounds i32, ptr %A, i64 %indvars.iv28.i
%8 = load i32, ptr %arrayidx5.i, align 4, !tbaa !5
%cmp6.not.i = icmp slt i32 %8, %4
%indvars.iv.next29.i = add i64 %indvars.iv28.i, -1
br i1 %cmp6.not.i, label %while.end8.i, label %while.cond3.i, !llvm.loop !17
while.end8.i: ; preds = %while.cond3.i
%9 = trunc i64 %indvars.iv.i13 to i32
%10 = trunc i64 %indvars.iv28.i to i32
%cmp9.not.i16 = icmp sgt i32 %9, %10
br i1 %cmp9.not.i16, label %partition.exit, label %if.then.i
if.then.i: ; preds = %while.end8.i
%arrayidx5.i.le = getelementptr inbounds i32, ptr %A, i64 %indvars.iv28.i
store i32 %8, ptr %arrayidx.i14.le, align 4, !tbaa !5
store i32 %6, ptr %arrayidx5.i.le, align 4, !tbaa !5
%inc10.i = add nsw i32 %9, 1
%dec11.i = add nsw i32 %10, -1
br label %while.cond.i12
partition.exit: ; preds = %while.end8.i
%sub = add nsw i32 %9, -1
tail call void @quicksort(i32 noundef %i.tr, i32 noundef %sub, ptr noundef nonnull %A)
br label %tailrecurse
if.end: ; preds = %pivot.exit, %while.cond.i
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nosync nounwind memory(argmem: read) uwtable
define dso_local i32 @pivot(i32 noundef %i, i32 noundef %j, ptr nocapture noundef readonly %A) local_unnamed_addr #4 {
entry:
%idxprom = sext i32 %i to i64
%arrayidx = getelementptr inbounds i32, ptr %A, i64 %idxprom
%smax = tail call i32 @llvm.smax.i32(i32 %j, i32 %i)
%wide.trip.count = sext i32 %smax to i64
br label %while.cond
while.cond: ; preds = %land.rhs, %entry
%indvars.iv = phi i64 [ %indvars.iv.next, %land.rhs ], [ %idxprom, %entry ]
%exitcond.not = icmp eq i64 %indvars.iv, %wide.trip.count
br i1 %exitcond.not, label %if.end12, label %land.rhs
land.rhs: ; preds = %while.cond
%indvars.iv.next = add nsw i64 %indvars.iv, 1
%0 = load i32, ptr %arrayidx, align 4, !tbaa !5
%arrayidx2 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv.next
%1 = load i32, ptr %arrayidx2, align 4, !tbaa !5
%cmp3 = icmp eq i32 %0, %1
br i1 %cmp3, label %while.cond, label %if.else, !llvm.loop !15
if.else: ; preds = %land.rhs
%2 = trunc i64 %indvars.iv.next to i32
%sext = shl i64 %indvars.iv.next, 32
%idxprom7 = ashr exact i64 %sext, 32
%arrayidx8 = getelementptr inbounds i32, ptr %A, i64 %idxprom7
%3 = load i32, ptr %arrayidx8, align 4, !tbaa !5
%cmp9.not = icmp slt i32 %0, %3
%k.0.i = select i1 %cmp9.not, i32 %2, i32 %i
br label %if.end12
if.end12: ; preds = %while.cond, %if.else
%pv.0 = phi i32 [ %k.0.i, %if.else ], [ -1, %while.cond ]
ret i32 %pv.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local i32 @partition(i32 noundef %i, i32 noundef %j, i32 noundef %a, ptr nocapture noundef %A) local_unnamed_addr #5 {
entry:
br label %while.cond
while.cond: ; preds = %if.then, %entry
%r.0 = phi i32 [ %j, %entry ], [ %dec11, %if.then ]
%l.0 = phi i32 [ %i, %entry ], [ %inc10, %if.then ]
%0 = sext i32 %l.0 to i64
br label %while.cond1
while.cond1: ; preds = %while.cond1, %while.cond
%indvars.iv = phi i64 [ %indvars.iv.next, %while.cond1 ], [ %0, %while.cond ]
%arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
%1 = load i32, ptr %arrayidx, align 4, !tbaa !5
%cmp = icmp slt i32 %1, %a
%indvars.iv.next = add i64 %indvars.iv, 1
br i1 %cmp, label %while.cond1, label %while.cond3.preheader, !llvm.loop !16
while.cond3.preheader: ; preds = %while.cond1
%arrayidx.le = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
%2 = trunc i64 %indvars.iv to i32
%3 = sext i32 %r.0 to i64
br label %while.cond3
while.cond3: ; preds = %while.cond3, %while.cond3.preheader
%indvars.iv28 = phi i64 [ %indvars.iv.next29, %while.cond3 ], [ %3, %while.cond3.preheader ]
%arrayidx5 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv28
%4 = load i32, ptr %arrayidx5, align 4, !tbaa !5
%cmp6.not = icmp slt i32 %4, %a
%indvars.iv.next29 = add i64 %indvars.iv28, -1
br i1 %cmp6.not, label %while.end8, label %while.cond3, !llvm.loop !17
while.end8: ; preds = %while.cond3
%5 = trunc i64 %indvars.iv28 to i32
%cmp9.not = icmp sgt i32 %2, %5
br i1 %cmp9.not, label %while.end12, label %if.then
if.then: ; preds = %while.end8
%arrayidx5.le = getelementptr inbounds i32, ptr %A, i64 %indvars.iv28
store i32 %4, ptr %arrayidx.le, align 4, !tbaa !5
store i32 %1, ptr %arrayidx5.le, align 4, !tbaa !5
%inc10 = add nsw i32 %2, 1
%dec11 = add nsw i32 %5, -1
br label %while.cond
while.end12: ; preds = %while.end8
ret i32 %2
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @swap(i32 noundef %i, i32 noundef %j, ptr nocapture noundef %A) local_unnamed_addr #6 {
entry:
%idxprom = sext i32 %i to i64
%arrayidx = getelementptr inbounds i32, ptr %A, i64 %idxprom
%0 = load i32, ptr %arrayidx, align 4, !tbaa !5
%idxprom1 = sext i32 %j to i64
%arrayidx2 = getelementptr inbounds i32, ptr %A, i64 %idxprom1
%1 = load i32, ptr %arrayidx2, align 4, !tbaa !5
store i32 %1, ptr %arrayidx, align 4, !tbaa !5
store i32 %0, ptr %arrayidx2, align 4, !tbaa !5
ret void
}
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #7
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #7
attributes #0 = { nofree 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 = { 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 = { nofree nosync nounwind memory(argmem: 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 #4 = { nofree nosync nounwind memory(argmem: read) 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 #5 = { nofree norecurse nosync nounwind memory(argmem: 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 #6 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: 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 #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10, !12, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !10, !13, !12}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
|
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
ll aa;
ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}
int main(void){
ll n,k,i,ans=0;
scanf("%lld%lld",&n,&k);
ll h[n];
for(i=0;i<n;i++){
scanf("%lld",&h[i]);
}
qsort(h,n,sizeof(ll),compare);
for(i=0;i<n-k;i++){
ans+=h[i];
}
printf("%lld\n",ans);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208061/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208061/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [9 x i8] c"%lld%lld\00", align 1
@.str.1 = private unnamed_addr constant [5 x i8] c"%lld\00", align 1
@.str.2 = private unnamed_addr constant [6 x i8] c"%lld\0A\00", align 1
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @swap(ptr nocapture noundef %a, ptr nocapture noundef %b) local_unnamed_addr #0 {
entry:
%0 = load i64, ptr %b, align 8, !tbaa !5
%1 = load i64, ptr %a, align 8, !tbaa !5
store i64 %1, ptr %b, align 8, !tbaa !5
store i64 %0, ptr %a, align 8, !tbaa !5
ret void
}
; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable
define dso_local i64 @max2(i64 noundef %a, i64 noundef %b) local_unnamed_addr #2 {
entry:
%cond = tail call i64 @llvm.smax.i64(i64 %a, i64 %b)
ret i64 %cond
}
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable
define dso_local i64 @min2(i64 noundef %a, i64 noundef %b) local_unnamed_addr #2 {
entry:
%cond = tail call i64 @llvm.smin.i64(i64 %a, i64 %b)
ret i64 %cond
}
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable
define dso_local i64 @ABS(i64 noundef %a) local_unnamed_addr #2 {
entry:
%cond = tail call i64 @llvm.abs.i64(i64 %a, i1 true)
ret i64 %cond
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @compare(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) #3 {
entry:
%0 = load i64, ptr %a, align 8, !tbaa !5
%1 = load i64, ptr %b, align 8, !tbaa !5
%sub = sub nsw i64 %0, %1
%conv = trunc i64 %sub to i32
ret i32 %conv
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #4 {
entry:
%n = alloca i64, align 8
%k = alloca i64, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %n) #9
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %k) #9
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n, ptr noundef nonnull %k)
%0 = load i64, ptr %n, align 8, !tbaa !5
%1 = call ptr @llvm.stacksave.p0()
%vla = alloca i64, i64 %0, align 16
%2 = load i64, ptr %n, align 8, !tbaa !5
%cmp16 = icmp sgt i64 %2, 0
br i1 %cmp16, label %for.body, label %for.end
for.body: ; preds = %entry, %for.body
%i.017 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
%arrayidx = getelementptr inbounds i64, ptr %vla, i64 %i.017
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %arrayidx)
%inc = add nuw nsw i64 %i.017, 1
%3 = load i64, ptr %n, align 8, !tbaa !5
%cmp = icmp slt i64 %inc, %3
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !9
for.end: ; preds = %for.body, %entry
%.lcssa = phi i64 [ %2, %entry ], [ %3, %for.body ]
call void @qsort(ptr noundef nonnull %vla, i64 noundef %.lcssa, i64 noundef 8, ptr noundef nonnull @compare) #9
%4 = load i64, ptr %n, align 8, !tbaa !5
%5 = load i64, ptr %k, align 8, !tbaa !5
%sub = sub nsw i64 %4, %5
%cmp318 = icmp sgt i64 %sub, 0
br i1 %cmp318, label %for.body4.preheader, label %for.end8
for.body4.preheader: ; preds = %for.end
%min.iters.check = icmp ult i64 %sub, 4
br i1 %min.iters.check, label %for.body4.preheader27, label %vector.ph
vector.ph: ; preds = %for.body4.preheader
%n.vec = and i64 %sub, -4
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%vec.phi = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %8, %vector.body ]
%vec.phi25 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %9, %vector.body ]
%6 = getelementptr inbounds i64, ptr %vla, i64 %index
%wide.load = load <2 x i64>, ptr %6, align 16, !tbaa !5
%7 = getelementptr inbounds i64, ptr %6, i64 2
%wide.load26 = load <2 x i64>, ptr %7, align 16, !tbaa !5
%8 = add <2 x i64> %wide.load, %vec.phi
%9 = add <2 x i64> %wide.load26, %vec.phi25
%index.next = add nuw i64 %index, 4
%10 = icmp eq i64 %index.next, %n.vec
br i1 %10, label %middle.block, label %vector.body, !llvm.loop !11
middle.block: ; preds = %vector.body
%bin.rdx = add <2 x i64> %9, %8
%11 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
%cmp.n = icmp eq i64 %sub, %n.vec
br i1 %cmp.n, label %for.end8, label %for.body4.preheader27
for.body4.preheader27: ; preds = %for.body4.preheader, %middle.block
%i.120.ph = phi i64 [ 0, %for.body4.preheader ], [ %n.vec, %middle.block ]
%ans.019.ph = phi i64 [ 0, %for.body4.preheader ], [ %11, %middle.block ]
br label %for.body4
for.body4: ; preds = %for.body4.preheader27, %for.body4
%i.120 = phi i64 [ %inc7, %for.body4 ], [ %i.120.ph, %for.body4.preheader27 ]
%ans.019 = phi i64 [ %add, %for.body4 ], [ %ans.019.ph, %for.body4.preheader27 ]
%arrayidx5 = getelementptr inbounds i64, ptr %vla, i64 %i.120
%12 = load i64, ptr %arrayidx5, align 8, !tbaa !5
%add = add nsw i64 %12, %ans.019
%inc7 = add nuw nsw i64 %i.120, 1
%exitcond.not = icmp eq i64 %inc7, %sub
br i1 %exitcond.not, label %for.end8, label %for.body4, !llvm.loop !14
for.end8: ; preds = %for.body4, %middle.block, %for.end
%ans.0.lcssa = phi i64 [ 0, %for.end ], [ %11, %middle.block ], [ %add, %for.body4 ]
%call9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %ans.0.lcssa)
call void @llvm.stackrestore.p0(ptr %1)
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %k) #9
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %n) #9
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #6
; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #7
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #6
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #8
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #8
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.abs.i64(i64, i1 immarg) #8
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #8
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nosync nounwind willreturn memory(none) 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 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 = { nofree 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 #5 = { 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 #6 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #7 = { 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 #8 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #9 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10, !12, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !10, !13, !12}
|
#include <stdio.h>
#include <stdlib.h>
int H[200005];
int comp(const void*a,const void*b)//用来做比较的函数。
{ return *(int*)a-*(int*)b;}
int main()
{
int N,K;
scanf("%d%d",&N,&K);
long long i;
for(i=0;i<N;i++)
{
scanf("%d",&H[i]);
}
qsort(H,N,sizeof(int),comp);
long long sum;
if(K>=N)
{
printf("0");
}
else
{
sum=0;
for(i=0;i<N-K;i++)
{
sum=sum+(long long)H[i];
}
printf("%lld",sum);
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208111/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208111/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@H = dso_local global [200005 x i32] zeroinitializer, align 16
@.str.3 = private unnamed_addr constant [5 x i8] c"%lld\00", align 1
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @comp(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) #0 {
entry:
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %b, align 4, !tbaa !5
%sub = sub nsw i32 %0, %1
ret i32 %sub
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
entry:
%N = alloca i32, align 4
%K = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %K) #7
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N, ptr noundef nonnull %K)
%0 = load i32, ptr %N, align 4, !tbaa !5
%conv24 = sext i32 %0 to i64
%cmp25 = icmp sgt i32 %0, 0
br i1 %cmp25, label %for.body, label %for.end
for.body: ; preds = %entry, %for.body
%i.026 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
%arrayidx = getelementptr inbounds [200005 x i32], ptr @H, i64 0, i64 %i.026
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %arrayidx)
%inc = add nuw nsw i64 %i.026, 1
%1 = load i32, ptr %N, align 4, !tbaa !5
%conv = sext i32 %1 to i64
%cmp = icmp slt i64 %inc, %conv
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !9
for.end: ; preds = %for.body, %entry
%conv.lcssa = phi i64 [ %conv24, %entry ], [ %conv, %for.body ]
call void @qsort(ptr noundef nonnull @H, i64 noundef %conv.lcssa, i64 noundef 4, ptr noundef nonnull @comp) #7
%2 = load i32, ptr %K, align 4, !tbaa !5
%3 = load i32, ptr %N, align 4, !tbaa !5
%cmp4.not = icmp slt i32 %2, %3
br i1 %cmp4.not, label %for.cond7.preheader, label %if.then
for.cond7.preheader: ; preds = %for.end
%sub = sub nsw i32 %3, %2
%conv8 = sext i32 %sub to i64
%cmp927 = icmp sgt i32 %sub, 0
br i1 %cmp927, label %for.body11.preheader, label %for.end16
for.body11.preheader: ; preds = %for.cond7.preheader
%min.iters.check = icmp ult i32 %sub, 4
br i1 %min.iters.check, label %for.body11.preheader36, label %vector.ph
vector.ph: ; preds = %for.body11.preheader
%n.vec = and i64 %conv8, -4
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%vec.phi = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %8, %vector.body ]
%vec.phi34 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %9, %vector.body ]
%4 = getelementptr inbounds [200005 x i32], ptr @H, i64 0, i64 %index
%wide.load = load <2 x i32>, ptr %4, align 16, !tbaa !5
%5 = getelementptr inbounds i32, ptr %4, i64 2
%wide.load35 = load <2 x i32>, ptr %5, align 8, !tbaa !5
%6 = sext <2 x i32> %wide.load to <2 x i64>
%7 = sext <2 x i32> %wide.load35 to <2 x i64>
%8 = add <2 x i64> %vec.phi, %6
%9 = add <2 x i64> %vec.phi34, %7
%index.next = add nuw i64 %index, 4
%10 = icmp eq i64 %index.next, %n.vec
br i1 %10, label %middle.block, label %vector.body, !llvm.loop !11
middle.block: ; preds = %vector.body
%bin.rdx = add <2 x i64> %9, %8
%11 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
%cmp.n = icmp eq i64 %n.vec, %conv8
br i1 %cmp.n, label %for.end16, label %for.body11.preheader36
for.body11.preheader36: ; preds = %for.body11.preheader, %middle.block
%sum.029.ph = phi i64 [ 0, %for.body11.preheader ], [ %11, %middle.block ]
%i.128.ph = phi i64 [ 0, %for.body11.preheader ], [ %n.vec, %middle.block ]
br label %for.body11
if.then: ; preds = %for.end
%putchar = call i32 @putchar(i32 48)
br label %if.end
for.body11: ; preds = %for.body11.preheader36, %for.body11
%sum.029 = phi i64 [ %add, %for.body11 ], [ %sum.029.ph, %for.body11.preheader36 ]
%i.128 = phi i64 [ %inc15, %for.body11 ], [ %i.128.ph, %for.body11.preheader36 ]
%arrayidx12 = getelementptr inbounds [200005 x i32], ptr @H, i64 0, i64 %i.128
%12 = load i32, ptr %arrayidx12, align 4, !tbaa !5
%conv13 = sext i32 %12 to i64
%add = add nsw i64 %sum.029, %conv13
%inc15 = add nuw nsw i64 %i.128, 1
%exitcond.not = icmp eq i64 %inc15, %conv8
br i1 %exitcond.not, label %for.end16, label %for.body11, !llvm.loop !14
for.end16: ; preds = %for.body11, %middle.block, %for.cond7.preheader
%sum.0.lcssa = phi i64 [ 0, %for.cond7.preheader ], [ %11, %middle.block ], [ %add, %for.body11 ]
%call17 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %sum.0.lcssa)
br label %if.end
if.end: ; preds = %for.end16, %if.then
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %K) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #7
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #4
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #5
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #6
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 = { nofree 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = { nofree nounwind }
attributes #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10, !12, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !10, !13, !12}
|
#include<stdio.h>
#define MAX 100010
int main()
{
int a, b, c, d, i;
scanf("%d%d%d%d", &a, &b, &c, &d);
if (b < d) {
int t = b;
b = d;
d = t;
t = a;
a = c;
c = t;
}
for (i = 0; i < c; i++) {
if (((b - d) + i*a) % c == 0) break;
}
if (i == c) {
printf("-1\n");
}
else printf("%d\n", i*a+b);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_20817/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_20817/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [9 x i8] c"%d%d%d%d\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
@str = private unnamed_addr constant [3 x i8] c"-1\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
%d = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %d) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c, ptr noundef nonnull %d)
%0 = load i32, ptr %b, align 4, !tbaa !5
%1 = load i32, ptr %d, align 4, !tbaa !5
%cmp = icmp slt i32 %0, %1
%.pre = load i32, ptr %c, align 4, !tbaa !5
br i1 %cmp, label %if.then, label %if.end
if.then: ; preds = %entry
store i32 %1, ptr %b, align 4, !tbaa !5
store i32 %0, ptr %d, align 4, !tbaa !5
%2 = load i32, ptr %a, align 4, !tbaa !5
store i32 %.pre, ptr %a, align 4, !tbaa !5
store i32 %2, ptr %c, align 4, !tbaa !5
br label %if.end
if.end: ; preds = %if.then, %entry
%3 = phi i32 [ %0, %if.then ], [ %1, %entry ]
%4 = phi i32 [ %1, %if.then ], [ %0, %entry ]
%5 = phi i32 [ %2, %if.then ], [ %.pre, %entry ]
%cmp119 = icmp sgt i32 %5, 0
br i1 %cmp119, label %for.body.lr.ph, label %for.end
for.body.lr.ph: ; preds = %if.end
%sub = sub i32 %4, %3
%6 = load i32, ptr %a, align 4, !tbaa !5
br label %for.body
for.body: ; preds = %for.body.lr.ph, %for.inc
%i.020 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
%mul = mul nsw i32 %6, %i.020
%add = add nsw i32 %sub, %mul
%rem = srem i32 %add, %5
%cmp2 = icmp eq i32 %rem, 0
br i1 %cmp2, label %for.end, label %for.inc
for.inc: ; preds = %for.body
%inc = add nuw nsw i32 %i.020, 1
%exitcond.not = icmp eq i32 %inc, %5
br i1 %exitcond.not, label %if.then6, label %for.body, !llvm.loop !9
for.end: ; preds = %for.body, %if.end
%i.0.lcssa = phi i32 [ 0, %if.end ], [ %i.020, %for.body ]
%cmp5 = icmp eq i32 %i.0.lcssa, %5
br i1 %cmp5, label %if.then6, label %if.else
if.then6: ; preds = %for.inc, %for.end
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %if.end11
if.else: ; preds = %for.end
%7 = load i32, ptr %a, align 4, !tbaa !5
%mul8 = mul nsw i32 %7, %i.0.lcssa
%add9 = add nsw i32 %mul8, %4
%call10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %add9)
br label %if.end11
if.end11: ; preds = %if.else, %if.then6
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %d) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
attributes #0 = { nofree 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 = { 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 = { nofree nounwind }
attributes #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
#include <stdio.h>
int main() {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
if (a == b) printf("%d\n", c);
if (a == c) printf("%d\n", b);
if (c == b) printf("%d\n", a);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208212/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208212/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [7 x i8] c"%d%d%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c)
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %b, align 4, !tbaa !5
%cmp = icmp eq i32 %0, %1
br i1 %cmp, label %if.then, label %if.end
if.then: ; preds = %entry
%2 = load i32, ptr %c, align 4, !tbaa !5
%call1 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %2)
%.pre = load i32, ptr %a, align 4, !tbaa !5
%.pre12.pre = load i32, ptr %b, align 4, !tbaa !5
br label %if.end
if.end: ; preds = %if.then, %entry
%.pre12 = phi i32 [ %.pre12.pre, %if.then ], [ %1, %entry ]
%3 = phi i32 [ %.pre, %if.then ], [ %0, %entry ]
%4 = load i32, ptr %c, align 4, !tbaa !5
%cmp2 = icmp eq i32 %3, %4
br i1 %cmp2, label %if.then3, label %if.end5
if.then3: ; preds = %if.end
%call4 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.pre12)
%.pre10 = load i32, ptr %c, align 4, !tbaa !5
%.pre11 = load i32, ptr %b, align 4, !tbaa !5
br label %if.end5
if.end5: ; preds = %if.then3, %if.end
%5 = phi i32 [ %.pre11, %if.then3 ], [ %.pre12, %if.end ]
%6 = phi i32 [ %.pre10, %if.then3 ], [ %4, %if.end ]
%cmp6 = icmp eq i32 %6, %5
br i1 %cmp6, label %if.then7, label %if.end9
if.then7: ; preds = %if.end5
%7 = load i32, ptr %a, align 4, !tbaa !5
%call8 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %7)
br label %if.end9
if.end9: ; preds = %if.then7, %if.end5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(void){
int a, b, c,d;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
d = 0;
if(a -c ==0){
d = b;
}else if(b-c==0){
d = a;
}else if(a-b==0){
d = c;
}else{
}
printf("%d",d);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208263/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208263/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a)
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %b)
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %c)
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %c, align 4, !tbaa !5
%cmp = icmp eq i32 %0, %1
%2 = load i32, ptr %b, align 4, !tbaa !5
br i1 %cmp, label %if.end12, label %if.else
if.else: ; preds = %entry
%cmp4 = icmp eq i32 %2, %1
br i1 %cmp4, label %if.end12, label %if.else6
if.else6: ; preds = %if.else
%cmp8 = icmp eq i32 %0, %2
%spec.select = select i1 %cmp8, i32 %1, i32 0
br label %if.end12
if.end12: ; preds = %entry, %if.else6, %if.else
%d.0 = phi i32 [ %0, %if.else ], [ %spec.select, %if.else6 ], [ %2, %entry ]
%call13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %d.0)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(void)
{
int a, b, c;
scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);
if(a==b){
printf("%d", c);
}else if(a==c){
printf("%d", b);
}else{
printf("%d", a);
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208306/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208306/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a)
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %b)
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %c)
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %b, align 4, !tbaa !5
%cmp = icmp eq i32 %0, %1
%2 = load i32, ptr %c, align 4, !tbaa !5
%cmp4 = icmp eq i32 %0, %2
%. = select i1 %cmp4, i32 %1, i32 %0
%.sink = select i1 %cmp, i32 %2, i32 %.
%call6 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %.sink)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(void){
int i,s[3];
for(i=0; i<=2; i++){
scanf("%d",&s[i]);
}
if(s[0]==s[1]){
printf("%d\n",s[2]);
}
else if(s[1]==s[2]){
printf("%d\n",s[0]);
}
else{
printf("%d\n",s[1]);
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208357/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208357/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca [3 x i32], align 4
call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %s) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s)
%arrayidx.1 = getelementptr inbounds [3 x i32], ptr %s, i64 0, i64 1
%call.1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx.1)
%arrayidx.2 = getelementptr inbounds [3 x i32], ptr %s, i64 0, i64 2
%call.2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx.2)
%0 = load i32, ptr %s, align 4, !tbaa !5
%1 = load i32, ptr %arrayidx.1, align 4, !tbaa !5
%cmp3 = icmp eq i32 %0, %1
%2 = load i32, ptr %arrayidx.2, align 4, !tbaa !5
%cmp8 = icmp eq i32 %1, %2
%. = select i1 %cmp8, i32 %0, i32 %1
%.sink = select i1 %cmp3, i32 %2, i32 %.
%call11 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.sink)
call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %s) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main(void)
{
int a[3];
int n1, n2;
int c1, c2;
int i;
c1 = 0; c2 = 0;
n1 = -200; n2 = -200;
for ( i=0; i<3; i++ ) {
scanf("%d", &a[i]);
if ( n1 == -200 ) {
n1 = a[i];
c1 = 1;
} else if ( n1 == a[i] ) {
c1 = 2;
} else if ( n2 == -200 ) {
n2 = a[i];
c2 = 1;
} else if ( n2 == a[i] ) {
c2 = 2;
}
}
if ( c1 == 2 ) {
printf("%d\n", n2);
} else {
printf("%d\n", n1);
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208443/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208443/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
for.inc:
%a = alloca [3 x i32], align 4
call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %a) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a)
%0 = load i32, ptr %a, align 4, !tbaa !5
%arrayidx.1 = getelementptr inbounds [3 x i32], ptr %a, i64 0, i64 1
%call.1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx.1)
%cmp1.1 = icmp eq i32 %0, -200
%1 = load i32, ptr %arrayidx.1, align 4, !tbaa !5
br i1 %cmp1.1, label %for.inc.1, label %if.else.1
if.else.1: ; preds = %for.inc
%cmp6.1 = icmp eq i32 %0, %1
%spec.select = select i1 %cmp6.1, i32 -200, i32 %1
%arrayidx.244 = getelementptr inbounds [3 x i32], ptr %a, i64 0, i64 2
%call.245 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx.244)
%2 = load i32, ptr %arrayidx.244, align 4, !tbaa !5
%cmp6.2 = icmp eq i32 %0, %2
br i1 %cmp6.2, label %if.end26, label %for.inc.2
for.inc.1: ; preds = %for.inc
%arrayidx.2 = getelementptr inbounds [3 x i32], ptr %a, i64 0, i64 2
%call.2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx.2)
%cmp1.2 = icmp eq i32 %1, -200
%3 = load i32, ptr %arrayidx.2, align 4, !tbaa !5
br i1 %cmp1.2, label %if.else24, label %if.else.2.thread
if.else.2.thread: ; preds = %for.inc.1
%cmp6.262 = icmp eq i32 %1, %3
br i1 %cmp6.262, label %if.end26, label %if.else24
for.inc.2: ; preds = %if.else.1
%cmp9.2 = icmp eq i32 %spec.select, -200
%spec.select.2 = select i1 %cmp9.2, i32 %2, i32 %spec.select
br i1 %cmp6.1, label %if.end26, label %if.else24
if.else24: ; preds = %for.inc.1, %if.else.2.thread, %for.inc.2
%n1.1.258 = phi i32 [ %0, %for.inc.2 ], [ %1, %if.else.2.thread ], [ %3, %for.inc.1 ]
br label %if.end26
if.end26: ; preds = %for.inc.2, %if.else.2.thread, %if.else.1, %if.else24
%n1.1.258.sink = phi i32 [ %n1.1.258, %if.else24 ], [ %spec.select.2, %for.inc.2 ], [ -200, %if.else.2.thread ], [ %spec.select, %if.else.1 ]
%call25 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %n1.1.258.sink)
call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %a) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
return *(ll*)b-*(ll*)a;
}
int min(int a,int b){
if(a>b)return b;
return a;
}
int max(int a,int b){
if(a>b)return a;
return b;
}
int gcd(int a,int b){
if(!b)return a;
return gcd(b,a%b);
}
int kt(ll a){
int sum=0;
while(a){
a/=10;
sum++;
}
return sum;
}
int ks(ll a){
int sum=0;
while(a){
sum+=a%10;
a/=10;
}
return sum;
}
int a[27];
int b[27];
int main(void){
char s[200001],t[200001];
scanf("%s %s",s,t);
int l=strlen(s);
FOR(l)a[s[i]-'a']++;
FOR(l)b[t[i]-'a']++;
qsort(a,27,sizeof(int),u);
qsort(b,27,sizeof(int),u);
int flg=1;
FOR(27)if(a[i]!=b[i])flg=0;
char c[2][4]={"No","Yes"};
PRS(c[flg]);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208487/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208487/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%s %s\00", align 1
@a = dso_local global [27 x i32] zeroinitializer, align 16
@b = dso_local global [27 x i32] zeroinitializer, align 16
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @u(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) #0 {
entry:
%0 = load i64, ptr %a, align 8, !tbaa !5
%1 = load i64, ptr %b, align 8, !tbaa !5
%sub = sub nsw i64 %0, %1
%conv = trunc i64 %sub to i32
ret i32 %conv
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @d(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) local_unnamed_addr #0 {
entry:
%0 = load i64, ptr %b, align 8, !tbaa !5
%1 = load i64, ptr %a, align 8, !tbaa !5
%sub = sub nsw i64 %0, %1
%conv = trunc i64 %sub to i32
ret i32 %conv
}
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable
define dso_local i32 @min(i32 noundef %a, i32 noundef %b) local_unnamed_addr #1 {
entry:
%b.a = tail call i32 @llvm.smin.i32(i32 %a, i32 %b)
ret i32 %b.a
}
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable
define dso_local i32 @max(i32 noundef %a, i32 noundef %b) local_unnamed_addr #1 {
entry:
%a.b = tail call i32 @llvm.smax.i32(i32 %a, i32 %b)
ret i32 %a.b
}
; Function Attrs: nofree norecurse nosync nounwind memory(none) uwtable
define dso_local i32 @gcd(i32 noundef %a, i32 noundef %b) local_unnamed_addr #2 {
entry:
%tobool.not4 = icmp eq i32 %b, 0
br i1 %tobool.not4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%b.tr6 = phi i32 [ %rem, %if.end ], [ %b, %entry ]
%a.tr5 = phi i32 [ %b.tr6, %if.end ], [ %a, %entry ]
%rem = srem i32 %a.tr5, %b.tr6
%tobool.not = icmp eq i32 %rem, 0
br i1 %tobool.not, label %return, label %if.end
return: ; preds = %if.end, %entry
%a.tr.lcssa = phi i32 [ %a, %entry ], [ %b.tr6, %if.end ]
ret i32 %a.tr.lcssa
}
; Function Attrs: nofree norecurse nosync nounwind memory(none) uwtable
define dso_local i32 @kt(i64 noundef %a) local_unnamed_addr #2 {
entry:
%tobool.not3 = icmp eq i64 %a, 0
br i1 %tobool.not3, label %while.end, label %while.body
while.body: ; preds = %entry, %while.body
%sum.05 = phi i32 [ %inc, %while.body ], [ 0, %entry ]
%a.addr.04 = phi i64 [ %div, %while.body ], [ %a, %entry ]
%div = sdiv i64 %a.addr.04, 10
%inc = add nuw nsw i32 %sum.05, 1
%a.addr.04.off = add i64 %a.addr.04, 9
%tobool.not = icmp ult i64 %a.addr.04.off, 19
br i1 %tobool.not, label %while.end, label %while.body, !llvm.loop !9
while.end: ; preds = %while.body, %entry
%sum.0.lcssa = phi i32 [ 0, %entry ], [ %inc, %while.body ]
ret i32 %sum.0.lcssa
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3
; Function Attrs: nofree norecurse nosync nounwind memory(none) uwtable
define dso_local i32 @ks(i64 noundef %a) local_unnamed_addr #2 {
entry:
%tobool.not5 = icmp eq i64 %a, 0
br i1 %tobool.not5, label %while.end, label %while.body
while.body: ; preds = %entry, %while.body
%sum.07 = phi i32 [ %conv1, %while.body ], [ 0, %entry ]
%a.addr.06 = phi i64 [ %div, %while.body ], [ %a, %entry ]
%rem = srem i64 %a.addr.06, 10
%0 = trunc i64 %rem to i32
%conv1 = add i32 %sum.07, %0
%div = sdiv i64 %a.addr.06, 10
%a.addr.06.off = add i64 %a.addr.06, 9
%tobool.not = icmp ult i64 %a.addr.06.off, 19
br i1 %tobool.not, label %while.end, label %while.body, !llvm.loop !11
while.end: ; preds = %while.body, %entry
%sum.0.lcssa = phi i32 [ 0, %entry ], [ %conv1, %while.body ]
ret i32 %sum.0.lcssa
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #4 {
entry:
%s = alloca [200001 x i8], align 16
%t = alloca [200001 x i8], align 16
%c = alloca [2 x [4 x i8]], align 8
call void @llvm.lifetime.start.p0(i64 200001, ptr nonnull %s) #10
call void @llvm.lifetime.start.p0(i64 200001, ptr nonnull %t) #10
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s, ptr noundef nonnull %t)
%call3 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %s) #11
%conv = trunc i64 %call3 to i32
%cmp52 = icmp sgt i32 %conv, 0
br i1 %cmp52, label %for.body.preheader, label %for.cond.cleanup13
for.body.preheader: ; preds = %entry
%wide.trip.count = and i64 %call3, 4294967295
%0 = add nsw i64 %wide.trip.count, -1
%xtraiter = and i64 %call3, 1
%1 = icmp eq i64 %0, 0
br i1 %1, label %for.cond10.preheader.unr-lcssa, label %for.body.preheader.new
for.body.preheader.new: ; preds = %for.body.preheader
%unroll_iter = sub nsw i64 %wide.trip.count, %xtraiter
br label %for.body
for.cond10.preheader.unr-lcssa: ; preds = %for.body, %for.body.preheader
%indvars.iv.unr = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next.1, %for.body ]
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br i1 %lcmp.mod.not, label %for.cond10.preheader, label %for.body.epil
for.body.epil: ; preds = %for.cond10.preheader.unr-lcssa
%arrayidx.epil = getelementptr inbounds [200001 x i8], ptr %s, i64 0, i64 %indvars.iv.unr
%2 = load i8, ptr %arrayidx.epil, align 1, !tbaa !12
%conv5.epil = sext i8 %2 to i64
%sub.epil = add nsw i64 %conv5.epil, -97
%arrayidx7.epil = getelementptr inbounds [27 x i32], ptr @a, i64 0, i64 %sub.epil
%3 = load i32, ptr %arrayidx7.epil, align 4, !tbaa !13
%inc.epil = add nsw i32 %3, 1
store i32 %inc.epil, ptr %arrayidx7.epil, align 4, !tbaa !13
br label %for.cond10.preheader
for.cond10.preheader: ; preds = %for.cond10.preheader.unr-lcssa, %for.body.epil
br i1 %cmp52, label %for.body14.preheader, label %for.cond.cleanup13
for.body14.preheader: ; preds = %for.cond10.preheader
%xtraiter84 = and i64 %call3, 1
%4 = icmp eq i64 %0, 0
br i1 %4, label %for.cond.cleanup13.loopexit.unr-lcssa, label %for.body14.preheader.new
for.body14.preheader.new: ; preds = %for.body14.preheader
%unroll_iter86 = sub nsw i64 %wide.trip.count, %xtraiter84
br label %for.body14
for.body: ; preds = %for.body, %for.body.preheader.new
%indvars.iv = phi i64 [ 0, %for.body.preheader.new ], [ %indvars.iv.next.1, %for.body ]
%niter = phi i64 [ 0, %for.body.preheader.new ], [ %niter.next.1, %for.body ]
%arrayidx = getelementptr inbounds [200001 x i8], ptr %s, i64 0, i64 %indvars.iv
%5 = load i8, ptr %arrayidx, align 2, !tbaa !12
%conv5 = sext i8 %5 to i64
%sub = add nsw i64 %conv5, -97
%arrayidx7 = getelementptr inbounds [27 x i32], ptr @a, i64 0, i64 %sub
%6 = load i32, ptr %arrayidx7, align 4, !tbaa !13
%inc = add nsw i32 %6, 1
store i32 %inc, ptr %arrayidx7, align 4, !tbaa !13
%indvars.iv.next = or i64 %indvars.iv, 1
%arrayidx.1 = getelementptr inbounds [200001 x i8], ptr %s, i64 0, i64 %indvars.iv.next
%7 = load i8, ptr %arrayidx.1, align 1, !tbaa !12
%conv5.1 = sext i8 %7 to i64
%sub.1 = add nsw i64 %conv5.1, -97
%arrayidx7.1 = getelementptr inbounds [27 x i32], ptr @a, i64 0, i64 %sub.1
%8 = load i32, ptr %arrayidx7.1, align 4, !tbaa !13
%inc.1 = add nsw i32 %8, 1
store i32 %inc.1, ptr %arrayidx7.1, align 4, !tbaa !13
%indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
%niter.next.1 = add i64 %niter, 2
%niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
br i1 %niter.ncmp.1, label %for.cond10.preheader.unr-lcssa, label %for.body, !llvm.loop !15
for.cond.cleanup13.loopexit.unr-lcssa: ; preds = %for.body14, %for.body14.preheader
%indvars.iv59.unr = phi i64 [ 0, %for.body14.preheader ], [ %indvars.iv.next60.1, %for.body14 ]
%lcmp.mod85.not = icmp eq i64 %xtraiter84, 0
br i1 %lcmp.mod85.not, label %for.cond.cleanup13, label %for.body14.epil
for.body14.epil: ; preds = %for.cond.cleanup13.loopexit.unr-lcssa
%arrayidx16.epil = getelementptr inbounds [200001 x i8], ptr %t, i64 0, i64 %indvars.iv59.unr
%9 = load i8, ptr %arrayidx16.epil, align 1, !tbaa !12
%conv17.epil = sext i8 %9 to i64
%sub18.epil = add nsw i64 %conv17.epil, -97
%arrayidx20.epil = getelementptr inbounds [27 x i32], ptr @b, i64 0, i64 %sub18.epil
%10 = load i32, ptr %arrayidx20.epil, align 4, !tbaa !13
%inc21.epil = add nsw i32 %10, 1
store i32 %inc21.epil, ptr %arrayidx20.epil, align 4, !tbaa !13
br label %for.cond.cleanup13
for.cond.cleanup13: ; preds = %for.body14.epil, %for.cond.cleanup13.loopexit.unr-lcssa, %entry, %for.cond10.preheader
call void @qsort(ptr noundef nonnull @a, i64 noundef 27, i64 noundef 4, ptr noundef nonnull @u) #10
call void @qsort(ptr noundef nonnull @b, i64 noundef 27, i64 noundef 4, ptr noundef nonnull @u) #10
%11 = load <2 x i32>, ptr @a, align 16, !tbaa !13
%12 = load <2 x i32>, ptr @b, align 16, !tbaa !13
%13 = icmp eq <2 x i32> %11, %12
%.fr = freeze <2 x i1> %13
%14 = load i32, ptr getelementptr inbounds ([27 x i32], ptr @a, i64 0, i64 2), align 8, !tbaa !13
%15 = load i32, ptr getelementptr inbounds ([27 x i32], ptr @b, i64 0, i64 2), align 8, !tbaa !13
%cmp35.not.2 = icmp eq i32 %14, %15
%16 = load <8 x i32>, ptr getelementptr inbounds ([27 x i32], ptr @a, i64 0, i64 3), align 4, !tbaa !13
%17 = load <8 x i32>, ptr getelementptr inbounds ([27 x i32], ptr @b, i64 0, i64 3), align 4, !tbaa !13
%18 = icmp eq <8 x i32> %16, %17
%19 = load <16 x i32>, ptr getelementptr inbounds ([27 x i32], ptr @a, i64 0, i64 11), align 4, !tbaa !13
%20 = load <16 x i32>, ptr getelementptr inbounds ([27 x i32], ptr @b, i64 0, i64 11), align 4, !tbaa !13
%21 = icmp eq <16 x i32> %19, %20
%22 = freeze <16 x i1> %21
%23 = bitcast <16 x i1> %22 to i16
%24 = icmp eq i16 %23, -1
%25 = freeze <8 x i1> %18
%26 = bitcast <8 x i1> %25 to i8
%27 = icmp eq i8 %26, -1
%op.rdx = and i1 %24, %27
%cmp35.not.2.fr = freeze i1 %cmp35.not.2
%op.rdx81 = and i1 %op.rdx, %cmp35.not.2.fr
%28 = extractelement <2 x i1> %.fr, i64 1
%29 = extractelement <2 x i1> %.fr, i64 0
%op.rdx82 = and i1 %28, %29
%op.rdx83 = and i1 %op.rdx81, %op.rdx82
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %c) #10
store i64 32481055248248654, ptr %c, align 8
%idxprom40 = zext i1 %op.rdx83 to i64
%arrayidx41 = getelementptr inbounds [2 x [4 x i8]], ptr %c, i64 0, i64 %idxprom40
%puts = call i32 @puts(ptr nonnull dereferenceable(1) %arrayidx41)
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %c) #10
call void @llvm.lifetime.end.p0(i64 200001, ptr nonnull %t) #10
call void @llvm.lifetime.end.p0(i64 200001, ptr nonnull %s) #10
ret i32 0
for.body14: ; preds = %for.body14, %for.body14.preheader.new
%indvars.iv59 = phi i64 [ 0, %for.body14.preheader.new ], [ %indvars.iv.next60.1, %for.body14 ]
%niter87 = phi i64 [ 0, %for.body14.preheader.new ], [ %niter87.next.1, %for.body14 ]
%arrayidx16 = getelementptr inbounds [200001 x i8], ptr %t, i64 0, i64 %indvars.iv59
%30 = load i8, ptr %arrayidx16, align 2, !tbaa !12
%conv17 = sext i8 %30 to i64
%sub18 = add nsw i64 %conv17, -97
%arrayidx20 = getelementptr inbounds [27 x i32], ptr @b, i64 0, i64 %sub18
%31 = load i32, ptr %arrayidx20, align 4, !tbaa !13
%inc21 = add nsw i32 %31, 1
store i32 %inc21, ptr %arrayidx20, align 4, !tbaa !13
%indvars.iv.next60 = or i64 %indvars.iv59, 1
%arrayidx16.1 = getelementptr inbounds [200001 x i8], ptr %t, i64 0, i64 %indvars.iv.next60
%32 = load i8, ptr %arrayidx16.1, align 1, !tbaa !12
%conv17.1 = sext i8 %32 to i64
%sub18.1 = add nsw i64 %conv17.1, -97
%arrayidx20.1 = getelementptr inbounds [27 x i32], ptr @b, i64 0, i64 %sub18.1
%33 = load i32, ptr %arrayidx20.1, align 4, !tbaa !13
%inc21.1 = add nsw i32 %33, 1
store i32 %inc21.1, ptr %arrayidx20.1, align 4, !tbaa !13
%indvars.iv.next60.1 = add nuw nsw i64 %indvars.iv59, 2
%niter87.next.1 = add i64 %niter87, 2
%niter87.ncmp.1 = icmp eq i64 %niter87.next.1, %unroll_iter86
br i1 %niter87.ncmp.1, label %for.cond.cleanup13.loopexit.unr-lcssa, label %for.body14, !llvm.loop !16
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #6
; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #7
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #8
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #9
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #9
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 nofree nosync nounwind willreturn memory(none) 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 = { nofree norecurse nosync nounwind memory(none) 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nofree 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 #5 = { 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 #6 = { 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 #7 = { 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 #8 = { nofree nounwind }
attributes #9 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #10 = { nounwind }
attributes #11 = { nounwind willreturn memory(read) }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
|
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//環境で固定された変数を宣言
#define IN 200000
#define INPUTSIZE IN+2
int main() {
//変数宣言
int i, j;
char Sin[INPUTSIZE], Tin[INPUTSIZE];
char c;
//入力受付
fgets(Sin, INPUTSIZE, stdin);
fgets(Tin, INPUTSIZE, stdin);
int size = strlen(Sin);
//文字列交換
for (i = 0; i < size; i++) {
if (Sin[i] != Tin[i]) {
c = Sin[i];
for (j = 0; j < size; j++) {
if (Sin[j] == c || Sin[j] == Tin[i]) {
if (j < i) goto MyEndFlag;
if (Sin[j] == c) Sin[j] = Tin[i];
else if(Sin[j] == Tin[i]) Sin[j] = c;
////代入後に判定
//if (j <= i && Sin[j] != Tin[j]) goto MyEndFlag;
}
}
}
}
//プログラムの終了
MyEndFlag:
printf(i == size ? "Yes\n":"No\n");
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208537/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208537/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@stdin = external local_unnamed_addr global ptr, align 8
@.str = private unnamed_addr constant [5 x i8] c"Yes\0A\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"No\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%Sin = alloca [200002 x i8], align 16
%Tin = alloca [200002 x i8], align 16
call void @llvm.lifetime.start.p0(i64 200002, ptr nonnull %Sin) #4
call void @llvm.lifetime.start.p0(i64 200002, ptr nonnull %Tin) #4
%0 = load ptr, ptr @stdin, align 8, !tbaa !5
%call = call ptr @fgets(ptr noundef nonnull %Sin, i32 noundef 200002, ptr noundef %0)
%1 = load ptr, ptr @stdin, align 8, !tbaa !5
%call2 = call ptr @fgets(ptr noundef nonnull %Tin, i32 noundef 200002, ptr noundef %1)
%call4 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %Sin) #5
%conv = trunc i64 %call4 to i32
%cmp95 = icmp sgt i32 %conv, 0
br i1 %cmp95, label %for.body.us.preheader, label %MyEndFlag
for.body.us.preheader: ; preds = %entry
%wide.trip.count106 = and i64 %call4, 4294967295
br label %for.body.us
for.body.us: ; preds = %for.body.us.preheader, %for.inc62.us
%indvars.iv103 = phi i64 [ 0, %for.body.us.preheader ], [ %indvars.iv.next104, %for.inc62.us ]
%arrayidx.us = getelementptr inbounds [200002 x i8], ptr %Sin, i64 0, i64 %indvars.iv103
%2 = load i8, ptr %arrayidx.us, align 1, !tbaa !9
%arrayidx8.us = getelementptr inbounds [200002 x i8], ptr %Tin, i64 0, i64 %indvars.iv103
%3 = load i8, ptr %arrayidx8.us, align 1, !tbaa !9
%cmp10.not.us = icmp eq i8 %2, %3
br i1 %cmp10.not.us, label %for.inc62.us, label %for.body17.us
for.body17.us: ; preds = %for.body.us, %for.inc.us
%indvars.iv = phi i64 [ %indvars.iv.next, %for.inc.us ], [ 0, %for.body.us ]
%arrayidx19.us = getelementptr inbounds [200002 x i8], ptr %Sin, i64 0, i64 %indvars.iv
%4 = load i8, ptr %arrayidx19.us, align 1, !tbaa !9
%cmp22.us = icmp eq i8 %4, %2
br i1 %cmp22.us, label %if.then32.us, label %lor.lhs.false.us
lor.lhs.false.us: ; preds = %for.body17.us
%cmp30.us = icmp eq i8 %4, %3
br i1 %cmp30.us, label %if.then32.thread.us, label %for.inc.us
if.then32.thread.us: ; preds = %lor.lhs.false.us
%cmp3389.us = icmp ult i64 %indvars.iv, %indvars.iv103
br i1 %cmp3389.us, label %MyEndFlag.loopexit, label %for.inc.us.sink.split
if.then32.us: ; preds = %for.body17.us
%cmp33.us = icmp ult i64 %indvars.iv, %indvars.iv103
br i1 %cmp33.us, label %MyEndFlag.loopexit, label %for.inc.us.sink.split
for.inc.us.sink.split: ; preds = %if.then32.us, %if.then32.thread.us
%.sink = phi i8 [ %2, %if.then32.thread.us ], [ %3, %if.then32.us ]
store i8 %.sink, ptr %arrayidx19.us, align 1, !tbaa !9
br label %for.inc.us
for.inc.us: ; preds = %for.inc.us.sink.split, %lor.lhs.false.us
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count106
br i1 %exitcond.not, label %for.inc62.us, label %for.body17.us, !llvm.loop !10
for.inc62.us: ; preds = %for.inc.us, %for.body.us
%indvars.iv.next104 = add nuw nsw i64 %indvars.iv103, 1
%exitcond107.not = icmp eq i64 %indvars.iv.next104, %wide.trip.count106
br i1 %exitcond107.not, label %MyEndFlag, label %for.body.us, !llvm.loop !12
MyEndFlag.loopexit: ; preds = %if.then32.thread.us, %if.then32.us
%5 = trunc i64 %indvars.iv103 to i32
br label %MyEndFlag
MyEndFlag: ; preds = %for.inc62.us, %MyEndFlag.loopexit, %entry
%i.092 = phi i32 [ 0, %entry ], [ %5, %MyEndFlag.loopexit ], [ %conv, %for.inc62.us ]
%cmp65 = icmp eq i32 %i.092, %conv
%cond = select i1 %cmp65, ptr @.str, ptr @.str.1
%call67 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %cond)
call void @llvm.lifetime.end.p0(i64 200002, ptr nonnull %Tin) #4
call void @llvm.lifetime.end.p0(i64 200002, ptr nonnull %Sin) #4
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: nofree nounwind
declare noundef ptr @fgets(ptr noundef, i32 noundef, ptr nocapture noundef) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = { 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 #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
|
#include <stdio.h>
int main(void)
{
int a, b, c, d;
int p;
int com_x, com_y;
scanf("%d %d %d %d %d", &a, &b, &c, &d, &p);
com_x = a * p;
if (c >= p){
com_y = b;
}
else if (c < p){
com_y = b + (p - c) * d;
}
if (com_x < com_y){
printf("%d\n", com_x);
}
else {
printf("%d\n", com_y);
}
return (0);
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208601/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208601/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [15 x i8] c"%d %d %d %d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
%d = alloca i32, align 4
%p = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %d) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %p) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c, ptr noundef nonnull %d, ptr noundef nonnull %p)
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %p, align 4, !tbaa !5
%mul = mul nsw i32 %1, %0
%2 = load i32, ptr %c, align 4, !tbaa !5
%cmp.not = icmp slt i32 %2, %1
%3 = load i32, ptr %b, align 4, !tbaa !5
%sub = sub nsw i32 %1, %2
%4 = load i32, ptr %d, align 4
%mul3 = mul nsw i32 %4, %sub
%add = select i1 %cmp.not, i32 %mul3, i32 0
%com_y.0 = add nsw i32 %3, %add
%com_y.0.sink = call i32 @llvm.smin.i32(i32 %mul, i32 %com_y.0)
%call9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %com_y.0.sink)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %p) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %d) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #3
attributes #0 = { nofree 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main(void)
{
int A, B, C, D, P;
scanf("%d %d %d %d %d", &A, &B, &C, &D, &P);
if (P > C){
if ( A * P > B + ((P - C) * D)){
printf("%d\n", B + ((P - C) * D));
}
else if( A * P < B + ((P - C) * D)){
printf("%d\n", A * P);
}
}
else {
if ( A * P > B ){
printf("%d\n", B);
}
else if( A * P < B ){
printf("%d\n", A * P);
}
}
return (0);
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208652/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208652/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [15 x i8] c"%d %d %d %d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%A = alloca i32, align 4
%B = alloca i32, align 4
%C = alloca i32, align 4
%D = alloca i32, align 4
%P = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %A) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %B) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %C) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %D) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %P) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %A, ptr noundef nonnull %B, ptr noundef nonnull %C, ptr noundef nonnull %D, ptr noundef nonnull %P)
%0 = load i32, ptr %P, align 4, !tbaa !5
%1 = load i32, ptr %C, align 4, !tbaa !5
%cmp = icmp sgt i32 %0, %1
%2 = load i32, ptr %A, align 4, !tbaa !5
%mul = mul nsw i32 %2, %0
%3 = load i32, ptr %B, align 4, !tbaa !5
br i1 %cmp, label %if.then, label %if.else17
if.then: ; preds = %entry
%sub = sub nsw i32 %0, %1
%4 = load i32, ptr %D, align 4, !tbaa !5
%mul1 = mul nsw i32 %4, %sub
%add = add nsw i32 %mul1, %3
%cmp2 = icmp sgt i32 %mul, %add
br i1 %cmp2, label %if.end30.sink.split, label %if.else
if.else: ; preds = %if.then
%cmp12 = icmp slt i32 %mul, %add
br i1 %cmp12, label %if.end30.sink.split, label %if.end30
if.else17: ; preds = %entry
%cmp19 = icmp sgt i32 %mul, %3
br i1 %cmp19, label %if.end30.sink.split, label %if.else22
if.else22: ; preds = %if.else17
%cmp24 = icmp slt i32 %mul, %3
br i1 %cmp24, label %if.end30.sink.split, label %if.end30
if.end30.sink.split: ; preds = %if.else22, %if.else17, %if.else, %if.then
%.sink = phi i32 [ %add, %if.then ], [ %mul, %if.else ], [ %3, %if.else17 ], [ %mul, %if.else22 ]
%call21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.sink)
br label %if.end30
if.end30: ; preds = %if.end30.sink.split, %if.else22, %if.else
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %P) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %D) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %C) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %B) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %A) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(void) {
int a, b, c, d, e;
int x, y;
scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
x = a * e;
y = (e > c) ?
(b + d*(e - c)): b;
int n = x < y ? x : y;
printf("%d\n", n);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208702/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208702/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [11 x i8] c"%d%d%d%d%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
%d = alloca i32, align 4
%e = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %d) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %e) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c, ptr noundef nonnull %d, ptr noundef nonnull %e)
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %e, align 4, !tbaa !5
%2 = load i32, ptr %c, align 4, !tbaa !5
%cmp = icmp sgt i32 %1, %2
%3 = load i32, ptr %b, align 4, !tbaa !5
%4 = load i32, ptr %d, align 4
%sub = sub nsw i32 %1, %2
%mul1 = mul nsw i32 %4, %sub
%add = select i1 %cmp, i32 %mul1, i32 0
%cond = add nsw i32 %3, %add
%mul = mul nsw i32 %1, %0
%cond6 = call i32 @llvm.smin.i32(i32 %mul, i32 %cond)
%call7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %cond6)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %e) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %d) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #3
attributes #0 = { nofree 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(){
int a,b,c,d,p,x,y;
scanf("%d %d %d %d %d",&a,&b,&c,&d,&p);
x=a*p;
if (p<=c){
y=b;
}
else{
y=b+(p-c)*d;
}
if (x<y)
printf("%d\n",x);
else
printf("%d\n",y);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208746/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208746/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [15 x i8] c"%d %d %d %d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
%d = alloca i32, align 4
%p = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %d) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %p) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c, ptr noundef nonnull %d, ptr noundef nonnull %p)
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %p, align 4, !tbaa !5
%mul = mul nsw i32 %1, %0
%2 = load i32, ptr %c, align 4, !tbaa !5
%cmp.not = icmp sgt i32 %1, %2
%3 = load i32, ptr %b, align 4, !tbaa !5
%sub = sub nsw i32 %1, %2
%4 = load i32, ptr %d, align 4
%mul1 = mul nsw i32 %4, %sub
%add = select i1 %cmp.not, i32 %mul1, i32 0
%y.0 = add nsw i32 %3, %add
%y.0.sink = call i32 @llvm.smin.i32(i32 %mul, i32 %y.0)
%call6 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %y.0.sink)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %p) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %d) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #3
attributes #0 = { nofree 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <stdlib.h>
#define N 2000
int compare(const void *a, const void *b) {
int ia = *(int *) a;
int ib = *(int *) b;
return ia - ib;
}
int main() {
static int ll[N];
int n, i, j, k, ans;
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d", &ll[i]);
qsort(ll, n, sizeof *ll, compare);
ans = 0;
for (i = 0; i < n; i++)
for (j = i + 1; j < n; j++)
for (k = j + 1; k < n; k++) {
int a, b, c;
a = ll[i];
b = ll[j];
c = ll[k];
if (c >= a + b)
break;
else if (b < c + a && a < b + c)
ans++;
}
printf("%d\n", ans);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208854/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208854/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@main.ll = internal global [2000 x i32] zeroinitializer, align 16
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @compare(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) #0 {
entry:
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %b, align 4, !tbaa !5
%sub = sub nsw i32 %0, %1
ret i32 %sub
}
; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #2 {
entry:
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%cmp74 = icmp sgt i32 %0, 0
br i1 %cmp74, label %for.body, label %entry.for.end_crit_edge
entry.for.end_crit_edge: ; preds = %entry
%.pre = sext i32 %0 to i64
br label %for.end
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
%arrayidx = getelementptr inbounds [2000 x i32], ptr @main.ll, i64 0, i64 %indvars.iv
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx)
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%1 = load i32, ptr %n, align 4, !tbaa !5
%2 = sext i32 %1 to i64
%cmp = icmp slt i64 %indvars.iv.next, %2
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !9
for.end: ; preds = %for.body, %entry.for.end_crit_edge
%conv.pre-phi = phi i64 [ %.pre, %entry.for.end_crit_edge ], [ %2, %for.body ]
call void @qsort(ptr noundef nonnull @main.ll, i64 noundef %conv.pre-phi, i64 noundef 4, ptr noundef nonnull @compare) #5
%3 = load i32, ptr %n, align 4, !tbaa !5
%cmp385 = icmp sgt i32 %3, 0
br i1 %cmp385, label %for.body5.preheader, label %for.end43
for.body5.preheader: ; preds = %for.end
%4 = zext i32 %3 to i64
%wide.trip.count106 = zext i32 %3 to i64
br label %for.body5
for.cond2.loopexit: ; preds = %for.inc38, %for.body5
%ans.1.lcssa = phi i32 [ %ans.086, %for.body5 ], [ %ans.2.lcssa, %for.inc38 ]
%indvars.iv.next92 = add nuw nsw i64 %indvars.iv91, 1
%indvars.iv.next99 = add nuw nsw i64 %indvars.iv98, 1
%exitcond107.not = icmp eq i64 %indvars.iv.next104, %wide.trip.count106
br i1 %exitcond107.not, label %for.end43, label %for.body5, !llvm.loop !11
for.body5: ; preds = %for.body5.preheader, %for.cond2.loopexit
%indvars.iv103 = phi i64 [ 0, %for.body5.preheader ], [ %indvars.iv.next104, %for.cond2.loopexit ]
%indvars.iv98 = phi i64 [ 1, %for.body5.preheader ], [ %indvars.iv.next99, %for.cond2.loopexit ]
%indvars.iv91 = phi i64 [ 2, %for.body5.preheader ], [ %indvars.iv.next92, %for.cond2.loopexit ]
%ans.086 = phi i32 [ 0, %for.body5.preheader ], [ %ans.1.lcssa, %for.cond2.loopexit ]
%indvars.iv.next104 = add nuw nsw i64 %indvars.iv103, 1
%cmp781 = icmp ult i64 %indvars.iv.next104, %4
br i1 %cmp781, label %for.body9.lr.ph, label %for.cond2.loopexit
for.body9.lr.ph: ; preds = %for.body5
%arrayidx16 = getelementptr inbounds [2000 x i32], ptr @main.ll, i64 0, i64 %indvars.iv103
br label %for.body9
for.body9: ; preds = %for.body9.lr.ph, %for.inc38
%indvars.iv100 = phi i64 [ %indvars.iv98, %for.body9.lr.ph ], [ %indvars.iv.next101, %for.inc38 ]
%indvars.iv93 = phi i64 [ %indvars.iv91, %for.body9.lr.ph ], [ %indvars.iv.next94, %for.inc38 ]
%ans.182 = phi i32 [ %ans.086, %for.body9.lr.ph ], [ %ans.2.lcssa, %for.inc38 ]
%indvars.iv.next101 = add nuw nsw i64 %indvars.iv100, 1
%5 = trunc i64 %indvars.iv.next101 to i32
%cmp1276 = icmp sgt i32 %3, %5
br i1 %cmp1276, label %for.body14.lr.ph, label %for.inc38
for.body14.lr.ph: ; preds = %for.body9
%6 = load i32, ptr %arrayidx16, align 4, !tbaa !5
%arrayidx18 = getelementptr inbounds [2000 x i32], ptr @main.ll, i64 0, i64 %indvars.iv100
%7 = load i32, ptr %arrayidx18, align 4, !tbaa !5
%add21 = add nsw i32 %7, %6
br label %for.body14
for.body14: ; preds = %for.body14.lr.ph, %for.inc35
%indvars.iv95 = phi i64 [ %indvars.iv93, %for.body14.lr.ph ], [ %indvars.iv.next96, %for.inc35 ]
%ans.278 = phi i32 [ %ans.182, %for.body14.lr.ph ], [ %ans.3, %for.inc35 ]
%arrayidx20 = getelementptr inbounds [2000 x i32], ptr @main.ll, i64 0, i64 %indvars.iv95
%8 = load i32, ptr %arrayidx20, align 4, !tbaa !5
%cmp22.not = icmp slt i32 %8, %add21
br i1 %cmp22.not, label %for.inc35, label %for.inc38
for.inc35: ; preds = %for.body14
%add24 = add nsw i32 %8, %6
%cmp25 = icmp slt i32 %7, %add24
%add27 = add nsw i32 %8, %7
%cmp28 = icmp slt i32 %6, %add27
%or.cond = select i1 %cmp25, i1 %cmp28, i1 false
%inc31 = zext i1 %or.cond to i32
%ans.3 = add nsw i32 %ans.278, %inc31
%indvars.iv.next96 = add nuw nsw i64 %indvars.iv95, 1
%9 = trunc i64 %indvars.iv.next96 to i32
%cmp12 = icmp sgt i32 %3, %9
br i1 %cmp12, label %for.body14, label %for.inc38, !llvm.loop !12
for.inc38: ; preds = %for.inc35, %for.body14, %for.body9
%ans.2.lcssa = phi i32 [ %ans.182, %for.body9 ], [ %ans.278, %for.body14 ], [ %ans.3, %for.inc35 ]
%indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
%exitcond.not = icmp eq i64 %indvars.iv.next101, %wide.trip.count106
br i1 %exitcond.not, label %for.cond2.loopexit, label %for.body9, !llvm.loop !13
for.end43: ; preds = %for.cond2.loopexit, %for.end
%ans.0.lcssa = phi i32 [ 0, %for.end ], [ %ans.1.lcssa, %for.cond2.loopexit ]
%call44 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %ans.0.lcssa)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #5
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #4
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 = { nofree 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 = { 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 #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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
|
#include<stdio.h>
#include<stdlib.h>
int comp(const void*a,const void*b){
if(*(int*)a > *(int*)b)return 1;
else return -1;
}
int main(){
int n;scanf("%d",&n);int tri=0;
int* arr = (int*)malloc(sizeof(int)*2003);
for(int i=0 ;i<n;i++)scanf("%d",&arr[i]);
qsort(arr,n,sizeof(int),comp);
/*int stopper = -1,prev,k,big=0;
for(int i=0;i<n;i++){
stopper = -1;
prev = i+2;
for(int j=i+1;j<n;j++){
if(j!=i+1 )prev = stopper;
if(stopper == j) prev = j+1;
for( k=prev;k<n;k++){
if(arr[i]+arr[j] > arr[k]){//printf("%d %d %d\n",arr[i],arr[j],arr[k] );
big++;
}
else if(k!=n-1){stopper = k;break;}
if(k==n-1){stopper = n;}
}
if(big!=0){tri+=(k-(j+1));}
}
}
*/
for(int i=0;i<n-2;i++){
for(int j=i+1;j<n-1;j++){
for(int k = j+1;k<n;k++){
if(arr[i]+arr[j] > arr[k])tri++;
else break;
}
}
}
printf("%d",tri );
}
/*
4 - 3 4 2 1
1 2 3 4 5 6 7
1 3 5 7 9
218 786 704 233 645 728 389
218 233 389 645 704 728 786
*/ | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208904/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208904/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @comp(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) #0 {
entry:
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %b, align 4, !tbaa !5
%cmp = icmp sgt i32 %0, %1
%. = select i1 %cmp, i32 1, i32 -1
ret i32 %.
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
entry:
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #6
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%call1 = call noalias dereferenceable_or_null(8012) ptr @malloc(i64 noundef 8012) #7
%0 = load i32, ptr %n, align 4, !tbaa !5
%cmp58 = icmp sgt i32 %0, 0
br i1 %cmp58, label %for.body, label %entry.for.cond.cleanup_crit_edge
entry.for.cond.cleanup_crit_edge: ; preds = %entry
%.pre = sext i32 %0 to i64
br label %for.cond.cleanup
for.cond.cleanup: ; preds = %for.body, %entry.for.cond.cleanup_crit_edge
%conv.pre-phi = phi i64 [ %.pre, %entry.for.cond.cleanup_crit_edge ], [ %4, %for.body ]
call void @qsort(ptr noundef %call1, i64 noundef %conv.pre-phi, i64 noundef 4, ptr noundef nonnull @comp) #6
%1 = load i32, ptr %n, align 4, !tbaa !5
%cmp569 = icmp sgt i32 %1, 2
br i1 %cmp569, label %for.body8.lr.ph, label %for.cond.cleanup7
for.body8.lr.ph: ; preds = %for.cond.cleanup
%sub = add nsw i32 %1, -2
%sub10 = add nsw i32 %1, -1
%2 = zext i32 %sub10 to i64
%wide.trip.count90 = zext i32 %sub to i64
%wide.trip.count = zext i32 %sub10 to i64
br label %for.body8
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
%arrayidx = getelementptr inbounds i32, ptr %call1, i64 %indvars.iv
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef %arrayidx)
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%3 = load i32, ptr %n, align 4, !tbaa !5
%4 = sext i32 %3 to i64
%cmp = icmp slt i64 %indvars.iv.next, %4
br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !9
for.cond4.loopexit: ; preds = %cleanup, %for.body8
%tri.1.lcssa = phi i32 [ %tri.070, %for.body8 ], [ %tri.2.lcssa, %cleanup ]
%indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
%indvars.iv.next83 = add nuw nsw i64 %indvars.iv82, 1
%exitcond91.not = icmp eq i64 %indvars.iv.next88, %wide.trip.count90
br i1 %exitcond91.not, label %for.cond.cleanup7, label %for.body8, !llvm.loop !11
for.cond.cleanup7: ; preds = %for.cond4.loopexit, %for.cond.cleanup
%tri.0.lcssa = phi i32 [ 0, %for.cond.cleanup ], [ %tri.1.lcssa, %for.cond4.loopexit ]
%call42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %tri.0.lcssa)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #6
ret i32 0
for.body8: ; preds = %for.body8.lr.ph, %for.cond4.loopexit
%indvars.iv87 = phi i64 [ 0, %for.body8.lr.ph ], [ %indvars.iv.next88, %for.cond4.loopexit ]
%indvars.iv82 = phi i64 [ 1, %for.body8.lr.ph ], [ %indvars.iv.next83, %for.cond4.loopexit ]
%indvars.iv75 = phi i64 [ 2, %for.body8.lr.ph ], [ %indvars.iv.next76, %for.cond4.loopexit ]
%tri.070 = phi i32 [ 0, %for.body8.lr.ph ], [ %tri.1.lcssa, %for.cond4.loopexit ]
%indvars.iv.next88 = add nuw nsw i64 %indvars.iv87, 1
%cmp1165 = icmp ult i64 %indvars.iv.next88, %2
br i1 %cmp1165, label %for.body14.lr.ph, label %for.cond4.loopexit
for.body14.lr.ph: ; preds = %for.body8
%arrayidx22 = getelementptr inbounds i32, ptr %call1, i64 %indvars.iv87
br label %for.body14
for.body14: ; preds = %for.body14.lr.ph, %cleanup
%indvars.iv84 = phi i64 [ %indvars.iv82, %for.body14.lr.ph ], [ %indvars.iv.next85, %cleanup ]
%indvars.iv77 = phi i64 [ %indvars.iv75, %for.body14.lr.ph ], [ %indvars.iv.next78, %cleanup ]
%tri.166 = phi i32 [ %tri.070, %for.body14.lr.ph ], [ %tri.2.lcssa, %cleanup ]
%indvars.iv.next85 = add nuw nsw i64 %indvars.iv84, 1
%5 = trunc i64 %indvars.iv.next85 to i32
%cmp1760 = icmp sgt i32 %1, %5
br i1 %cmp1760, label %for.body20.lr.ph, label %cleanup
for.body20.lr.ph: ; preds = %for.body14
%6 = load i32, ptr %arrayidx22, align 4, !tbaa !5
%arrayidx24 = getelementptr inbounds i32, ptr %call1, i64 %indvars.iv84
%7 = load i32, ptr %arrayidx24, align 4, !tbaa !5
%add25 = add nsw i32 %7, %6
br label %for.body20
for.body20: ; preds = %for.body20.lr.ph, %if.then
%indvars.iv79 = phi i64 [ %indvars.iv77, %for.body20.lr.ph ], [ %indvars.iv.next80, %if.then ]
%tri.261 = phi i32 [ %tri.166, %for.body20.lr.ph ], [ %inc30, %if.then ]
%arrayidx27 = getelementptr inbounds i32, ptr %call1, i64 %indvars.iv79
%8 = load i32, ptr %arrayidx27, align 4, !tbaa !5
%cmp28 = icmp sgt i32 %add25, %8
br i1 %cmp28, label %if.then, label %cleanup
if.then: ; preds = %for.body20
%inc30 = add nsw i32 %tri.261, 1
%indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
%9 = trunc i64 %indvars.iv.next80 to i32
%cmp17 = icmp sgt i32 %1, %9
br i1 %cmp17, label %for.body20, label %cleanup, !llvm.loop !12
cleanup: ; preds = %if.then, %for.body20, %for.body14
%tri.2.lcssa = phi i32 [ %tri.166, %for.body14 ], [ %tri.261, %for.body20 ], [ %inc30, %if.then ]
%indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
%exitcond.not = icmp eq i64 %indvars.iv.next85, %wide.trip.count
br i1 %exitcond.not, label %for.cond4.loopexit, label %for.body14, !llvm.loop !13
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 = { nofree 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
|
// Aizu 2372: IkaNumber
// 2017.10.30 bal4u@uu
#include <stdio.h>
#define INF 0x7fffffff
#define M 1000000007
void multiply(int f[2][2], int m[2][2])
{
unsigned long long x, y, z, w;
x = (unsigned long long)f[0][0]*m[0][0] + (unsigned long long)f[0][1]*m[1][0];
y = (unsigned long long)f[0][0]*m[0][1] + (unsigned long long)f[0][1]*m[1][1];
z = (unsigned long long)f[1][0]*m[0][0] + (unsigned long long)f[1][1]*m[1][0];
w = (unsigned long long)f[1][0]*m[0][1] + (unsigned long long)f[1][1]*m[1][1];
f[0][0] = (int)(x % M);
f[0][1] = (int)(y % M);
f[1][0] = (int)(z % M);
f[1][1] = (int)(w % M);
}
void power(int f[2][2], int n)
{
int m[2][2] = {{1,1},{1,0}};
if( n == 0 || n == 1) return;
power(f, n >> 1);
multiply(f, f);
if (n & 1) multiply(f, m);
}
int fib(int n)
{
int f[2][2] = {{1,1},{1,0}};
// if (n == 0) return 0;
power(f, n-1);
return f[0][0];
}
int main()
{
unsigned long long K, l, r, m;
int a, b;
scanf("%llu", &K);
l = 0;
if (K < INF) r = K; else r = INF;
while (l+1 < r) {
m = (l + r) >> 1;
if (m * (m + 1) < K) l = m; else r = m;
}
K -= l * (l + 1);
a = (int)((l<<1) + (K-1)/r + 1);
if (K > r) K -= r;
if (K <= (r+1)>>1) b = (int)((K<<1) - 1);
else b = (int)(r - (r & 1) - (((K - ((r+1)>>1) - 1))<<1));
printf("%d\n", (int)(((long long)fib(a-b+2)*fib(b+1)) % M));
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208955/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208955/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@__const.fib.f = private unnamed_addr constant [2 x [2 x i32]] [[2 x i32] [i32 1, i32 1], [2 x i32] [i32 1, i32 0]], align 16
@.str = private unnamed_addr constant [5 x i8] c"%llu\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @multiply(ptr nocapture noundef %f, ptr nocapture noundef readonly %m) local_unnamed_addr #0 {
entry:
%0 = load i32, ptr %f, align 4, !tbaa !5
%conv = sext i32 %0 to i64
%1 = load i32, ptr %m, align 4, !tbaa !5
%conv4 = sext i32 %1 to i64
%mul = mul nsw i64 %conv4, %conv
%arrayidx6 = getelementptr inbounds [2 x i32], ptr %f, i64 0, i64 1
%2 = load i32, ptr %arrayidx6, align 4, !tbaa !5
%conv7 = sext i32 %2 to i64
%arrayidx8 = getelementptr inbounds [2 x i32], ptr %m, i64 1
%3 = load i32, ptr %arrayidx8, align 4, !tbaa !5
%conv10 = sext i32 %3 to i64
%mul11 = mul nsw i64 %conv10, %conv7
%add = add i64 %mul11, %mul
%arrayidx16 = getelementptr inbounds [2 x i32], ptr %m, i64 0, i64 1
%4 = load i32, ptr %arrayidx16, align 4, !tbaa !5
%conv17 = sext i32 %4 to i64
%mul18 = mul nsw i64 %conv17, %conv
%arrayidx23 = getelementptr inbounds [2 x i32], ptr %m, i64 1, i64 1
%5 = load i32, ptr %arrayidx23, align 4, !tbaa !5
%conv24 = sext i32 %5 to i64
%mul25 = mul nsw i64 %conv24, %conv7
%add26 = add i64 %mul25, %mul18
%arrayidx27 = getelementptr inbounds [2 x i32], ptr %f, i64 1
%6 = load i32, ptr %arrayidx27, align 4, !tbaa !5
%conv29 = sext i32 %6 to i64
%mul33 = mul nsw i64 %conv29, %conv4
%arrayidx35 = getelementptr inbounds [2 x i32], ptr %f, i64 1, i64 1
%7 = load i32, ptr %arrayidx35, align 4, !tbaa !5
%conv36 = sext i32 %7 to i64
%mul40 = mul nsw i64 %conv36, %conv10
%add41 = add i64 %mul40, %mul33
%mul48 = mul nsw i64 %conv29, %conv17
%mul55 = mul nsw i64 %conv36, %conv24
%add56 = add i64 %mul55, %mul48
%rem = urem i64 %add, 1000000007
%conv57 = trunc i64 %rem to i32
store i32 %conv57, ptr %f, align 4, !tbaa !5
%rem60 = urem i64 %add26, 1000000007
%conv61 = trunc i64 %rem60 to i32
store i32 %conv61, ptr %arrayidx6, align 4, !tbaa !5
%rem64 = urem i64 %add41, 1000000007
%conv65 = trunc i64 %rem64 to i32
store i32 %conv65, ptr %arrayidx27, align 4, !tbaa !5
%rem68 = urem i64 %add56, 1000000007
%conv69 = trunc i64 %rem68 to i32
store i32 %conv69, ptr %arrayidx35, align 4, !tbaa !5
ret void
}
; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @power(ptr nocapture noundef %f, i32 noundef %n) local_unnamed_addr #2 {
entry:
%or.cond = icmp ult i32 %n, 2
br i1 %or.cond, label %cleanup, label %if.end
if.end: ; preds = %entry
%shr = ashr i32 %n, 1
tail call void @power(ptr noundef %f, i32 noundef %shr)
%0 = load i32, ptr %f, align 4, !tbaa !5
%conv.i = sext i32 %0 to i64
%mul.i = mul nsw i64 %conv.i, %conv.i
%arrayidx6.i = getelementptr inbounds [2 x i32], ptr %f, i64 0, i64 1
%1 = load i32, ptr %arrayidx6.i, align 4, !tbaa !5
%conv7.i = sext i32 %1 to i64
%arrayidx8.i = getelementptr inbounds [2 x i32], ptr %f, i64 1
%2 = load i32, ptr %arrayidx8.i, align 4, !tbaa !5
%conv10.i = sext i32 %2 to i64
%mul11.i = mul nsw i64 %conv10.i, %conv7.i
%add.i = add i64 %mul11.i, %mul.i
%arrayidx23.i = getelementptr inbounds [2 x i32], ptr %f, i64 1, i64 1
%3 = load i32, ptr %arrayidx23.i, align 4, !tbaa !5
%conv24.i = sext i32 %3 to i64
%mul25.i44 = add nsw i64 %conv24.i, %conv.i
%add26.i = mul i64 %mul25.i44, %conv7.i
%add41.i = mul i64 %mul25.i44, %conv10.i
%mul55.i = mul nsw i64 %conv24.i, %conv24.i
%add56.i = add i64 %mul55.i, %mul11.i
%rem.i = urem i64 %add.i, 1000000007
%conv57.i = trunc i64 %rem.i to i32
store i32 %conv57.i, ptr %f, align 4, !tbaa !5
%rem60.i = urem i64 %add26.i, 1000000007
%conv61.i = trunc i64 %rem60.i to i32
store i32 %conv61.i, ptr %arrayidx6.i, align 4, !tbaa !5
%rem64.i = urem i64 %add41.i, 1000000007
%conv65.i = trunc i64 %rem64.i to i32
store i32 %conv65.i, ptr %arrayidx8.i, align 4, !tbaa !5
%rem68.i = urem i64 %add56.i, 1000000007
%conv69.i = trunc i64 %rem68.i to i32
store i32 %conv69.i, ptr %arrayidx23.i, align 4, !tbaa !5
%and = and i32 %n, 1
%tobool.not = icmp eq i32 %and, 0
br i1 %tobool.not, label %cleanup, label %if.then2
if.then2: ; preds = %if.end
%add.i18 = add nuw nsw i64 %rem60.i, %rem.i
%add41.i32 = add nuw nsw i64 %rem68.i, %rem64.i
%add.i18.frozen = freeze i64 %add.i18
%rem.i36.urem = add i64 %add.i18.frozen, 3294967289
%rem.i36.cmp = icmp ult i64 %add.i18.frozen, 1000000007
%rem.i36 = select i1 %rem.i36.cmp, i64 %add.i18.frozen, i64 %rem.i36.urem
%conv57.i37 = trunc i64 %rem.i36 to i32
store i32 %conv57.i37, ptr %f, align 4, !tbaa !5
store i32 %conv57.i, ptr %arrayidx6.i, align 4, !tbaa !5
%add41.i32.frozen = freeze i64 %add41.i32
%rem64.i40.urem = add i64 %add41.i32.frozen, 3294967289
%rem64.i40.cmp = icmp ult i64 %add41.i32.frozen, 1000000007
%rem64.i40 = select i1 %rem64.i40.cmp, i64 %add41.i32.frozen, i64 %rem64.i40.urem
%conv65.i41 = trunc i64 %rem64.i40 to i32
store i32 %conv65.i41, ptr %arrayidx8.i, align 4, !tbaa !5
store i32 %conv65.i, ptr %arrayidx23.i, align 4, !tbaa !5
br label %cleanup
cleanup: ; preds = %if.end, %if.then2, %entry
ret void
}
; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3
; Function Attrs: nofree nosync nounwind memory(none) uwtable
define dso_local i32 @fib(i32 noundef %n) local_unnamed_addr #4 {
entry:
%f = alloca [2 x [2 x i32]], align 16
call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %f) #8
call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %f, ptr noundef nonnull align 16 dereferenceable(16) @__const.fib.f, i64 16, i1 false)
%sub = add nsw i32 %n, -1
call void @power(ptr noundef nonnull %f, i32 noundef %sub)
%0 = load i32, ptr %f, align 16, !tbaa !5
call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %f) #8
ret i32 %0
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #5 {
entry:
%f.i63 = alloca [2 x [2 x i32]], align 16
%f.i = alloca [2 x [2 x i32]], align 16
%K = alloca i64, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %K) #8
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %K)
%0 = load i64, ptr %K, align 8, !tbaa !9
%. = call i64 @llvm.umin.i64(i64 %0, i64 2147483647)
%cmp164 = icmp ugt i64 %0, 1
br i1 %cmp164, label %while.body, label %while.end
while.body: ; preds = %entry, %while.body
%l.066 = phi i64 [ %shr.l.0, %while.body ], [ 0, %entry ]
%r.165 = phi i64 [ %r.1.shr, %while.body ], [ %., %entry ]
%add2 = add i64 %l.066, %r.165
%shr = lshr i64 %add2, 1
%add3 = add nuw i64 %shr, 1
%mul = mul i64 %add3, %shr
%cmp4 = icmp ult i64 %mul, %0
%r.1.shr = select i1 %cmp4, i64 %r.165, i64 %shr
%shr.l.0 = select i1 %cmp4, i64 %shr, i64 %l.066
%add = add i64 %shr.l.0, 1
%cmp1 = icmp ult i64 %add, %r.1.shr
br i1 %cmp1, label %while.body, label %while.end, !llvm.loop !11
while.end: ; preds = %while.body, %entry
%r.1.lcssa = phi i64 [ %., %entry ], [ %r.1.shr, %while.body ]
%l.0.lcssa = phi i64 [ 0, %entry ], [ %shr.l.0, %while.body ]
%add.lcssa = phi i64 [ 1, %entry ], [ %add, %while.body ]
%mul9 = mul i64 %add.lcssa, %l.0.lcssa
%sub = sub i64 %0, %mul9
%cmp13 = icmp ugt i64 %sub, %r.1.lcssa
%sub16 = select i1 %cmp13, i64 %r.1.lcssa, i64 0
%spec.select = sub i64 %sub, %sub16
store i64 %spec.select, ptr %K, align 8, !tbaa !9
%add18 = add nuw i64 %r.1.lcssa, 1
%shr19 = lshr i64 %add18, 1
%cmp20.not = icmp ugt i64 %spec.select, %shr19
br i1 %cmp20.not, label %if.else26, label %if.then22
if.then22: ; preds = %while.end
%storemerge.tr = trunc i64 %spec.select to i32
%1 = shl i32 %storemerge.tr, 1
%conv25 = add i32 %1, -1
br label %if.end35
if.else26: ; preds = %while.end
%sub27 = and i64 %r.1.lcssa, 4294967294
%2 = xor i64 %shr19, -1
%sub31 = add i64 %spec.select, %2
%shl32 = shl i64 %sub31, 1
%sub33 = sub i64 %sub27, %shl32
%conv34 = trunc i64 %sub33 to i32
br label %if.end35
if.end35: ; preds = %if.else26, %if.then22
%b.0 = phi i32 [ %conv25, %if.then22 ], [ %conv34, %if.else26 ]
%shl = shl i64 %l.0.lcssa, 1
%sub10 = add i64 %sub, -1
%div = udiv i64 %sub10, %r.1.lcssa
%add11 = add i64 %div, %shl
%3 = trunc i64 %add11 to i32
call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %f.i) #8
call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %f.i, ptr noundef nonnull align 16 dereferenceable(16) @__const.fib.f, i64 16, i1 false)
%reass.sub = sub i32 %3, %b.0
%sub.i = add i32 %reass.sub, 2
call void @power(ptr noundef nonnull %f.i, i32 noundef %sub.i)
%4 = load i32, ptr %f.i, align 16, !tbaa !5
call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %f.i) #8
%conv39 = sext i32 %4 to i64
call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %f.i63) #8
call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %f.i63, ptr noundef nonnull align 16 dereferenceable(16) @__const.fib.f, i64 16, i1 false)
call void @power(ptr noundef nonnull %f.i63, i32 noundef %b.0)
%5 = load i32, ptr %f.i63, align 16, !tbaa !5
call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %f.i63) #8
%conv42 = sext i32 %5 to i64
%mul43 = mul nsw i64 %conv42, %conv39
%rem = srem i64 %mul43, 1000000007
%conv44 = trunc i64 %rem to i32
%call45 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %conv44)
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %K) #8
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #6
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #7
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nosync nounwind memory(argmem: 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nofree nosync nounwind memory(none) 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 #5 = { nofree 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 #6 = { 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 #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!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 long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
|
#include<stdio.h>
#include<stdlib.h>
typedef struct UnionFind{
int *parent;
int n;
} UnionFind;
UnionFind* newUnionFind(int n){
UnionFind *u=(UnionFind *)calloc(1,sizeof(UnionFind));
u->parent=(int *)calloc(n,sizeof(int));
u->n=n;
for(int i=0;i<n;i++) u->parent[i]=-1;
return u;
}
int root(UnionFind *u,int x){
if(u->parent[x]<0) return x;
return u->parent[x]=root(u,u->parent[x]);
}
int same(UnionFind *u,int x,int y){
return root(u,x)==root(u,y);
}
int getSize(UnionFind *u,int x){
return -u->parent[root(u,x)];
}
void unite(UnionFind *u,int x,int y){
x=root(u,x);
y=root(u,y);
if(x==y) return;
if(u->parent[x]>u->parent[y]){
int swap=x;
x=y;
y=swap;
}
u->parent[x]+=u->parent[y];
u->parent[y]=x;
}
typedef long long int int64;
typedef struct weightEdge{
int a,b;
int64 c;
} edge;
int cmpEdge(const void *a,const void *b){
int64 p=((edge *)a)->c;
int64 q=((edge *)b)->c;
return p==q?0:p<q?1:-1;
}
void run(void){
int n;
scanf("%d",&n);
edge *e=(edge *)calloc(n-1,sizeof(edge));
int i;
for(i=0;i<n-1;i++){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
a--;b--;
e[i]=(edge){a,b,c};
}
qsort(e,n-1,sizeof(edge),cmpEdge);
int *r=(int *)calloc(n,sizeof(int));
for(i=0;i<n;i++) r[i]=i;
edge *binaryTreeEdge=(edge *)calloc(2*n,sizeof(edge));
int len=0;
UnionFind *u=newUnionFind(n);
for(i=0;i<n-1;i++){
int a=e[i].a;
int b=e[i].b;
int64 c=e[i].c;
int64 sa=getSize(u,a);
int64 sb=getSize(u,b);
binaryTreeEdge[len++]=(edge){n+i,r[root(u,a)],sb*c};
binaryTreeEdge[len++]=(edge){n+i,r[root(u,b)],sa*c};
unite(u,a,b);
r[root(u,a)]=n+i;
}
int64 *dp=(int64 *)calloc(2*n,sizeof(int64));
for(i=len-1;i>=0;i--){
int from=binaryTreeEdge[i].a;
int to=binaryTreeEdge[i].b;
int64 weight=binaryTreeEdge[i].c;
dp[to]=dp[from]+weight;
}
for(i=0;i<n;i++) printf("%lld\n",dp[i]);
}
int main(void){
run();
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_208999/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_208999/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.UnionFind = type { ptr, i32 }
%struct.weightEdge = type { i32, i32, i64 }
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [7 x i8] c"%d%d%d\00", align 1
@.str.2 = private unnamed_addr constant [6 x i8] c"%lld\0A\00", align 1
; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: none, inaccessiblemem: readwrite) uwtable
define dso_local noalias ptr @newUnionFind(i32 noundef %n) local_unnamed_addr #0 {
entry:
%call = tail call noalias dereferenceable_or_null(16) ptr @calloc(i64 noundef 1, i64 noundef 16) #9
%conv = sext i32 %n to i64
%call1 = tail call noalias ptr @calloc(i64 noundef %conv, i64 noundef 4) #9
store ptr %call1, ptr %call, align 8, !tbaa !5
%n2 = getelementptr inbounds %struct.UnionFind, ptr %call, i64 0, i32 1
store i32 %n, ptr %n2, align 8, !tbaa !11
%cmp12 = icmp sgt i32 %n, 0
br i1 %cmp12, label %for.body.preheader, label %for.cond.cleanup
for.body.preheader: ; preds = %entry
%0 = zext i32 %n to i64
%1 = shl nuw nsw i64 %0, 2
tail call void @llvm.memset.p0.i64(ptr align 4 %call1, i8 -1, i64 %1, i1 false), !tbaa !12
br label %for.cond.cleanup
for.cond.cleanup: ; preds = %for.body.preheader, %entry
ret ptr %call
}
; 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 nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local i32 @root(ptr nocapture noundef readonly %u, i32 noundef %x) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr %u, align 8, !tbaa !5
%idxprom = sext i32 %x to i64
%arrayidx = getelementptr inbounds i32, ptr %0, i64 %idxprom
%1 = load i32, ptr %arrayidx, align 4, !tbaa !12
%cmp = icmp slt i32 %1, 0
br i1 %cmp, label %common.ret13, label %if.end
common.ret13: ; preds = %entry, %if.end
%common.ret13.op = phi i32 [ %call, %if.end ], [ %x, %entry ]
ret i32 %common.ret13.op
if.end: ; preds = %entry
%call = tail call i32 @root(ptr noundef nonnull %u, i32 noundef %1)
%2 = load ptr, ptr %u, align 8, !tbaa !5
%arrayidx6 = getelementptr inbounds i32, ptr %2, i64 %idxprom
store i32 %call, ptr %arrayidx6, align 4, !tbaa !12
br label %common.ret13
}
; Function Attrs: nofree nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local i32 @same(ptr nocapture noundef readonly %u, i32 noundef %x, i32 noundef %y) local_unnamed_addr #3 {
entry:
%call = tail call i32 @root(ptr noundef %u, i32 noundef %x)
%call1 = tail call i32 @root(ptr noundef %u, i32 noundef %y)
%cmp = icmp eq i32 %call, %call1
%conv = zext i1 %cmp to i32
ret i32 %conv
}
; Function Attrs: nofree nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local i32 @getSize(ptr nocapture noundef readonly %u, i32 noundef %x) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr %u, align 8, !tbaa !5
%call = tail call i32 @root(ptr noundef nonnull %u, i32 noundef %x)
%idxprom = sext i32 %call to i64
%arrayidx = getelementptr inbounds i32, ptr %0, i64 %idxprom
%1 = load i32, ptr %arrayidx, align 4, !tbaa !12
%sub = sub nsw i32 0, %1
ret i32 %sub
}
; Function Attrs: nofree nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @unite(ptr nocapture noundef readonly %u, i32 noundef %x, i32 noundef %y) local_unnamed_addr #3 {
entry:
%call = tail call i32 @root(ptr noundef %u, i32 noundef %x)
%call1 = tail call i32 @root(ptr noundef %u, i32 noundef %y)
%cmp = icmp eq i32 %call, %call1
br i1 %cmp, label %return, label %if.end
if.end: ; preds = %entry
%0 = load ptr, ptr %u, align 8, !tbaa !5
%idxprom = sext i32 %call to i64
%arrayidx = getelementptr inbounds i32, ptr %0, i64 %idxprom
%1 = load i32, ptr %arrayidx, align 4, !tbaa !12
%idxprom3 = sext i32 %call1 to i64
%arrayidx4 = getelementptr inbounds i32, ptr %0, i64 %idxprom3
%2 = load i32, ptr %arrayidx4, align 4, !tbaa !12
%cmp5 = icmp sgt i32 %1, %2
%spec.select = select i1 %cmp5, i32 %call, i32 %call1
%spec.select33 = select i1 %cmp5, i32 %call1, i32 %call
%idxprom9 = sext i32 %spec.select to i64
%arrayidx10 = getelementptr inbounds i32, ptr %0, i64 %idxprom9
%3 = load i32, ptr %arrayidx10, align 4, !tbaa !12
%idxprom12 = sext i32 %spec.select33 to i64
%arrayidx13 = getelementptr inbounds i32, ptr %0, i64 %idxprom12
%4 = load i32, ptr %arrayidx13, align 4, !tbaa !12
%add = add nsw i32 %4, %3
store i32 %add, ptr %arrayidx13, align 4, !tbaa !12
store i32 %spec.select33, ptr %arrayidx10, align 4, !tbaa !12
br label %return
return: ; preds = %entry, %if.end
ret void
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @cmpEdge(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) #4 {
entry:
%c = getelementptr inbounds %struct.weightEdge, ptr %a, i64 0, i32 2
%0 = load i64, ptr %c, align 8, !tbaa !13
%c1 = getelementptr inbounds %struct.weightEdge, ptr %b, i64 0, i32 2
%1 = load i64, ptr %c1, align 8, !tbaa !13
%cmp = icmp eq i64 %0, %1
%cmp2 = icmp slt i64 %0, %1
%cond = select i1 %cmp2, i32 1, i32 -1
%cond3 = select i1 %cmp, i32 0, i32 %cond
ret i32 %cond3
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @run() local_unnamed_addr #5 {
entry:
%n = alloca i32, align 4
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #10
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !12
%sub = add nsw i32 %0, -1
%conv = sext i32 %sub to i64
%call1 = call noalias ptr @calloc(i64 noundef %conv, i64 noundef 16) #9
%cmp170 = icmp sgt i32 %0, 1
br i1 %cmp170, label %for.body, label %for.end
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #10
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #10
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #10
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c)
%1 = load i32, ptr %a, align 4, !tbaa !12
%dec = add nsw i32 %1, -1
%2 = load i32, ptr %b, align 4, !tbaa !12
%dec5 = add nsw i32 %2, -1
%arrayidx = getelementptr inbounds %struct.weightEdge, ptr %call1, i64 %indvars.iv
%3 = load i32, ptr %c, align 4, !tbaa !12
%conv9 = sext i32 %3 to i64
store i32 %dec, ptr %arrayidx, align 8, !tbaa.struct !16
%.compoundliteral.sroa.2.0.arrayidx.sroa_idx = getelementptr inbounds i8, ptr %arrayidx, i64 4
store i32 %dec5, ptr %.compoundliteral.sroa.2.0.arrayidx.sroa_idx, align 4, !tbaa.struct !18
%.compoundliteral.sroa.3.0.arrayidx.sroa_idx = getelementptr inbounds i8, ptr %arrayidx, i64 8
store i64 %conv9, ptr %.compoundliteral.sroa.3.0.arrayidx.sroa_idx, align 8, !tbaa.struct !19
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #10
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #10
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #10
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%4 = load i32, ptr %n, align 4, !tbaa !12
%sub2 = add nsw i32 %4, -1
%5 = sext i32 %sub2 to i64
%cmp = icmp slt i64 %indvars.iv.next, %5
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !20
for.end: ; preds = %for.body, %entry
%conv11.pre-phi = phi i64 [ %conv, %entry ], [ %5, %for.body ]
call void @qsort(ptr noundef %call1, i64 noundef %conv11.pre-phi, i64 noundef 16, ptr noundef nonnull @cmpEdge) #10
%6 = load i32, ptr %n, align 4, !tbaa !12
%conv12 = sext i32 %6 to i64
%call13 = call noalias ptr @calloc(i64 noundef %conv12, i64 noundef 4) #9
%cmp15172 = icmp sgt i32 %6, 0
br i1 %cmp15172, label %for.body17.preheader, label %for.end22
for.body17.preheader: ; preds = %for.end
%wide.trip.count = zext i32 %6 to i64
%min.iters.check = icmp ult i32 %6, 8
br i1 %min.iters.check, label %for.body17.preheader215, label %vector.ph
vector.ph: ; preds = %for.body17.preheader
%n.vec = and i64 %wide.trip.count, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
%step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
%7 = getelementptr inbounds i32, ptr %call13, i64 %index
store <4 x i32> %vec.ind, ptr %7, align 4, !tbaa !12
%8 = getelementptr inbounds i32, ptr %7, i64 4
store <4 x i32> %step.add, ptr %8, align 4, !tbaa !12
%index.next = add nuw i64 %index, 8
%vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
%9 = icmp eq i64 %index.next, %n.vec
br i1 %9, label %middle.block, label %vector.body, !llvm.loop !22
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count
br i1 %cmp.n, label %for.end22, label %for.body17.preheader215
for.body17.preheader215: ; preds = %for.body17.preheader, %middle.block
%indvars.iv187.ph = phi i64 [ 0, %for.body17.preheader ], [ %n.vec, %middle.block ]
br label %for.body17
for.body17: ; preds = %for.body17.preheader215, %for.body17
%indvars.iv187 = phi i64 [ %indvars.iv.next188, %for.body17 ], [ %indvars.iv187.ph, %for.body17.preheader215 ]
%arrayidx19 = getelementptr inbounds i32, ptr %call13, i64 %indvars.iv187
%10 = trunc i64 %indvars.iv187 to i32
store i32 %10, ptr %arrayidx19, align 4, !tbaa !12
%indvars.iv.next188 = add nuw nsw i64 %indvars.iv187, 1
%exitcond.not = icmp eq i64 %indvars.iv.next188, %wide.trip.count
br i1 %exitcond.not, label %for.end22, label %for.body17, !llvm.loop !25
for.end22: ; preds = %for.body17, %middle.block, %for.end
%mul = shl nsw i32 %6, 1
%conv23 = sext i32 %mul to i64
%call24 = call noalias ptr @calloc(i64 noundef %conv23, i64 noundef 16) #9
%call.i = call noalias dereferenceable_or_null(16) ptr @calloc(i64 noundef 1, i64 noundef 16) #9
%call1.i = call noalias ptr @calloc(i64 noundef %conv12, i64 noundef 4) #9
store ptr %call1.i, ptr %call.i, align 8, !tbaa !5
%n2.i = getelementptr inbounds %struct.UnionFind, ptr %call.i, i64 0, i32 1
store i32 %6, ptr %n2.i, align 8, !tbaa !11
br i1 %cmp15172, label %newUnionFind.exit, label %for.end76.thread
newUnionFind.exit: ; preds = %for.end22
%11 = zext i32 %6 to i64
%12 = shl nuw nsw i64 %11, 2
call void @llvm.memset.p0.i64(ptr align 4 %call1.i, i8 -1, i64 %12, i1 false), !tbaa !12
%cmp28175.not = icmp eq i32 %6, 1
br i1 %cmp28175.not, label %for.end76.thread, label %for.body30
for.body30: ; preds = %newUnionFind.exit, %unite.exit
%indvars.iv192 = phi i64 [ %indvars.iv.next193, %unite.exit ], [ 0, %newUnionFind.exit ]
%indvars.iv190 = phi i64 [ %indvars.iv.next191, %unite.exit ], [ 0, %newUnionFind.exit ]
%arrayidx33 = getelementptr inbounds %struct.weightEdge, ptr %call1, i64 %indvars.iv190
%13 = load i32, ptr %arrayidx33, align 8, !tbaa !26
%b38 = getelementptr inbounds %struct.weightEdge, ptr %call1, i64 %indvars.iv190, i32 1
%14 = load i32, ptr %b38, align 4, !tbaa !27
%c42 = getelementptr inbounds %struct.weightEdge, ptr %call1, i64 %indvars.iv190, i32 2
%15 = load i64, ptr %c42, align 8, !tbaa !13
%call.i160 = call i32 @root(ptr noundef nonnull %call.i, i32 noundef %13)
%idxprom.i = sext i32 %call.i160 to i64
%arrayidx.i = getelementptr inbounds i32, ptr %call1.i, i64 %idxprom.i
%16 = load i32, ptr %arrayidx.i, align 4, !tbaa !12
%sub.i = sub nsw i32 0, %16
%conv44 = sext i32 %sub.i to i64
%call.i161 = call i32 @root(ptr noundef nonnull %call.i, i32 noundef %14)
%idxprom.i162 = sext i32 %call.i161 to i64
%arrayidx.i163 = getelementptr inbounds i32, ptr %call1.i, i64 %idxprom.i162
%17 = load i32, ptr %arrayidx.i163, align 4, !tbaa !12
%sub.i164 = sub nsw i32 0, %17
%conv46 = sext i32 %sub.i164 to i64
%18 = or i64 %indvars.iv192, 1
%arrayidx49 = getelementptr inbounds %struct.weightEdge, ptr %call24, i64 %indvars.iv192
%19 = load i32, ptr %n, align 4, !tbaa !12
%20 = trunc i64 %indvars.iv190 to i32
%add = add nsw i32 %19, %20
%call53 = call i32 @root(ptr noundef nonnull %call.i, i32 noundef %13)
%idxprom54 = sext i32 %call53 to i64
%arrayidx55 = getelementptr inbounds i32, ptr %call13, i64 %idxprom54
%21 = load i32, ptr %arrayidx55, align 4, !tbaa !12
%mul57 = mul nsw i64 %15, %conv46
store i32 %add, ptr %arrayidx49, align 8, !tbaa.struct !16
%.compoundliteral50.sroa.2.0.arrayidx49.sroa_idx = getelementptr inbounds i8, ptr %arrayidx49, i64 4
store i32 %21, ptr %.compoundliteral50.sroa.2.0.arrayidx49.sroa_idx, align 4, !tbaa.struct !18
%.compoundliteral50.sroa.3.0.arrayidx49.sroa_idx = getelementptr inbounds i8, ptr %arrayidx49, i64 8
store i64 %mul57, ptr %.compoundliteral50.sroa.3.0.arrayidx49.sroa_idx, align 8, !tbaa.struct !19
%indvars.iv.next193 = add nuw nsw i64 %indvars.iv192, 2
%arrayidx60 = getelementptr inbounds %struct.weightEdge, ptr %call24, i64 %18
%22 = load i32, ptr %n, align 4, !tbaa !12
%add63 = add nsw i32 %22, %20
%call65 = call i32 @root(ptr noundef nonnull %call.i, i32 noundef %14)
%idxprom66 = sext i32 %call65 to i64
%arrayidx67 = getelementptr inbounds i32, ptr %call13, i64 %idxprom66
%23 = load i32, ptr %arrayidx67, align 4, !tbaa !12
%mul69 = mul nsw i64 %15, %conv44
store i32 %add63, ptr %arrayidx60, align 8, !tbaa.struct !16
%.compoundliteral61.sroa.2.0.arrayidx60.sroa_idx = getelementptr inbounds i8, ptr %arrayidx60, i64 4
store i32 %23, ptr %.compoundliteral61.sroa.2.0.arrayidx60.sroa_idx, align 4, !tbaa.struct !18
%.compoundliteral61.sroa.3.0.arrayidx60.sroa_idx = getelementptr inbounds i8, ptr %arrayidx60, i64 8
store i64 %mul69, ptr %.compoundliteral61.sroa.3.0.arrayidx60.sroa_idx, align 8, !tbaa.struct !19
%call.i165 = call i32 @root(ptr noundef nonnull %call.i, i32 noundef %13)
%call1.i166 = call i32 @root(ptr noundef nonnull %call.i, i32 noundef %14)
%cmp.i = icmp eq i32 %call.i165, %call1.i166
br i1 %cmp.i, label %unite.exit, label %if.end.i
if.end.i: ; preds = %for.body30
%idxprom.i167 = sext i32 %call.i165 to i64
%arrayidx.i168 = getelementptr inbounds i32, ptr %call1.i, i64 %idxprom.i167
%24 = load i32, ptr %arrayidx.i168, align 4, !tbaa !12
%idxprom3.i = sext i32 %call1.i166 to i64
%arrayidx4.i = getelementptr inbounds i32, ptr %call1.i, i64 %idxprom3.i
%25 = load i32, ptr %arrayidx4.i, align 4, !tbaa !12
%cmp5.i = icmp sgt i32 %24, %25
%spec.select.i = select i1 %cmp5.i, i32 %call.i165, i32 %call1.i166
%spec.select33.i = select i1 %cmp5.i, i32 %call1.i166, i32 %call.i165
%idxprom9.i = sext i32 %spec.select.i to i64
%arrayidx10.i = getelementptr inbounds i32, ptr %call1.i, i64 %idxprom9.i
%26 = load i32, ptr %arrayidx10.i, align 4, !tbaa !12
%idxprom12.i = sext i32 %spec.select33.i to i64
%arrayidx13.i = getelementptr inbounds i32, ptr %call1.i, i64 %idxprom12.i
%27 = load i32, ptr %arrayidx13.i, align 4, !tbaa !12
%add.i = add nsw i32 %27, %26
store i32 %add.i, ptr %arrayidx13.i, align 4, !tbaa !12
store i32 %spec.select33.i, ptr %arrayidx10.i, align 4, !tbaa !12
br label %unite.exit
unite.exit: ; preds = %for.body30, %if.end.i
%28 = load i32, ptr %n, align 4, !tbaa !12
%add70 = add nsw i32 %28, %20
%call71 = call i32 @root(ptr noundef nonnull %call.i, i32 noundef %13)
%idxprom72 = sext i32 %call71 to i64
%arrayidx73 = getelementptr inbounds i32, ptr %call13, i64 %idxprom72
store i32 %add70, ptr %arrayidx73, align 4, !tbaa !12
%indvars.iv.next191 = add nuw nsw i64 %indvars.iv190, 1
%29 = load i32, ptr %n, align 4, !tbaa !12
%sub27 = add nsw i32 %29, -1
%30 = sext i32 %sub27 to i64
%cmp28 = icmp slt i64 %indvars.iv.next191, %30
br i1 %cmp28, label %for.body30, label %for.end76, !llvm.loop !28
for.end76.thread: ; preds = %newUnionFind.exit, %for.end22
%call79209 = call noalias ptr @calloc(i64 noundef %conv23, i64 noundef 8) #9
br label %for.cond102.preheader
for.end76: ; preds = %unite.exit
%31 = trunc i64 %indvars.iv.next193 to i32
%.pre = shl nsw i32 %29, 1
%.pre205 = sext i32 %.pre to i64
%call79 = call noalias ptr @calloc(i64 noundef %.pre205, i64 noundef 8) #9
%cmp82180 = icmp sgt i32 %31, 0
br i1 %cmp82180, label %for.body84.preheader, label %for.cond102.preheader
for.body84.preheader: ; preds = %for.end76
%32 = and i64 %indvars.iv.next193, 4294967294
br label %for.body84
for.cond102.preheader: ; preds = %for.body84, %for.end76.thread, %for.end76
%call79211 = phi ptr [ %call79209, %for.end76.thread ], [ %call79, %for.end76 ], [ %call79, %for.body84 ]
%33 = phi i32 [ %6, %for.end76.thread ], [ %29, %for.end76 ], [ %29, %for.body84 ]
%cmp103182 = icmp sgt i32 %33, 0
br i1 %cmp103182, label %for.body105, label %for.end111
for.body84: ; preds = %for.body84, %for.body84.preheader
%indvars.iv198 = phi i64 [ %32, %for.body84.preheader ], [ %indvars.iv.next199.1, %for.body84 ]
%indvars.iv.next199 = add nsw i64 %indvars.iv198, -1
%idxprom85 = and i64 %indvars.iv.next199, 4294967295
%arrayidx86 = getelementptr inbounds %struct.weightEdge, ptr %call24, i64 %idxprom85
%34 = load i32, ptr %arrayidx86, align 8, !tbaa !26
%b90 = getelementptr inbounds %struct.weightEdge, ptr %call24, i64 %idxprom85, i32 1
%35 = load i32, ptr %b90, align 4, !tbaa !27
%c93 = getelementptr inbounds %struct.weightEdge, ptr %call24, i64 %idxprom85, i32 2
%36 = load i64, ptr %c93, align 8, !tbaa !13
%idxprom94 = sext i32 %34 to i64
%arrayidx95 = getelementptr inbounds i64, ptr %call79, i64 %idxprom94
%37 = load i64, ptr %arrayidx95, align 8, !tbaa !17
%add96 = add nsw i64 %37, %36
%idxprom97 = sext i32 %35 to i64
%arrayidx98 = getelementptr inbounds i64, ptr %call79, i64 %idxprom97
store i64 %add96, ptr %arrayidx98, align 8, !tbaa !17
%indvars.iv.next199.1 = add nsw i64 %indvars.iv198, -2
%idxprom85.1 = and i64 %indvars.iv.next199.1, 4294967294
%arrayidx86.1 = getelementptr inbounds %struct.weightEdge, ptr %call24, i64 %idxprom85.1
%38 = load i32, ptr %arrayidx86.1, align 8, !tbaa !26
%b90.1 = getelementptr inbounds %struct.weightEdge, ptr %call24, i64 %idxprom85.1, i32 1
%39 = load i32, ptr %b90.1, align 4, !tbaa !27
%c93.1 = getelementptr inbounds %struct.weightEdge, ptr %call24, i64 %idxprom85.1, i32 2
%40 = load i64, ptr %c93.1, align 8, !tbaa !13
%idxprom94.1 = sext i32 %38 to i64
%arrayidx95.1 = getelementptr inbounds i64, ptr %call79, i64 %idxprom94.1
%41 = load i64, ptr %arrayidx95.1, align 8, !tbaa !17
%add96.1 = add nsw i64 %41, %40
%idxprom97.1 = sext i32 %39 to i64
%arrayidx98.1 = getelementptr inbounds i64, ptr %call79, i64 %idxprom97.1
store i64 %add96.1, ptr %arrayidx98.1, align 8, !tbaa !17
%cmp82.1.not = icmp eq i64 %indvars.iv.next199, 1
br i1 %cmp82.1.not, label %for.cond102.preheader, label %for.body84, !llvm.loop !29
for.body105: ; preds = %for.cond102.preheader, %for.body105
%indvars.iv201 = phi i64 [ %indvars.iv.next202, %for.body105 ], [ 0, %for.cond102.preheader ]
%arrayidx107 = getelementptr inbounds i64, ptr %call79211, i64 %indvars.iv201
%42 = load i64, ptr %arrayidx107, align 8, !tbaa !17
%call108 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %42)
%indvars.iv.next202 = add nuw nsw i64 %indvars.iv201, 1
%43 = load i32, ptr %n, align 4, !tbaa !12
%44 = sext i32 %43 to i64
%cmp103 = icmp slt i64 %indvars.iv.next202, %44
br i1 %cmp103, label %for.body105, label %for.end111, !llvm.loop !30
for.end111: ; preds = %for.body105, %for.cond102.preheader
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #10
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #6
; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #7
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #6
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #5 {
entry:
tail call void @run()
ret i32 0
}
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #8
attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) 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 #3 = { nofree nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 #5 = { nofree 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 #6 = { 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 #7 = { 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 #8 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #9 = { nounwind allocsize(0,1) }
attributes #10 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"UnionFind", !7, i64 0, !10, i64 8}
!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 8}
!12 = !{!10, !10, i64 0}
!13 = !{!14, !15, i64 8}
!14 = !{!"weightEdge", !10, i64 0, !10, i64 4, !15, i64 8}
!15 = !{!"long long", !8, i64 0}
!16 = !{i64 0, i64 4, !12, i64 4, i64 4, !12, i64 8, i64 8, !17}
!17 = !{!15, !15, i64 0}
!18 = !{i64 0, i64 4, !12, i64 4, i64 8, !17}
!19 = !{i64 0, i64 8, !17}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21, !23, !24}
!23 = !{!"llvm.loop.isvectorized", i32 1}
!24 = !{!"llvm.loop.unroll.runtime.disable"}
!25 = distinct !{!25, !21, !24, !23}
!26 = !{!14, !10, i64 0}
!27 = !{!14, !10, i64 4}
!28 = distinct !{!28, !21}
!29 = distinct !{!29, !21}
!30 = distinct !{!30, !21}
|
#include<stdio.h>
int main()
{
int H, W, h, w;
H>0, W>0;
H>=h, W>=w;
scanf("%d %d", &H ,&W);
scanf("%d %d", &h ,&w);
printf("%d\n", (H-h)*(W-w));
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209040/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209040/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%H = alloca i32, align 4
%W = alloca i32, align 4
%h = alloca i32, align 4
%w = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %H) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %W) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %h) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %w) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %H, ptr noundef nonnull %W)
%call7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %h, ptr noundef nonnull %w)
%0 = load i32, ptr %H, align 4, !tbaa !5
%1 = load i32, ptr %h, align 4, !tbaa !5
%sub = sub nsw i32 %0, %1
%2 = load i32, ptr %W, align 4, !tbaa !5
%3 = load i32, ptr %w, align 4, !tbaa !5
%sub8 = sub nsw i32 %2, %3
%mul = mul nsw i32 %sub8, %sub
%call9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %mul)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %w) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %h) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %W) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %H) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(void){
int H, W, h ,w;
scanf("%d%d%d%d", &H, &W, &h, &w);
printf("%d\n", H*W-(h*W+w*H-h*w));
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209084/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209084/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [9 x i8] c"%d%d%d%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%H = alloca i32, align 4
%W = alloca i32, align 4
%h = alloca i32, align 4
%w = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %H) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %W) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %h) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %w) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %H, ptr noundef nonnull %W, ptr noundef nonnull %h, ptr noundef nonnull %w)
%0 = load i32, ptr %H, align 4, !tbaa !5
%1 = load i32, ptr %W, align 4, !tbaa !5
%2 = load i32, ptr %h, align 4, !tbaa !5
%3 = load i32, ptr %w, align 4, !tbaa !5
%reass.add = sub i32 %2, %0
%reass.mul = mul i32 %reass.add, %3
%reass.add6 = sub i32 %0, %2
%reass.mul7 = mul i32 %reass.add6, %1
%sub4 = add i32 %reass.mul7, %reass.mul
%call5 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %sub4)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %w) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %h) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %W) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %H) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(void){
int H,W,h,w,white;
scanf("%d %d %d %d",&H,&W,&h,&w);
white = H*W-h*W-w*H+h*w;
printf("%d",white);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209134/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209134/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [12 x i8] c"%d %d %d %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%H = alloca i32, align 4
%W = alloca i32, align 4
%h = alloca i32, align 4
%w = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %H) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %W) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %h) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %w) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %H, ptr noundef nonnull %W, ptr noundef nonnull %h, ptr noundef nonnull %w)
%0 = load i32, ptr %H, align 4, !tbaa !5
%1 = load i32, ptr %W, align 4, !tbaa !5
%2 = load i32, ptr %h, align 4, !tbaa !5
%mul6 = sub i32 %0, %2
%sub = mul i32 %mul6, %1
%3 = load i32, ptr %w, align 4, !tbaa !5
%reass.add = sub i32 %2, %0
%reass.mul = mul i32 %reass.add, %3
%add = add i32 %reass.mul, %sub
%call5 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %add)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %w) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %h) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %W) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %H) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main()
{
int all,h,w,y,s;
scanf("%d %d",&h,&w);
all = h*w;
scanf("%d %d",&y,&s);
all = all-y*w;
all = all-(s*h);
all = all+y*s;
printf("%d\n",all);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209178/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209178/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%h = alloca i32, align 4
%w = alloca i32, align 4
%y = alloca i32, align 4
%s = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %h) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %w) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %y) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %s) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %h, ptr noundef nonnull %w)
%0 = load i32, ptr %h, align 4, !tbaa !5
%1 = load i32, ptr %w, align 4, !tbaa !5
%mul = mul nsw i32 %1, %0
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %y, ptr noundef nonnull %s)
%2 = load i32, ptr %y, align 4, !tbaa !5
%3 = load i32, ptr %w, align 4, !tbaa !5
%mul2 = mul nsw i32 %3, %2
%4 = load i32, ptr %s, align 4, !tbaa !5
%5 = load i32, ptr %h, align 4, !tbaa !5
%reass.add = sub i32 %2, %5
%reass.mul = mul i32 %reass.add, %4
%sub4 = sub i32 %mul, %mul2
%add = add i32 %sub4, %reass.mul
%call6 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %add)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %s) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %y) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %w) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %h) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main(){
int h,w,H,W;
scanf("%d%d%d%d",&H,&W,&h, &w);
printf("%d\n", (H-h)*(W-w));
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209220/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209220/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [9 x i8] c"%d%d%d%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%h = alloca i32, align 4
%w = alloca i32, align 4
%H = alloca i32, align 4
%W = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %h) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %w) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %H) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %W) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %H, ptr noundef nonnull %W, ptr noundef nonnull %h, ptr noundef nonnull %w)
%0 = load i32, ptr %H, align 4, !tbaa !5
%1 = load i32, ptr %h, align 4, !tbaa !5
%sub = sub nsw i32 %0, %1
%2 = load i32, ptr %W, align 4, !tbaa !5
%3 = load i32, ptr %w, align 4, !tbaa !5
%sub1 = sub nsw i32 %2, %3
%mul = mul nsw i32 %sub1, %sub
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %mul)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %W) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %H) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %w) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %h) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main(int argc, const char * argv[]) {
// insert code here...
int a, b, c, d, ans;
scanf("%d %d %d %d", &a, &b, &c, &d);
ans = a*b - b*c -(d*(a-c));
printf("%d\n", ans);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209279/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209279/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [12 x i8] c"%d %d %d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main(i32 noundef %argc, ptr nocapture noundef readnone %argv) local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
%d = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %d) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c, ptr noundef nonnull %d)
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %b, align 4, !tbaa !5
%2 = load i32, ptr %c, align 4, !tbaa !5
%mul6 = sub i32 %0, %2
%sub = mul i32 %mul6, %1
%3 = load i32, ptr %d, align 4, !tbaa !5
%sub2.neg = sub i32 %2, %0
%mul3.neg = mul i32 %sub2.neg, %3
%sub4 = add i32 %mul3.neg, %sub
%call5 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %sub4)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %d) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int gyo, retsu, h, w;
int mas;
int jokyo1, jokyo2;
int kyo;
int nokori;
scanf("%d", &gyo);
scanf("%d", &retsu);
scanf("%d", &h);
scanf("%d", &w);
mas = gyo * retsu;
jokyo1 = h * retsu;
jokyo2 = w * gyo;
kyo = h * w;
nokori=mas-(jokyo1+jokyo2-kyo);
printf("%d\n", nokori);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209321/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209321/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main(i32 noundef %argc, ptr nocapture noundef readnone %argv) local_unnamed_addr #0 {
entry:
%gyo = alloca i32, align 4
%retsu = alloca i32, align 4
%h = alloca i32, align 4
%w = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %gyo) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %retsu) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %h) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %w) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %gyo)
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %retsu)
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %h)
%call3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %w)
%0 = load i32, ptr %gyo, align 4, !tbaa !5
%1 = load i32, ptr %retsu, align 4, !tbaa !5
%2 = load i32, ptr %h, align 4, !tbaa !5
%3 = load i32, ptr %w, align 4, !tbaa !5
%reass.add = sub i32 %2, %0
%reass.mul = mul i32 %reass.add, %3
%reass.add9 = sub i32 %0, %2
%reass.mul10 = mul i32 %reass.add9, %1
%sub7 = add i32 %reass.mul10, %reass.mul
%call8 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %sub7)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %w) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %h) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %retsu) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %gyo) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main(){
int H, W;
int h,w;
scanf("%d %d", &H, &W);
scanf("%d %d", &h, &w);
//int remain_row = H-h;
printf("%d", (H-h)*(W-w));
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209365/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209365/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%H = alloca i32, align 4
%W = alloca i32, align 4
%h = alloca i32, align 4
%w = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %H) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %W) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %h) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %w) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %H, ptr noundef nonnull %W)
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %h, ptr noundef nonnull %w)
%0 = load i32, ptr %H, align 4, !tbaa !5
%1 = load i32, ptr %h, align 4, !tbaa !5
%sub = sub nsw i32 %0, %1
%2 = load i32, ptr %W, align 4, !tbaa !5
%3 = load i32, ptr %w, align 4, !tbaa !5
%sub2 = sub nsw i32 %2, %3
%mul = mul nsw i32 %sub2, %sub
%call3 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %mul)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %w) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %h) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %W) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %H) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(){
int h,w,a,b;
scanf("%d %d %d %d",&h,&w,&a,&b);
printf("%d\n",(h-a)*(w-b));
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209415/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209415/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [12 x i8] c"%d %d %d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%h = alloca i32, align 4
%w = alloca i32, align 4
%a = alloca i32, align 4
%b = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %h) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %w) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %h, ptr noundef nonnull %w, ptr noundef nonnull %a, ptr noundef nonnull %b)
%0 = load i32, ptr %h, align 4, !tbaa !5
%1 = load i32, ptr %a, align 4, !tbaa !5
%sub = sub nsw i32 %0, %1
%2 = load i32, ptr %w, align 4, !tbaa !5
%3 = load i32, ptr %b, align 4, !tbaa !5
%sub1 = sub nsw i32 %2, %3
%mul = mul nsw i32 %sub1, %sub
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %mul)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %w) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %h) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int a,i,x,y,z=0;
int num[100000];
int min = 1000006;
int result[100000];
int main(void) {
while(scanf("%d",&a) && a!=0){
num[i]=a;
i++;
}
for(int k=0;k<i;k++){
//printf("y\n");
for(int y=0;y*y<=num[k];y++){
//printf("y\n");
for(int z=0;z*z*z <= num[k];z++){
//printf("y\n");
x = num[k]-y*y-z*z*z;
//printf("%d\n",x);
if(x>=0){
if(x+y+z<=min) min=x+y+z;
else;
}
else;
}
}
result[k]=min;
min=1000006;
}
//printf("%d\n",result[3]);
// printf("%d\n",i);
for(int k=0;k<i;k++){
printf("%d\n",result[k]);
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209488/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209488/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@z = dso_local local_unnamed_addr global i32 0, align 4
@min = dso_local local_unnamed_addr global i32 1000006, align 4
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@a = dso_local global i32 0, align 4
@num = dso_local local_unnamed_addr global [100000 x i32] zeroinitializer, align 16
@i = dso_local local_unnamed_addr global i32 0, align 4
@x = dso_local local_unnamed_addr global i32 0, align 4
@result = dso_local local_unnamed_addr global [100000 x i32] zeroinitializer, align 16
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
@y = dso_local local_unnamed_addr global i32 0, align 4
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%call72 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a)
%tobool73 = icmp ne i32 %call72, 0
%0 = load i32, ptr @a, align 4
%cmp74 = icmp ne i32 %0, 0
%1 = select i1 %tobool73, i1 %cmp74, i1 false
br i1 %1, label %while.body, label %for.cond.preheader
for.cond.preheader: ; preds = %while.body, %entry
%2 = load i32, ptr @i, align 4, !tbaa !5
%cmp195 = icmp sgt i32 %2, 0
br i1 %cmp195, label %for.cond2.preheader.preheader, label %for.cond.cleanup42
for.cond2.preheader.preheader: ; preds = %for.cond.preheader
%min.promoted = load i32, ptr @min, align 4, !tbaa !5
%wide.trip.count = zext i32 %2 to i64
br label %for.cond2.preheader
while.body: ; preds = %entry, %while.body
%3 = phi i32 [ %5, %while.body ], [ %0, %entry ]
%4 = load i32, ptr @i, align 4, !tbaa !5
%idxprom = sext i32 %4 to i64
%arrayidx = getelementptr inbounds [100000 x i32], ptr @num, i64 0, i64 %idxprom
store i32 %3, ptr %arrayidx, align 4, !tbaa !5
%inc = add nsw i32 %4, 1
store i32 %inc, ptr @i, align 4, !tbaa !5
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a)
%tobool = icmp ne i32 %call, 0
%5 = load i32, ptr @a, align 4
%cmp = icmp ne i32 %5, 0
%6 = select i1 %tobool, i1 %cmp, i1 false
br i1 %6, label %while.body, label %for.cond.preheader, !llvm.loop !9
for.cond2.preheader: ; preds = %for.cond2.preheader.preheader, %for.cond.cleanup6
%indvars.iv = phi i64 [ 0, %for.cond2.preheader.preheader ], [ %indvars.iv.next, %for.cond.cleanup6 ]
%min.promoted819096 = phi i32 [ %min.promoted, %for.cond2.preheader.preheader ], [ 1000006, %for.cond.cleanup6 ]
%arrayidx4 = getelementptr inbounds [100000 x i32], ptr @num, i64 0, i64 %indvars.iv
%7 = load i32, ptr %arrayidx4, align 4, !tbaa !5
%cmp5.not86 = icmp slt i32 %7, 0
br i1 %cmp5.not86, label %for.cond.cleanup6, label %for.cond8.preheader
for.cond40.preheader: ; preds = %for.cond.cleanup6
store i32 1000006, ptr @min, align 4, !tbaa !5
br i1 %cmp195, label %for.body43, label %for.cond.cleanup42
for.cond8.preheader: ; preds = %for.cond2.preheader, %for.cond8.for.cond.cleanup14_crit_edge
%min.promoted8192 = phi i32 [ %min.promoted8193, %for.cond8.for.cond.cleanup14_crit_edge ], [ %min.promoted819096, %for.cond2.preheader ]
%mul89 = phi i32 [ %mul, %for.cond8.for.cond.cleanup14_crit_edge ], [ 0, %for.cond2.preheader ]
%y.088 = phi i32 [ %inc32, %for.cond8.for.cond.cleanup14_crit_edge ], [ 0, %for.cond2.preheader ]
%min.promoted8587 = phi i32 [ %min.promoted82, %for.cond8.for.cond.cleanup14_crit_edge ], [ %min.promoted819096, %for.cond2.preheader ]
br label %for.body15
for.cond2.for.cond.cleanup6_crit_edge.split: ; preds = %for.cond8.for.cond.cleanup14_crit_edge
store i32 %sub21, ptr @x, align 4, !tbaa !5
br label %for.cond.cleanup6
for.cond.cleanup6: ; preds = %for.cond2.for.cond.cleanup6_crit_edge.split, %for.cond2.preheader
%min.promoted8194 = phi i32 [ %min.promoted8193, %for.cond2.for.cond.cleanup6_crit_edge.split ], [ %min.promoted819096, %for.cond2.preheader ]
%arrayidx35 = getelementptr inbounds [100000 x i32], ptr @result, i64 0, i64 %indvars.iv
store i32 %min.promoted8194, ptr %arrayidx35, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
br i1 %exitcond.not, label %for.cond40.preheader, label %for.cond2.preheader, !llvm.loop !11
for.cond8.for.cond.cleanup14_crit_edge: ; preds = %for.inc
%inc32 = add nuw nsw i32 %y.088, 1
%mul = mul nsw i32 %inc32, %inc32
%cmp5.not = icmp sgt i32 %mul, %7
br i1 %cmp5.not, label %for.cond2.for.cond.cleanup6_crit_edge.split, label %for.cond8.preheader, !llvm.loop !12
for.body15: ; preds = %for.cond8.preheader, %for.inc
%min.promoted8191 = phi i32 [ %min.promoted8192, %for.cond8.preheader ], [ %min.promoted8193, %for.inc ]
%min.promoted83 = phi i32 [ %min.promoted8587, %for.cond8.preheader ], [ %min.promoted82, %for.inc ]
%mul1080 = phi i32 [ 0, %for.cond8.preheader ], [ %mul10, %for.inc ]
%z.079 = phi i32 [ 0, %for.cond8.preheader ], [ %inc30, %for.inc ]
%add237678 = phi i32 [ %min.promoted8587, %for.cond8.preheader ], [ %add2375, %for.inc ]
%8 = add i32 %mul89, %mul1080
%sub21 = sub i32 %7, %8
%cmp22 = icmp sgt i32 %sub21, -1
br i1 %cmp22, label %if.then, label %for.inc
if.then: ; preds = %for.body15
%add = add nuw i32 %z.079, %y.088
%add23 = add i32 %add, %sub21
%cmp24.not = icmp sgt i32 %add23, %add237678
br i1 %cmp24.not, label %for.inc, label %if.then25
if.then25: ; preds = %if.then
br label %for.inc
for.inc: ; preds = %if.then, %if.then25, %for.body15
%min.promoted8193 = phi i32 [ %min.promoted8191, %if.then ], [ %add23, %if.then25 ], [ %min.promoted8191, %for.body15 ]
%min.promoted82 = phi i32 [ %min.promoted83, %if.then ], [ %add23, %if.then25 ], [ %min.promoted83, %for.body15 ]
%add2375 = phi i32 [ %add237678, %if.then ], [ %add23, %if.then25 ], [ %add237678, %for.body15 ]
%inc30 = add nuw nsw i32 %z.079, 1
%mul9 = mul nsw i32 %inc30, %inc30
%mul10 = mul nsw i32 %mul9, %inc30
%cmp13.not = icmp sgt i32 %mul10, %7
br i1 %cmp13.not, label %for.cond8.for.cond.cleanup14_crit_edge, label %for.body15, !llvm.loop !13
for.cond.cleanup42: ; preds = %for.body43, %for.cond.preheader, %for.cond40.preheader
ret i32 0
for.body43: ; preds = %for.cond40.preheader, %for.body43
%indvars.iv101 = phi i64 [ %indvars.iv.next102, %for.body43 ], [ 0, %for.cond40.preheader ]
%arrayidx45 = getelementptr inbounds [100000 x i32], ptr @result, i64 0, i64 %indvars.iv101
%9 = load i32, ptr %arrayidx45, align 4, !tbaa !5
%call46 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %9)
%indvars.iv.next102 = add nuw nsw i64 %indvars.iv101, 1
%10 = load i32, ptr @i, align 4, !tbaa !5
%11 = sext i32 %10 to i64
%cmp41 = icmp slt i64 %indvars.iv.next102, %11
br i1 %cmp41, label %for.body43, label %for.cond.cleanup42, !llvm.loop !14
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1
attributes #0 = { nofree 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 = { 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" }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
|
#include <stdio.h>
int main(){
char s[200001],t[200001];
int i,m,bl[200001];
long n;
scanf("%s",s);
for (i=m=0;s[i]!='\0';)
if (s[i]=='A') {
t[m++]='A';
i++;
} else if (s[i]=='B' && s[i+1]=='C') {
if (t[m-1]=='B') bl[m-1]++;
else {
bl[m]=1;
t[m++]='B';
}
i+=2;
} else {
if (t[m-1]!='X') t[m++]='X';
i++;
}
t[m]='\0';
n=0;
for (i=m-1;i>=0;i--)
if (t[i]=='A' && t[i+1]=='B') {
n+=bl[i+1];
if (i>0 && t[i-1]=='B')
bl[i-1]+=bl[i+1];
else {
t[i]='B';
bl[i]=bl[i+1];
}
}
printf("%ld\n",n);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209567/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209567/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.1 = private unnamed_addr constant [5 x i8] c"%ld\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca [200001 x i8], align 16
%t = alloca [200001 x i8], align 16
%bl = alloca [200001 x i32], align 16
call void @llvm.lifetime.start.p0(i64 200001, ptr nonnull %s) #3
call void @llvm.lifetime.start.p0(i64 200001, ptr nonnull %t) #3
call void @llvm.lifetime.start.p0(i64 800004, ptr nonnull %bl) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s)
br label %for.cond
for.cond: ; preds = %if.end52, %entry
%i.0 = phi i32 [ 0, %entry ], [ %add37, %if.end52 ]
%m.0 = phi i32 [ 0, %entry ], [ %m.3, %if.end52 ]
%idxprom = zext i32 %i.0 to i64
%arrayidx = getelementptr inbounds [200001 x i8], ptr %s, i64 0, i64 %idxprom
%0 = load i8, ptr %arrayidx, align 1, !tbaa !5
switch i8 %0, label %if.else38 [
i8 0, label %for.end
i8 65, label %if.then
i8 66, label %land.lhs.true
]
if.then: ; preds = %for.cond
%inc = add nsw i32 %m.0, 1
%idxprom7 = sext i32 %m.0 to i64
%arrayidx8 = getelementptr inbounds [200001 x i8], ptr %t, i64 0, i64 %idxprom7
store i8 65, ptr %arrayidx8, align 1, !tbaa !5
br label %if.end52
land.lhs.true: ; preds = %for.cond
%add = add nuw nsw i32 %i.0, 1
%idxprom15 = zext i32 %add to i64
%arrayidx16 = getelementptr inbounds [200001 x i8], ptr %s, i64 0, i64 %idxprom15
%1 = load i8, ptr %arrayidx16, align 1, !tbaa !5
%cmp18 = icmp eq i8 %1, 67
br i1 %cmp18, label %if.then20, label %if.else38
if.then20: ; preds = %land.lhs.true
%sub = add nsw i32 %m.0, -1
%idxprom21 = sext i32 %sub to i64
%arrayidx22 = getelementptr inbounds [200001 x i8], ptr %t, i64 0, i64 %idxprom21
%2 = load i8, ptr %arrayidx22, align 1, !tbaa !5
%cmp24 = icmp eq i8 %2, 66
br i1 %cmp24, label %if.then26, label %if.else31
if.then26: ; preds = %if.then20
%arrayidx29 = getelementptr inbounds [200001 x i32], ptr %bl, i64 0, i64 %idxprom21
%3 = load i32, ptr %arrayidx29, align 4, !tbaa !8
%inc30 = add nsw i32 %3, 1
store i32 %inc30, ptr %arrayidx29, align 4, !tbaa !8
br label %if.end52
if.else31: ; preds = %if.then20
%idxprom32 = sext i32 %m.0 to i64
%arrayidx33 = getelementptr inbounds [200001 x i32], ptr %bl, i64 0, i64 %idxprom32
store i32 1, ptr %arrayidx33, align 4, !tbaa !8
%inc34 = add nsw i32 %m.0, 1
%arrayidx36 = getelementptr inbounds [200001 x i8], ptr %t, i64 0, i64 %idxprom32
store i8 66, ptr %arrayidx36, align 1, !tbaa !5
br label %if.end52
if.else38: ; preds = %for.cond, %land.lhs.true
%sub39 = add nsw i32 %m.0, -1
%idxprom40 = sext i32 %sub39 to i64
%arrayidx41 = getelementptr inbounds [200001 x i8], ptr %t, i64 0, i64 %idxprom40
%4 = load i8, ptr %arrayidx41, align 1, !tbaa !5
%cmp43.not = icmp eq i8 %4, 88
br i1 %cmp43.not, label %if.end52, label %if.then45
if.then45: ; preds = %if.else38
%inc46 = add nsw i32 %m.0, 1
%idxprom47 = sext i32 %m.0 to i64
%arrayidx48 = getelementptr inbounds [200001 x i8], ptr %t, i64 0, i64 %idxprom47
store i8 88, ptr %arrayidx48, align 1, !tbaa !5
br label %if.end52
if.end52: ; preds = %if.else38, %if.then45, %if.then26, %if.else31, %if.then
%.sink = phi i32 [ 1, %if.then ], [ 2, %if.else31 ], [ 2, %if.then26 ], [ 1, %if.then45 ], [ 1, %if.else38 ]
%m.3 = phi i32 [ %inc, %if.then ], [ %inc34, %if.else31 ], [ %m.0, %if.then26 ], [ %inc46, %if.then45 ], [ %m.0, %if.else38 ]
%add37 = add nuw nsw i32 %i.0, %.sink
br label %for.cond, !llvm.loop !10
for.end: ; preds = %for.cond
%idxprom53 = sext i32 %m.0 to i64
%arrayidx54 = getelementptr inbounds [200001 x i8], ptr %t, i64 0, i64 %idxprom53
store i8 0, ptr %arrayidx54, align 1, !tbaa !5
%cmp57135 = icmp sgt i32 %m.0, 0
br i1 %cmp57135, label %for.body59.preheader, label %for.end105
for.body59.preheader: ; preds = %for.end
%5 = zext i32 %m.0 to i64
br label %for.body59
for.body59: ; preds = %for.body59.preheader, %for.inc
%indvars.iv = phi i64 [ %5, %for.body59.preheader ], [ %indvars.iv.next, %for.inc ]
%n.0137 = phi i64 [ 0, %for.body59.preheader ], [ %n.1, %for.inc ]
%indvars.iv.next = add nsw i64 %indvars.iv, -1
%idxprom60 = and i64 %indvars.iv.next, 4294967295
%arrayidx61 = getelementptr inbounds [200001 x i8], ptr %t, i64 0, i64 %idxprom60
%6 = load i8, ptr %arrayidx61, align 1, !tbaa !5
%cmp63 = icmp eq i8 %6, 65
br i1 %cmp63, label %land.lhs.true65, label %for.inc
land.lhs.true65: ; preds = %for.body59
%arrayidx68 = getelementptr inbounds [200001 x i8], ptr %t, i64 0, i64 %indvars.iv
%7 = load i8, ptr %arrayidx68, align 1, !tbaa !5
%cmp70 = icmp eq i8 %7, 66
br i1 %cmp70, label %if.then72, label %for.inc
if.then72: ; preds = %land.lhs.true65
%arrayidx75 = getelementptr inbounds [200001 x i32], ptr %bl, i64 0, i64 %indvars.iv
%8 = load i32, ptr %arrayidx75, align 4, !tbaa !8
%conv76 = sext i32 %8 to i64
%add77 = add nsw i64 %n.0137, %conv76
%cmp78 = icmp ugt i64 %indvars.iv, 1
br i1 %cmp78, label %land.lhs.true80, label %if.else95
land.lhs.true80: ; preds = %if.then72
%sub81 = add nuw i64 %indvars.iv, 4294967294
%idxprom82 = and i64 %sub81, 4294967295
%arrayidx83 = getelementptr inbounds [200001 x i8], ptr %t, i64 0, i64 %idxprom82
%9 = load i8, ptr %arrayidx83, align 1, !tbaa !5
%cmp85 = icmp eq i8 %9, 66
br i1 %cmp85, label %if.then87, label %if.else95
if.then87: ; preds = %land.lhs.true80
%arrayidx93 = getelementptr inbounds [200001 x i32], ptr %bl, i64 0, i64 %idxprom82
%10 = load i32, ptr %arrayidx93, align 4, !tbaa !8
%add94 = add nsw i32 %10, %8
store i32 %add94, ptr %arrayidx93, align 4, !tbaa !8
br label %for.inc
if.else95: ; preds = %land.lhs.true80, %if.then72
store i8 66, ptr %arrayidx61, align 1, !tbaa !5
%arrayidx102 = getelementptr inbounds [200001 x i32], ptr %bl, i64 0, i64 %idxprom60
store i32 %8, ptr %arrayidx102, align 4, !tbaa !8
br label %for.inc
for.inc: ; preds = %for.body59, %land.lhs.true65, %if.else95, %if.then87
%n.1 = phi i64 [ %add77, %if.then87 ], [ %add77, %if.else95 ], [ %n.0137, %land.lhs.true65 ], [ %n.0137, %for.body59 ]
%cmp57 = icmp ugt i64 %indvars.iv, 1
br i1 %cmp57, label %for.body59, label %for.end105, !llvm.loop !12
for.end105: ; preds = %for.inc, %for.end
%n.0.lcssa = phi i64 [ 0, %for.end ], [ %n.1, %for.inc ]
%call106 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %n.0.lcssa)
call void @llvm.lifetime.end.p0(i64 800004, ptr nonnull %bl) #3
call void @llvm.lifetime.end.p0(i64 200001, ptr nonnull %t) #3
call void @llvm.lifetime.end.p0(i64 200001, ptr nonnull %s) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
|
// ABC066 B - ss
#include <stdio.h>
#include <string.h>
int main(void) {
char S[201];
scanf("%s", S);
int slen = strlen(S);
int flag = 1;
for (int i = slen - 2; i > 0; i -= 2) {
int center = i / 2;
flag = 1;
for (int j = 0; j < center; j++) {
if (S[j] != S[center + j]) {
flag = 0;
break;
}
}
if (flag) {
printf("%d\n", center * 2);
return 0;
}
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209624/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209624/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%S = alloca [201 x i8], align 16
call void @llvm.lifetime.start.p0(i64 201, ptr nonnull %S) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %S)
%call2 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %S) #5
%conv = trunc i64 %call2 to i32
%cmp42 = icmp slt i32 %conv, 3
br i1 %cmp42, label %cleanup24, label %for.body
for.cond.loopexit: ; preds = %for.body8
%cmp = icmp slt i32 %i.043.in, 5
br i1 %cmp, label %cleanup24, label %for.body, !llvm.loop !5
for.body: ; preds = %entry, %for.cond.loopexit
%i.043.in = phi i32 [ %i.043, %for.cond.loopexit ], [ %conv, %entry ]
%i.043 = add nsw i32 %i.043.in, -2
%cmp538.not = icmp ult i32 %i.043, 2
br i1 %cmp538.not, label %cleanup21.critedge, label %for.body8.preheader
for.body8.preheader: ; preds = %for.body
%div36 = lshr i32 %i.043, 1
%0 = zext i32 %div36 to i64
br label %for.body8
for.cond4: ; preds = %for.body8
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%cmp5 = icmp ult i64 %indvars.iv.next, %0
br i1 %cmp5, label %for.body8, label %cleanup21.critedge, !llvm.loop !7
for.body8: ; preds = %for.body8.preheader, %for.cond4
%indvars.iv = phi i64 [ 0, %for.body8.preheader ], [ %indvars.iv.next, %for.cond4 ]
%arrayidx = getelementptr inbounds [201 x i8], ptr %S, i64 0, i64 %indvars.iv
%1 = load i8, ptr %arrayidx, align 1, !tbaa !8
%2 = add nuw nsw i64 %indvars.iv, %0
%arrayidx11 = getelementptr inbounds [201 x i8], ptr %S, i64 0, i64 %2
%3 = load i8, ptr %arrayidx11, align 1, !tbaa !8
%cmp13.not = icmp eq i8 %1, %3
br i1 %cmp13.not, label %for.cond4, label %for.cond.loopexit
cleanup21.critedge: ; preds = %for.body, %for.cond4
%mul.c = and i32 %i.043, -2
%call16.c = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %mul.c)
br label %cleanup24
cleanup24: ; preds = %for.cond.loopexit, %entry, %cleanup21.critedge
call void @llvm.lifetime.end.p0(i64 201, ptr nonnull %S) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
attributes #0 = { nofree 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 = { 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 = { 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 #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = !{!9, !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <string.h>
int main(void)
{
char s[201];
scanf("%s",s);
int len=strlen(s);
fprintf(stderr,"%s\nlen=%d\n",s,len);
int ans=0,i;
while(ans==0)
{
len-=2;
{fprintf(stderr,"\n%d",len); }
ans=len;
for(i=0;i<=len/2-1;i++)
{
if(s[i]!=s[len/2+i])
{ans=0; break;}
}
if(len<0){fprintf(stderr,"\nstop len<0\n"); break;}
}
printf("\n%d\n",ans);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209668/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209668/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = private unnamed_addr constant [11 x i8] c"%s\0Alen=%d\0A\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"\0A%d\00", align 1
@.str.3 = private unnamed_addr constant [13 x i8] c"\0Astop len<0\0A\00", align 1
@.str.4 = private unnamed_addr constant [5 x i8] c"\0A%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca [201 x i8], align 16
call void @llvm.lifetime.start.p0(i64 201, ptr nonnull %s) #5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s)
%call2 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %s) #6
%conv = trunc i64 %call2 to i32
%0 = load ptr, ptr @stderr, align 8, !tbaa !5
%call4 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.1, ptr noundef nonnull %s, i32 noundef %conv) #7
br label %while.cond
while.cond: ; preds = %for.end, %entry
%len.0 = phi i32 [ %conv, %entry ], [ %sub, %for.end ]
%ans.0 = phi i32 [ 0, %entry ], [ %ans.1, %for.end ]
%cmp = icmp eq i32 %ans.0, 0
br i1 %cmp, label %while.body, label %while.end
while.body: ; preds = %while.cond
%sub = add nsw i32 %len.0, -2
%1 = load ptr, ptr @stderr, align 8, !tbaa !5
%call6 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull @.str.2, i32 noundef %sub) #7
%cmp8.not.not34 = icmp sgt i32 %len.0, 3
br i1 %cmp8.not.not34, label %for.body.preheader, label %for.end
for.body.preheader: ; preds = %while.body
%div4042 = lshr i32 %sub, 1
%2 = zext i32 %div4042 to i64
%wide.trip.count = zext i32 %div4042 to i64
br label %for.body
for.cond: ; preds = %for.body
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !9
for.body: ; preds = %for.body.preheader, %for.cond
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.cond ]
%arrayidx = getelementptr inbounds [201 x i8], ptr %s, i64 0, i64 %indvars.iv
%3 = load i8, ptr %arrayidx, align 1, !tbaa !11
%4 = add nuw nsw i64 %indvars.iv, %2
%arrayidx13 = getelementptr inbounds [201 x i8], ptr %s, i64 0, i64 %4
%5 = load i8, ptr %arrayidx13, align 1, !tbaa !11
%cmp15.not = icmp eq i8 %3, %5
br i1 %cmp15.not, label %for.cond, label %for.end
for.end: ; preds = %for.cond, %for.body, %while.body
%ans.1 = phi i32 [ %sub, %while.body ], [ 0, %for.body ], [ %sub, %for.cond ]
%cmp17 = icmp slt i32 %len.0, 2
br i1 %cmp17, label %if.then19, label %while.cond, !llvm.loop !12
if.then19: ; preds = %for.end
%6 = load ptr, ptr @stderr, align 8, !tbaa !5
%7 = call i64 @fwrite(ptr nonnull @.str.3, i64 12, i64 1, ptr %6) #7
br label %while.end
while.end: ; preds = %while.cond, %if.then19
%ans.2 = phi i32 [ %ans.1, %if.then19 ], [ %ans.0, %while.cond ]
%call22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %ans.2)
call void @llvm.lifetime.end.p0(i64 201, ptr nonnull %s) #5
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #4
attributes #0 = { nofree 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 = { 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 = { 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 #4 = { nofree nounwind }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { cold }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}
|
#include <stdio.h>
#include <string.h>
int main(void){
char str[200];
scanf("%s",str);
int n=strlen(str);
for(int i=n-2; i; i-=2){
if(strncmp(str, str+i/2, i/2)==0){
printf("%d\n" ,i);
return 0;
}
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209718/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209718/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%str = alloca [200 x i8], align 16
call void @llvm.lifetime.start.p0(i64 200, ptr nonnull %str) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %str)
%call2 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %str) #5
%conv = trunc i64 %call2 to i32
br label %for.cond
for.cond: ; preds = %for.body, %entry
%i.0.in = phi i32 [ %conv, %entry ], [ %i.0, %for.body ]
%i.0 = add nsw i32 %i.0.in, -2
%tobool.not = icmp eq i32 %i.0, 0
br i1 %tobool.not, label %cleanup11, label %for.body
for.body: ; preds = %for.cond
%div = sdiv i32 %i.0, 2
%idx.ext = sext i32 %div to i64
%add.ptr = getelementptr inbounds i8, ptr %str, i64 %idx.ext
%call7 = call i32 @strncmp(ptr noundef nonnull %str, ptr noundef nonnull %add.ptr, i64 noundef %idx.ext) #5
%cmp = icmp eq i32 %call7, 0
br i1 %cmp, label %if.then, label %for.cond, !llvm.loop !5
if.then: ; preds = %for.body
%call9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %i.0)
br label %cleanup11
cleanup11: ; preds = %for.cond, %if.then
call void @llvm.lifetime.end.p0(i64 200, ptr nonnull %str) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strncmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = { 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 #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
|
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv){
char str[200];
scanf("%s\n", str);
for (int i = strlen(str) - 2;; i -= 2) {
int flag = 1;
for (int j = 0; j < (i / 2); j++) {
if(str[j] != str[j + (i / 2)]){
flag = 0;
break;
}
}
if(flag) {
printf("%d\n", i);
return 0;
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209761/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209761/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main(i32 noundef %argc, ptr nocapture noundef readnone %argv) local_unnamed_addr #0 {
entry:
%str = alloca [200 x i8], align 16
call void @llvm.lifetime.start.p0(i64 200, ptr nonnull %str) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %str)
%call2 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %str) #5
%0 = trunc i64 %call2 to i32
%i.029 = add i32 %0, -2
%cmp2631 = icmp sgt i32 %i.029, 1
br i1 %cmp2631, label %for.body.lr.ph, label %cleanup18.critedge
for.cond.loopexit: ; preds = %for.body
%i.0 = add nsw i32 %i.032, -2
%cmp26 = icmp sgt i32 %i.032, 3
br i1 %cmp26, label %for.body.lr.ph, label %cleanup18.critedge
for.body.lr.ph: ; preds = %entry, %for.cond.loopexit
%i.032 = phi i32 [ %i.0, %for.cond.loopexit ], [ %i.029, %entry ]
%div334044 = lshr i32 %i.032, 1
%1 = zext i32 %div334044 to i64
%wide.trip.count = zext i32 %div334044 to i64
br label %for.body
for.cond3: ; preds = %for.body
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
br i1 %exitcond.not, label %cleanup18.critedge, label %for.body, !llvm.loop !5
for.body: ; preds = %for.body.lr.ph, %for.cond3
%indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.cond3 ]
%arrayidx = getelementptr inbounds [200 x i8], ptr %str, i64 0, i64 %indvars.iv
%2 = load i8, ptr %arrayidx, align 1, !tbaa !7
%3 = add nuw nsw i64 %indvars.iv, %1
%arrayidx8 = getelementptr inbounds [200 x i8], ptr %str, i64 0, i64 %3
%4 = load i8, ptr %arrayidx8, align 1, !tbaa !7
%cmp10.not = icmp eq i8 %2, %4
br i1 %cmp10.not, label %for.cond3, label %for.cond.loopexit
cleanup18.critedge: ; preds = %for.cond.loopexit, %for.cond3, %entry
%i.0.lcssa = phi i32 [ %i.029, %entry ], [ %i.032, %for.cond3 ], [ %i.0, %for.cond.loopexit ]
%call13.c = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %i.0.lcssa)
call void @llvm.lifetime.end.p0(i64 200, ptr nonnull %str) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
attributes #0 = { nofree 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 = { 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 = { 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 #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#define SQ(X) \
( (X) * (X) )
#define SQD(X,Y) \
( SQ(X) + SQ(Y) )
int zcos (
double x1,
double y1,
double x2,
double y2
)
{
double pred = ( x1 * y2 - y1 * x2 );
if ( pred > 0. )
{
return ( 1 );
}
else if ( pred < 0. )
{
return ( -1 );
}
return ( 0 );
}
/** Application main entry point. */
int main (
int argc,
char * argv[ ]
)
{
double x[ 4 ], y[ 4 ];
int i;
while ( scanf ( " %lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
x, y, x + 1, y + 1, x + 2, y + 2, x + 3, y + 3 ) == 8 )
{
int positive = 0, negative = 0;
for ( i = 0; i < 4; ++i )
{
int pred = zcos ( x[ ( i + 1 ) % 4 ] - x[ i ],
y[ ( i + 1 ) % 4 ] - y[ i ],
x[ ( i + 2 ) % 4 ] - x[ ( i + 1 ) % 4 ],
y[ ( i + 2 ) % 4 ] - y[ ( i + 1 ) % 4 ] );
positive += !!( pred > 0 );
negative += !!( pred < 0 );
}
puts ( positive && negative ? "NO" : "YES" );
}
return ( 0 );
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209804/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209804/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [33 x i8] c" %lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"NO\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"YES\00", align 1
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable
define dso_local i32 @zcos(double noundef %x1, double noundef %y1, double noundef %x2, double noundef %y2) local_unnamed_addr #0 {
entry:
%0 = fneg double %y1
%neg = fmul double %0, %x2
%1 = tail call double @llvm.fmuladd.f64(double %x1, double %y2, double %neg)
%cmp = fcmp ogt double %1, 0.000000e+00
%cmp2 = fcmp olt double %1, 0.000000e+00
%. = sext i1 %cmp2 to i32
%retval.0 = select i1 %cmp, i32 1, i32 %.
ret i32 %retval.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 nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main(i32 noundef %argc, ptr nocapture noundef readnone %argv) local_unnamed_addr #3 {
entry:
%x = alloca [4 x double], align 16
%y = alloca [4 x double], align 16
call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %x) #6
call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %y) #6
%add.ptr = getelementptr inbounds double, ptr %x, i64 1
%add.ptr4 = getelementptr inbounds double, ptr %y, i64 1
%add.ptr6 = getelementptr inbounds double, ptr %x, i64 2
%add.ptr8 = getelementptr inbounds double, ptr %y, i64 2
%add.ptr10 = getelementptr inbounds double, ptr %x, i64 3
%add.ptr12 = getelementptr inbounds double, ptr %y, i64 3
%call68 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x, ptr noundef nonnull %y, ptr noundef nonnull %add.ptr, ptr noundef nonnull %add.ptr4, ptr noundef nonnull %add.ptr6, ptr noundef nonnull %add.ptr8, ptr noundef nonnull %add.ptr10, ptr noundef nonnull %add.ptr12)
%cmp69 = icmp eq i32 %call68, 8
br i1 %cmp69, label %for.cond.preheader, label %while.end
for.cond.preheader: ; preds = %entry, %for.cond.preheader
%0 = load <2 x double>, ptr %x, align 16
%1 = load double, ptr %add.ptr10, align 8, !tbaa !5
%2 = load <2 x double>, ptr %add.ptr, align 8, !tbaa !5
%3 = shufflevector <2 x double> %0, <2 x double> %2, <2 x i32> <i32 0, i32 2>
%4 = fsub <2 x double> %2, %3
%5 = load <2 x double>, ptr %add.ptr8, align 16, !tbaa !5
%6 = shufflevector <2 x double> %4, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
%7 = load <2 x double>, ptr %y, align 16, !tbaa !5
%8 = shufflevector <2 x double> %7, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%9 = shufflevector <2 x double> %8, <2 x double> %5, <2 x i32> <i32 0, i32 2>
%10 = fsub <2 x double> %5, %9
%11 = shufflevector <2 x double> %10, <2 x double> poison, <2 x i32> <i32 poison, i32 0>
%12 = shufflevector <2 x double> %7, <2 x double> %5, <2 x i32> <i32 0, i32 3>
%13 = fsub <2 x double> %8, %12
%14 = shufflevector <2 x double> %13, <2 x double> %11, <2 x i32> <i32 0, i32 3>
%15 = fneg <2 x double> %14
%16 = insertelement <2 x double> %0, double %1, i64 1
%17 = insertelement <2 x double> %2, double %1, i64 0
%18 = fsub <2 x double> %16, %17
%19 = shufflevector <2 x double> %6, <2 x double> %18, <2 x i32> <i32 0, i32 3>
%20 = fmul <2 x double> %19, %15
%21 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %4, <2 x double> %10, <2 x double> %20)
%22 = extractelement <2 x double> %21, i64 0
%cmp.i = fcmp ogt double %22, 0.000000e+00
%lnot.ext = zext i1 %cmp.i to i32
%23 = extractelement <2 x double> %21, i64 1
%cmp.i.1 = fcmp ogt double %23, 0.000000e+00
%24 = fcmp olt <2 x double> %21, zeroinitializer
%lnot.ext.1 = zext i1 %cmp.i.1 to i32
%add44.1 = add nuw nsw i32 %lnot.ext, %lnot.ext.1
%25 = zext <2 x i1> %24 to <2 x i32>
%shift = shufflevector <2 x i32> %25, <2 x i32> poison, <2 x i32> <i32 1, i32 poison>
%26 = add nuw nsw <2 x i32> %shift, %25
%add50.1 = extractelement <2 x i32> %26, i64 0
%27 = shufflevector <2 x double> %10, <2 x double> %13, <2 x i32> <i32 3, i32 1>
%28 = fneg <2 x double> %27
%29 = shufflevector <2 x double> %4, <2 x double> %18, <2 x i32> <i32 0, i32 2>
%30 = fmul <2 x double> %29, %28
%31 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> %13, <2 x double> %30)
%32 = extractelement <2 x double> %31, i64 1
%cmp.i.2 = fcmp ogt double %32, 0.000000e+00
%lnot.ext.2 = zext i1 %cmp.i.2 to i32
%add44.2 = add nuw nsw i32 %add44.1, %lnot.ext.2
%33 = fcmp olt <2 x double> %31, zeroinitializer
%34 = extractelement <2 x i1> %33, i64 1
%call41.lobit.2 = zext i1 %34 to i32
%add50.2 = add nuw nsw i32 %add50.1, %call41.lobit.2
%35 = extractelement <2 x double> %31, i64 0
%cmp.i.3 = fcmp ogt double %35, 0.000000e+00
%lnot.ext.3.neg = sext i1 %cmp.i.3 to i32
%36 = extractelement <2 x i1> %33, i64 0
%call41.lobit.3.neg = sext i1 %36 to i32
%tobool = icmp ne i32 %add44.2, %lnot.ext.3.neg
%tobool51 = icmp ne i32 %add50.2, %call41.lobit.3.neg
%37 = select i1 %tobool, i1 %tobool51, i1 false
%cond = select i1 %37, ptr @.str.1, ptr @.str.2
%call52 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %cond)
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x, ptr noundef nonnull %y, ptr noundef nonnull %add.ptr, ptr noundef nonnull %add.ptr4, ptr noundef nonnull %add.ptr6, ptr noundef nonnull %add.ptr8, ptr noundef nonnull %add.ptr10, ptr noundef nonnull %add.ptr12)
%cmp = icmp eq i32 %call, 8
br i1 %cmp, label %for.cond.preheader, label %while.end, !llvm.loop !9
while.end: ; preds = %for.cond.preheader, %entry
call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %y) #6
call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %x) #6
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #4
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #5
attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) 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 nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nofree 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 = { 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
#include <stdio.h>
#define N 100005
int a[N];
int main(void)
{
int n, i, max;
scanf("%d", &n);
for (i=1; i<=n; ++i)
scanf("%d", &a[i]);
max = 0;
for (i=1; i<=n; ++i)
if (a[i] > max)
max = a[i];
printf("%d\n", max);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_20992/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_20992/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@a = dso_local global [100005 x i32] zeroinitializer, align 16
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%cmp.not21 = icmp slt i32 %0, 1
br i1 %cmp.not21, label %for.end12, label %for.body
for.cond2.preheader: ; preds = %for.body
%cmp3.not23 = icmp slt i32 %9, 1
br i1 %cmp3.not23, label %for.end12, label %for.body4.preheader
for.body4.preheader: ; preds = %for.cond2.preheader
%1 = add nuw i32 %9, 1
%wide.trip.count = zext i32 %1 to i64
%2 = add nsw i64 %wide.trip.count, -1
%min.iters.check = icmp ult i32 %9, 8
br i1 %min.iters.check, label %for.body4.preheader36, label %vector.ph
vector.ph: ; preds = %for.body4.preheader
%n.vec = and i64 %2, -8
%ind.end = or i64 %n.vec, 1
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %5, %vector.body ]
%vec.phi34 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %6, %vector.body ]
%offset.idx = or i64 %index, 1
%3 = getelementptr inbounds [100005 x i32], ptr @a, i64 0, i64 %offset.idx
%wide.load = load <4 x i32>, ptr %3, align 4, !tbaa !5
%4 = getelementptr inbounds i32, ptr %3, i64 4
%wide.load35 = load <4 x i32>, ptr %4, align 4, !tbaa !5
%5 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load, <4 x i32> %vec.phi)
%6 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load35, <4 x i32> %vec.phi34)
%index.next = add nuw i64 %index, 8
%7 = icmp eq i64 %index.next, %n.vec
br i1 %7, label %middle.block, label %vector.body, !llvm.loop !9
middle.block: ; preds = %vector.body
%rdx.minmax = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %5, <4 x i32> %6)
%8 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %rdx.minmax)
%cmp.n = icmp eq i64 %2, %n.vec
br i1 %cmp.n, label %for.end12, label %for.body4.preheader36
for.body4.preheader36: ; preds = %for.body4.preheader, %middle.block
%indvars.iv29.ph = phi i64 [ 1, %for.body4.preheader ], [ %ind.end, %middle.block ]
%max.025.ph = phi i32 [ 0, %for.body4.preheader ], [ %8, %middle.block ]
br label %for.body4
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 1, %entry ]
%arrayidx = getelementptr inbounds [100005 x i32], ptr @a, i64 0, i64 %indvars.iv
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx)
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%9 = load i32, ptr %n, align 4, !tbaa !5
%10 = sext i32 %9 to i64
%cmp.not.not = icmp slt i64 %indvars.iv, %10
br i1 %cmp.not.not, label %for.body, label %for.cond2.preheader, !llvm.loop !13
for.body4: ; preds = %for.body4.preheader36, %for.body4
%indvars.iv29 = phi i64 [ %indvars.iv.next30, %for.body4 ], [ %indvars.iv29.ph, %for.body4.preheader36 ]
%max.025 = phi i32 [ %spec.select, %for.body4 ], [ %max.025.ph, %for.body4.preheader36 ]
%arrayidx6 = getelementptr inbounds [100005 x i32], ptr @a, i64 0, i64 %indvars.iv29
%11 = load i32, ptr %arrayidx6, align 4, !tbaa !5
%spec.select = call i32 @llvm.smax.i32(i32 %11, i32 %max.025)
%indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
%exitcond.not = icmp eq i64 %indvars.iv.next30, %wide.trip.count
br i1 %exitcond.not, label %for.end12, label %for.body4, !llvm.loop !14
for.end12: ; preds = %for.body4, %middle.block, %entry, %for.cond2.preheader
%max.0.lcssa = phi i32 [ 0, %for.cond2.preheader ], [ 0, %entry ], [ %8, %middle.block ], [ %spec.select, %for.body4 ]
%call13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %max.0.lcssa)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #3
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x i32> @llvm.smax.v4i32(<4 x i32>, <4 x i32>) #3
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.smax.v4i32(<4 x i32>) #3
attributes #0 = { nofree 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10, !12, !11}
|
#include <stdio.h>
int main(){
int n,l;
scanf("%d %d",&n,&l);
char alpha[51];
scanf("%s",alpha);
alpha[l-1]+=32;
printf("%s",alpha);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_209970/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_209970/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%l = alloca i32, align 4
%alpha = alloca [51 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %l) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n, ptr noundef nonnull %l)
call void @llvm.lifetime.start.p0(i64 51, ptr nonnull %alpha) #3
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %alpha)
%0 = load i32, ptr %l, align 4, !tbaa !5
%sub = add nsw i32 %0, -1
%idxprom = sext i32 %sub to i64
%arrayidx = getelementptr inbounds [51 x i8], ptr %alpha, i64 0, i64 %idxprom
%1 = load i8, ptr %arrayidx, align 1, !tbaa !9
%add = add i8 %1, 32
store i8 %add, ptr %arrayidx, align 1, !tbaa !9
%call4 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, ptr noundef nonnull %alpha)
call void @llvm.lifetime.end.p0(i64 51, ptr nonnull %alpha) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %l) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #3
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree 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 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
|
#include<stdio.h>
int main(){
int n,k,i;
scanf("%d%d",&n,&k);
char s[n+1];
scanf("%s",s);
for(i=0;i<n;i++)
if(i+1==k)
printf("%c",s[i]+32);
else
printf("%c",s[i]);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_210019/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_210019/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%k = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n, ptr noundef nonnull %k)
%0 = load i32, ptr %n, align 4, !tbaa !5
%add = add nsw i32 %0, 1
%1 = zext i32 %add to i64
%2 = call ptr @llvm.stacksave.p0()
%vla = alloca i8, i64 %1, align 16
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %vla)
%3 = load i32, ptr %n, align 4, !tbaa !5
%cmp15 = icmp sgt i32 %3, 0
br i1 %cmp15, label %for.body, label %for.end
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%4 = load i32, ptr %k, align 4, !tbaa !5
%5 = zext i32 %4 to i64
%cmp3 = icmp eq i64 %indvars.iv.next, %5
%arrayidx = getelementptr inbounds i8, ptr %vla, i64 %indvars.iv
%6 = load i8, ptr %arrayidx, align 1, !tbaa !9
%conv = sext i8 %6 to i32
%add4 = add nsw i32 %conv, 32
%add4.sink = select i1 %cmp3, i32 %add4, i32 %conv
%putchar14 = call i32 @putchar(i32 %add4.sink)
%7 = load i32, ptr %n, align 4, !tbaa !5
%8 = sext i32 %7 to i64
%cmp = icmp slt i64 %indvars.iv.next, %8
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !10
for.end: ; preds = %for.body, %entry
call void @llvm.stackrestore.p0(ptr %2)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #5
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #4
attributes #0 = { nofree 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 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #4 = { nofree nounwind }
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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
|
#include <stdio.h>
int main()
{
int n, s; // n types of sugar, s dollars
int i;
int d, c;
int max = -1;
scanf("%d %d", &n, &s);
for(i=0; i<n; i++)
{
scanf("%d %d", &d, &c);
if(d<s || (d==s && c==0))//can buy
{
if( (100-c)%100 > max)
max = (100-c)%100;
}
}
printf("%d", max);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_21007/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_21007/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%s = alloca i32, align 4
%d = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %s) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %d) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n, ptr noundef nonnull %s)
%0 = load i32, ptr %n, align 4, !tbaa !5
%cmp14 = icmp sgt i32 %0, 0
br i1 %cmp14, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%max.016 = phi i32 [ %max.1, %for.inc ], [ -1, %entry ]
%i.015 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %d, ptr noundef nonnull %c)
%1 = load i32, ptr %d, align 4, !tbaa !5
%2 = load i32, ptr %s, align 4, !tbaa !5
%cmp2 = icmp slt i32 %1, %2
%.pre = load i32, ptr %c, align 4
br i1 %cmp2, label %if.then, label %lor.lhs.false
lor.lhs.false: ; preds = %for.body
%cmp3 = icmp eq i32 %1, %2
%cmp4 = icmp eq i32 %.pre, 0
%or.cond = select i1 %cmp3, i1 %cmp4, i1 false
br i1 %or.cond, label %if.then, label %for.inc
if.then: ; preds = %lor.lhs.false, %for.body
%sub = sub nsw i32 100, %.pre
%rem = srem i32 %sub, 100
%spec.select = call i32 @llvm.smax.i32(i32 %rem, i32 %max.016)
br label %for.inc
for.inc: ; preds = %if.then, %lor.lhs.false
%max.1 = phi i32 [ %max.016, %lor.lhs.false ], [ %spec.select, %if.then ]
%inc = add nuw nsw i32 %i.015, 1
%3 = load i32, ptr %n, align 4, !tbaa !5
%cmp = icmp slt i32 %inc, %3
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !9
for.end: ; preds = %for.inc, %entry
%max.0.lcssa = phi i32 [ -1, %entry ], [ %max.1, %for.inc ]
%call10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %max.0.lcssa)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %d) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %s) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #3
attributes #0 = { nofree 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
#include <stdio.h>
#include <ctype.h>
int main(void){
int N, K;
scanf("%d%d", &N, &K);
char S[N], ans[N];
scanf("%s", S);
S[K-1] = tolower(S[K-1]);
printf("%s\n", S);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_210112/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_210112/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%N = alloca i32, align 4
%K = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #6
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %K) #6
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N, ptr noundef nonnull %K)
%0 = load i32, ptr %N, align 4, !tbaa !5
%1 = zext i32 %0 to i64
%2 = call ptr @llvm.stacksave.p0()
%vla = alloca i8, i64 %1, align 16
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %vla)
%call3 = tail call ptr @__ctype_tolower_loc() #7
%3 = load ptr, ptr %call3, align 8, !tbaa !9
%4 = load i32, ptr %K, align 4, !tbaa !5
%sub = add nsw i32 %4, -1
%idxprom = sext i32 %sub to i64
%arrayidx = getelementptr inbounds i8, ptr %vla, i64 %idxprom
%5 = load i8, ptr %arrayidx, align 1, !tbaa !11
%idxprom4 = sext i8 %5 to i64
%arrayidx5 = getelementptr inbounds i32, ptr %3, i64 %idxprom4
%6 = load i32, ptr %arrayidx5, align 4, !tbaa !5
%conv6 = trunc i32 %6 to i8
store i8 %conv6, ptr %arrayidx, align 1, !tbaa !11
%puts = call i32 @puts(ptr nonnull dereferenceable(1) %vla)
call void @llvm.stackrestore.p0(ptr %2)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %K) #6
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_tolower_loc() local_unnamed_addr #4
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #5
attributes #0 = { nofree 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 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #4 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { nofree nounwind }
attributes #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!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 = !{!7, !7, i64 0}
|
#include <ctype.h>
#include <stdio.h>
int main(void)
{
int N, K;
char S[55];
scanf("%d%d%s", &N, &K, S);
S[K-1] = tolower(S[K-1]);
printf("%s\n", S);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_210156/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_210156/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [7 x i8] c"%d%d%s\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%N = alloca i32, align 4
%K = alloca i32, align 4
%S = alloca [55 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %K) #5
call void @llvm.lifetime.start.p0(i64 55, ptr nonnull %S) #5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N, ptr noundef nonnull %K, ptr noundef nonnull %S)
%call1 = tail call ptr @__ctype_tolower_loc() #6
%0 = load ptr, ptr %call1, align 8, !tbaa !5
%1 = load i32, ptr %K, align 4, !tbaa !9
%sub = add nsw i32 %1, -1
%idxprom = sext i32 %sub to i64
%arrayidx = getelementptr inbounds [55 x i8], ptr %S, i64 0, i64 %idxprom
%2 = load i8, ptr %arrayidx, align 1, !tbaa !11
%idxprom2 = sext i8 %2 to i64
%arrayidx3 = getelementptr inbounds i32, ptr %0, i64 %idxprom2
%3 = load i32, ptr %arrayidx3, align 4, !tbaa !9
%conv4 = trunc i32 %3 to i8
store i8 %conv4, ptr %arrayidx, align 1, !tbaa !11
%puts = call i32 @puts(ptr nonnull dereferenceable(1) %S)
call void @llvm.lifetime.end.p0(i64 55, ptr nonnull %S) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %K) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #5
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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_tolower_loc() local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #4
attributes #0 = { nofree 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 = { 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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 nounwind }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(none) }
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!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 = !{!7, !7, i64 0}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.