You are looking at lesson 6. Your place is still lesson 7, task 1: Modules.
Extra: to the processor, a[i] is the address "start + i · 4". Find that calculation in the assembly of practice/06/search.c.
Extra. Not graded. How does the processor find a[i]?
Open the tool window's Assembly tab. On the left is your practice/06/search.c.
An array in memory is its elements one after another. The address of a[i] = the start of the array + i · the size of an element. In linear_search, the line if (a[i] == x) shows it directly:
lea rdx, 0[0+rax*4]: i · 4 (an int takes 4 bytes);add rax, rdx: added to the start of the array a;mov eax, DWORD PTR [rax]: the 4 bytes at that address are read.There is no check that i stays inside the array: the processor simply reads whatever is at that address. That is why C doesn't report an error out of bounds but reads "something", and only the sanitizers catch it.
a is stored as a QWORD (8 bytes): the function gets not the array but its address.checks is reached by name (checks[rip]), local variables through rbp: a global lives in one place for the program's whole run.(right - left) / 2 becomes shr, add, sar: dividing by 2 is a shift by one bit (with a correction for negative numbers).Switch to -O1: the whole of a[i] == x fits in one instruction, cmp DWORD PTR [rcx+rax*4], ...: the processor can compute the address "start + index · 4" by itself.
C source search.c
x86-64 assembly -O0
x86-64 assembly -O1
Each one ticks itself when you do it.
All six done. You know your way around.
It is laid out like CLion: the same panels in the same places. This tour shows each one, and you can reopen it any time with Tour.
Switches the left panel: Lesson plan, Project files, Changes. Click the active icon again to hide the panel.
In CLion: the tool window bar runs down the left edge, too.
This part is not on this task: it appears when a task needs it.
Every task in this lesson. Now marks your place. Clicking a task only lets you look; it never moves your place. Project files and Changes open here too.
In CLion: this spot holds the Project view (the file tree).
This part is not on this task: it appears when a task needs it.
Opens the file for your task by itself. A tab appears for each file the step opens. The breadcrumbs above the code show the folder.
In CLion: the same editor tabs and breadcrumbs.
This part is not on this task: it appears when a task needs it.
Diff shows what changed, like git diff: red is the old code, green the new.
In CLion: the diff view in the Commit window looks the same.
This part is not on this task: it appears when a task needs it.
Terminal for build commands, Database to see your tables. They open by themselves when a task needs them. Drag the top edge to resize.
In CLion: Terminal, and the Database tool window.
This part is not on this task: it appears when a task needs it.
What to do now, right above the code, so you never miss it. Numbered notes in the code explain the important lines. Details shows what you should see and a hint.
In CLion: no equivalent: this is your lecturer's guide.
This part is not on this task: it appears when a task needs it.
Done is the only button that moves you forward. Look back lets you review without losing your place.
This part is not on this task: it appears when a task needs it.
Guided, Focus code or Floating. You can drag the panel edges too. Your layout is remembered for next time.
In CLion: you can also rearrange and hide tool windows.
This part is not on this task: it appears when a task needs it.
Six small missions. Each one ticks itself when you do it, so you know you have found everything.