#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 *, int, int, int);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main(void) {
  int price, money, change;
  while (1) {
    scanf("%d %d\n", &price, &money);
    if (price == 0 && money == 0)
      break;
    change = money - price;
    printf("%d %d %d\n", (change % 500) / 100, (change % 1000) / 500,
           change / 1000);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecd(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    115c <main+0x3c>
cmpl   $0x0,-0xc(%rbp)
jne    115c <main+0x3c>
jmp    11b5 <main+0x95>
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x1f4,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x10(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x1f4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    -0x14(%rbp),%edx
mov    %eax,%ecx
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed4(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
mov    (%rsp),%ecx
mov    %eax,%edx
or     %ecx,%edx
je     1200 <main+0xe0>
lea    0xeac(%rip),%r14
lea    0xea8(%rip),%r15
lea    0x4(%rsp),%r12
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
sub    %eax,%ecx
movslq %ecx,%rax
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x25,%rdx
mov    %rcx,%rdi
shr    $0x3f,%rdi
add    %edi,%edx
imul   $0x1f4,%edx,%edx
mov    %eax,%esi
sub    %edx,%esi
movswl %si,%edx
imul   $0x147b,%edx,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0x13,%edx
add    %esi,%edx
movswl %dx,%esi
sar    $0x26,%rcx
add    %edi,%ecx
imul   $0x3e8,%ecx,%edx
sub    %edx,%eax
movswl %ax,%edx
imul   $0xffff8313,%edx,%edx
shr    $0x10,%edx
add    %eax,%edx
movzwl %dx,%eax
movswl %ax,%edx
shr    $0xf,%eax
sar    $0x8,%edx
add    %eax,%edx
movswl %dx,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
mov    (%rsp),%ecx
mov    %eax,%edx
or     %ecx,%edx
jne    1170 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"%d %d\0A\00"
@.str.1 = [10 x i8] c"%d %d %d\0A\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 ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %31, label %11
11: ; preds = %0, %11
%12 = phi i32 [ %28, %11 ], [ %8, %0 ]
%13 = phi i32 [ %26, %11 ], [ %6, %0 ]
%14 = sub nsw i32 %12, %13
%15 = srem i32 %14, 500
%16 = trunc i32 %15 to i16
%17 = sdiv i16 %16, 100
%18 = sext i16 %17 to i32
%19 = srem i32 %14, 1000
%20 = trunc i32 %19 to i16
%21 = sdiv i16 %20, 500
%22 = sext i16 %21 to i32
%23 = sdiv i32 %14, 1000
%24 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %22, i32 %23)
%25 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%26 = load i32, i32* %1
%27 = icmp eq i32 %26, 0
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, 0
%30 = select i1 %27, i1 %29, i1 false
br i1 %30, label %31, label %11
31: ; preds = %11, %0
ret i32 0
}