#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 */
scalar_t__ is_prime(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int prime_count = 0;
  int total_count = 1;
  int n = 1;
  int step = 2;
  int side_len = 1;
  double percent = 0.0;
  do {
    for (int i = 0; i < 4; i++) {
      n += step;
      if (is_prime(n))
        prime_count++;
    }
    total_count += 4;
    step += 2;
    side_len += 2;
    percent = (double)prime_count / (double)total_count;
  } while (percent >= 0.1);
  printf("%i", side_len);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x2,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    11a9 <main+0x89>
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     1196 <main+0x76>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119b <main+0x7b>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1168 <main+0x48>
mov    -0x18(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe1c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    1161 <main+0x41>
mov    -0x24(%rbp),%esi
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x2,%r14d
mov    $0x1,%ebp
xor    %ebx,%ebx
mov    $0x5,%r15d
nopw   0x0(%rax,%rax,1)
add    %r14d,%ebp
mov    %ebp,%edi
call   1040 <is_prime@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebx
add    %r14d,%ebp
mov    %ebp,%edi
call   1040 <is_prime@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebx
add    %r14d,%ebp
mov    %ebp,%edi
call   1040 <is_prime@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebx
add    %r14d,%ebp
mov    %ebp,%edi
call   1040 <is_prime@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebx
add    $0x2,%r14d
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r15d,%xmm1
divsd  %xmm1,%xmm0
add    $0x4,%r15d
ucomisd 0xe59(%rip),%xmm0
jae    1140 <main+0x20>
add    $0xffffffff,%r14d
lea    0xe54(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\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
%11 = alloca double
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 1, i32* %7
store i32 1, i32* %8
store i32 2, i32* %9
store i32 1, i32* %10
store double 0.000000e+00, double* %11
br label %13
13: ; preds = %43, %2
store i32 0, i32* %12
br label %14
14: ; preds = %28, %13
%15 = load i32, i32* %12
%16 = icmp slt i32 %15, 4
br i1 %16, label %17, label %31
17: ; preds = %14
%18 = load i32, i32* %9
%19 = load i32, i32* %8
%20 = add nsw i32 %19, %18
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = call i64 @is_prime(i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %17
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %27
27: ; preds = %24, %17
br label %28
28: ; preds = %27
%29 = load i32, i32* %12
%30 = add nsw i32 %29, 1
store i32 %30, i32* %12
br label %14
31: ; preds = %14
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 4
store i32 %33, i32* %7
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 2
store i32 %35, i32* %9
%36 = load i32, i32* %10
%37 = add nsw i32 %36, 2
store i32 %37, i32* %10
%38 = load i32, i32* %6
%39 = sitofp i32 %38 to double
%40 = load i32, i32* %7
%41 = sitofp i32 %40 to double
%42 = fdiv double %39, %41
store double %42, double* %11
br label %43
43: ; preds = %31
%44 = load double, double* %11
%45 = fcmp oge double %44, 1.000000e-01
br i1 %45, label %13, label %46
46: ; preds = %43
%47 = load i32, i32* %10
%48 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %47)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i32 [ 0, %2 ], [ %28, %3 ]
%5 = phi i32 [ 1, %2 ], [ %29, %3 ]
%6 = phi i32 [ 1, %2 ], [ %24, %3 ]
%7 = phi i32 [ 2, %2 ], [ %30, %3 ]
%8 = phi i32 [ 1, %2 ], [ %31, %3 ]
%9 = add nsw i32 %6, %7
%10 = tail call i64 @is_prime(i32 %9)
%11 = icmp ne i64 %10, 0
%12 = zext i1 %11 to i32
%13 = add nsw i32 %4, %12
%14 = add nsw i32 %9, %7
%15 = tail call i64 @is_prime(i32 %14)
%16 = icmp ne i64 %15, 0
%17 = zext i1 %16 to i32
%18 = add nsw i32 %13, %17
%19 = add nsw i32 %14, %7
%20 = tail call i64 @is_prime(i32 %19)
%21 = icmp ne i64 %20, 0
%22 = zext i1 %21 to i32
%23 = add nsw i32 %18, %22
%24 = add nsw i32 %19, %7
%25 = tail call i64 @is_prime(i32 %24)
%26 = icmp ne i64 %25, 0
%27 = zext i1 %26 to i32
%28 = add nsw i32 %23, %27
%29 = add nuw nsw i32 %5, 4
%30 = add nuw nsw i32 %7, 2
%31 = add nuw nsw i32 %8, 2
%32 = sitofp i32 %28 to double
%33 = sitofp i32 %29 to double
%34 = fdiv double %32, %33
%35 = fcmp ult double %34, 1.000000e-01
br i1 %35, label %36, label %3
36: ; preds = %3
%37 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %31)
ret i32 0
}