#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *, int *);
int main(void) {
  int m, n, k = 0, i = 0, count = 0;
  while (k < 1) {
    printf("Please input non-negative numbers for m, n and k: ");
    scanf(" %d %d %d", &m, &n, &k);
  }
  for (i = m; i <= n; i++) {
    if (i % k == 0) {
      count = count + i;
      printf("Adding to count: %d\n", count);
    }
  }
  printf("Final count of integers divisible by %d, between %d and %d: %d\n", k,
         m, n, count);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x10(%rbp)
jge    1179 <main+0x59>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
jmp    1144 <main+0x24>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11c8 <main+0xa8>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    11b5 <main+0x95>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ba <main+0x9a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117f <main+0x5f>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x4(%rsp)
lea    0xec5(%rip),%r14
lea    0xef1(%rip),%r15
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%rbp
lea    0x4(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    1160 <main+0x40>
mov    0xc(%rsp),%ebx
mov    0x8(%rsp),%ecx
xor    %ebp,%ebp
cmp    %ecx,%ebx
jg     11d0 <main+0xb0>
lea    0xea5(%rip),%r14
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebx,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    11bb <main+0x9b>
add    %ebx,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%ecx
cmp    %ecx,%ebx
jge    11c8 <main+0xa8>
add    $0x1,%ebx
mov    0x4(%rsp),%esi
jmp    11a0 <main+0x80>
mov    0x4(%rsp),%esi
mov    0xc(%rsp),%ebx
lea    0xe7b(%rip),%rdi
mov    %ebx,%edx
mov    %ebp,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [51 x i8] c"Please input non-negative numbers for m, n and k: \00"
@.str.1 = [10 x i8] c" %d %d %d\00"
@.str.2 = [21 x i8] c"Adding to count: %d\0A\00"
@.str.3 = [64 x i8] c"Final count of integers divisible by %d, between %d and %d: %d\0A\00"
@EXIT_SUCCESS = global i32 0
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
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %10, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
br label %7
13: ; preds = %7
%14 = load i32, i32* %2
store i32 %14, i32* %5
br label %15
15: ; preds = %31, %13
%16 = load i32, i32* %5
%17 = load i32, i32* %3
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %34
19: ; preds = %15
%20 = load i32, i32* %5
%21 = load i32, i32* %4
%22 = srem i32 %20, %21
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %19
%25 = load i32, i32* %6
%26 = load i32, i32* %5
%27 = add nsw i32 %25, %26
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %24, %19
br label %31
31: ; preds = %30
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %15
34: ; preds = %15
%35 = load i32, i32* %4
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = load i32, i32* %6
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 %36, i32 %37, i32 %38)
%40 = load i32, i32* @EXIT_SUCCESS
ret i32 %40
}

LLVM IR (-O2):
@.str = [51 x i8] c"Please input non-negative numbers for m, n and k: \00"
@.str.1 = [10 x i8] c" %d %d %d\00"
@.str.2 = [21 x i8] c"Adding to count: %d\0A\00"
@.str.3 = [64 x i8] c"Final count of integers divisible by %d, between %d and %d: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
br label %7
7: ; preds = %0, %7
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 1
br i1 %11, label %7, label %12
12: ; preds = %7
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = icmp sgt i32 %13, %14
br i1 %15, label %37, label %16
16: ; preds = %12, %31
%17 = phi i32 [ %28, %31 ], [ %14, %12 ]
%18 = phi i32 [ %33, %31 ], [ %10, %12 ]
%19 = phi i32 [ %29, %31 ], [ 0, %12 ]
%20 = phi i32 [ %32, %31 ], [ %13, %12 ]
%21 = srem i32 %20, %18
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %16
%24 = add nsw i32 %19, %20
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %2
br label %27
27: ; preds = %16, %23
%28 = phi i32 [ %26, %23 ], [ %17, %16 ]
%29 = phi i32 [ %24, %23 ], [ %19, %16 ]
%30 = icmp slt i32 %20, %28
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = add nsw i32 %20, 1
%33 = load i32, i32* %3
br label %16
34: ; preds = %27
%35 = load i32, i32* %3
%36 = load i32, i32* %1
br label %37
37: ; preds = %34, %12
%38 = phi i32 [ %13, %12 ], [ %36, %34 ]
%39 = phi i32 [ %10, %12 ], [ %35, %34 ]
%40 = phi i32 [ 0, %12 ], [ %29, %34 ]
%41 = phi i32 [ %14, %12 ], [ %28, %34 ]
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i32 %39, i32 %38, i32 %41, i32 %40)
%43 = load i32, i32* @EXIT_SUCCESS
ret i32 %43
}