SlideShare a Scribd company logo
Write an MPI program that implements a shell-sort like parallel algorithm that sorts an array of
integers. The initial array is partitioned into equal size sub-arrays which are distributed to the
processes (one per process). The parallel algorithm is described in Section 9.3.2 of the textbook
(pages 398-399). It consists of two phases: (i) the processes that are far away from each other
compare and split their assigned sub-arrays (using a hypercube pattern of communication); (ii)
perform odd-even transposition iterations as long as the sub-arrays are changing. The following
is a high-level pseudocode description of the algorithm: Algorithm 1 Shell-sort like parallel
algorithm 1: {Phase I: Hypercube Compare-Exchange.} 2: for i = (d 1) to 0 do 3: if (i-th bit of
rank) = 1 then 4: compare-split-hi(i); 5: else 6: compare-split-low(i); 7: {Phase II: Odd-even
Transposition Iterations.} 8: done = FALSE 9: while done = FALSE do 10: {Perform odd-even
iterations} 11: if received items need to be passed further then 12: broadcast FALSE to all
processes; 13: else 14: broadcast TRUE to all processes; 15: if all processes broadcast TRUE
then 16: done = TRUE In the algorithm description: d - the number of bits required to represent
the ID’s of the processes (d=3 for 8 processes). compare-split-hi(i) - performs a compare-and-
split operation so that processor i keeps half of the merged sub-arrays containing the greatest
integers. compare-split-low(i) - performs a compare-and-split operation so that processor i keeps
half of the merged sub-arrays containing the smallest integers. Test the program on 8 processes.
The input array should consist of 128 random integers from the range [0, 128]. The array is
generated at process 0 which is responsible for partitioning the array and sending the sub-arrays
to the other processors. Process 0 will keep its corresponding sub-array, so that it can participate
in the algorithm. At the end of the computation, process 0 collects all the sub-arrays and displays
the sorted array. Compare the execution times for your parallel shell-sort implementation with
those of the standard odd-even transposition sort (given in the textbook, section 6.3.5, pages 248-
250) and the serial quicksort. For this performance comparison you should use 8 processors and
randomly generated integer arrays of sizes: 216, 220, 224, and 230. The random integers should
be in the range [0, 128]. Produce a plot showing the execution times of the three algorithms.
Produce another plot to show the speedup obtained by the parallel shell-sort with respect to the
sequential quicksort. Write a short (max. 2 pages) report describing the implementation and the
obtained results. The report should be typeset using Latex and the plots should be generated
using gnuplot.
Solution
Answer:
Assembly Language Code :
.zero 1
.LC0:
.string " "
print_ar(int*, int):
push rbp
mov rbp, rsp
sub rsp, 32
mov QWORD PTR [rbp-24], rdi
mov DWORD PTR [rbp-28], esi
mov DWORD PTR [rbp-4], 0
.L3:
mov eax, DWORD PTR [rbp-4]
cmp eax, DWORD PTR [rbp-28]
jge .L2
mov eax, DWORD PTR [rbp-4]
cdqe
lea rdx, [0+rax*4]
mov rax, QWORD PTR [rbp-24]
add rax, rdx
mov eax, DWORD PTR [rax]
mov esi, eax
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream >::operator<<(int)
mov esi, OFFSET FLAT:.LC0
mov rdi, rax
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
add DWORD PTR [rbp-4], 1
jmp .L3
.L2:
mov esi, OFFSET FLAT:std::basic_ostream >& std::endl >(std::basic_ostream >&)
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&))
nop
leave
ret
shell_sort(int*, int):
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-24], rdi
mov DWORD PTR [rbp-28], esi
mov eax, DWORD PTR [rbp-28]
mov edx, eax
shr edx, 31
add eax, edx
sar eax
mov DWORD PTR [rbp-8], eax
.L10:
cmp DWORD PTR [rbp-8], 0
jle .L11
mov eax, DWORD PTR [rbp-8]
mov DWORD PTR [rbp-12], eax
.L9:
mov eax, DWORD PTR [rbp-12]
cmp eax, DWORD PTR [rbp-28]
jge .L6
mov eax, DWORD PTR [rbp-12]
cdqe
lea rdx, [0+rax*4]
mov rax, QWORD PTR [rbp-24]
add rax, rdx
mov eax, DWORD PTR [rax]
mov DWORD PTR [rbp-16], eax
mov eax, DWORD PTR [rbp-12]
mov DWORD PTR [rbp-4], eax
.L8:
mov eax, DWORD PTR [rbp-4]
cmp eax, DWORD PTR [rbp-8]
jl .L7
mov eax, DWORD PTR [rbp-4]
sub eax, DWORD PTR [rbp-8]
cdqe
lea rdx, [0+rax*4]
mov rax, QWORD PTR [rbp-24]
add rax, rdx
mov eax, DWORD PTR [rax]
cmp eax, DWORD PTR [rbp-16]
jle .L7
mov eax, DWORD PTR [rbp-4]
cdqe
lea rdx, [0+rax*4]
mov rax, QWORD PTR [rbp-24]
add rdx, rax
mov eax, DWORD PTR [rbp-4]
sub eax, DWORD PTR [rbp-8]
cdqe
lea rcx, [0+rax*4]
mov rax, QWORD PTR [rbp-24]
add rax, rcx
mov eax, DWORD PTR [rax]
mov DWORD PTR [rdx], eax
mov eax, DWORD PTR [rbp-8]
sub DWORD PTR [rbp-4], eax
jmp .L8
.L7:
mov eax, DWORD PTR [rbp-4]
cdqe
lea rdx, [0+rax*4]
mov rax, QWORD PTR [rbp-24]
add rdx, rax
mov eax, DWORD PTR [rbp-16]
mov DWORD PTR [rdx], eax
add DWORD PTR [rbp-12], 1
jmp .L9
.L6:
mov eax, DWORD PTR [rbp-8]
mov edx, eax
shr edx, 31
add eax, edx
sar eax
mov DWORD PTR [rbp-8], eax
jmp .L10
.L11:
nop
pop rbp
ret
.LC1:
.string "Intial Array : "
.LC2:
.string "Sorted Array : "
main:
push rbp
mov rbp, rsp
sub rsp, 48
mov DWORD PTR [rbp-48], 1
mov DWORD PTR [rbp-44], 4
mov DWORD PTR [rbp-40], 16
mov DWORD PTR [rbp-36], 30
mov DWORD PTR [rbp-32], 29
mov DWORD PTR [rbp-28], 18
mov DWORD PTR [rbp-24], 100
mov DWORD PTR [rbp-20], 2
mov DWORD PTR [rbp-16], 43
mov DWORD PTR [rbp-12], 1
mov esi, OFFSET FLAT:.LC1
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
lea rax, [rbp-48]
mov esi, 10
mov rdi, rax
call print_ar(int*, int)
lea rax, [rbp-48]
mov esi, 10
mov rdi, rax
call shell_sort(int*, int)
mov esi, OFFSET FLAT:.LC2
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
lea rax, [rbp-48]
mov esi, 10
mov rdi, rax
call print_ar(int*, int)
mov eax, 0
leave
ret
__static_initialization_and_destruction_0(int, int):
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], edi
mov DWORD PTR [rbp-8], esi
cmp DWORD PTR [rbp-4], 1
jne .L16
cmp DWORD PTR [rbp-8], 65535
jne .L16
mov edi, OFFSET FLAT:std::__ioinit
call std::ios_base::Init::Init()
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:std::__ioinit
mov edi, OFFSET FLAT:std::ios_base::Init::~Init()
call __cxa_atexit
.L16:
nop
leave
ret
push rbp
mov rbp, rsp
mov esi, 65535
mov edi, 1
call __static_initialization_and_destruction_0(int, int)
pop rbp
ret
Ad

