#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, numInv, 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;
  num3 *= 10;
  num2 *= 100;
  num1 *= 1000;
  numInv = num1 + num2 + num3 + num4;
  if (numInicial == numInv)
    printf("Capiuca");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
imul   $0xa,-0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
imul   $0x64,-0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
imul   $0x3e8,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11cf <main+0xaf>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
lea    0xef6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
movslq 0x4(%rsp),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%edx
mov    %eax,%ecx
sub    %edx,%ecx
imul   $0x51eb851f,%rax,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
shr    $0x25,%rdx
add    %esi,%edx
imul   $0x64,%edx,%edx
mov    %eax,%esi
sub    %edx,%esi
movsbl %sil,%edx
imul   $0x67,%edx,%edx
movzwl %dx,%edx
movswl %dx,%esi
shr    $0xf,%edx
shr    $0xa,%esi
add    %dl,%sil
movsbl %sil,%r8d
imul   $0x10624dd3,%rax,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x26,%rsi
add    %edi,%esi
imul   $0x3e8,%esi,%edi
mov    %eax,%edx
sub    %edi,%edx
movswl %dx,%edx
imul   $0x147b,%edx,%edx
mov    %edx,%edi
shr    $0x1f,%edi
sar    $0x13,%edx
add    %edi,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
movswl %dx,%edx
imul   $0x64,%r8d,%edi
imul   $0x3e8,%ecx,%ecx
add    %esi,%ecx
add    %edi,%ecx
add    %edx,%ecx
cmp    %ecx,%eax
jne    11ee <main+0xce>
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
pop    %rax
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 = [8 x i8] c"Capiuca\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = srem i32 %9, 10
store i32 %10, i32* %3
%11 = load i32, i32* %1
%12 = srem i32 %11, 100
%13 = sdiv i32 %12, 10
store i32 %13, i32* %4
%14 = load i32, i32* %1
%15 = srem i32 %14, 1000
%16 = sdiv i32 %15, 100
store i32 %16, i32* %5
%17 = load i32, i32* %1
%18 = sdiv i32 %17, 1000
store i32 %18, i32* %6
%19 = load i32, i32* %5
%20 = mul nsw i32 %19, 10
store i32 %20, i32* %5
%21 = load i32, i32* %4
%22 = mul nsw i32 %21, 100
store i32 %22, i32* %4
%23 = load i32, i32* %3
%24 = mul nsw i32 %23, 1000
store i32 %24, i32* %3
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = add nsw i32 %25, %26
%28 = load i32, i32* %5
%29 = add nsw i32 %27, %28
%30 = load i32, i32* %6
%31 = add nsw i32 %29, %30
store i32 %31, i32* %2
%32 = load i32, i32* %1
%33 = load i32, i32* %2
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %37
35: ; preds = %0
%36 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %37
37: ; preds = %35, %0
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 = [8 x i8] c"Capiuca\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @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 = sdiv i32 %5, 1000
%15 = mul nsw i16 %13, 10
%16 = sext i16 %15 to i32
%17 = mul nsw i32 %10, 100
%18 = mul nsw i32 %6, 1000
%19 = add nsw i32 %18, %14
%20 = add nsw i32 %19, %17
%21 = add nsw i32 %20, %16
%22 = icmp eq i32 %5, %21
br i1 %22, label %23, label %25
23: ; preds = %0
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %23, %0
ret void
}