Emitting LLVM IR for control flow

I’m following the excellent Kaleidoscope tutorial to learn how to build an interpreter using LLVM. Apologize if this list is not the best place to post beginner’s questions. In Kaleidoscope 2.7 when I run

def binary : 1 (x y) y;

def testfor (x)
(for c = 1, c<2 in
x = x +1 ) :


unexpectadly get 3.000000 instead of 2.000000. This happens, I believe, because the instruction

%faddtmp = fadd double %x1.0, 1.000000e+000 ; <double> [#uses=2]
is being generated before
%ltcmptmp = fcmp ult double %c.0, 2.000000e+000 ; [#uses=1]
br i1 %ltcmptmp, label %loop, label %afterloop

and therefore the loop body is emited first and only afterwards we determine whether the loop should exit. I was wondering if this is the intended behaviour, since the fibi(x) example in chapter 7 uses this extra loop to return correct values for fibonacci numbers, or perhaps a known bug in Kaleidoscope.

Any advice would be much apreciated