Recommended

PDF
Implement an MPI program to perform matrix-matrix multiplication AB .pdf
meerobertsonheyde608
 
PDF
Write a program in MIPS that reads in a Roman form number from th.pdf
santanadenisesarin13
 
PDF
WCTF 2018 binja Editorial
Charo_IT
 
PPTX
Advanced procedures in assembly language Full chapter ppt
Muhammad Sikandar Mustafa
 
PDF
Qemu JIT Code Generator and System Emulation
National Cheng Kung University
 
PPTX
Hadoop and HBase experiences in perf log project
Mao Geng
 
PPTX
Operating System Engineering
Programming Homework Help
 
PPTX
[ASM]Lab6
Nora Youssef
 
PDF
Please convert the following C code to assembly Y86int j,k; .....pdf
foottraders
 
PDF
Spark workshop
Wojciech Pituła
 
PPT
Advance ROP Attacks
n|u - The Open Security Community
 
PPTX
Basic ASM by @binaryheadache
camsec
 
PDF
Real Time Big Data Management
Albert Bifet
 
PDF
Please convert the following C code to assembly Y86int i,j; ......pdf
SIGMATAX1
 
PDF
Scale17x buffer overflows
johseg
 
PDF
Sergi Álvarez & Roi Martín - Radare2 Preview [RootedCON 2010]
RootedCON
 
