; ModuleID = './src_work/qsort_large.c'
source_filename = "./src_work/qsort_large.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-unknown-linux-gnu"

%struct.my3DVertexStruct = type { i32, i32, i32, double }

@stderr = external global ptr, align 8
@.str = private unnamed_addr constant [27 x i8] c"Usage: qsort_large <file>\0A\00", align 1
@.str.1 = private unnamed_addr constant [2 x i8] c"r\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.3 = private unnamed_addr constant [57 x i8] c"\0ASorting %d vectors based on distance from the origin.\0A\0A\00", align 1
@.str.4 = private unnamed_addr constant [18 x i8] c"sorted_output.dat\00", align 1
@.str.5 = private unnamed_addr constant [3 x i8] c"wt\00", align 1
@.str.6 = private unnamed_addr constant [32 x i8] c"\0AError: Can't open output file\0A\00", align 1
@.str.7 = private unnamed_addr constant [10 x i8] c"%d %d %d\0A\00", align 1

; Function Attrs:  nounwind uwtable
define dso_local i32 @compare(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8
  %7 = load ptr, ptr %3, align 8
  %8 = getelementptr inbounds %struct.my3DVertexStruct, ptr %7, i32 0, i32 3
  %9 = load double, ptr %8, align 8
  store double %9, ptr %5, align 8
  %10 = load ptr, ptr %4, align 8
  %11 = getelementptr inbounds %struct.my3DVertexStruct, ptr %10, i32 0, i32 3
  %12 = load double, ptr %11, align 8
  store double %12, ptr %6, align 8
  %13 = load double, ptr %5, align 8
  %14 = load double, ptr %6, align 8
  %15 = fcmp ogt double %13, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %2
  br label %23

17:                                               ; preds = %2
  %18 = load double, ptr %5, align 8
  %19 = load double, ptr %6, align 8
  %20 = fcmp oeq double %18, %19
  %21 = zext i1 %20 to i64
  %22 = select i1 %20, i32 0, i32 -1
  br label %23

23:                                               ; preds = %17, %16
  %24 = phi i32 [ 1, %16 ], [ %22, %17 ]
  ret i32 %24
}

; Function Attrs:  nounwind uwtable
define dso_local i32 @main1(i32 noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca [60000 x %struct.my3DVertexStruct], align 16
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 %0, ptr %4, align 4
  store ptr %1, ptr %5, align 8
  store i32 %2, ptr %6, align 4
  store ptr null, ptr %7, align 8
  store i32 0, ptr %11, align 4
  %15 = load i32, ptr %4, align 4
  %16 = icmp slt i32 %15, 2
  br i1 %16, label %17, label %20

17:                                               ; preds = %3
  %18 = load ptr, ptr @stderr, align 8
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str)
  call void @exit(i32 noundef 1) #4
  unreachable

20:                                               ; preds = %3
  %21 = load ptr, ptr %5, align 8
  %22 = getelementptr inbounds ptr, ptr %21, i64 1
  %23 = load ptr, ptr %22, align 8
  %24 = call ptr @fopen(ptr noundef %23, ptr noundef @.str.1)
  store ptr %24, ptr %9, align 8
  br label %25

25:                                               ; preds = %42, %20
  %26 = load ptr, ptr %9, align 8
  %27 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %26, ptr noundef @.str.2, ptr noundef %12)
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %29, label %40

29:                                               ; preds = %25
  %30 = load ptr, ptr %9, align 8
  %31 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %30, ptr noundef @.str.2, ptr noundef %13)
  %32 = icmp eq i32 %31, 1
  br i1 %32, label %33, label %40

33:                                               ; preds = %29
  %34 = load ptr, ptr %9, align 8
  %35 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %34, ptr noundef @.str.2, ptr noundef %14)
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %37, label %40

37:                                               ; preds = %33
  %38 = load i32, ptr %11, align 4
  %39 = icmp slt i32 %38, 60000
  br label %40

40:                                               ; preds = %37, %33, %29, %25
  %41 = phi i1 [ false, %33 ], [ false, %29 ], [ false, %25 ], [ %39, %37 ]
  br i1 %41, label %42, label %76

42:                                               ; preds = %40
  %43 = load i32, ptr %12, align 4
  %44 = load i32, ptr %11, align 4
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [60000 x %struct.my3DVertexStruct], ptr %8, i64 0, i64 %45
  %47 = getelementptr inbounds %struct.my3DVertexStruct, ptr %46, i32 0, i32 0
  store i32 %43, ptr %47, align 8
  %48 = load i32, ptr %13, align 4
  %49 = load i32, ptr %11, align 4
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [60000 x %struct.my3DVertexStruct], ptr %8, i64 0, i64 %50
  %52 = getelementptr inbounds %struct.my3DVertexStruct, ptr %51, i32 0, i32 1
  store i32 %48, ptr %52, align 4
  %53 = load i32, ptr %14, align 4
  %54 = load i32, ptr %11, align 4
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [60000 x %struct.my3DVertexStruct], ptr %8, i64 0, i64 %55
  %57 = getelementptr inbounds %struct.my3DVertexStruct, ptr %56, i32 0, i32 2
  store i32 %53, ptr %57, align 8
  %58 = load i32, ptr %12, align 4
  %59 = sitofp i32 %58 to double
  %60 = call double @pow(double noundef %59, double noundef 2.000000e+00) #5
  %61 = load i32, ptr %13, align 4
  %62 = sitofp i32 %61 to double
  %63 = call double @pow(double noundef %62, double noundef 2.000000e+00) #5
  %64 = fadd double %60, %63
  %65 = load i32, ptr %14, align 4
  %66 = sitofp i32 %65 to double
  %67 = call double @pow(double noundef %66, double noundef 2.000000e+00) #5
  %68 = fadd double %64, %67
  %69 = call double @sqrt(double noundef %68) #5
  %70 = load i32, ptr %11, align 4
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [60000 x %struct.my3DVertexStruct], ptr %8, i64 0, i64 %71
  %73 = getelementptr inbounds %struct.my3DVertexStruct, ptr %72, i32 0, i32 3
  store double %69, ptr %73, align 8
  %74 = load i32, ptr %11, align 4
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %11, align 4
  br label %25, !llvm.loop !6

