#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 main() {
  int i;
  int divisor;
  int total;
  printf("Enter a number:\n");
  scanf("%d", &i);
  for (divisor = 1; divisor <= i; divisor++) {
    if ((i % divisor == 0)) {
      total++;
    }
  }
  printf("%d has %d divisors.\n", i, total);
  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    0xecd(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     118c <main+0x6c>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1179 <main+0x59>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117e <main+0x5e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1154 <main+0x34>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe7b(%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    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%r9d
cmp    $0x1,%r9d
jne    1160 <main+0x30>
mov    $0x1,%esi
jmp    11a0 <main+0x70>
mov    %r9d,%r8d
and    $0xfffffffe,%r8d
neg    %r8d
mov    $0x1,%edi
nop
mov    %r9d,%eax
xor    %edx,%edx
div    %edi
cmp    $0x1,%edx
adc    $0x0,%ecx
lea    0x1(%rdi),%esi
mov    %r9d,%eax
xor    %edx,%edx
div    %esi
cmp    $0x1,%edx
adc    $0x0,%ecx
mov    %edi,%esi
add    $0x2,%esi
lea    (%r8,%rdi,1),%eax
add    $0x2,%eax
mov    %esi,%edi
cmp    $0x1,%eax
jne    1170 <main+0x40>
test   $0x1,%r9b
je     11b3 <main+0x83>
mov    %r9d,%eax
xor    %edx,%edx
div    %esi
cmp    $0x1,%edx
adc    $0x0,%ecx
lea    0xe49(%rip),%rdi
mov    %r9d,%esi
mov    %ecx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter a number:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"%d has %d divisors.\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 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %7
7: ; preds = %20, %0
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp sle i32 %8, %9
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = srem i32 %12, %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %19
19: ; preds = %16, %11
br label %20
20: ; preds = %19
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %7
23: ; preds = %7
%24 = load i32, i32* %2
%25 = load i32, i32* %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %25)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"%d has %d divisors.\0A\00"
@str = [16 x i8] c"Enter a number:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
%7 = and i32 %5, 1
%8 = icmp eq i32 %5, 1
br i1 %8, label %27, label %9
9: ; preds = %0
%10 = and i32 %5, 2147483646
br label %11
11: ; preds = %11, %9
%12 = phi i32 [ undef, %9 ], [ %23, %11 ]
%13 = phi i32 [ 1, %9 ], [ %24, %11 ]
%14 = phi i32 [ 0, %9 ], [ %25, %11 ]
%15 = urem i32 %5, %13
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = add nsw i32 %12, %17
%19 = add nuw i32 %13, 1
%20 = urem i32 %5, %19
%21 = icmp eq i32 %20, 0
%22 = zext i1 %21 to i32
%23 = add nsw i32 %18, %22
%24 = add nuw i32 %13, 2
%25 = add i32 %14, 2
%26 = icmp eq i32 %25, %10
br i1 %26, label %27, label %11
27: ; preds = %11, %0
%28 = phi i32 [ undef, %0 ], [ %23, %11 ]
%29 = phi i32 [ 1, %0 ], [ %24, %11 ]
%30 = icmp eq i32 %7, 0
br i1 %30, label %36, label %31
31: ; preds = %27
%32 = urem i32 %5, %29
%33 = icmp eq i32 %32, 0
%34 = zext i1 %33 to i32
%35 = add nsw i32 %28, %34
br label %36
36: ; preds = %27, %31
%37 = phi i32 [ %28, %27 ], [ %35, %31 ]
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %5, i32 %37)
ret i32 0
}