#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 *);
int main(void) {
  int m = 0, n = 0, k, small, large, c, sum = 0;
  printf("Enter the range of numbers n(largest) and m(smallest), and a number "
         "k\n");
  scanf("%d %d %d", &m, &n, &k);
  if (n <= m) {
    printf("The result is 0\n");
  } else {
    printf("These are numbers that are divisors for both %d and %d\n", m, n);
    for (c = m; c < n + 1; c++) {
      if (c % k == 0) {
        printf("%d \n", c);
        sum += c;
      }
    }
    printf("The sum of the divisors of both %d and %d is %d \n", m, n, sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1189 <main+0x69>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1208 <main+0xe8>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11f1 <main+0xd1>
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    11de <main+0xbe>
mov    -0x1c(%rbp),%esi
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11e3 <main+0xc3>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a3 <main+0x83>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xf24(%rip),%rdi
call   1030 <puts@plt>
lea    0xea5(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1050 <scanf@plt>
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%esi
cmp    %esi,%edx
jle    11d8 <main+0xa8>
lea    0xe87(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%ebx
mov    0x4(%rsp),%ecx
cmp    %ecx,%ebx
jg     11ea <main+0xba>
lea    0xed0(%rip),%r14
xor    %ebp,%ebp
jmp    11b9 <main+0x89>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x1(%rbx),%eax
cmp    %ecx,%ebx
mov    %eax,%ebx
jge    11e6 <main+0xb6>
mov    %ebx,%eax
cltd
idivl  0xc(%rsp)
test   %edx,%edx
jne    11b0 <main+0x80>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    %ebx,%ebp
mov    0x4(%rsp),%ecx
jmp    11b0 <main+0x80>
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
jmp    11fe <main+0xce>
mov    0x8(%rsp),%ebx
lea    0xe50(%rip),%rdi
mov    %ebx,%esi
mov    %ecx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [71 x i8] c"Enter the range of numbers n(largest) and m(smallest), and a number k\0A\00"
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.2 = [17 x i8] c"The result is 0\0A\00"
@.str.3 = [56 x i8] c"These are numbers that are divisors for both %d and %d\0A\00"
@.str.4 = [5 x i8] c"%d \0A\00"
@.str.5 = [50 x i8] c"The sum of the divisors of both %d and %d is %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %46
16: ; preds = %0
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0), i32 %17, i32 %18)
%20 = load i32, i32* %2
store i32 %20, i32* %7
br label %21
21: ; preds = %38, %16
%22 = load i32, i32* %7
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
%25 = icmp slt i32 %22, %24
br i1 %25, label %26, label %41
26: ; preds = %21
%27 = load i32, i32* %7
%28 = load i32, i32* %4
%29 = srem i32 %27, %28
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %26
%32 = load i32, i32* %7
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = add nsw i32 %35, %34
store i32 %36, i32* %8
br label %37
37: ; preds = %31, %26
br label %38
38: ; preds = %37
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %21
41: ; preds = %21
%42 = load i32, i32* %2
%43 = load i32, i32* %3
%44 = load i32, i32* %8
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0), i32 %42, i32 %43, i32 %44)
br label %46
46: ; preds = %41, %14
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.3 = [56 x i8] c"These are numbers that are divisors for both %d and %d\0A\00"
@.str.4 = [5 x i8] c"%d \0A\00"
@.str.5 = [50 x i8] c"The sum of the divisors of both %d and %d is %d \0A\00"
@str = [70 x i8] c"Enter the range of numbers n(largest) and m(smallest), and a number k\00"
@str.6 = [16 x i8] c"The result is 0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%9 = load i32, i32* %2
%10 = load i32, i32* %1
%11 = icmp sgt i32 %9, %10
br i1 %11, label %14, label %12
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0))
br label %42
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0), i32 %10, i32 %9)
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = icmp sgt i32 %16, %17
br i1 %18, label %37, label %19
19: ; preds = %14, %30
%20 = phi i32 [ %31, %30 ], [ %17, %14 ]
%21 = phi i32 [ %32, %30 ], [ 0, %14 ]
%22 = phi i32 [ %33, %30 ], [ %16, %14 ]
%23 = load i32, i32* %3
%24 = srem i32 %22, %23
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %19
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%28 = add nsw i32 %21, %22
%29 = load i32, i32* %2
br label %30
30: ; preds = %19, %26
%31 = phi i32 [ %29, %26 ], [ %20, %19 ]
%32 = phi i32 [ %28, %26 ], [ %21, %19 ]
%33 = add nsw i32 %22, 1
%34 = icmp slt i32 %22, %31
br i1 %34, label %19, label %35
35: ; preds = %30
%36 = load i32, i32* %1
br label %37
37: ; preds = %35, %14
%38 = phi i32 [ %16, %14 ], [ %36, %35 ]
%39 = phi i32 [ 0, %14 ], [ %32, %35 ]
%40 = phi i32 [ %17, %14 ], [ %31, %35 ]
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0), i32 %38, i32 %40, i32 %39)
br label %42
42: ; preds = %37, %12
ret i32 0
}