#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
int /*<<< orphan*/ bubble_sort(int);
scalar_t__ clock();
int czytanie(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sortuj_spis(int);
int /*<<< orphan*/ utworz_spis(char *, int);
int main(int arg_num, char *arg[]) {
  int ile;
  if (arg_num == 3) {
    ile = czytanie(arg[1]);
    if (ile > 0) {
      utworz_spis(arg[1], ile);
      printf("Ilosc lini w bazie wynosi %i\n", ile);
      clock_t pocz1 = clock();
      sortuj_spis(ile);
      clock_t koniec1 = clock();
      clock_t pocz2 = clock();
      bubble_sort(ile);
      clock_t koniec2 = clock();
      printf("|%10s|%10s|\n", "QSORT", "BUBBLESORT");
      printf("|----------|----------|\n");
      printf("|%10lf|%10lf|\n", (double)(koniec1 - pocz1) / CLOCKS_PER_SEC,
             (double)(koniec2 - pocz2) / CLOCKS_PER_SEC);
    }
  } else
    printf("\n Niepoprawne wywolanie: './porzadkuj baza_danych.txt "
           "posortowane.txt'\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1264 <main+0x104>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <czytanie@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    125f <main+0xff>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
call   1030 <utworz_spis@plt>
mov    -0x14(%rbp),%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <sortuj_spis@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
call   1080 <bubble_sort@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x38(%rbp)
lea    0xe20(%rip),%rdi
lea    0xe26(%rip),%rsi
lea    0xe25(%rip),%rdx
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2db3(%rip),%rax
divsd  (%rax),%xmm0
mov    -0x38(%rbp),%rax
sub    -0x30(%rbp),%rax
cvtsi2sd %rax,%xmm1
mov    0x2d9b(%rip),%rax
divsd  (%rax),%xmm1
lea    0xdfd(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
jmp    1272 <main+0x112>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x3,%edi
jne    1243 <main+0xd3>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1080 <czytanie@plt>
test   %eax,%eax
jle    124f <main+0xdf>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
mov    %eax,%esi
call   1030 <utworz_spis@plt>
lea    0xe57(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%r14
mov    %ebp,%edi
call   1060 <sortuj_spis@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%r15
mov    %ebp,%edi
call   1090 <bubble_sort@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%rbx
lea    0xe2f(%rip),%rdi
lea    0xe35(%rip),%rsi
lea    0xe34(%rip),%rdx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe88(%rip),%rdi
call   1040 <puts@plt>
sub    %r14,%r12
cvtsi2sd %r12,%xmm0
mov    0x2dc9(%rip),%rax
movsd  (%rax),%xmm2
divsd  %xmm2,%xmm0
sub    %r15,%rbx
cvtsi2sd %rbx,%xmm1
divsd  %xmm2,%xmm1
lea    0xe02(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
jmp    124f <main+0xdf>
lea    0xe01(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Ilosc lini w bazie wynosi %i\0A\00"
@.str.1 = [13 x i8] c"|%10s|%10s|\0A\00"
@.str.2 = [6 x i8] c"QSORT\00"
@.str.3 = [11 x i8] c"BUBBLESORT\00"
@.str.4 = [25 x i8] c"|----------|----------|\0A\00"
@.str.5 = [15 x i8] c"|%10lf|%10lf|\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.6 = [73 x i8] c"\0A Niepoprawne wywolanie: './porzadkuj baza_danych.txt posortowane.txt'\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 3
br i1 %12, label %13, label %52
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @czytanie(i8* %16)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %51
20: ; preds = %13
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i32, i32* %6
%25 = call i32 @utworz_spis(i8* %23, i32 %24)
%26 = load i32, i32* %6
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = call i64 (...) @clock()
store i64 %28, i64* %7
%29 = load i32, i32* %6
%30 = call i32 @sortuj_spis(i32 %29)
%31 = call i64 (...) @clock()
store i64 %31, i64* %8
%32 = call i64 (...) @clock()
store i64 %32, i64* %9
%33 = load i32, i32* %6
%34 = call i32 @bubble_sort(i32 %33)
%35 = call i64 (...) @clock()
store i64 %35, i64* %10
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%38 = load i64, i64* %8
%39 = load i64, i64* %7
%40 = sub nsw i64 %38, %39
%41 = sitofp i64 %40 to double
%42 = load double, double* @CLOCKS_PER_SEC
%43 = fdiv double %41, %42
%44 = load i64, i64* %10
%45 = load i64, i64* %9
%46 = sub nsw i64 %44, %45
%47 = sitofp i64 %46 to double
%48 = load double, double* @CLOCKS_PER_SEC
%49 = fdiv double %47, %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), double %43, double %49)
br label %51
51: ; preds = %20, %13
br label %54
52: ; preds = %2
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.6, i64 0, i64 0))
br label %54
54: ; preds = %52, %51
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"Ilosc lini w bazie wynosi %i\0A\00"
@.str.1 = [13 x i8] c"|%10s|%10s|\0A\00"
@.str.2 = [6 x i8] c"QSORT\00"
@.str.3 = [11 x i8] c"BUBBLESORT\00"
@.str.5 = [15 x i8] c"|%10lf|%10lf|\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@str = [72 x i8] c"\0A Niepoprawne wywolanie: './porzadkuj baza_danych.txt posortowane.txt'\0A\00"
@str.7 = [24 x i8] c"|----------|----------|\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %29
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @czytanie(i8* %6)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %31
9: ; preds = %4
%10 = load i8*, i8** %5
%11 = tail call i32 @utworz_spis(i8* %10, i32 %7)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %7)
%13 = tail call i64 (...) @clock()
%14 = tail call i32 @sortuj_spis(i32 %7)
%15 = tail call i64 (...) @clock()
%16 = tail call i64 (...) @clock()
%17 = tail call i32 @bubble_sort(i32 %7)
%18 = tail call i64 (...) @clock()
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.7, i64 0, i64 0))
%21 = sub nsw i64 %15, %13
%22 = sitofp i64 %21 to double
%23 = load double, double* @CLOCKS_PER_SEC
%24 = fdiv double %22, %23
%25 = sub nsw i64 %18, %16
%26 = sitofp i64 %25 to double
%27 = fdiv double %26, %23
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), double %24, double %27)
br label %31
29: ; preds = %2
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @str, i64 0, i64 0))
br label %31
31: ; preds = %4, %9, %29
ret i32 0
}