PDF
Parallel and Distributed computing: why parallellismpdf
HafizMuhammadAzeemAk
 
PPTX
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Sergey Platonov
 
PDF
Stata Programming Cheat Sheet
Laura Hughes
 
PPT
Basic concept of MATLAB.ppt
aliraza2732
 
PPT
Introduction to Assembly Language
Motaz Saad
 
PDF
Vectorization in ATLAS
Roberto Agostino Vitillo
 
PPTX
C++ and Assembly: Debugging and Reverse Engineering
corehard_by
 
PDF
Stata cheatsheet programming
Tim Essam
 
PDF
Redis Lua Scripts
Itamar Haber
 
PPTX
Python basics
Hoang Nguyen
 
PPTX
Python basics
Young Alista
 
PPTX
Python basics
Harry Potter
 
PDF
Explain how HPV leads to cervical cancer and oral cancer. Include.pdf
bharatchawla141
 
PDF
Consider L = {a^nb^2nc^P p 0}. Prove L is not a context-free langu.pdf
bharatchawla141
 

More Related Content

Similar to Write an MPI program that implements a shell-sort like parallel algo.pdf (20)

PDF
Please convert the following C code to assembly Y86int j,k; .....pdf
foottraders
 
PDF
Spark workshop
Wojciech Pituła
 
PPT
Advance ROP Attacks
n|u - The Open Security Community
 
PPTX
Basic ASM by @binaryheadache
camsec
 
PDF
Real Time Big Data Management
Albert Bifet
 
PDF
Please convert the following C code to assembly Y86int i,j; ......pdf
SIGMATAX1
 
PDF
Scale17x buffer overflows
johseg
 
PDF
Sergi Álvarez & Roi Martín - Radare2 Preview [RootedCON 2010]
RootedCON
 
PDF
Parallel and Distributed computing: why parallellismpdf
HafizMuhammadAzeemAk
 
PPTX
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Sergey Platonov
 
PDF
Stata Programming Cheat Sheet
Laura Hughes
 
PPT
Basic concept of MATLAB.ppt
aliraza2732
 
PPT
Introduction to Assembly Language
Motaz Saad
 
PDF
Vectorization in ATLAS
Roberto Agostino Vitillo
 
PPTX
C++ and Assembly: Debugging and Reverse Engineering
corehard_by
 
PDF
Stata cheatsheet programming
Tim Essam
 
PDF
Redis Lua Scripts
Itamar Haber
 
PPTX
Python basics
Hoang Nguyen
 
PPTX
Python basics
Young Alista
 
PPTX
Python basics
Harry Potter
 
Please convert the following C code to assembly Y86int j,k; .....pdf
foottraders
 
Spark workshop
Wojciech Pituła
 
Basic ASM by @binaryheadache
camsec
 
Real Time Big Data Management
Albert Bifet
 
Please convert the following C code to assembly Y86int i,j; ......pdf
SIGMATAX1
 
Scale17x buffer overflows
johseg
 
Sergi Álvarez & Roi Martín - Radare2 Preview [RootedCON 2010]
RootedCON
 
Parallel and Distributed computing: why parallellismpdf
HafizMuhammadAzeemAk
 
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Sergey Platonov
 
Stata Programming Cheat Sheet
Laura Hughes
 
Basic concept of MATLAB.ppt
aliraza2732
 
Introduction to Assembly Language
Motaz Saad
 
Vectorization in ATLAS
Roberto Agostino Vitillo
 
C++ and Assembly: Debugging and Reverse Engineering
corehard_by
 
Stata cheatsheet programming
Tim Essam
 
Redis Lua Scripts
Itamar Haber
 
Python basics
Hoang Nguyen
 
Python basics
Young Alista
 
Python basics
Harry Potter
 

More from bharatchawla141 (20)

PDF
Explain how HPV leads to cervical cancer and oral cancer. Include.pdf
bharatchawla141
 
PDF
Consider L = {a^nb^2nc^P p 0}. Prove L is not a context-free langu.pdf
bharatchawla141
 
PDF
Differentiate between analog and digital signals.SolutionIn ana.pdf
bharatchawla141
 
PDF
describe two properties of iPS and ES cells, including the meaning i.pdf
bharatchawla141
 
