typedef struct TreeNode { struct TreeNode *left; struct TreeNode *right; long val; } TreeNode; Each TreeNode stores a val and two pointers (left, right) to its children, which are themselves TreeNode structs. Address OxO (NULL) indicates the child is empty. Recall that the C syntax t->val is equivalent to (*t).val. Disassembled Mystery Code. Alice remembers the mystery function's signature: long mystery (TreeNode* t) { } Alice recovered and disassembled the machine code for mystery and its caller, callmystery. 0x401106 : 0x40113c : 0x40113c subq $0x8,%rsp 0x401140 call 0x401145 addq 0x401149 ret $0x0,%eax %rdi,%rdi 0x401106 movą 0x40110b testq 0x40110e je 0x401110 pushq 0x401111 pushq 0x401112 subq 0x401116 movq 0x401119 movq 0x40111d movq 0x401120 call 0x401125 addq 0x401128 movq 0x40112c call 0x401131 addq %rbp,%rax 0x401134 addq $0x8,%rsp 0x401138 popq %rbx 0x401139 popq %rbp 0x40113a ret 40113a %rbp %rbx $0x8,%rsp %rdi,%rbx 0x10 (%rdi), %rbp (%rdi), %rdi 401106 %rax,%rbp 0x8(%rbx), %rdi 401106 401106 $0x8,%rsp

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

Please answer the following with the reference;

1a.  What is the purpose of the movq 0x10 (%rdi), rbp instruction here (at the C level or higher)? How does this relate to the earlier call to pushq rbp?

 

1b. Alice just remembered that the original C code had the following structure! Using what you now know about mystery, fill in the blanks with C code.

long mystery ( TreeNode* t){

If (    ) {

return       ;

}

 

return

}

typedef struct TreeNode {
struct TreeNode *left;
struct TreeNode *right;
long val;
} TreeNode;
Each TreeNode stores a val and two pointers (left, right) to its children, which are themselves
TreeNode structs. Address OxO (NULL) indicates the child is empty. Recall that the C syntax t->val
is equivalent to (*t). val.
Disassembled Mystery Code. Alice remembers the mystery function's signature:
long mystery (TreeNode* t) {...}
Alice recovered and disassembled the machine code for mystery and its caller, callmystery.
0x401106 <mystery>:
0x40113c <callmystery>:
0x40113c subq $0x8,%rsp
0x401140 call 401106 <mystery>
0x401145
addq
$0x8, %rsp
0x401149
ret
$0x0,%eax
%rdi, %rdi
40113a <mystery+0x34>
0x401106
movq
0x40110b testq
0x40110e je
0x401110 pushq
%rbp
0x401111 pushq %rbx
0x401112 subq
0x401116
0x401119
0x40111d movq
0x401120
call
0x401125 addq
0x401128 movq
0x40112c
0x401131 addq %rbp,%rax
0x401134 addq
$0x8,%rsp
0x401138 popq %rbx
0x401139 popq %rbp
0x40113a
ret
$0x8,%rsp
%rdi,%rbx
movq
movq 0x10(%rdi), %rbp
(%rdi), %rdi
401106 <mystery>
%rax, %rbp
0x8 (%rbx), %rdi
call 401106 <mystery>
Transcribed Image Text:typedef struct TreeNode { struct TreeNode *left; struct TreeNode *right; long val; } TreeNode; Each TreeNode stores a val and two pointers (left, right) to its children, which are themselves TreeNode structs. Address OxO (NULL) indicates the child is empty. Recall that the C syntax t->val is equivalent to (*t). val. Disassembled Mystery Code. Alice remembers the mystery function's signature: long mystery (TreeNode* t) {...} Alice recovered and disassembled the machine code for mystery and its caller, callmystery. 0x401106 <mystery>: 0x40113c <callmystery>: 0x40113c subq $0x8,%rsp 0x401140 call 401106 <mystery> 0x401145 addq $0x8, %rsp 0x401149 ret $0x0,%eax %rdi, %rdi 40113a <mystery+0x34> 0x401106 movq 0x40110b testq 0x40110e je 0x401110 pushq %rbp 0x401111 pushq %rbx 0x401112 subq 0x401116 0x401119 0x40111d movq 0x401120 call 0x401125 addq 0x401128 movq 0x40112c 0x401131 addq %rbp,%rax 0x401134 addq $0x8,%rsp 0x401138 popq %rbx 0x401139 popq %rbp 0x40113a ret $0x8,%rsp %rdi,%rbx movq movq 0x10(%rdi), %rbp (%rdi), %rdi 401106 <mystery> %rax, %rbp 0x8 (%rbx), %rdi call 401106 <mystery>
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Types of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education