#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 */
typedef int /*<<< orphan*/ digits;

/* Variables and functions */
int /*<<< orphan*/ find(int *, int, int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int nmultiplier(int);
int pow10(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int div;
  int max = 0;
  int val = -1;
  for (div = 1; div < 1000; ++div) {
    int i;
    int digits[1000];
    int ndigits;
    int num = 1;
    int nn = nmultiplier(div);
    memset(digits, 0, sizeof(digits));
    ndigits = 0;
    for (i = 0; i < 1000; ++i) {
      num *= pow10(nn);
      num %= div;
      if (!find(digits, ndigits, num))
        digits[ndigits++] = num;
    }
    if (ndigits > max) {
      max = ndigits;
      val = div;
    }
  }
  printf("%d\n", val);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jge    1283 <main+0x133>
movl   $0x1,-0xfc8(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <nmultiplier@plt>
mov    %eax,-0xfcc(%rbp)
lea    -0xfc0(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1060 <memset@plt>
movl   $0x0,-0xfc4(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x3e8,-0x20(%rbp)
jge    1252 <main+0x102>
mov    -0xfcc(%rbp),%edi
call   1030 <pow10@plt>
imul   -0xfc8(%rbp),%eax
mov    %eax,-0xfc8(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0xfc8(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0xfc8(%rbp)
lea    -0xfc0(%rbp),%rdi
mov    -0xfc4(%rbp),%esi
mov    -0xfc8(%rbp),%edx
call   1070 <find@plt>
cmp    $0x0,%eax
jne    123f <main+0xef>
mov    -0xfc8(%rbp),%ecx
mov    -0xfc4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xfc4(%rbp)
cltq
mov    %ecx,-0xfc0(%rbp,%rax,4)
jmp    1244 <main+0xf4>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c7 <main+0x77>
mov    -0xfc4(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    1270 <main+0x120>
mov    -0xfc4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1275 <main+0x125>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117e <main+0x2e>
mov    -0x1c(%rbp),%esi
lea    0xd73(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xfd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xfb8,%rsp
xor    %eax,%eax
mov    $0xffffffff,%esi
mov    $0x1,%r12d
lea    0x10(%rsp),%r15
jmp    119e <main+0x4e>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x8(%rsp),%eax
cmp    %eax,%ebp
cmovg  %ebp,%eax
mov    0xc(%rsp),%esi
cmovg  %r12d,%esi
add    $0x1,%r12d
cmp    $0x3e8,%r12d
je     1201 <main+0xb1>
mov    %eax,0x8(%rsp)
mov    %esi,0xc(%rsp)
mov    %r12d,%edi
call   1040 <nmultiplier@plt>
mov    %eax,%r13d
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1060 <memset@plt>
mov    $0x3e8,%r14d
mov    $0x1,%ebx
xor    %ebp,%ebp
jmp    11d6 <main+0x86>
nop
add    $0xffffffff,%r14d
je     1180 <main+0x30>
mov    %r13d,%edi
call   1030 <pow10@plt>
imul   %ebx,%eax
cltd
idiv   %r12d
mov    %edx,%ebx
mov    %r15,%rdi
mov    %ebp,%esi
call   1070 <find@plt>
test   %eax,%eax
jne    11d0 <main+0x80>
movslq %ebp,%rax
add    $0x1,%ebp
mov    %ebx,0x10(%rsp,%rax,4)
jmp    11d0 <main+0x80>
lea    0xdf8(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xfb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000 x i32]
%4 = bitcast [1000 x i32]* %3 to i8*
%5 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 0
br label %6
6: ; preds = %2, %29
%7 = phi i32 [ 1, %2 ], [ %33, %29 ]
%8 = phi i32 [ -1, %2 ], [ %32, %29 ]
%9 = phi i32 [ 0, %2 ], [ %31, %29 ]
%10 = call i32 @nmultiplier(i32 %7)
%11 = call i32 @memset(i32* %5, i32 0, i32 4000)
br label %12
12: ; preds = %6, %25
%13 = phi i32 [ 1, %6 ], [ %18, %25 ]
%14 = phi i32 [ 0, %6 ], [ %26, %25 ]
%15 = phi i32 [ 0, %6 ], [ %27, %25 ]
%16 = call i32 @pow10(i32 %10)
%17 = mul nsw i32 %16, %13
%18 = srem i32 %17, %7
%19 = call i32 @find(i32* %5, i32 %14, i32 %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %12
%22 = add nsw i32 %14, 1
%23 = sext i32 %14 to i64
%24 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %23
store i32 %18, i32* %24
br label %25
25: ; preds = %12, %21
%26 = phi i32 [ %14, %12 ], [ %22, %21 ]
%27 = add nuw nsw i32 %15, 1
%28 = icmp eq i32 %27, 1000
br i1 %28, label %29, label %12
29: ; preds = %25
%30 = icmp sgt i32 %26, %9
%31 = select i1 %30, i32 %26, i32 %9
%32 = select i1 %30, i32 %7, i32 %8
%33 = add nuw nsw i32 %7, 1
%34 = icmp eq i32 %33, 1000
br i1 %34, label %35, label %6
35: ; preds = %29
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
ret i32 0
}