PDF
Coffman Company issued 1,000,000 10 year 10 percent bonds January 1,.pdf
bharatchawla141
 
PDF
A JAR file contains an image named images Fall.png. Java class na.pdf
bharatchawla141
 
PDF
A 71-year-old male patient comes to the hospital after having been p.pdf
bharatchawla141
 
PDF
You are carrying out experiments in cell fusion by fusing together ce.pdf
bharatchawla141
 
PDF
Which of the following are roles of proteins Pick ALL that apply..pdf
bharatchawla141
 
PDF
When are a persons fellowship, autonomy, and competence face threa.pdf
bharatchawla141
 
PDF
What is the function in homworts Where can one find homwortsS.pdf
bharatchawla141
 
PDF
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
bharatchawla141
 
PDF
Two paragraph opinion about the film editing of the movie LIFE OF .pdf
bharatchawla141
 
PDF
True or False The aDDM fixes the SV reference problem by assuming t.pdf
bharatchawla141
 
PDF
The number of visits to public libraries increased from 1.4 billion i.pdf
bharatchawla141
 
PDF
The first table contains data of the Student entry. Attributes are Si.pdf
bharatchawla141
 
PDF
Save for Later 12) Viruses, adware and spyware are referred to collec.pdf
bharatchawla141
 
PDF
Sustainability Sustainability is an important consideration for any.pdf
bharatchawla141
 
PDF
Research health data stewardship and in your post show why it is imp.pdf
bharatchawla141
 
PDF
Read carefully. Im not sure if the point class is correct but postin.pdf
bharatchawla141
 
Explain how HPV leads to cervical cancer and oral cancer. Include.pdf
bharatchawla141
 
Consider L = {a^nb^2nc^P p 0}. Prove L is not a context-free langu.pdf
bharatchawla141
 
Differentiate between analog and digital signals.SolutionIn ana.pdf
bharatchawla141
 
describe two properties of iPS and ES cells, including the meaning i.pdf
bharatchawla141
 
Coffman Company issued 1,000,000 10 year 10 percent bonds January 1,.pdf
bharatchawla141
 
A JAR file contains an image named images Fall.png. Java class na.pdf
bharatchawla141
 
A 71-year-old male patient comes to the hospital after having been p.pdf
bharatchawla141
 
You are carrying out experiments in cell fusion by fusing together ce.pdf
bharatchawla141
 
Which of the following are roles of proteins Pick ALL that apply..pdf
bharatchawla141
 
When are a persons fellowship, autonomy, and competence face threa.pdf
bharatchawla141
 
What is the function in homworts Where can one find homwortsS.pdf
bharatchawla141
 
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
bharatchawla141
 
Two paragraph opinion about the film editing of the movie LIFE OF .pdf
bharatchawla141
 
True or False The aDDM fixes the SV reference problem by assuming t.pdf
bharatchawla141
 
The number of visits to public libraries increased from 1.4 billion i.pdf
bharatchawla141
 
The first table contains data of the Student entry. Attributes are Si.pdf
bharatchawla141
 
Save for Later 12) Viruses, adware and spyware are referred to collec.pdf
bharatchawla141
 
Sustainability Sustainability is an important consideration for any.pdf
bharatchawla141
 
Research health data stewardship and in your post show why it is imp.pdf
bharatchawla141
 
Read carefully. Im not sure if the point class is correct but postin.pdf
bharatchawla141
 
Ad

Recently uploaded (20)

PPTX
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
PPT
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
PDF
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
PPTX
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
PPTX
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
PPTX
Project 4 PART 1 AI Assistant Vocational Education
barmanjit380
 
PPTX
A Case of Identity A Sociological Approach Fix.pptx
Ismail868386
 
PPTX
How to use grouped() method in Odoo 18 - Odoo Slides
Celine George
 
PDF
COM and NET Component Services 1st Edition Juval Löwy
kboqcyuw976
 
PDF
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
PPTX
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
PDF
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
PPTX
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
PPTX
Comparing Translational and Rotational Motion.pptx
AngeliqueTolentinoDe
 
PDF
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
 
PPTX
Peer Teaching Observations During School Internship
AjayaMohanty7
 
PDF
VCE Literature Section A Exam Response Guide
jpinnuck
 
PPTX
JSON, XML and Data Science introduction.pptx
Ramakrishna Reddy Bijjam
 
DOCX
MUSIC AND ARTS 5 DLL MATATAG LESSON EXEMPLAR QUARTER 1_Q1_W1.docx
DianaValiente5
 
