#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 calculaDigitos(int, int *, int *);
int calculaResto(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int cpf[11];
  int multiplicadores1[] = {10, 9, 8, 7, 6, 5, 4, 3, 2};
  int multiplicadores2[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2};
  int i, soma, resto, digitoVerificador, digitoVerificador1, digitoVerificador2;
  printf("\nEntre com os digitos de seu CPF, separados por ENTER: ");
  for (i = 0; i <= 10; i = i + 1) {
    scanf("%d", &cpf[i]);
  }
  soma = calculaDigitos(1, cpf, multiplicadores1);
  digitoVerificador1 = calculaResto(soma);
  soma = calculaDigitos(2, cpf, multiplicadores2);
  digitoVerificador2 = calculaResto(soma);
  if ((cpf[9] == digitoVerificador1) && cpf[10] == digitoVerificador2)
    printf("CPF Valido");
  else
    printf("CPF Invalido");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe93(%rip),%rsi
mov    $0x24,%edx
call   1040 <memcpy@plt>
lea    -0x90(%rbp),%rdi
lea    0xeab(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0xa,-0x94(%rbp)
jg     11e4 <main+0x94>
movslq -0x94(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xec5(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11a5 <main+0x55>
lea    -0x30(%rbp),%rsi
lea    -0x60(%rbp),%rdx
mov    $0x1,%edi
call   1060 <calculaDigitos@plt>
mov    %eax,-0x98(%rbp)
mov    -0x98(%rbp),%edi
call   1070 <calculaResto@plt>
mov    %eax,-0xa4(%rbp)
lea    -0x30(%rbp),%rsi
lea    -0x90(%rbp),%rdx
mov    $0x2,%edi
call   1060 <calculaDigitos@plt>
mov    %eax,-0x98(%rbp)
mov    -0x98(%rbp),%edi
call   1070 <calculaResto@plt>
mov    %eax,-0xa8(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0xa4(%rbp),%eax
jne    1268 <main+0x118>
mov    -0x8(%rbp),%eax
cmp    -0xa8(%rbp),%eax
jne    1268 <main+0x118>
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
jmp    1274 <main+0x124>
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    0xed0(%rip),%eax
mov    %eax,0x50(%rsp)
movaps 0xeb5(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe99(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    0xedd(%rip),%rax
mov    %rax,0x80(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xea2(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
lea    0xeea(%rip),%rbx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x24(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x28(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x30(%rsp),%rdx
mov    $0x1,%edi
mov    %r14,%rsi
call   1050 <calculaDigitos@plt>
mov    %eax,%edi
call   1060 <calculaResto@plt>
mov    %eax,%ebx
lea    0x60(%rsp),%rdx
mov    $0x2,%edi
mov    %r14,%rsi
call   1050 <calculaDigitos@plt>
mov    %eax,%edi
call   1060 <calculaResto@plt>
xor    0x24(%rsp),%ebx
xor    0x28(%rsp),%eax
lea    0xe1a(%rip),%rcx
lea    0xe1e(%rip),%rdi
or     %ebx,%eax
cmove  %rcx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.multiplicadores1 = [9 x i32] [i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2]
@__const.main.multiplicadores2 = [10 x i32] [i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2]
@.str = [56 x i8] c"\0AEntre com os digitos de seu CPF, separados por ENTER: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"CPF Valido\00"
@.str.3 = [13 x i8] c"CPF Invalido\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [11 x i32]
%3 = alloca [9 x i32]
%4 = alloca [10 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = bitcast [9 x i32]* %3 to i8*
%12 = bitcast [10 x i32]* %4 to i8*
%13 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %14
14: ; preds = %22, %0
%15 = load i32, i32* %5
%16 = icmp sle i32 %15, 10
br i1 %16, label %17, label %25
17: ; preds = %14
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 %19
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %20)
br label %22
22: ; preds = %17
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %14
25: ; preds = %14
%26 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 0
%27 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 0
%28 = call i32 @calculaDigitos(i32 1, i32* %26, i32* %27)
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = call i32 @calculaResto(i32 %29)
store i32 %30, i32* %9
%31 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 0
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%33 = call i32 @calculaDigitos(i32 2, i32* %31, i32* %32)
store i32 %33, i32* %6
%34 = load i32, i32* %6
%35 = call i32 @calculaResto(i32 %34)
store i32 %35, i32* %10
%36 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 9
%37 = load i32, i32* %36
%38 = load i32, i32* %9
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %47
40: ; preds = %25
%41 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 10
%42 = load i32, i32* %41
%43 = load i32, i32* %10
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %49
47: ; preds = %40, %25
%48 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %47, %45
ret i32 0
}

LLVM IR (-O2):
@__const.main.multiplicadores1 = [9 x i32] [i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2]
@__const.main.multiplicadores2 = [10 x i32] [i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2]
@.str = [56 x i8] c"\0AEntre com os digitos de seu CPF, separados por ENTER: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"CPF Valido\00"
@.str.3 = [13 x i8] c"CPF Invalido\00"
define i32 @main() {
%1 = alloca [11 x i32]
%2 = alloca [9 x i32]
%3 = alloca [10 x i32]
%4 = bitcast [11 x i32]* %1 to i8*
%5 = bitcast [9 x i32]* %2 to i8*
%6 = bitcast [10 x i32]* %3 to i8*
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 1
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%12 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 2
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%14 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 3
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 4
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 5
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
%20 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 6
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %20)
%22 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 7
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
%24 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 8
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %24)
%26 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 9
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %26)
%28 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 10
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %28)
%30 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%31 = call i32 @calculaDigitos(i32 1, i32* %8, i32* %30)
%32 = call i32 @calculaResto(i32 %31)
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%34 = call i32 @calculaDigitos(i32 2, i32* %8, i32* %33)
%35 = call i32 @calculaResto(i32 %34)
%36 = load i32, i32* %26
%37 = icmp eq i32 %36, %32
%38 = load i32, i32* %28
%39 = icmp eq i32 %38, %35
%40 = select i1 %37, i1 %39, i1 false
%41 = select i1 %40, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0)
%42 = call i32 @printf(i8* dereferenceable(1) %41)
ret i32 0
}