#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 /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int a, b, c, q, r;
  scanf("%d %d", &a, &b);
  r = a;
  q = 0;
  if (b == 1) {
    q = a;
    r = 0;
  } else {
    while (r > b) {
      a = a - b;
      q++;
      r = a;
    }
  }
  printf("%d\n%d", q, r);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    116c <main+0x4c>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    119f <main+0x7f>
jmp    1171 <main+0x51>
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    119a <main+0x7a>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1171 <main+0x51>
jmp    119f <main+0x7f>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
call   1040 <scanf@plt>
mov    (%rsp),%edx
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
jne    1147 <main+0x27>
mov    %edx,%esi
xor    %edx,%edx
jmp    115c <main+0x3c>
xor    %esi,%esi
cmp    %eax,%edx
jle    115c <main+0x3c>
xor    %esi,%esi
nop
sub    %eax,%edx
add    $0x1,%esi
cmp    %eax,%edx
jg     1150 <main+0x30>
mov    %edx,(%rsp)
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [6 x i8] c"%d\0A%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 ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 1
br i1 %8, label %18, label %9
9: ; preds = %0
%10 = icmp sgt i32 %6, %7
br i1 %10, label %11, label %18
11: ; preds = %9, %11
%12 = phi i32 [ %15, %11 ], [ 0, %9 ]
%13 = phi i32 [ %14, %11 ], [ %6, %9 ]
%14 = sub nsw i32 %13, %7
%15 = add nuw nsw i32 %12, 1
%16 = icmp sgt i32 %14, %7
br i1 %16, label %11, label %17
17: ; preds = %11
store i32 %14, i32* %1
br label %18
18: ; preds = %9, %17, %0
%19 = phi i32 [ %6, %0 ], [ %15, %17 ], [ 0, %9 ]
%20 = phi i32 [ 0, %0 ], [ %14, %17 ], [ %6, %9 ]
%21 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %20)
ret i32 0
}