#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int i, n, m, t, sum, count = 0;
  printf("Please input two integers:");
  scanf("%d %d", &n, &m);
  printf("The result is:\n");
  for (i = 1; i <= n; i++) {
    sum = 0;
    t = i;
    sum = (t % 10) * (t % 10);
    while (t /= 10)
      sum += (t % 10) * (t % 10);
    if (i / m == sum) {
      count++;
      if (count % 5)
        printf("%d\t", i);
      else
        printf("%d\n", i);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1040 <scanf@plt>
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1257 <main+0x137>
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x20(%rbp),%edx
imul   %eax,%edx
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11eb <main+0xcb>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x24(%rbp),%eax
imul   %edx,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11aa <main+0x8a>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    -0x18(%rbp),%eax
jne    1244 <main+0x124>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     122e <main+0x10e>
mov    -0x8(%rbp),%esi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123f <main+0x11f>
mov    -0x8(%rbp),%esi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1244 <main+0x124>
jmp    1249 <main+0x129>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116d <main+0x4d>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecb(%rip),%rdi
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
call   1050 <scanf@plt>
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,(%rsp)
jle    1257 <main+0x127>
mov    $0x1,%r15d
mov    $0xcccccccd,%r14d
lea    0xe9b(%rip),%r12
xor    %r13d,%r13d
jmp    11a1 <main+0x71>
nopl   0x0(%rax,%rax,1)
lea    0x1(%r15),%eax
cmp    (%rsp),%r15d
mov    %eax,%r15d
jge    1257 <main+0x127>
mov    %r15d,%eax
imul   %r14,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %r15d,%ecx
sub    %eax,%ecx
imul   %ecx,%ecx
cmp    $0xa,%r15d
jb     1215 <main+0xe5>
mov    %r15d,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cltq
imul   $0x66666667,%rax,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
lea    (%rdx,%rsi,1),%eax
movslq %eax,%rdi
imul   $0x66666667,%rdi,%rbp
mov    %rbp,%rbx
shr    $0x3f,%rbx
sar    $0x22,%rbp
add    %ebx,%ebp
add    %ebp,%ebp
lea    0x0(%rbp,%rbp,4),%ebp
sub    %ebp,%edi
imul   %edi,%edi
add    %edi,%ecx
add    %esi,%edx
add    $0x9,%edx
cmp    $0x12,%edx
ja     11d0 <main+0xa0>
mov    %r15d,%eax
cltd
idivl  0x4(%rsp)
cmp    %ecx,%eax
jne    1190 <main+0x60>
add    $0x1,%r13d
imul   $0xcccccccd,%r13d,%eax
add    $0x19999999,%eax
cmp    $0x33333333,%eax
mov    %r12,%rdi
lea    0xde1(%rip),%rax
cmovb  %rax,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1190 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [27 x i8] c"Please input two integers:\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.3 = [4 x i8] c"%d\09\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@str = [15 x i8] c"The result is:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 1
br i1 %9, label %41, label %10
10: ; preds = %0, %36
%11 = phi i32 [ %37, %36 ], [ 0, %0 ]
%12 = phi i32 [ %38, %36 ], [ 1, %0 ]
%13 = urem i32 %12, 10
%14 = mul nuw nsw i32 %13, %13
%15 = icmp ult i32 %12, 10
br i1 %15, label %25, label %16
16: ; preds = %10, %16
%17 = phi i32 [ %19, %16 ], [ %12, %10 ]
%18 = phi i32 [ %22, %16 ], [ %14, %10 ]
%19 = sdiv i32 %17, 10
%20 = srem i32 %19, 10
%21 = mul nsw i32 %20, %20
%22 = add nuw nsw i32 %21, %18
%23 = add nsw i32 %19, 9
%24 = icmp ult i32 %23, 19
br i1 %24, label %25, label %16
25: ; preds = %16, %10
%26 = phi i32 [ %14, %10 ], [ %22, %16 ]
%27 = load i32, i32* %2
%28 = sdiv i32 %12, %27
%29 = icmp eq i32 %28, %26
br i1 %29, label %30, label %36
30: ; preds = %25
%31 = add nsw i32 %11, 1
%32 = srem i32 %31, 5
%33 = icmp eq i32 %32, 0
%34 = select i1 %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %34, i32 %12)
br label %36
36: ; preds = %30, %25
%37 = phi i32 [ %11, %25 ], [ %31, %30 ]
%38 = add nuw nsw i32 %12, 1
%39 = load i32, i32* %1
%40 = icmp slt i32 %12, %39
br i1 %40, label %10, label %41
41: ; preds = %36, %0
ret i32 0
}