#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*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, ...);
long long strlen(char *);
int main() {
  long long int len, i, j, num, div, rem, l;
  char a[1000], total[1000];
  scanf("%s", a);
  scanf("%lld", &num);
  len = strlen(a);
  div = 0;
  rem = 0;
  i = 0;
  l = 0;
  while (i < len) {
    rem = (rem * 10 + a[i] - '0') % num;
    div = (div * 10 + a[i] - '0') / num;
    printf("%lld", div);
    div = rem;
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x430(%rbp),%rsi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xea5(%rip),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x430(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    1216 <main+0xe6>
imul   $0xa,-0x38(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbq -0x430(%rbp,%rcx,1),%rcx
ff ff
add    %rcx,%rax
sub    $0x30,%rax
cqto
idivq  -0x28(%rbp)
mov    %rdx,-0x38(%rbp)
imul   $0xa,-0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbq -0x430(%rbp,%rcx,1),%rcx
ff ff
add    %rcx,%rax
sub    $0x30,%rax
cqto
idivq  -0x28(%rbp)
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe0b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1199 <main+0x69>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3f8,%rsp
lea    0xebb(%rip),%rdi
xor    %ebx,%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xea6(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %rax,%rax
jle    11da <main+0xaa>
mov    %rax,%r15
lea    0xe83(%rip),%r14
xor    %r12d,%r12d
jmp    11ac <main+0x7c>
cs nopw 0x0(%rax,%rax,1)
nop
cqto
idiv   %rcx
mov    %rdx,%r12
mov    %rax,%rsi
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
je     11da <main+0xaa>
lea    (%r12,%r12,4),%rax
movsbq 0x10(%rsp,%rbx,1),%rcx
lea    (%rcx,%rax,2),%rax
add    $0xffffffffffffffd0,%rax
mov    0x8(%rsp),%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
jne    1190 <main+0x60>
xor    %edx,%edx
div    %ecx
mov    %edx,%r12d
mov    %eax,%esi
jmp    119b <main+0x6b>
xor    %eax,%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"%lld\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca [1000 x i8]
%10 = alloca [1000 x i8]
store i32 0, i32* %1
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %5)
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%15 = call i64 @strlen(i8* %14)
store i64 %15, i64* %2
store i64 0, i64* %6
store i64 0, i64* %7
store i64 0, i64* %3
store i64 0, i64* %8
br label %16
16: ; preds = %20, %0
%17 = load i64, i64* %3
%18 = load i64, i64* %2
%19 = icmp slt i64 %17, %18
br i1 %19, label %20, label %46
20: ; preds = %16
%21 = load i64, i64* %7
%22 = mul nsw i64 %21, 10
%23 = load i64, i64* %3
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i64
%27 = add nsw i64 %22, %26
%28 = sub nsw i64 %27, 48
%29 = load i64, i64* %5
%30 = srem i64 %28, %29
store i64 %30, i64* %7
%31 = load i64, i64* %6
%32 = mul nsw i64 %31, 10
%33 = load i64, i64* %3
%34 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i64
%37 = add nsw i64 %32, %36
%38 = sub nsw i64 %37, 48
%39 = load i64, i64* %5
%40 = sdiv i64 %38, %39
store i64 %40, i64* %6
%41 = load i64, i64* %6
%42 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %41)
%43 = load i64, i64* %7
store i64 %43, i64* %6
%44 = load i64, i64* %3
%45 = add nsw i64 %44, 1
store i64 %45, i64* %3
br label %16
46: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"%lld\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca [1000 x i8]
%3 = bitcast i64* %1 to i8*
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%7 = call i64 @strlen(i8* %4)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %0, %9
%10 = phi i64 [ %22, %9 ], [ 0, %0 ]
%11 = phi i64 [ %19, %9 ], [ 0, %0 ]
%12 = mul nsw i64 %11, 10
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %10
%14 = load i8, i8* %13
%15 = sext i8 %14 to i64
%16 = add i64 %12, -48
%17 = add i64 %16, %15
%18 = load i64, i64* %1
%19 = srem i64 %17, %18
%20 = sdiv i64 %17, %18
%21 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %20)
%22 = add nuw nsw i64 %10, 1
%23 = icmp eq i64 %22, %7
br i1 %23, label %24, label %9
24: ; preds = %9, %0
ret i32 0
}