#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 getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int C, C1, C2, C3, Cinverso, Soma, Mult1, Mult2, Mult3, SomaMult, CodVer;
  printf("\n ** Calculo do digito verificador de uma Conta Corrente **\n\n");
  printf("Informe o numero da conta corrente, c/3 digitos sendo o 1 numero "
         "diferente de 0: ");
  scanf("%i", &C);
  C1 = C / 100;
  C2 = (C % 100) / 10;
  C3 = ((C % 100) % 10) / 1;
  Cinverso = C3 * 100 + C2 * 10 + C1;
  Soma = C + Cinverso;
  Mult1 = (Soma / 100) * 1;
  Mult2 = ((Soma % 100) / 10) * 2;
  Mult3 = (((Soma % 100) % 10) / 1) * 3;
  SomaMult = Mult1 + Mult2 + Mult3;
  CodVer = (SomaMult % 10);
  printf("\nO digito verificador é: %i.\n\n", CodVer);
  printf("<<Marco Tulio>>");
  getchar(), getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf35(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x1,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
imul   $0x64,-0x10(%rbp),%eax
imul   $0xa,-0xc(%rbp),%ecx
add    %ecx,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
shl    $0x0,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
shl    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x1,%ecx
cltd
idiv   %ecx
imul   $0x3,%eax,%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf3d(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
movslq 0x4(%rsp),%r8
imul   $0x51eb851f,%r8,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%esi
mov    %r8d,%edx
sub    %esi,%edx
movsbl %dl,%esi
imul   $0x67,%esi,%esi
movzwl %si,%esi
movswl %si,%edi
shr    $0xf,%esi
shr    $0xa,%edi
add    %sil,%dil
movzbl %dil,%esi
add    %esi,%esi
lea    (%rsi,%rsi,4),%esi
mov    %edx,%eax
sub    %sil,%al
movsbl %al,%eax
imul   $0x64,%eax,%esi
add    %r8d,%edx
add    %ecx,%edx
sub    %eax,%edx
add    %esi,%edx
movslq %edx,%rcx
imul   $0x51eb851f,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rax
add    %edx,%eax
imul   $0x64,%eax,%edx
sub    %edx,%ecx
movsbl %cl,%edx
imul   $0x67,%edx,%edx
movzwl %dx,%edx
movswl %dx,%esi
shr    $0xf,%edx
shr    $0xa,%esi
add    %dl,%sil
movsbl %sil,%edx
movzbl %dl,%esi
add    %esi,%esi
lea    (%rsi,%rsi,4),%esi
sub    %sil,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,2),%ecx
movsbl %cl,%ecx
lea    (%rax,%rdx,2),%eax
add    %ecx,%eax
movslq %eax,%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
lea    0xe23(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [62 x i8] c"\0A ** Calculo do digito verificador de uma Conta Corrente **\0A\0A\00"
@.str.1 = [82 x i8] c"Informe o numero da conta corrente, c/3 digitos sendo o 1 numero diferente de 0: \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [32 x i8] c"\0AO digito verificador \C3\A9: %i.\0A\0A\00"
@.str.4 = [16 x i8] c"<<Marco Tulio>>\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
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = sdiv i32 %15, 100
store i32 %16, i32* %2
%17 = load i32, i32* %1
%18 = srem i32 %17, 100
%19 = sdiv i32 %18, 10
store i32 %19, i32* %3
%20 = load i32, i32* %1
%21 = srem i32 %20, 100
%22 = srem i32 %21, 10
%23 = sdiv i32 %22, 1
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = mul nsw i32 %24, 100
%26 = load i32, i32* %3
%27 = mul nsw i32 %26, 10
%28 = add nsw i32 %25, %27
%29 = load i32, i32* %2
%30 = add nsw i32 %28, %29
store i32 %30, i32* %5
%31 = load i32, i32* %1
%32 = load i32, i32* %5
%33 = add nsw i32 %31, %32
store i32 %33, i32* %6
%34 = load i32, i32* %6
%35 = sdiv i32 %34, 100
%36 = mul nsw i32 %35, 1
store i32 %36, i32* %7
%37 = load i32, i32* %6
%38 = srem i32 %37, 100
%39 = sdiv i32 %38, 10
%40 = mul nsw i32 %39, 2
store i32 %40, i32* %8
%41 = load i32, i32* %6
%42 = srem i32 %41, 100
%43 = srem i32 %42, 10
%44 = sdiv i32 %43, 1
%45 = mul nsw i32 %44, 3
store i32 %45, i32* %9
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = add nsw i32 %46, %47
%49 = load i32, i32* %9
%50 = add nsw i32 %48, %49
store i32 %50, i32* %10
%51 = load i32, i32* %10
%52 = srem i32 %51, 10
store i32 %52, i32* %11
%53 = load i32, i32* %11
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%56 = call i32 (...) @getchar()
%57 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [82 x i8] c"Informe o numero da conta corrente, c/3 digitos sendo o 1 numero diferente de 0: \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [32 x i8] c"\0AO digito verificador \C3\A9: %i.\0A\0A\00"
@.str.4 = [16 x i8] c"<<Marco Tulio>>\00"
@str = [61 x i8] c"\0A ** Calculo do digito verificador de uma Conta Corrente **\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = sdiv i32 %6, 100
%8 = srem i32 %6, 100
%9 = trunc i32 %8 to i8
%10 = srem i8 %9, 10
%11 = sext i8 %10 to i32
%12 = mul nsw i32 %11, 100
%13 = add i32 %8, %6
%14 = add i32 %13, %7
%15 = sub i32 %14, %11
%16 = add i32 %15, %12
%17 = sdiv i32 %16, 100
%18 = srem i32 %16, 100
%19 = trunc i32 %18 to i8
%20 = sdiv i8 %19, 10
%21 = sext i8 %20 to i32
%22 = shl nsw i32 %21, 1
%23 = srem i8 %19, 10
%24 = mul nsw i8 %23, 3
%25 = sext i8 %24 to i32
%26 = add nsw i32 %22, %17
%27 = add nsw i32 %26, %25
%28 = srem i32 %27, 10
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 (...) @getchar()
%32 = call i32 (...) @getchar()
ret i32 0
}