#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*/ scanf(char *, int *);
int /*<<< orphan*/ the_magic(int, int, int);
int main() {
  int input, temp;
  int l = 1, required_number;
  scanf("%d", &input);
  scanf("%d", &required_number);
  temp = input;
  while (temp > 1) {
    temp /= 10;
    l++;
  }
  the_magic(input, l, required_number);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1030 <scanf@plt>
lea    0xeb3(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jle    1182 <main+0x62>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115c <main+0x3c>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <the_magic@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <scanf@plt>
mov    0xc(%rsp),%edi
mov    $0x1,%esi
cmp    $0x2,%edi
jl     1174 <main+0x54>
mov    $0x1,%esi
mov    $0xcccccccd,%eax
mov    %edi,%ecx
mov    %ecx,%edx
imul   %rax,%rdx
shr    $0x23,%rdx
add    $0x1,%esi
cmp    $0x13,%ecx
mov    %edx,%ecx
ja     1160 <main+0x40>
mov    0x8(%rsp),%edx
call   1040 <the_magic@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%8 = load i32, i32* %2
store i32 %8, i32* %3
br label %9
9: ; preds = %12, %0
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32, i32* %3
%14 = sdiv i32 %13, 10
store i32 %14, i32* %3
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %9
17: ; preds = %9
%18 = load i32, i32* %2
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = call i32 @the_magic(i32 %18, i32 %19, i32 %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %15
9: ; preds = %0, %9
%10 = phi i32 [ %13, %9 ], [ 1, %0 ]
%11 = phi i32 [ %12, %9 ], [ %7, %0 ]
%12 = udiv i32 %11, 10
%13 = add nuw nsw i32 %10, 1
%14 = icmp ugt i32 %11, 19
br i1 %14, label %9, label %15
15: ; preds = %9, %0
%16 = phi i32 [ 1, %0 ], [ %13, %9 ]
%17 = load i32, i32* %2
%18 = call i32 @the_magic(i32 %7, i32 %16, i32 %17)
ret i32 0
}