PPTX
How to Add New Item in CogMenu in Odoo 18
Celine George
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
Project 4 PART 1 AI Assistant Vocational Education
barmanjit380
 
A Case of Identity A Sociological Approach Fix.pptx
Ismail868386
 
How to use grouped() method in Odoo 18 - Odoo Slides
Celine George
 
COM and NET Component Services 1st Edition Juval Löwy
kboqcyuw976
 
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
Comparing Translational and Rotational Motion.pptx
AngeliqueTolentinoDe
 
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
 
Peer Teaching Observations During School Internship
AjayaMohanty7
 
VCE Literature Section A Exam Response Guide
jpinnuck
 
JSON, XML and Data Science introduction.pptx
Ramakrishna Reddy Bijjam
 
MUSIC AND ARTS 5 DLL MATATAG LESSON EXEMPLAR QUARTER 1_Q1_W1.docx
DianaValiente5
 
How to Add New Item in CogMenu in Odoo 18
Celine George
 
Ad

Write an MPI program that implements a shell-sort like parallel algo.pdf

  • 1. Write an MPI program that implements a shell-sort like parallel algorithm that sorts an array of integers. The initial array is partitioned into equal size sub-arrays which are distributed to the processes (one per process). The parallel algorithm is described in Section 9.3.2 of the textbook (pages 398-399). It consists of two phases: (i) the processes that are far away from each other compare and split their assigned sub-arrays (using a hypercube pattern of communication); (ii) perform odd-even transposition iterations as long as the sub-arrays are changing. The following is a high-level pseudocode description of the algorithm: Algorithm 1 Shell-sort like parallel algorithm 1: {Phase I: Hypercube Compare-Exchange.} 2: for i = (d 1) to 0 do 3: if (i-th bit of rank) = 1 then 4: compare-split-hi(i); 5: else 6: compare-split-low(i); 7: {Phase II: Odd-even Transposition Iterations.} 8: done = FALSE 9: while done = FALSE do 10: {Perform odd-even iterations} 11: if received items need to be passed further then 12: broadcast FALSE to all processes; 13: else 14: broadcast TRUE to all processes; 15: if all processes broadcast TRUE then 16: done = TRUE In the algorithm description: d - the number of bits required to represent the ID’s of the processes (d=3 for 8 processes). compare-split-hi(i) - performs a compare-and- split operation so that processor i keeps half of the merged sub-arrays containing the greatest integers. compare-split-low(i) - performs a compare-and-split operation so that processor i keeps half of the merged sub-arrays containing the smallest integers. Test the program on 8 processes. The input array should consist of 128 random integers from the range [0, 128]. The array is generated at process 0 which is responsible for partitioning the array and sending the sub-arrays to the other processors. Process 0 will keep its corresponding sub-array, so that it can participate in the algorithm. At the end of the computation, process 0 collects all the sub-arrays and displays the sorted array. Compare the execution times for your parallel shell-sort implementation with those of the standard odd-even transposition sort (given in the textbook, section 6.3.5, pages 248- 250) and the serial quicksort. For this performance comparison you should use 8 processors and randomly generated integer arrays of sizes: 216, 220, 224, and 230. The random integers should be in the range [0, 128]. Produce a plot showing the execution times of the three algorithms. Produce another plot to show the speedup obtained by the parallel shell-sort with respect to the sequential quicksort. Write a short (max. 2 pages) report describing the implementation and the obtained results. The report should be typeset using Latex and the plots should be generated using gnuplot. Solution Answer: Assembly Language Code :
  • 2. .zero 1 .LC0: .string " " print_ar(int*, int): push rbp mov rbp, rsp sub rsp, 32 mov QWORD PTR [rbp-24], rdi mov DWORD PTR [rbp-28], esi mov DWORD PTR [rbp-4], 0 .L3: mov eax, DWORD PTR [rbp-4] cmp eax, DWORD PTR [rbp-28] jge .L2 mov eax, DWORD PTR [rbp-4] cdqe lea rdx, [0+rax*4] mov rax, QWORD PTR [rbp-24] add rax, rdx mov eax, DWORD PTR [rax] mov esi, eax mov edi, OFFSET FLAT:std::cout call std::basic_ostream >::operator<<(int) mov esi, OFFSET FLAT:.LC0 mov rdi, rax call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) add DWORD PTR [rbp-4], 1 jmp .L3 .L2: mov esi, OFFSET FLAT:std::basic_ostream >& std::endl >(std::basic_ostream >&) mov edi, OFFSET FLAT:std::cout call std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&)) nop leave ret shell_sort(int*, int):
  • 3. push rbp mov rbp, rsp mov QWORD PTR [rbp-24], rdi mov DWORD PTR [rbp-28], esi mov eax, DWORD PTR [rbp-28] mov edx, eax shr edx, 31 add eax, edx sar eax mov DWORD PTR [rbp-8], eax .L10: cmp DWORD PTR [rbp-8], 0 jle .L11 mov eax, DWORD PTR [rbp-8] mov DWORD PTR [rbp-12], eax .L9: mov eax, DWORD PTR [rbp-12] cmp eax, DWORD PTR [rbp-28] jge .L6 mov eax, DWORD PTR [rbp-12] cdqe lea rdx, [0+rax*4] mov rax, QWORD PTR [rbp-24] add rax, rdx mov eax, DWORD PTR [rax] mov DWORD PTR [rbp-16], eax mov eax, DWORD PTR [rbp-12] mov DWORD PTR [rbp-4], eax .L8: mov eax, DWORD PTR [rbp-4] cmp eax, DWORD PTR [rbp-8] jl .L7 mov eax, DWORD PTR [rbp-4] sub eax, DWORD PTR [rbp-8] cdqe lea rdx, [0+rax*4]
  • 4. mov rax, QWORD PTR [rbp-24] add rax, rdx mov eax, DWORD PTR [rax] cmp eax, DWORD PTR [rbp-16] jle .L7 mov eax, DWORD PTR [rbp-4] cdqe lea rdx, [0+rax*4] mov rax, QWORD PTR [rbp-24] add rdx, rax mov eax, DWORD PTR [rbp-4] sub eax, DWORD PTR [rbp-8] cdqe lea rcx, [0+rax*4] mov rax, QWORD PTR [rbp-24] add rax, rcx mov eax, DWORD PTR [rax] mov DWORD PTR [rdx], eax mov eax, DWORD PTR [rbp-8] sub DWORD PTR [rbp-4], eax jmp .L8 .L7: mov eax, DWORD PTR [rbp-4] cdqe lea rdx, [0+rax*4] mov rax, QWORD PTR [rbp-24] add rdx, rax mov eax, DWORD PTR [rbp-16] mov DWORD PTR [rdx], eax add DWORD PTR [rbp-12], 1 jmp .L9 .L6: mov eax, DWORD PTR [rbp-8] mov edx, eax shr edx, 31 add eax, edx
  • 5. sar eax mov DWORD PTR [rbp-8], eax jmp .L10 .L11: nop pop rbp ret .LC1: .string "Intial Array : " .LC2: .string "Sorted Array : " main: push rbp mov rbp, rsp sub rsp, 48 mov DWORD PTR [rbp-48], 1 mov DWORD PTR [rbp-44], 4 mov DWORD PTR [rbp-40], 16 mov DWORD PTR [rbp-36], 30 mov DWORD PTR [rbp-32], 29 mov DWORD PTR [rbp-28], 18 mov DWORD PTR [rbp-24], 100 mov DWORD PTR [rbp-20], 2 mov DWORD PTR [rbp-16], 43 mov DWORD PTR [rbp-12], 1 mov esi, OFFSET FLAT:.LC1 mov edi, OFFSET FLAT:std::cout call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) lea rax, [rbp-48] mov esi, 10 mov rdi, rax call print_ar(int*, int) lea rax, [rbp-48] mov esi, 10 mov rdi, rax call shell_sort(int*, int)
  • 6. mov esi, OFFSET FLAT:.LC2 mov edi, OFFSET FLAT:std::cout call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) lea rax, [rbp-48] mov esi, 10 mov rdi, rax call print_ar(int*, int) mov eax, 0 leave ret __static_initialization_and_destruction_0(int, int): push rbp mov rbp, rsp sub rsp, 16 mov DWORD PTR [rbp-4], edi mov DWORD PTR [rbp-8], esi cmp DWORD PTR [rbp-4], 1 jne .L16 cmp DWORD PTR [rbp-8], 65535 jne .L16 mov edi, OFFSET FLAT:std::__ioinit call std::ios_base::Init::Init() mov edx, OFFSET FLAT:__dso_handle mov esi, OFFSET FLAT:std::__ioinit mov edi, OFFSET FLAT:std::ios_base::Init::~Init() call __cxa_atexit .L16: nop leave ret push rbp mov rbp, rsp mov esi, 65535 mov edi, 1 call __static_initialization_and_destruction_0(int, int) pop rbp
  • 7. ret