#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 *);
void Task2() {
  int n, k, i;
  printf("Enter values for 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.\n", i, n);
}


x86 assembly (clang, -O0):
<Task2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1176 <Task2+0x56>
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1151 <Task2+0x31>
mov    -0xc(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Task2>:
push   %rax
lea    0xf03(%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 <Task2+0x3c>
xor    %esi,%esi
sub    %eax,%edx
add    $0x1,%esi
cmp    %eax,%edx
jg     1160 <Task2+0x30>
mov    %edx,(%rsp)
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
pop    %rax
ret

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

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [53 x i8] c"Result of the division is %d and the residue is %d.\0A\00"
@str = [26 x i8] c"Enter values for N and K:\00"
define void @Task2() {
%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 ([26 x i8], [26 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 ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19)
ret void
}