#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, j;
  int sumDivisors;
  int m;
  printf("Entre com o valor de M: ");
  scanf("%d", &m);
  printf("Números perfeitos entre 0 e %d (intervalo ABERTO): ", m);
  for (i = 1; i < m; i++) {
    sumDivisors = 0;
    for (j = 1; j <= i / 2; j++) {
      if (i % j == 0) {
        sumDivisors += j;
      }
    }
    if (sumDivisors == i) {
      printf("%d ", i);
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%esi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f9 <main+0xd9>
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jg     11c9 <main+0xa9>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11b6 <main+0x96>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11bb <main+0x9b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117f <main+0x5f>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11e6 <main+0xc6>
mov    -0x8(%rbp),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11eb <main+0xcb>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1165 <main+0x45>
lea    0xe55(%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   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebd(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%r8d
cmp    $0x2,%r8d
jl     124c <main+0x11c>
mov    $0x1,%r12d
lea    0xec5(%rip),%r15
mov    $0x1,%ebp
jmp    11ac <main+0x7c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebp
cmp    %r8d,%ebp
jge    124c <main+0x11c>
mov    %ebp,%r9d
shr    %r9d
cmp    $0x2,%r9d
cmovb  %r12d,%r9d
cmp    $0x2,%ebp
jb     11a0 <main+0x70>
cmp    $0x4,%ebp
jae    1200 <main+0xd0>
mov    $0x1,%ebx
xor    %edi,%edi
test   $0x1,%r9b
je     11e1 <main+0xb1>
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
test   %edx,%edx
cmovne %r14d,%ebx
add    %edi,%ebx
mov    %ebx,%edi
cmp    %ebp,%edi
jne    11a0 <main+0x70>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%r8d
jmp    11a0 <main+0x70>
nopl   0x0(%rax,%rax,1)
mov    %r9d,%esi
and    $0x3ffffffe,%esi
mov    $0x1,%ebx
xor    %edi,%edi
jmp    1229 <main+0xf9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    %eax,%edi
add    $0x2,%ebx
cmp    %esi,%ecx
je     11cb <main+0x9b>
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
mov    %ebx,%eax
test   %edx,%edx
je     1237 <main+0x107>
xor    %eax,%eax
add    %eax,%edi
lea    0x1(%rbx),%ecx
mov    %ebp,%eax
xor    %edx,%edx
div    %ecx
mov    %ecx,%eax
test   %edx,%edx
je     1220 <main+0xf0>
xor    %eax,%eax
jmp    1220 <main+0xf0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Entre com o valor de M: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [53 x i8] c"N\C3\BAmeros perfeitos entre 0 e %d (intervalo ABERTO): \00"
@.str.3 = [4 x i8] c"%d \00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%8 = load i32, i32* %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %8)
store i32 1, i32* %2
br label %10
10: ; preds = %41, %0
%11 = load i32, i32* %2
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %44
14: ; preds = %10
store i32 0, i32* %4
store i32 1, i32* %3
br label %15
15: ; preds = %30, %14
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = sdiv i32 %17, 2
%19 = icmp sle i32 %16, %18
br i1 %19, label %20, label %33
20: ; preds = %15
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = srem i32 %21, %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %20
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = add nsw i32 %27, %26
store i32 %28, i32* %4
br label %29
29: ; preds = %25, %20
br label %30
30: ; preds = %29
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %15
33: ; preds = %15
%34 = load i32, i32* %4
%35 = load i32, i32* %2
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i32, i32* %2
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %37, %33
br label %41
41: ; preds = %40
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %10
44: ; preds = %10
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Entre com o valor de M: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [53 x i8] c"N\C3\BAmeros perfeitos entre 0 e %d (intervalo ABERTO): \00"
@.str.3 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 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 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %56
9: ; preds = %0, %52
%10 = phi i32 [ %53, %52 ], [ %7, %0 ]
%11 = phi i32 [ %54, %52 ], [ 1, %0 ]
%12 = lshr i32 %11, 1
%13 = call i32 @llvm.umax.i32(i32 %12, i32 1)
%14 = icmp ult i32 %11, 2
br i1 %14, label %52, label %15
15: ; preds = %9
%16 = and i32 %13, 1
%17 = icmp ult i32 %11, 4
br i1 %17, label %36, label %18
18: ; preds = %15
%19 = and i32 %13, 1073741822
br label %20
20: ; preds = %20, %18
%21 = phi i32 [ 0, %18 ], [ %32, %20 ]
%22 = phi i32 [ 1, %18 ], [ %33, %20 ]
%23 = phi i32 [ 0, %18 ], [ %34, %20 ]
%24 = urem i32 %11, %22
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i32 %22, i32 0
%27 = add nuw nsw i32 %26, %21
%28 = add nuw nsw i32 %22, 1
%29 = urem i32 %11, %28
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i32 %28, i32 0
%32 = add nuw nsw i32 %31, %27
%33 = add nuw nsw i32 %22, 2
%34 = add i32 %23, 2
%35 = icmp eq i32 %34, %19
br i1 %35, label %36, label %20
36: ; preds = %20, %15
%37 = phi i32 [ undef, %15 ], [ %32, %20 ]
%38 = phi i32 [ 0, %15 ], [ %32, %20 ]
%39 = phi i32 [ 1, %15 ], [ %33, %20 ]
%40 = icmp eq i32 %16, 0
br i1 %40, label %46, label %41
41: ; preds = %36
%42 = urem i32 %11, %39
%43 = icmp eq i32 %42, 0
%44 = select i1 %43, i32 %39, i32 0
%45 = add nuw nsw i32 %44, %38
br label %46
46: ; preds = %36, %41
%47 = phi i32 [ %37, %36 ], [ %45, %41 ]
%48 = icmp eq i32 %47, %11
br i1 %48, label %49, label %52
49: ; preds = %46
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%51 = load i32, i32* %1
br label %52
52: ; preds = %9, %46, %49
%53 = phi i32 [ %10, %46 ], [ %51, %49 ], [ %10, %9 ]
%54 = add nuw nsw i32 %11, 1
%55 = icmp slt i32 %54, %53
br i1 %55, label %9, label %56
56: ; preds = %52, %0
%57 = call i32 @putchar(i32 10)
ret i32 0
}