#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 /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int dividend, divisor, rest;
  scanf("%d %d", &dividend, &divisor);
  if (divisor < 0) {
    divisor *= -1;
  }
  rest = dividend % divisor;
  if (rest > 0) {
    dividend += divisor;
  }
  printf("%d\n", dividend - rest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jge    1154 <main+0x34>
imul   $0xffffffff,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    1171 <main+0x51>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
sub    -0x10(%rbp),%esi
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    (%rsp),%ecx
test   %ecx,%ecx
jns    1141 <main+0x21>
neg    %ecx
mov    %ecx,(%rsp)
mov    0x4(%rsp),%esi
mov    %esi,%eax
cltd
idiv   %ecx
test   %edx,%edx
jle    1154 <main+0x34>
add    %ecx,%esi
mov    %esi,0x4(%rsp)
sub    %edx,%esi
lea    0xea9(%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 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i32, i32* %3
%10 = mul nsw i32 %9, -1
store i32 %10, i32* %3
br label %11
11: ; preds = %8, %0
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = srem i32 %12, %13
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = add nsw i32 %19, %18
store i32 %20, i32* %2
br label %21
21: ; preds = %17, %11
%22 = load i32, i32* %2
%23 = load i32, i32* %4
%24 = sub nsw i32 %22, %23
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
ret i32 0
}

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