#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 pow(int, int const);
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  const int N = 2;
  int base = 10;
  int c1 = 0;
  int c2 = 0;
  int k;
  for (k = 1; k < pow(base, N); k++) {
    c1++;
    if (k % (base - 1) == (k * k) % (base - 1)) {
      c2++;
      printf("%d ", k);
    }
  }
  printf("\nTring %d numbers instead of %d numbers saves %f%%\n", c2, c1,
         100.0 - 100.0 * c2 / c1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11d4 <main+0xb4>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x20(%rbp),%edx
cmp    %eax,%edx
jne    11c1 <main+0xa1>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c6 <main+0xa6>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1152 <main+0x32>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe19(%rip),%xmm1
mulsd  %xmm0,%xmm1
cvtsi2sdl -0x10(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe04(%rip),%xmm0
subsd  %xmm1,%xmm0
lea    0xe05(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xa,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
xor    %ebx,%ebx
mov    $0x0,%r15d
cmp    $0x2,%eax
jl     11c0 <main+0xa0>
mov    $0x1,%ebp
lea    0xeb9(%rip),%r14
xor    %r15d,%r15d
xor    %ebx,%ebx
jmp    1179 <main+0x59>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    $0xa,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
lea    0x1(%rbx),%ecx
cmp    %eax,%ecx
jge    11c0 <main+0xa0>
mov    %ebp,%eax
imul   $0x38e38e39,%rax,%rax
shr    $0x21,%rax
lea    (%rax,%rax,8),%eax
mov    %ebx,%ecx
add    $0x1,%ebx
neg    %eax
add    %ecx,%eax
add    $0x1,%eax
mov    %ebx,%ecx
imul   %ecx,%ecx
imul   $0x38e38e39,%rcx,%rdx
shr    $0x21,%rdx
lea    (%rdx,%rdx,8),%edx
sub    %edx,%ecx
cmp    %ecx,%eax
jne    1160 <main+0x40>
add    $0x1,%r15d
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1160 <main+0x40>
cvtsi2sd %r15d,%xmm1
movsd  0xe33(%rip),%xmm0
mulsd  %xmm0,%xmm1
cvtsi2sd %ebx,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
lea    0xe28(%rip),%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [52 x i8] c"\0ATring %d numbers instead of %d numbers saves %f%%\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %2
store i32 10, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 1, i32* %6
br label %7
7: ; preds = %32, %0
%8 = load i32, i32* %6
%9 = load i32, i32* %3
%10 = call i32 @pow(i32 %9, i32 2)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %35
12: ; preds = %7
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 1
store i32 %14, i32* %4
%15 = load i32, i32* %6
%16 = load i32, i32* %3
%17 = sub nsw i32 %16, 1
%18 = srem i32 %15, %17
%19 = load i32, i32* %6
%20 = load i32, i32* %6
%21 = mul nsw i32 %19, %20
%22 = load i32, i32* %3
%23 = sub nsw i32 %22, 1
%24 = srem i32 %21, %23
%25 = icmp eq i32 %18, %24
br i1 %25, label %26, label %31
26: ; preds = %12
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
%29 = load i32, i32* %6
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %26, %12
br label %32
32: ; preds = %31
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %7
35: ; preds = %7
%36 = load i32, i32* %5
%37 = load i32, i32* %4
%38 = load i32, i32* %5
%39 = sitofp i32 %38 to double
%40 = fmul double 1.000000e+02, %39
%41 = load i32, i32* %4
%42 = sitofp i32 %41 to double
%43 = fdiv double %40, %42
%44 = fsub double 1.000000e+02, %43
%45 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i32 %36, i32 %37, double %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
@.str.1 = [52 x i8] c"\0ATring %d numbers instead of %d numbers saves %f%%\0A\00"
define i32 @main() {
%1 = tail call i32 @pow(i32 10, i32 2)
%2 = icmp sgt i32 %1, 1
br i1 %2, label %3, label %20
3: ; preds = %0, %15
%4 = phi i32 [ %17, %15 ], [ 1, %0 ]
%5 = phi i32 [ %16, %15 ], [ 0, %0 ]
%6 = phi i32 [ %7, %15 ], [ 0, %0 ]
%7 = add nuw nsw i32 %6, 1
%8 = urem i32 %4, 9
%9 = mul nsw i32 %4, %4
%10 = urem i32 %9, 9
%11 = icmp eq i32 %8, %10
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = add nsw i32 %5, 1
%14 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
br label %15
15: ; preds = %3, %12
%16 = phi i32 [ %13, %12 ], [ %5, %3 ]
%17 = add nuw nsw i32 %4, 1
%18 = tail call i32 @pow(i32 10, i32 2)
%19 = icmp slt i32 %17, %18
br i1 %19, label %3, label %20
20: ; preds = %15, %0
%21 = phi i32 [ 0, %0 ], [ %7, %15 ]
%22 = phi i32 [ 0, %0 ], [ %16, %15 ]
%23 = sitofp i32 %22 to double
%24 = fmul double %23, 1.000000e+02
%25 = sitofp i32 %21 to double
%26 = fdiv double %24, %25
%27 = fsub double 1.000000e+02, %26
%28 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %21, double %27)
ret i32 0
}