#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 *, unsigned int *);
int main() {
  unsigned int i, n, m, verifica;
  m = verifica = 0;
  printf("Inserisci numero da verificare: ");
  scanf("%u", &n);
  printf("\nDivisori di %u: ", n);
  for (i = 1; i <= n / 2; i++) {
    if (n % i == 0) {
      m += i;
      printf("%u ", i);
    }
  }
  printf(" = %u\n", m);
  printf("Divisori di %u: ", m);
  for (i = 1; i <= m / 2; i++) {
    if (m % i == 0) {
      verifica += i;
      printf("%u ", i);
    }
  }
  printf(" = %u\n\n", verifica);
  if (n == verifica) {
    printf("Trovato numero amico: %u", m);
  } else {
    printf("%u non ha un numero amico", n);
  }
  printf("\n\n");
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0a(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%esi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
shr    $0x1,%ecx
cmp    %ecx,%eax
ja     11c2 <main+0xa2>
mov    -0xc(%rbp),%eax
xor    %edx,%edx
divl   -0x8(%rbp)
cmp    $0x0,%edx
jne    11af <main+0x8f>
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b4 <main+0x94>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1173 <main+0x53>
mov    -0x10(%rbp),%esi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
shr    $0x1,%ecx
cmp    %ecx,%eax
ja     123a <main+0x11a>
mov    -0x10(%rbp),%eax
xor    %edx,%edx
divl   -0x8(%rbp)
cmp    $0x0,%edx
jne    1227 <main+0x107>
mov    -0x8(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122c <main+0x10c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11eb <main+0xcb>
mov    -0x14(%rbp),%esi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    126d <main+0x14d>
mov    -0x10(%rbp),%esi
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127e <main+0x15e>
mov    -0xc(%rbp),%esi
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%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    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf08(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%ecx
mov    $0x0,%r12d
cmp    $0x2,%ecx
jae    11d4 <main+0xa4>
lea    0xeb1(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8b(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%r12d
jae    121c <main+0xec>
lea    0xe90(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
cmp    %r15d,%esi
jne    1272 <main+0x142>
lea    0xe7a(%rip),%rdi
mov    %r12d,%esi
jmp    1279 <main+0x149>
mov    $0x1,%ebx
lea    0xe53(%rip),%r14
xor    %r12d,%r12d
jmp    11fd <main+0xcd>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rbx),%eax
mov    %ecx,%edx
shr    %edx
cmp    %edx,%ebx
mov    %eax,%ebx
jae    117f <main+0x4f>
mov    %ecx,%eax
xor    %edx,%edx
div    %ebx
test   %edx,%edx
jne    11f0 <main+0xc0>
add    %ebx,%r12d
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%ecx
jmp    11f0 <main+0xc0>
mov    %r12d,%ebp
shr    %ebp
neg    %ebp
mov    $0x1,%ebx
lea    0xe04(%rip),%r14
xor    %r15d,%r15d
jmp    1256 <main+0x126>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
je     11a7 <main+0x77>
mov    %r12d,%eax
xor    %edx,%edx
div    %ebx
test   %edx,%edx
jne    1240 <main+0x110>
add    %ebx,%r15d
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1240 <main+0x110>
lea    0xde6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdbd(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Inserisci numero da verificare: \00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [18 x i8] c"\0ADivisori di %u: \00"
@.str.3 = [4 x i8] c"%u \00"
@.str.4 = [7 x i8] c" = %u\0A\00"
@.str.5 = [17 x i8] c"Divisori di %u: \00"
@.str.6 = [8 x i8] c" = %u\0A\0A\00"
@.str.7 = [25 x i8] c"Trovato numero amico: %u\00"
@.str.8 = [26 x i8] c"%u non ha un numero amico\00"
@.str.9 = [3 x i8] c"\0A\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
store i32 0, i32* %5
store i32 0, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 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* %3)
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %8)
store i32 1, i32* %2
br label %10
10: ; preds = %27, %0
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = udiv i32 %12, 2
%14 = icmp ule i32 %11, %13
br i1 %14, label %15, label %30
15: ; preds = %10
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = urem i32 %16, %17
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %15
%21 = load i32, i32* %2
%22 = load i32, i32* %4
%23 = add i32 %22, %21
store i32 %23, i32* %4
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %20, %15
br label %27
27: ; preds = %26
%28 = load i32, i32* %2
%29 = add i32 %28, 1
store i32 %29, i32* %2
br label %10
30: ; preds = %10
%31 = load i32, i32* %4
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %33)
store i32 1, i32* %2
br label %35
35: ; preds = %52, %30
%36 = load i32, i32* %2
%37 = load i32, i32* %4
%38 = udiv i32 %37, 2
%39 = icmp ule i32 %36, %38
br i1 %39, label %40, label %55
40: ; preds = %35
%41 = load i32, i32* %4
%42 = load i32, i32* %2
%43 = urem i32 %41, %42
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %51
45: ; preds = %40
%46 = load i32, i32* %2
%47 = load i32, i32* %5
%48 = add i32 %47, %46
store i32 %48, i32* %5
%49 = load i32, i32* %2
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %45, %40
br label %52
52: ; preds = %51
%53 = load i32, i32* %2
%54 = add i32 %53, 1
store i32 %54, i32* %2
br label %35
55: ; preds = %35
%56 = load i32, i32* %5
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %56)
%58 = load i32, i32* %3
%59 = load i32, i32* %5
%60 = icmp eq i32 %58, %59
br i1 %60, label %61, label %64
61: ; preds = %55
%62 = load i32, i32* %4
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %62)
br label %67
64: ; preds = %55
%65 = load i32, i32* %3
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %65)
br label %67
67: ; preds = %64, %61
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@.str = [33 x i8] c"Inserisci numero da verificare: \00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [18 x i8] c"\0ADivisori di %u: \00"
@.str.3 = [4 x i8] c"%u \00"
@.str.4 = [7 x i8] c" = %u\0A\00"
@.str.5 = [17 x i8] c"Divisori di %u: \00"
@.str.6 = [8 x i8] c" = %u\0A\0A\00"
@.str.7 = [25 x i8] c"Trovato numero amico: %u\00"
@.str.8 = [26 x i8] c"%u non ha un numero amico\00"
@str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 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 ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %1
%8 = icmp ult i32 %7, 2
br i1 %8, label %25, label %9
9: ; preds = %0, %19
%10 = phi i32 [ %20, %19 ], [ %7, %0 ]
%11 = phi i32 [ %21, %19 ], [ 0, %0 ]
%12 = phi i32 [ %22, %19 ], [ 1, %0 ]
%13 = urem i32 %10, %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %9
%16 = add i32 %11, %12
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%18 = load i32, i32* %1
br label %19
19: ; preds = %9, %15
%20 = phi i32 [ %18, %15 ], [ %10, %9 ]
%21 = phi i32 [ %16, %15 ], [ %11, %9 ]
%22 = add nuw i32 %12, 1
%23 = lshr i32 %20, 1
%24 = icmp ult i32 %12, %23
br i1 %24, label %9, label %25
25: ; preds = %19, %0
%26 = phi i32 [ 0, %0 ], [ %21, %19 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %26)
%29 = icmp ult i32 %26, 2
br i1 %29, label %44, label %30
30: ; preds = %25
%31 = lshr i32 %26, 1
br label %32
32: ; preds = %30, %40
%33 = phi i32 [ %41, %40 ], [ 0, %30 ]
%34 = phi i32 [ %42, %40 ], [ 1, %30 ]
%35 = urem i32 %26, %34
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = add i32 %33, %34
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %40
40: ; preds = %32, %37
%41 = phi i32 [ %38, %37 ], [ %33, %32 ]
%42 = add nuw i32 %34, 1
%43 = icmp eq i32 %34, %31
br i1 %43, label %44, label %32
44: ; preds = %40, %25
%45 = phi i32 [ 0, %25 ], [ %41, %40 ]
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %45)
%47 = load i32, i32* %1
%48 = icmp eq i32 %47, %45
br i1 %48, label %49, label %51
49: ; preds = %44
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %26)
br label %53
51: ; preds = %44
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %47)
br label %53
53: ; preds = %51, %49
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 1
}