#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 check_duplicates(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int find_pairs(int n) {
  char str_numer[6];
  char str_denom[6];
  char full_str[11];
  int solution_found = 0;
  int denom = 1234;
  int numer;
  int bufsize = 6;
  int duplicates;
  while (denom < 98766) {
    numer = denom * n;
    if (numer > 1233 && numer < 98766) {
      if (denom < 10000) {
        snprintf(str_denom, bufsize, "0%d", denom);
      } else {
        snprintf(str_denom, bufsize, "%d", denom);
      }
      if (numer < 10000) {
        snprintf(str_numer, bufsize, "0%d", numer);
      } else {
        snprintf(str_numer, bufsize, "%d", numer);
      }
      strcpy(full_str, str_denom);
      strcat(full_str, str_numer);
      duplicates = check_duplicates(full_str);
      if (duplicates == 0) {
        printf("%s / %s = %d\n", str_numer, str_denom, n);
        solution_found = 1;
      }
    }
    denom = denom + 1;
  }
  if (solution_found == 0) {
    printf("There are no solutions for %d.\n", n);
  }
}


x86 assembly (clang, -O0):
<find_pairs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x4d2,-0x28(%rbp)
movl   $0x6,-0x30(%rbp)
cmpl   $0x181ce,-0x28(%rbp)
jge    1280 <find_pairs+0x130>
mov    -0x28(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x4d1,-0x2c(%rbp)
jle    1272 <find_pairs+0x122>
cmpl   $0x181ce,-0x2c(%rbp)
jge    1272 <find_pairs+0x122>
cmpl   $0x2710,-0x28(%rbp)
jge    11c9 <find_pairs+0x79>
lea    -0x14(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x28(%rbp),%ecx
lea    0xe41(%rip),%rdx
call   1050 <snprintf@plt>
jmp    11df <find_pairs+0x8f>
lea    -0x14(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x28(%rbp),%ecx
lea    0xe27(%rip),%rdx
call   1050 <snprintf@plt>
cmpl   $0x2710,-0x2c(%rbp)
jge    1207 <find_pairs+0xb7>
lea    -0xe(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%ecx
lea    0xe03(%rip),%rdx
call   1050 <snprintf@plt>
jmp    121d <find_pairs+0xcd>
lea    -0xe(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%ecx
lea    0xde9(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x1f(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x1f(%rbp),%rdi
lea    -0xe(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x1f(%rbp),%rdi
call   1070 <check_duplicates@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    126d <find_pairs+0x11d>
lea    -0xe(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    -0x8(%rbp),%ecx
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x24(%rbp)
jmp    1272 <find_pairs+0x122>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1170 <find_pairs+0x20>
cmpl   $0x0,-0x24(%rbp)
jne    129b <find_pairs+0x14b>
mov    -0x8(%rbp),%esi
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_pairs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edi,%r14d
mov    $0x4d2,%ebx
mov    $0x1,%al
mov    %eax,0xc(%rsp)
mov    %r14d,%r13d
imul   %ebx,%r13d
jmp    1192 <find_pairs+0x42>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebx
add    %r14d,%r13d
cmp    $0x181ce,%ebx
je     1253 <find_pairs+0x103>
lea    -0x4d2(%r13),%eax
cmp    $0x17cfb,%eax
ja     1180 <find_pairs+0x30>
cmp    $0x2710,%ebx
lea    0xe54(%rip),%r15
mov    %r15,%rdx
lea    0xe49(%rip),%rbp
cmovb  %rbp,%rdx
lea    0x11(%rsp),%r12
mov    %r12,%rdi
mov    $0x6,%esi
mov    %ebx,%ecx
call   1050 <snprintf@plt>
cmp    $0x2710,%r13d
mov    %r15,%rdx
cmovb  %rbp,%rdx
lea    0x17(%rsp),%r15
mov    %r15,%rdi
mov    $0x6,%esi
mov    %r13d,%ecx
call   1050 <snprintf@plt>
lea    0x1d(%rsp),%rbp
mov    %rbp,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
mov    %rbp,%rdi
call   1070 <check_duplicates@plt>
test   %eax,%eax
jne    1180 <find_pairs+0x30>
movl   $0x0,0xc(%rsp)
lea    0xdd8(%rip),%rdi
lea    0x17(%rsp),%rsi
lea    0x11(%rsp),%rdx
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1(%rbx),%eax
cmp    $0x181cd,%ebx
mov    %eax,%ebx
jne    116c <find_pairs+0x1c>
jmp    126b <find_pairs+0x11b>
testb  $0x1,0xc(%rsp)
je     126b <find_pairs+0x11b>
lea    0xdb1(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"0%d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [14 x i8] c"%s / %s = %d\0A\00"
@.str.3 = [32 x i8] c"There are no solutions for %d.\0A\00"
define i32 @find_pairs(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [6 x i8]
%5 = alloca [6 x i8]
%6 = alloca [11 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %7
store i32 1234, i32* %8
store i32 6, i32* %10
br label %12
12: ; preds = %67, %1
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 98766
br i1 %14, label %15, label %70
15: ; preds = %12
%16 = load i32, i32* %8
%17 = load i32, i32* %3
%18 = mul nsw i32 %16, %17
store i32 %18, i32* %9
%19 = load i32, i32* %9
%20 = icmp sgt i32 %19, 1233
br i1 %20, label %21, label %67
21: ; preds = %15
%22 = load i32, i32* %9
%23 = icmp slt i32 %22, 98766
br i1 %23, label %24, label %67
24: ; preds = %21
%25 = load i32, i32* %8
%26 = icmp slt i32 %25, 10000
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%29 = load i32, i32* %10
%30 = load i32, i32* %8
%31 = call i32 @snprintf(i8* %28, i32 %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
br label %37
32: ; preds = %24
%33 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%34 = load i32, i32* %10
%35 = load i32, i32* %8
%36 = call i32 @snprintf(i8* %33, i32 %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %32, %27
%38 = load i32, i32* %9
%39 = icmp slt i32 %38, 10000
br i1 %39, label %40, label %45
40: ; preds = %37
%41 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%42 = load i32, i32* %10
%43 = load i32, i32* %9
%44 = call i32 @snprintf(i8* %41, i32 %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %43)
br label %50
45: ; preds = %37
%46 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%47 = load i32, i32* %10
%48 = load i32, i32* %9
%49 = call i32 @snprintf(i8* %46, i32 %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %45, %40
%51 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%52 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%53 = call i32 @strcpy(i8* %51, i8* %52)
%54 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%55 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%56 = call i32 @strcat(i8* %54, i8* %55)
%57 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%58 = call i32 @check_duplicates(i8* %57)
store i32 %58, i32* %11
%59 = load i32, i32* %11
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %66
61: ; preds = %50
%62 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%63 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%64 = load i32, i32* %3
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %62, i8* %63, i32 %64)
store i32 1, i32* %7
br label %66
66: ; preds = %61, %50
br label %67
67: ; preds = %66, %21, %15
%68 = load i32, i32* %8
%69 = add nsw i32 %68, 1
store i32 %69, i32* %8
br label %12
70: ; preds = %12
%71 = load i32, i32* %7
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = load i32, i32* %3
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %74)
br label %76
76: ; preds = %73, %70
%77 = load i32, i32* %2
ret i32 %77
}

LLVM IR (-O2):
@.str = [4 x i8] c"0%d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [14 x i8] c"%s / %s = %d\0A\00"
@.str.3 = [32 x i8] c"There are no solutions for %d.\0A\00"
define i32 @find_pairs(i32 %0) {
%2 = alloca [6 x i8]
%3 = alloca [6 x i8]
%4 = alloca [11 x i8]
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
br label %8
8: ; preds = %30, %1
%9 = phi i1 [ false, %30 ], [ true, %1 ]
%10 = phi i32 [ %32, %30 ], [ 1234, %1 ]
br label %11
11: ; preds = %8, %27
%12 = phi i32 [ %28, %27 ], [ %10, %8 ]
%13 = mul nsw i32 %12, %0
%14 = add i32 %13, -1234
%15 = icmp ult i32 %14, 97532
br i1 %15, label %16, label %27
16: ; preds = %11
%17 = icmp ult i32 %12, 10000
%18 = select i1 %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%19 = call i32 @snprintf(i8* %6, i32 6, i8* %18, i32 %12)
%20 = icmp ult i32 %13, 10000
%21 = select i1 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%22 = call i32 @snprintf(i8* %5, i32 6, i8* %21, i32 %13)
%23 = call i32 @strcpy(i8* %7, i8* %6)
%24 = call i32 @strcat(i8* %7, i8* %5)
%25 = call i32 @check_duplicates(i8* %7)
%26 = icmp eq i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %16, %11
%28 = add nuw nsw i32 %12, 1
%29 = icmp eq i32 %28, 98766
br i1 %29, label %34, label %11
30: ; preds = %16
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8* %6, i32 %0)
%32 = add nuw nsw i32 %12, 1
%33 = icmp eq i32 %32, 98766
br i1 %33, label %37, label %8
34: ; preds = %27
br i1 %9, label %35, label %37
35: ; preds = %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %0)
br label %37
37: ; preds = %30, %35, %34
ret i32 undef
}