#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 *, long *);
int main(void) {
  int contador = 0;
  int d[16];
  printf("Digite o número do seu cartão de crédito:\n");
  long number_cartao;
  scanf("%ld", &number_cartao);
  printf("%ld\n", number_cartao);
  while (number_cartao != 0) {
    number_cartao /= 10;
    d[++contador] = number_cartao;
  }
  printf("Seu cartão tem %d números.\n", contador);
  printf("Item 0: %d", d[0]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
lea    -0x58(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x58(%rbp),%rsi
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x58(%rbp)
je     119d <main+0x7d>
mov    -0x58(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cltq
mov    %ecx,-0x50(%rbp,%rax,4)
jmp    1166 <main+0x46>
mov    -0x8(%rbp),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb7(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%rsi
lea    0xea5(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdx
test   %rdx,%rdx
je     11b4 <main+0x84>
xor    %ebx,%ebx
movabs $0x6666666666666667,%rsi
66 66 66
xchg   %ax,%ax
mov    %rdx,%rcx
mov    %rdx,%rax
imul   %rsi
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
mov    %edx,0x14(%rsp,%rbx,4)
add    $0x1,%rbx
add    $0x9,%rcx
cmp    $0x12,%rcx
ja     1180 <main+0x50>
mov    %rdx,0x8(%rsp)
mov    0x10(%rsp),%ebp
jmp    11b4 <main+0x84>
lea    0xe4e(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Digite o n\C3\BAmero do seu cart\C3\A3o de cr\C3\A9dito:\0A\00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
@.str.3 = [30 x i8] c"Seu cart\C3\A3o tem %d n\C3\BAmeros.\0A\00"
@.str.4 = [11 x i8] c"Item 0: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [16 x i32]
%4 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %4)
%7 = load i64, i64* %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %7)
br label %9
9: ; preds = %12, %0
%10 = load i64, i64* %4
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = load i64, i64* %4
%14 = sdiv i64 %13, 10
store i64 %14, i64* %4
%15 = load i64, i64* %4
%16 = trunc i64 %15 to i32
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 %19
store i32 %16, i32* %20
br label %9
21: ; preds = %9
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
@.str.3 = [30 x i8] c"Seu cart\C3\A3o tem %d n\C3\BAmeros.\0A\00"
@.str.4 = [11 x i8] c"Item 0: %d\00"
@str = [45 x i8] c"Digite o n\C3\BAmero do seu cart\C3\A3o de cr\C3\A9dito:\00"
define i32 @main() {
%1 = alloca [16 x i32]
%2 = alloca i64
%3 = bitcast [16 x i32]* %1 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%5 = bitcast i64* %2 to i8*
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%7 = load i64, i64* %2
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %7)
%9 = load i64, i64* %2
%10 = icmp eq i64 %9, 0
br i1 %10, label %24, label %11
11: ; preds = %0, %11
%12 = phi i64 [ %16, %11 ], [ 0, %0 ]
%13 = phi i64 [ %14, %11 ], [ %9, %0 ]
%14 = sdiv i64 %13, 10
%15 = trunc i64 %14 to i32
%16 = add nuw nsw i64 %12, 1
%17 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 %16
store i32 %15, i32* %17
%18 = add i64 %13, 9
%19 = icmp ult i64 %18, 19
br i1 %19, label %20, label %11
20: ; preds = %11
%21 = trunc i64 %16 to i32
store i64 %14, i64* %2
%22 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 0
%23 = load i32, i32* %22
br label %24
24: ; preds = %20, %0
%25 = phi i32 [ %23, %20 ], [ undef, %0 ]
%26 = phi i32 [ %21, %20 ], [ 0, %0 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %25)
ret i32 0
}