#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int c, totalc;
  c = 0;
  totalc = 0;
  printf("Escribe una frase: ");
  while ((c = getchar()) != '\n' && c != EOF) {
    totalc++;
  }
  printf("Total de caracteres: %ld\n", totalc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xd(%rbp)
je     1177 <main+0x57>
mov    -0x8(%rbp),%eax
mov    0x2e79(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1187 <main+0x67>
jmp    1195 <main+0x75>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114b <main+0x2b>
mov    -0xc(%rbp),%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%ebx
mov    0x2eaa(%rip),%r14
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0x1,%ebx
cmp    $0xa,%eax
je     1154 <main+0x34>
cmp    (%r14),%eax
jne    1140 <main+0x20>
lea    0xeb9(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Escribe una frase: \00"
@EOF = global i32 0
@.str.1 = [26 x i8] c"Total de caracteres: %ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %14, %0
%6 = call i32 (...) @getchar()
store i32 %6, i32* %2
%7 = icmp ne i32 %6, 10
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = load i32, i32* %2
%10 = load i32, i32* @EOF
%11 = icmp ne i32 %9, %10
br label %12
12: ; preds = %8, %5
%13 = phi i1 [ false, %5 ], [ %11, %8 ]
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %5
17: ; preds = %12
%18 = load i32, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Escribe una frase: \00"
@EOF = global i32 0
@.str.1 = [26 x i8] c"Total de caracteres: %ld\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %2, %0
%3 = phi i32 [ 0, %0 ], [ %9, %2 ]
%4 = tail call i32 (...) @getchar()
%5 = icmp ne i32 %4, 10
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %4, %6
%8 = select i1 %5, i1 %7, i1 false
%9 = add nuw nsw i32 %3, 1
br i1 %8, label %2, label %10
10: ; preds = %2
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %3)
ret i32 0
}