76:                                               ; preds = %40
  %77 = load ptr, ptr %9, align 8
  %78 = call i32 @fclose(ptr noundef %77)
  br label %79

79:                                               ; preds = %76
  %80 = load i32, ptr %6, align 4
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %82, label %85

82:                                               ; preds = %79
  %83 = load i32, ptr %11, align 4
  %84 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %83)
  br label %85

85:                                               ; preds = %82, %79
  %86 = getelementptr inbounds [60000 x %struct.my3DVertexStruct], ptr %8, i64 0, i64 0
  %87 = load i32, ptr %11, align 4
  call void @qsortx(ptr noundef %86, i32 noundef %87, i32 noundef 24, ptr noundef @compare)
  %88 = load i32, ptr %6, align 4
  %89 = icmp ne i32 %88, 0
  br i1 %89, label %90, label %127

90:                                               ; preds = %85
  %91 = call ptr @fopen(ptr noundef @.str.4, ptr noundef @.str.5)
  store ptr %91, ptr %7, align 8
  %92 = icmp eq ptr %91, null
  br i1 %92, label %93, label %96

93:                                               ; preds = %90
  %94 = load ptr, ptr @stderr, align 8
  %95 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %94, ptr noundef @.str.6)
  call void @exit(i32 noundef 1) #4
  unreachable

96:                                               ; preds = %90
  store i32 0, ptr %10, align 4
  br label %97

97:                                               ; preds = %119, %96
  %98 = load i32, ptr %10, align 4
  %99 = load i32, ptr %11, align 4
  %100 = icmp slt i32 %98, %99
  br i1 %100, label %101, label %124

101:                                              ; preds = %97
  %102 = load ptr, ptr %7, align 8
  %103 = load i32, ptr %10, align 4
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [60000 x %struct.my3DVertexStruct], ptr %8, i64 0, i64 %104
  %106 = getelementptr inbounds %struct.my3DVertexStruct, ptr %105, i32 0, i32 0
  %107 = load i32, ptr %106, align 8
  %108 = load i32, ptr %10, align 4
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [60000 x %struct.my3DVertexStruct], ptr %8, i64 0, i64 %109
  %111 = getelementptr inbounds %struct.my3DVertexStruct, ptr %110, i32 0, i32 1
  %112 = load i32, ptr %111, align 4
  %113 = load i32, ptr %10, align 4
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [60000 x %struct.my3DVertexStruct], ptr %8, i64 0, i64 %114
  %116 = getelementptr inbounds %struct.my3DVertexStruct, ptr %115, i32 0, i32 2
  %117 = load i32, ptr %116, align 8
  %118 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %102, ptr noundef @.str.7, i32 noundef %107, i32 noundef %112, i32 noundef %117)
  br label %119

119:                                              ; preds = %101
  %120 = load i32, ptr %11, align 4
  %121 = sdiv i32 %120, 100
  %122 = load i32, ptr %10, align 4
  %123 = add nsw i32 %122, %121
  store i32 %123, ptr %10, align 4
  br label %97, !llvm.loop !8

124:                                              ; preds = %97
  %125 = load ptr, ptr %7, align 8
  %126 = call i32 @fclose(ptr noundef %125)
  br label %127

127:                                              ; preds = %124, %85
  ret i32 0
}

declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

declare ptr @fopen(ptr noundef, ptr noundef) #1

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: nounwind
declare double @sqrt(double noundef) #3

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #3

declare i32 @fclose(ptr noundef) #1

declare i32 @printf(ptr noundef, ...) #1

declare void @qsortx(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #1

attributes #0 = {  nounwind uwtable "frame-pointer"="all" "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 = { "frame-pointer"="all" "no-trapping-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 = { noreturn nounwind "frame-pointer"="all" "no-trapping-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 "frame-pointer"="all" "no-trapping-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 = { noreturn nounwind }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3, !4}
!llvm.ident = !{!5}

!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 = !{i32 7, !"frame-pointer", i32 2}
!5 = !{!"clang version 17.0.6"}
!6 = distinct !{!6, !7}
!7 = !{!"llvm.loop.mustprogress"}
!8 = distinct !{!8, !7}
