#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 *);
void main(void) {
  int numInicial, somaPar, somaImpar, num1, num2, num3, num4;
  printf("Insira o numero inicial de 4 algarismos: ");
  scanf("%i", &numInicial);
  num1 = numInicial % 10;
  num2 = numInicial % 100 / 10;
  num3 = numInicial % 1000 / 100;
  num4 = numInicial / 1000;
  somaImpar = 0;
  somaPar = 0;
  if (num1 % 2 == 0)
    somaPar += num1;
  else
    somaImpar += num1;
  if (num2 % 2 == 0)
    somaPar += num2;
  else
    somaImpar += num2;
  if (num3 % 2 == 0)
    somaPar += num3;
  else
    somaImpar += num3;
  if (num4 % 2 == 0)
    somaPar += num4;
  else
    somaImpar += num4;
  printf("A soma dos pares %i e impar %i", somaPar, somaImpar);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf09(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11c2 <main+0xa2>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11cb <main+0xab>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ed <main+0xcd>
mov    -0x14(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11f6 <main+0xd6>
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1218 <main+0xf8>
mov    -0x18(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1221 <main+0x101>
mov    -0x18(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1243 <main+0x123>
mov    -0x1c(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    124c <main+0x12c>
mov    -0x1c(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf06(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
movslq 0xc(%rsp),%rdx
imul   $0x66666667,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%ecx
mov    %edx,%r9d
sub    %ecx,%r9d
imul   $0x51eb851f,%rdx,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
shr    $0x25,%rcx
add    %esi,%ecx
imul   $0x64,%ecx,%ecx
mov    %edx,%esi
sub    %ecx,%esi
movsbl %sil,%ecx
imul   $0x67,%ecx,%ecx
movzwl %cx,%ecx
movswl %cx,%esi
shr    $0xf,%ecx
shr    $0xa,%esi
add    %cl,%sil
movsbl %sil,%r8d
imul   $0x10624dd3,%rdx,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x26,%rsi
add    %edi,%esi
imul   $0x3e8,%esi,%edi
sub    %edi,%edx
movswl %dx,%edx
imul   $0x147b,%edx,%edi
mov    %edi,%edx
shr    $0x1f,%edx
sar    $0x13,%edi
add    %edx,%edi
mov    %r9d,%edx
and    $0x1,%edx
mov    %edx,%ebx
neg    %ebx
and    %r9d,%ebx
test   %edx,%edx
cmovne %r14d,%r9d
mov    %r8d,%edx
and    $0x1,%edx
mov    %edx,%ebp
neg    %ebp
and    %r8d,%ebp
test   %edx,%edx
cmovne %r14d,%r8d
mov    %edi,%edx
and    $0x1,%edx
mov    %edx,%ecx
neg    %ecx
and    %edi,%ecx
test   %edx,%edx
cmovne %r14d,%edi
mov    %esi,%eax
and    $0x1,%eax
mov    %eax,%edx
neg    %edx
and    %esi,%edx
add    %ebx,%edx
add    %ebp,%edx
add    %ecx,%edx
test   %eax,%eax
cmovne %r14d,%esi
add    %r9d,%esi
add    %r8d,%esi
add    %edi,%esi
lea    0xdfb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Insira o numero inicial de 4 algarismos: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [31 x i8] c"A soma dos pares %i e impar %i\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = srem i32 %10, 10
store i32 %11, i32* %4
%12 = load i32, i32* %1
%13 = srem i32 %12, 100
%14 = sdiv i32 %13, 10
store i32 %14, i32* %5
%15 = load i32, i32* %1
%16 = srem i32 %15, 1000
%17 = sdiv i32 %16, 100
store i32 %17, i32* %6
%18 = load i32, i32* %1
%19 = sdiv i32 %18, 1000
store i32 %19, i32* %7
store i32 0, i32* %3
store i32 0, i32* %2
%20 = load i32, i32* %4
%21 = srem i32 %20, 2
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %0
%24 = load i32, i32* %4
%25 = load i32, i32* %2
%26 = add nsw i32 %25, %24
store i32 %26, i32* %2
br label %31
27: ; preds = %0
%28 = load i32, i32* %4
%29 = load i32, i32* %3
%30 = add nsw i32 %29, %28
store i32 %30, i32* %3
br label %31
31: ; preds = %27, %23
%32 = load i32, i32* %5
%33 = srem i32 %32, 2
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = load i32, i32* %5
%37 = load i32, i32* %2
%38 = add nsw i32 %37, %36
store i32 %38, i32* %2
br label %43
39: ; preds = %31
%40 = load i32, i32* %5
%41 = load i32, i32* %3
%42 = add nsw i32 %41, %40
store i32 %42, i32* %3
br label %43
43: ; preds = %39, %35
%44 = load i32, i32* %6
%45 = srem i32 %44, 2
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %43
%48 = load i32, i32* %6
%49 = load i32, i32* %2
%50 = add nsw i32 %49, %48
store i32 %50, i32* %2
br label %55
51: ; preds = %43
%52 = load i32, i32* %6
%53 = load i32, i32* %3
%54 = add nsw i32 %53, %52
store i32 %54, i32* %3
br label %55
55: ; preds = %51, %47
%56 = load i32, i32* %7
%57 = srem i32 %56, 2
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %55
%60 = load i32, i32* %7
%61 = load i32, i32* %2
%62 = add nsw i32 %61, %60
store i32 %62, i32* %2
br label %67
63: ; preds = %55
%64 = load i32, i32* %7
%65 = load i32, i32* %3
%66 = add nsw i32 %65, %64
store i32 %66, i32* %3
br label %67
67: ; preds = %63, %59
%68 = load i32, i32* %2
%69 = load i32, i32* %3
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %68, i32 %69)
ret void
}

LLVM IR (-O2):
@.str = [42 x i8] c"Insira o numero inicial de 4 algarismos: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [31 x i8] c"A soma dos pares %i e impar %i\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 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 = srem i32 %5, 10
%7 = srem i32 %5, 100
%8 = trunc i32 %7 to i8
%9 = sdiv i8 %8, 10
%10 = sext i8 %9 to i32
%11 = srem i32 %5, 1000
%12 = trunc i32 %11 to i16
%13 = sdiv i16 %12, 100
%14 = sext i16 %13 to i32
%15 = sdiv i32 %5, 1000
%16 = and i32 %6, 1
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i32 0, i32 %6
%19 = select i1 %17, i32 %6, i32 0
%20 = and i32 %10, 1
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i32 0, i32 %10
%23 = select i1 %21, i32 %10, i32 0
%24 = and i32 %14, 1
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i32 0, i32 %14
%27 = select i1 %25, i32 %14, i32 0
%28 = and i32 %15, 1
%29 = icmp eq i32 %28, 0
%30 = select i1 %29, i32 0, i32 %15
%31 = add nsw i32 %30, %18
%32 = add nsw i32 %31, %22
%33 = add nsw i32 %32, %26
%34 = select i1 %29, i32 %15, i32 0
%35 = add nsw i32 %34, %19
%36 = add nsw i32 %35, %23
%37 = add nsw i32 %36, %27
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %37, i32 %33)
ret void
}