int localscopes(x)
int x;
{
  int localval;
  int retval;
  int i;
  localval = 0;
  useit(localval);
  {
    int localval = x + 4 + sum_upto(3);
    int localval1 = x + 5 + sum_upto(3);
    useit(localval);
    useit(localval1);
    marker2();
    {
      int localval = localval1 + 3 + sum_upto(3);
      int localval2 = localval1 + sum_upto(1);
      useit(localval);
      useit(localval2);
      marker3();
      {
        int localval = localval2 + 3 + sum_upto(5);
        int localval3 = localval2 + sum_upto(1);
        useit(localval);
        useit(localval3);
        marker4();
        retval = x + localval1 + localval2 + localval3;
      }
    }
  }
  return retval;
}


x86 assembly (clang, -O0):
<localscopes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x0,%al
call   1060 <useit@plt>
mov    -0x4(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x40(%rbp)
mov    $0x3,%edi
mov    $0x0,%al
call   1050 <sum_upto@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x3c(%rbp)
mov    $0x3,%edi
mov    $0x0,%al
call   1050 <sum_upto@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x0,%al
call   1060 <useit@plt>
mov    -0x18(%rbp),%edi
mov    $0x0,%al
call   1060 <useit@plt>
mov    $0x0,%al
call   1030 <marker2@plt>
mov    -0x18(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x38(%rbp)
mov    $0x3,%edi
mov    $0x0,%al
call   1050 <sum_upto@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    $0x1,%edi
mov    $0x0,%al
call   1050 <sum_upto@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x0,%al
call   1060 <useit@plt>
mov    -0x20(%rbp),%edi
mov    $0x0,%al
call   1060 <useit@plt>
mov    $0x0,%al
call   1070 <marker3@plt>
mov    -0x20(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x30(%rbp)
mov    $0x5,%edi
mov    $0x0,%al
call   1050 <sum_upto@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    $0x1,%edi
mov    $0x0,%al
call   1050 <sum_upto@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x0,%al
call   1060 <useit@plt>
mov    -0x28(%rbp),%edi
mov    $0x0,%al
call   1060 <useit@plt>
mov    $0x0,%al
call   1040 <marker4@plt>
mov    -0x4(%rbp),%eax
add    -0x18(%rbp),%eax
add    -0x20(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<localscopes>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
xor    %edi,%edi
xor    %eax,%eax
call   1060 <useit@plt>
mov    $0x3,%edi
xor    %eax,%eax
call   1050 <sum_upto@plt>
lea    (%r14,%rax,1),%ebx
add    $0x4,%ebx
mov    $0x3,%edi
xor    %eax,%eax
call   1050 <sum_upto@plt>
mov    %r14d,%r12d
add    %eax,%r12d
lea    (%r14,%rax,1),%ebp
add    $0x5,%ebp
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <useit@plt>
mov    %ebp,%edi
xor    %eax,%eax
call   1060 <useit@plt>
xor    %eax,%eax
call   1030 <marker2@plt>
mov    $0x3,%edi
xor    %eax,%eax
call   1050 <sum_upto@plt>
lea    (%rax,%r12,1),%ebp
add    $0x8,%ebp
mov    $0x1,%edi
xor    %eax,%eax
call   1050 <sum_upto@plt>
lea    (%rax,%r12,1),%ebx
add    $0x5,%ebx
mov    %ebp,%edi
xor    %eax,%eax
call   1060 <useit@plt>
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <useit@plt>
xor    %eax,%eax
call   1070 <marker3@plt>
mov    $0x5,%edi
xor    %eax,%eax
call   1050 <sum_upto@plt>
lea    (%rax,%rbx,1),%r15d
add    $0x3,%r15d
mov    $0x1,%edi
xor    %eax,%eax
call   1050 <sum_upto@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <useit@plt>
mov    %ebp,%edi
xor    %eax,%eax
call   1060 <useit@plt>
xor    %eax,%eax
call   1040 <marker4@plt>
lea    (%r14,%r12,1),%eax
add    $0x5,%eax
add    %ebx,%eax
add    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @localscopes(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%12 = load i32, i32* %3
%13 = call i32 (i32, ...) bitcast (i32 (...)* @useit to i32 (i32, ...)*)(i32 %12)
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 4
%16 = call i32 (i32, ...) bitcast (i32 (...)* @sum_upto to i32 (i32, ...)*)(i32 3)
%17 = add nsw i32 %15, %16
store i32 %17, i32* %6
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 5
%20 = call i32 (i32, ...) bitcast (i32 (...)* @sum_upto to i32 (i32, ...)*)(i32 3)
%21 = add nsw i32 %19, %20
store i32 %21, i32* %7
%22 = load i32, i32* %6
%23 = call i32 (i32, ...) bitcast (i32 (...)* @useit to i32 (i32, ...)*)(i32 %22)
%24 = load i32, i32* %7
%25 = call i32 (i32, ...) bitcast (i32 (...)* @useit to i32 (i32, ...)*)(i32 %24)
%26 = call i32 (...) @marker2()
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 3
%29 = call i32 (i32, ...) bitcast (i32 (...)* @sum_upto to i32 (i32, ...)*)(i32 3)
%30 = add nsw i32 %28, %29
store i32 %30, i32* %8
%31 = load i32, i32* %7
%32 = call i32 (i32, ...) bitcast (i32 (...)* @sum_upto to i32 (i32, ...)*)(i32 1)
%33 = add nsw i32 %31, %32
store i32 %33, i32* %9
%34 = load i32, i32* %8
%35 = call i32 (i32, ...) bitcast (i32 (...)* @useit to i32 (i32, ...)*)(i32 %34)
%36 = load i32, i32* %9
%37 = call i32 (i32, ...) bitcast (i32 (...)* @useit to i32 (i32, ...)*)(i32 %36)
%38 = call i32 (...) @marker3()
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 3
%41 = call i32 (i32, ...) bitcast (i32 (...)* @sum_upto to i32 (i32, ...)*)(i32 5)
%42 = add nsw i32 %40, %41
store i32 %42, i32* %10
%43 = load i32, i32* %9
%44 = call i32 (i32, ...) bitcast (i32 (...)* @sum_upto to i32 (i32, ...)*)(i32 1)
%45 = add nsw i32 %43, %44
store i32 %45, i32* %11
%46 = load i32, i32* %10
%47 = call i32 (i32, ...) bitcast (i32 (...)* @useit to i32 (i32, ...)*)(i32 %46)
%48 = load i32, i32* %11
%49 = call i32 (i32, ...) bitcast (i32 (...)* @useit to i32 (i32, ...)*)(i32 %48)
%50 = call i32 (...) @marker4()
%51 = load i32, i32* %2
%52 = load i32, i32* %7
%53 = add nsw i32 %51, %52
%54 = load i32, i32* %9
%55 = add nsw i32 %53, %54
%56 = load i32, i32* %11
%57 = add nsw i32 %55, %56
store i32 %57, i32* %4
%58 = load i32, i32* %4
ret i32 %58
}

LLVM IR (-O2):
define i32 @localscopes(i32 %0) {
%2 = tail call i32 (i32, ...) bitcast (i32 (...)* @useit to i32 (i32, ...)*)(i32 0)
%3 = add nsw i32 %0, 4
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @sum_upto to i32 (i32, ...)*)(i32 3)
%5 = add nsw i32 %3, %4
%6 = add nsw i32 %0, 5
%7 = tail call i32 (i32, ...) bitcast (i32 (...)* @sum_upto to i32 (i32, ...)*)(i32 3)
%8 = add nsw i32 %6, %7
%9 = tail call i32 (i32, ...) bitcast (i32 (...)* @useit to i32 (i32, ...)*)(i32 %5)
%10 = tail call i32 (i32, ...) bitcast (i32 (...)* @useit to i32 (i32, ...)*)(i32 %8)
%11 = tail call i32 (...) @marker2()
%12 = add nsw i32 %8, 3
%13 = tail call i32 (i32, ...) bitcast (i32 (...)* @sum_upto to i32 (i32, ...)*)(i32 3)
%14 = add nsw i32 %12, %13
%15 = tail call i32 (i32, ...) bitcast (i32 (...)* @sum_upto to i32 (i32, ...)*)(i32 1)
%16 = add nsw i32 %15, %8
%17 = tail call i32 (i32, ...) bitcast (i32 (...)* @useit to i32 (i32, ...)*)(i32 %14)
%18 = tail call i32 (i32, ...) bitcast (i32 (...)* @useit to i32 (i32, ...)*)(i32 %16)
%19 = tail call i32 (...) @marker3()
%20 = add nsw i32 %16, 3
%21 = tail call i32 (i32, ...) bitcast (i32 (...)* @sum_upto to i32 (i32, ...)*)(i32 5)
%22 = add nsw i32 %20, %21
%23 = tail call i32 (i32, ...) bitcast (i32 (...)* @sum_upto to i32 (i32, ...)*)(i32 1)
%24 = add nsw i32 %23, %16
%25 = tail call i32 (i32, ...) bitcast (i32 (...)* @useit to i32 (i32, ...)*)(i32 %22)
%26 = tail call i32 (i32, ...) bitcast (i32 (...)* @useit to i32 (i32, ...)*)(i32 %24)
%27 = tail call i32 (...) @marker4()
%28 = add nsw i32 %8, %0
%29 = add nsw i32 %28, %16
%30 = add nsw i32 %29, %24
ret i32 %30
}