#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 /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int n, k, i;
  printf("Enter N and K:\n");
  scanf("%d %d", &n, &k);
  i = 0;
  while (n > k) {
    n -= k;
    i++;
  }
  printf("Result of the division is %d and the residue is %d", i, n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    117d <main+0x5d>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1158 <main+0x38>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf01(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
mov    (%rsp),%edx
xor    %esi,%esi
cmp    %eax,%edx
jle    116c <main+0x3c>
xor    %esi,%esi
sub    %eax,%edx
add    $0x1,%esi
cmp    %eax,%edx
jg     1160 <main+0x30>
mov    %edx,(%rsp)
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Enter N and K:\0A\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [51 x i8] c"Result of the division is %d and the residue is %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
store i32 0, i32* %4
br label %7
7: ; preds = %11, %0
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = icmp sgt i32 %8, %9
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = sub nsw i32 %13, %12
store i32 %14, i32* %2
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %7
17: ; preds = %7
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [51 x i8] c"Result of the division is %d and the residue is %d\00"
@str = [15 x i8] c"Enter N and K:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %2
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, %7
br i1 %9, label %10, label %17
10: ; preds = %0, %10
%11 = phi i32 [ %14, %10 ], [ 0, %0 ]
%12 = phi i32 [ %13, %10 ], [ %8, %0 ]
%13 = sub nsw i32 %12, %7
%14 = add nuw nsw i32 %11, 1
%15 = icmp sgt i32 %13, %7
br i1 %15, label %10, label %16
16: ; preds = %10
store i32 %13, i32* %1
br label %17
17: ; preds = %16, %0
%18 = phi i32 [ %14, %16 ], [ 0, %0 ]
%19 = phi i32 [ %13, %16 ], [ %8, %0 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19)
ret i32 0
}