#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 ipow(int, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  int d = 1;
  int n, nn, i, found;
  while (1) {
    for (n = ipow(10, d); n < 2 * ipow(10, d); n++) {
      found = 1;
      nn = digit_usage(n, 0);
      for (i = 2; i <= 6; i++) {
        if (nn != digit_usage(n * i, 0)) {
          found = 0;
          break;
        }
      }
      if (found) {
        printf("%d\n", n);
        return 0;
      }
    }
    d++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    $0xa,%edi
call   1050 <ipow@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
mov    $0xa,%edi
call   1050 <ipow@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    1219 <main+0xe9>
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%edi
xor    %esi,%esi
call   1040 <digit_usage@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x2,-0x20(%rbp)
cmpl   $0x6,-0x20(%rbp)
jg     11e5 <main+0xb5>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%edi
imul   -0x20(%rbp),%edi
xor    %esi,%esi
call   1040 <digit_usage@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
je     11d2 <main+0xa2>
movl   $0x0,-0x24(%rbp)
jmp    11e5 <main+0xb5>
jmp    11d7 <main+0xa7>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    119b <main+0x6b>
cmpl   $0x0,-0x24(%rbp)
je     1206 <main+0xd6>
mov    -0x18(%rbp),%esi
lea    0xe07(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret
jmp    120b <main+0xdb>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115d <main+0x2d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x1,%ebx
jmp    1157 <main+0x27>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x4(%rsp),%ebx
add    $0x1,%ebx
mov    $0xa,%edi
mov    %ebx,%esi
call   1050 <ipow@plt>
mov    %eax,%ebp
mov    $0xa,%edi
mov    %ebx,0x4(%rsp)
mov    %ebx,%esi
call   1050 <ipow@plt>
add    %eax,%eax
cmp    %eax,%ebp
jge    1150 <main+0x20>
lea    0x0(,%rbp,4),%r12d
lea    0x0(%rbp,%rbp,1),%r13d
lea    0x0(%r13,%r13,2),%ebx
lea    0x0(%rbp,%rbp,4),%r15d
lea    0x0(%rbp,%rbp,2),%r14d
jmp    11d8 <main+0xa8>
nopl   0x0(%rax)
mov    0x8(%rsp),%rbp
add    $0x1,%ebp
mov    $0xa,%edi
mov    0x4(%rsp),%esi
call   1050 <ipow@plt>
add    %eax,%eax
add    $0x4,%r12d
mov    0x10(%rsp),%r13
add    $0x2,%r13d
add    $0x6,%ebx
add    $0x5,%r15d
add    $0x3,%r14d
cmp    %eax,%ebp
jge    1150 <main+0x20>
mov    %rbp,0x8(%rsp)
mov    %ebp,%edi
xor    %esi,%esi
call   1040 <digit_usage@plt>
mov    %r12d,%ebp
mov    %r14d,%r12d
mov    %r15d,%r14d
mov    %eax,%r15d
mov    %r13,0x10(%rsp)
mov    %r13d,%edi
xor    %esi,%esi
call   1040 <digit_usage@plt>
mov    %r15d,(%rsp)
cmp    %eax,%r15d
mov    %r14d,%r15d
mov    %r12d,%r14d
mov    %ebp,%r12d
jne    11a0 <main+0x70>
mov    %r14d,%edi
xor    %esi,%esi
call   1040 <digit_usage@plt>
cmp    %eax,(%rsp)
jne    11a0 <main+0x70>
mov    %r12d,%edi
xor    %esi,%esi
call   1040 <digit_usage@plt>
cmp    %eax,(%rsp)
jne    11a0 <main+0x70>
mov    %r15d,%edi
xor    %esi,%esi
call   1040 <digit_usage@plt>
cmp    %eax,(%rsp)
jne    11a0 <main+0x70>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <digit_usage@plt>
cmp    %eax,(%rsp)
jne    11a0 <main+0x70>
lea    0xd9b(%rip),%rdi
mov    0x8(%rsp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %11
11: ; preds = %2, %48
%12 = load i32, i32* %6
%13 = call i32 @ipow(i32 10, i32 %12)
store i32 %13, i32* %7
br label %14
14: ; preds = %45, %11
%15 = load i32, i32* %7
%16 = load i32, i32* %6
%17 = call i32 @ipow(i32 10, i32 %16)
%18 = mul nsw i32 2, %17
%19 = icmp slt i32 %15, %18
br i1 %19, label %20, label %48
20: ; preds = %14
store i32 1, i32* %10
%21 = load i32, i32* %7
%22 = call i32 @digit_usage(i32 %21, i32 0)
store i32 %22, i32* %8
store i32 2, i32* %9
br label %23
23: ; preds = %35, %20
%24 = load i32, i32* %9
%25 = icmp sle i32 %24, 6
br i1 %25, label %26, label %38
26: ; preds = %23
%27 = load i32, i32* %8
%28 = load i32, i32* %7
%29 = load i32, i32* %9
%30 = mul nsw i32 %28, %29
%31 = call i32 @digit_usage(i32 %30, i32 0)
%32 = icmp ne i32 %27, %31
br i1 %32, label %33, label %34
33: ; preds = %26
store i32 0, i32* %10
br label %38
34: ; preds = %26
br label %35
35: ; preds = %34
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %23
38: ; preds = %33, %23
%39 = load i32, i32* %10
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* %7
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %42)
ret i32 0
44: ; preds = %38
br label %45
45: ; preds = %44
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %14
48: ; preds = %14
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %11
}

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