#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "usage: %s <N>\n", argv[0]);
    return 1;
  }
  int N = atoi(argv[1]);
  if (N <= 0)
    return 1;
  int count = 0;
  for (int inner_size = 3;; inner_size++) {
    int outer_size = 0;
    int squares_used = 0;
    for (outer_size = inner_size;; outer_size += 2) {
      squares_used += (outer_size - 1) * 4;
      if (squares_used > N)
        break;
      count++;
    }
    if (inner_size == outer_size)
      break;
  }
  printf("%d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1178 <main+0x48>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe99(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1231 <main+0x101>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     119e <main+0x6e>
movl   $0x1,-0x4(%rbp)
jmp    1231 <main+0x101>
movl   $0x0,-0x18(%rbp)
movl   $0x3,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
shl    $0x2,%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11e0 <main+0xb0>
jmp    11f7 <main+0xc7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
jmp    11c0 <main+0x90>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    1208 <main+0xd8>
jmp    121b <main+0xeb>
jmp    120d <main+0xdd>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ac <main+0x7c>
mov    -0x18(%rbp),%esi
lea    0xdea(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jne    11a1 <main+0x71>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
test   %eax,%eax
jle    11b9 <main+0x89>
mov    $0x3,%r9d
xor    %esi,%esi
mov    $0x10,%r8d
jmp    1173 <main+0x43>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r9d,%edi
lea    0x1(%r9),%ecx
add    $0x4,%r8d
cmp    %edi,%r9d
mov    %ecx,%r9d
je     11c0 <main+0x90>
lea    -0x4(,%r9,4),%ecx
ff
cmp    %eax,%ecx
jg     1160 <main+0x30>
mov    %r8d,%edx
mov    %r9d,%edi
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%esi
add    $0x2,%edi
add    %edx,%ecx
add    $0x8,%edx
cmp    %eax,%ecx
jle    1190 <main+0x60>
jmp    1163 <main+0x33>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe4c(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
pop    %rcx
ret
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"usage: %s <N>\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 1, i32* %3
br label %58
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = icmp sle i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %19
store i32 1, i32* %3
br label %58
27: ; preds = %19
store i32 0, i32* %7
store i32 3, i32* %8
br label %28
28: ; preds = %52, %27
store i32 0, i32* %9
store i32 0, i32* %10
%29 = load i32, i32* %8
store i32 %29, i32* %9
br label %30
30: ; preds = %43, %28
%31 = load i32, i32* %9
%32 = sub nsw i32 %31, 1
%33 = mul nsw i32 %32, 4
%34 = load i32, i32* %10
%35 = add nsw i32 %34, %33
store i32 %35, i32* %10
%36 = load i32, i32* %10
%37 = load i32, i32* %6
%38 = icmp sgt i32 %36, %37
br i1 %38, label %39, label %40
39: ; preds = %30
br label %46
40: ; preds = %30
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %43
43: ; preds = %40
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 2
store i32 %45, i32* %9
br label %30
46: ; preds = %39
%47 = load i32, i32* %8
%48 = load i32, i32* %9
%49 = icmp eq i32 %47, %48
br i1 %49, label %50, label %51
50: ; preds = %46
br label %55
51: ; preds = %46
br label %52
52: ; preds = %51
%53 = load i32, i32* %8
%54 = add nsw i32 %53, 1
store i32 %54, i32* %8
br label %28
55: ; preds = %50
%56 = load i32, i32* %7
%57 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %56)
store i32 0, i32* %3
br label %58
58: ; preds = %55, %26, %13
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"usage: %s <N>\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %36
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = icmp slt i32 %11, 1
br i1 %12, label %36, label %13
13: ; preds = %8, %29
%14 = phi i32 [ %30, %29 ], [ 0, %8 ]
%15 = phi i32 [ %33, %29 ], [ 3, %8 ]
%16 = shl i32 %15, 2
%17 = add i32 %16, -4
%18 = icmp sgt i32 %17, %11
br i1 %18, label %29, label %19
19: ; preds = %13, %19
%20 = phi i32 [ %27, %19 ], [ %17, %13 ]
%21 = phi i32 [ %24, %19 ], [ %15, %13 ]
%22 = phi i32 [ %23, %19 ], [ %14, %13 ]
%23 = add nsw i32 %22, 1
%24 = add nuw nsw i32 %21, 2
%25 = shl i32 %24, 2
%26 = add i32 %25, -4
%27 = add nsw i32 %26, %20
%28 = icmp sgt i32 %27, %11
br i1 %28, label %29, label %19
29: ; preds = %19, %13
%30 = phi i32 [ %14, %13 ], [ %23, %19 ]
%31 = phi i32 [ %15, %13 ], [ %24, %19 ]
%32 = icmp eq i32 %15, %31
%33 = add nuw nsw i32 %15, 1
br i1 %32, label %34, label %13
34: ; preds = %29
%35 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %36
36: ; preds = %34, %8, %4
%37 = phi i32 [ 1, %4 ], [ 0, %34 ], [ 1, %8 ]
ret i32 %37
}