#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_circular(int);
scalar_t__ is_prime(int);
int pow(int, int);
int /*<<< orphan*/ printf(char *, float);
float timeit();
int main(int argc, char *argv[]) {
  float start = timeit();
  int circular_primes = 0;
  for (int i = 0; i < pow(10, 6) + 1; i++) {
    if (is_prime(i) && is_circular(i))
      circular_primes++;
  }
  float stop = timeit();
  printf("Answer: %d\n", circular_primes);
  printf("Time: %f\n", stop - start);
  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)
mov    $0x0,%al
call   1070 <timeit@plt>
movss  %xmm0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    $0xa,%edi
mov    $0x6,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11e5 <main+0x95>
mov    -0x1c(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     11d2 <main+0x82>
mov    -0x1c(%rbp),%edi
call   1050 <is_circular@plt>
cmp    $0x0,%rax
je     11d2 <main+0x82>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11d7 <main+0x87>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1180 <main+0x30>
mov    $0x0,%al
call   1070 <timeit@plt>
movss  %xmm0,-0x20(%rbp)
cvtsi2ssl -0x18(%rbp),%xmm0
lea    0xe03(%rip),%rdi
call   1030 <printf@plt>
movss  -0x20(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
lea    0xdf9(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
xor    %eax,%eax
call   1070 <timeit@plt>
movss  %xmm0,0x4(%rsp)
mov    $0xa,%edi
mov    $0x6,%esi
call   1060 <pow@plt>
test   %eax,%eax
js     11b2 <main+0x62>
xor    %ebp,%ebp
mov    $0xffffffff,%ebx
jmp    1193 <main+0x43>
xchg   %ax,%ax
mov    $0xa,%edi
mov    $0x6,%esi
call   1060 <pow@plt>
cmp    %eax,%ebx
jge    11b2 <main+0x62>
add    $0x1,%ebx
mov    %ebx,%edi
call   1040 <is_prime@plt>
test   %rax,%rax
je     1180 <main+0x30>
mov    %ebx,%edi
call   1050 <is_circular@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
jmp    1180 <main+0x30>
xor    %eax,%eax
call   1070 <timeit@plt>
movss  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
movss  (%rsp),%xmm0
subss  0x4(%rsp),%xmm0
lea    0xe29(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Answer: %d\0A\00"
@.str.1 = [10 x i8] c"Time: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call float (...) @timeit()
store float %10, float* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %11
11: ; preds = %28, %2
%12 = load i32, i32* %8
%13 = call i32 @pow(i32 10, i32 6)
%14 = add nsw i32 %13, 1
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %31
16: ; preds = %11
%17 = load i32, i32* %8
%18 = call i64 @is_prime(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load i32, i32* %8
%22 = call i64 @is_circular(i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %27
27: ; preds = %24, %20, %16
br label %28
28: ; preds = %27
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %11
31: ; preds = %11
%32 = call float (...) @timeit()
store float %32, float* %9
%33 = load i32, i32* %7
%34 = sitofp i32 %33 to float
%35 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float %34)
%36 = load float, float* %9
%37 = load float, float* %6
%38 = fsub float %36, %37
%39 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), float %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Answer: %d\0A\00"
@.str.1 = [10 x i8] c"Time: %f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call float (...) @timeit()
%4 = tail call i32 @pow(i32 10, i32 6)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %23, %2
%7 = phi i32 [ 0, %2 ], [ %24, %23 ]
%8 = tail call float (...) @timeit()
%9 = sitofp i32 %7 to float
%10 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float %9)
%11 = fsub float %8, %3
%12 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), float %11)
ret i32 0
13: ; preds = %2, %23
%14 = phi i32 [ %24, %23 ], [ 0, %2 ]
%15 = phi i32 [ %25, %23 ], [ 0, %2 ]
%16 = tail call i64 @is_prime(i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %13
%19 = tail call i64 @is_circular(i32 %15)
%20 = icmp ne i64 %19, 0
%21 = zext i1 %20 to i32
%22 = add nsw i32 %14, %21
br label %23
23: ; preds = %18, %13
%24 = phi i32 [ %14, %13 ], [ %22, %18 ]
%25 = add nuw nsw i32 %15, 1
%26 = tail call i32 @pow(i32 10, i32 6)
%27 = icmp slt i32 %15, %26
br i1 %27, label %13, label %6
}