#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 reverse(int);
int main() {
  const int limit1 = 200;
  int row = 0;
  int num = 0;
  int n;
  for (n = 1; n < limit1; n++) {
    bool flag = true;
    int revNum = reverse(n);
    int m;
    for (m = 1; m < n / 2; m++) {
      int revDiv = reverse(m);
      if (n % m == 0) {
        if (revNum % revDiv == 0) {
          flag = true;
        } else {
          flag = false;
          break;
        }
      }
    }
    if (flag) {
      num++;
      row++;
      printf("%4d ", n);
      if (row % 10 == 0) {
        printf("\n");
      }
    }
  }
  printf("\n\nFound %d special divisors N that reverse(D) divides reverse(N) "
         "for all divisors D of N, where N < 200\n",
         num);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xc8,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0xc8,-0x14(%rbp)
jge    1251 <main+0x131>
movl   $0x1,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <reverse@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11ea <main+0xca>
mov    -0x20(%rbp),%edi
call   1030 <reverse@plt>
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
cltd
idivl  -0x20(%rbp)
cmp    $0x0,%edx
jne    11d7 <main+0xb7>
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x24(%rbp)
cmp    $0x0,%edx
jne    11c6 <main+0xa6>
movl   $0x1,-0x18(%rbp)
jmp    11d2 <main+0xb2>
movl   $0x0,-0x18(%rbp)
jmp    11ea <main+0xca>
jmp    11d7 <main+0xb7>
jmp    11dc <main+0xbc>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1171 <main+0x51>
cmpl   $0x0,-0x18(%rbp)
je     123e <main+0x11e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%esi
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1239 <main+0x119>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123e <main+0x11e>
jmp    1243 <main+0x123>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <main+0x2b>
mov    -0x10(%rbp),%esi
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
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
mov    $0x1,%r13d
xor    %r14d,%r14d
xor    %r15d,%r15d
jmp    118b <main+0x5b>
nopl   0x0(%rax)
add    $0x1,%r15d
add    $0x1,%r14d
lea    0xea1(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
imul   $0xcccccccd,%r14d,%eax
add    $0x19999998,%eax
ror    %eax
cmp    $0x19999998,%eax
jbe    11f0 <main+0xc0>
add    $0x1,%r13d
cmp    $0xc8,%r13d
je     11fc <main+0xcc>
mov    %r13d,%ebx
shr    %ebx
cmp    $0x3,%ebx
mov    $0x2,%eax
cmovb  %eax,%ebx
mov    %r13d,%edi
call   1030 <reverse@plt>
cmp    $0x4,%r13d
jb     1150 <main+0x20>
mov    %eax,%r12d
mov    $0x1,%ebp
jmp    11c7 <main+0x97>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebp
cmp    %ebp,%ebx
je     1150 <main+0x20>
mov    %ebp,%edi
call   1030 <reverse@plt>
mov    %eax,%ecx
mov    %r13d,%eax
xor    %edx,%edx
div    %ebp
test   %edx,%edx
jne    11c0 <main+0x90>
mov    %r12d,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     11c0 <main+0x90>
jmp    117e <main+0x4e>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    117e <main+0x4e>
lea    0xe02(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%4d \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [105 x i8] c"\0A\0AFound %d special divisors N that reverse(D) divides reverse(N) for all divisors D of N, where N < 200\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
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 200, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 1, i32* %5
br label %10
10: ; preds = %57, %0
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 200
br i1 %12, label %13, label %60
13: ; preds = %10
store i32 1, i32* %6
%14 = load i32, i32* %5
%15 = call i32 @reverse(i32 %14)
store i32 %15, i32* %7
store i32 1, i32* %8
br label %16
16: ; preds = %37, %13
%17 = load i32, i32* %8
%18 = load i32, i32* %5
%19 = sdiv i32 %18, 2
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %40
21: ; preds = %16
%22 = load i32, i32* %8
%23 = call i32 @reverse(i32 %22)
store i32 %23, i32* %9
%24 = load i32, i32* %5
%25 = load i32, i32* %8
%26 = srem i32 %24, %25
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %36
28: ; preds = %21
%29 = load i32, i32* %7
%30 = load i32, i32* %9
%31 = srem i32 %29, %30
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %28
store i32 1, i32* %6
br label %35
34: ; preds = %28
store i32 0, i32* %6
br label %40
35: ; preds = %33
br label %36
36: ; preds = %35, %21
br label %37
37: ; preds = %36
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
br label %16
40: ; preds = %34, %16
%41 = load i32, i32* %6
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %56
43: ; preds = %40
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 1
store i32 %45, i32* %4
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
%48 = load i32, i32* %5
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %3
%51 = srem i32 %50, 10
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %43
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %55
55: ; preds = %53, %43
br label %56
56: ; preds = %55, %40
br label %57
57: ; preds = %56
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
store i32 %59, i32* %5
br label %10
60: ; preds = %10
%61 = load i32, i32* %4
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([105 x i8], [105 x i8]* @.str.2, i64 0, i64 0), i32 %61)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%4d \00"
@.str.2 = [105 x i8] c"\0A\0AFound %d special divisors N that reverse(D) divides reverse(N) for all divisors D of N, where N < 200\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %28
%2 = phi i32 [ 0, %0 ], [ %30, %28 ]
%3 = phi i32 [ 1, %0 ], [ %31, %28 ]
%4 = phi i32 [ 0, %0 ], [ %29, %28 ]
%5 = lshr i32 %3, 1
%6 = call i32 @llvm.umax.i32(i32 %5, i32 2)
%7 = tail call i32 @reverse(i32 %3)
%8 = icmp ugt i32 %3, 3
br i1 %8, label %9, label %20
9: ; preds = %1, %17
%10 = phi i32 [ %18, %17 ], [ 1, %1 ]
%11 = tail call i32 @reverse(i32 %10)
%12 = urem i32 %3, %10
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = srem i32 %7, %11
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %28
17: ; preds = %9, %14
%18 = add nuw nsw i32 %10, 1
%19 = icmp eq i32 %18, %6
br i1 %19, label %20, label %9
20: ; preds = %17, %1
%21 = add nsw i32 %4, 1
%22 = add nsw i32 %2, 1
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %3)
%24 = srem i32 %22, 10
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = tail call i32 @putchar(i32 10)
br label %28
28: ; preds = %14, %20, %26
%29 = phi i32 [ %21, %26 ], [ %21, %20 ], [ %4, %14 ]
%30 = phi i32 [ %22, %26 ], [ %22, %20 ], [ %2, %14 ]
%31 = add nuw nsw i32 %3, 1
%32 = icmp eq i32 %31, 200
br i1 %32, label %33, label %1
33: ; preds = %28
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([105 x i8], [105 x i8]* @.str.2, i64 0, i64 0), i32 %29)
ret i32 0
}