#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 digit_usage(int, int /*<<< orphan*/);
int mknum(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  char s[6], str[20];
  int a, n, v, m = 0;
  for (a = 1; a < 10000; a++) {
    n = 0;
    str[0] = '\0';
    while (strlen(str) < 9) {
      n++;
      sprintf(s, "%d", a * n);
      strcat(str, s);
      if (strlen(str) == 9) {
        v = mknum(str);
        if (digit_usage(mknum(str), 0) == 0x3fe && v > m)
          m = v;
      }
    }
  }
  printf("%d\n", m);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x1,-0x34(%rbp)
cmpl   $0x2710,-0x34(%rbp)
jge    1245 <main+0xe5>
movl   $0x0,-0x38(%rbp)
movb   $0x0,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x9,%eax
jge    1232 <main+0xd2>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
lea    -0x16(%rbp),%rdi
mov    -0x34(%rbp),%edx
imul   -0x38(%rbp),%edx
lea    0xe37(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x16(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x9,%eax
jne    122d <main+0xcd>
lea    -0x30(%rbp),%rdi
call   1080 <mknum@plt>
mov    %eax,-0x3c(%rbp)
lea    -0x30(%rbp),%rdi
call   1080 <mknum@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1050 <digit_usage@plt>
cmp    $0x3fe,%eax
jne    1228 <main+0xc8>
mov    -0x3c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jle    1228 <main+0xc8>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    122d <main+0xcd>
jmp    119c <main+0x3c>
jmp    1237 <main+0xd7>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1184 <main+0x24>
mov    -0x40(%rbp),%esi
lea    0xdb4(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0x1,%r12d
movl   $0x0,0x4(%rsp)
lea    0x10(%rsp),%r13
lea    0xe78(%rip),%r15
lea    0xa(%rsp),%rbx
jmp    11a1 <main+0x41>
nop
add    $0x1,%r12d
cmp    $0x2710,%r12d
je     122e <main+0xce>
movb   $0x0,0x10(%rsp)
mov    %r13,%rdi
call   1030 <strlen@plt>
cmp    $0x8,%eax
jg     1190 <main+0x30>
mov    %r12d,%ebp
jmp    11df <main+0x7f>
nopl   0x0(%rax,%rax,1)
cmp    $0x3fe,%eax
cmove  %ebx,%ecx
mov    %ecx,0x4(%rsp)
mov    %r14,%rbx
mov    %r13,%rdi
call   1030 <strlen@plt>
add    %r12d,%ebp
cmp    $0x9,%eax
jge    1190 <main+0x30>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1070 <sprintf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
mov    %r13,%rdi
call   1030 <strlen@plt>
cmp    $0x9,%eax
jne    11cf <main+0x6f>
mov    %rbx,%r14
mov    %r13,%rdi
call   1080 <mknum@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   1080 <mknum@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1050 <digit_usage@plt>
mov    0x4(%rsp),%ecx
cmp    %ecx,%ebx
jg     11c0 <main+0x60>
mov    %ecx,%ebx
jmp    11c0 <main+0x60>
lea    0xdce(%rip),%rdi
mov    0x4(%rsp),%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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