#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 EXIT_SUCCESS;
int getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char **argv) {
  char cadena[10];
  int i = 1, car;
  printf("Introduce una palabra: ");
  scanf("%c", cadena);
  while (i < 10 - 1 && (car = getchar()) != '\n') {
    cadena[i] = car;
    i++;
  }
  cadena[i] = 0;
  printf("La longitud de la palabra introducida es: %d", i);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x20(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1a(%rbp),%rsi
lea    0xeb2(%rip),%rdi
call   1050 <scanf@plt>
xor    %eax,%eax
cmpl   $0x9,-0x20(%rbp)
mov    %al,-0x25(%rbp)
jge    118d <main+0x5d>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xa,%eax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    119d <main+0x6d>
jmp    11b8 <main+0x88>
mov    -0x24(%rbp),%eax
mov    %al,%cl
movslq -0x20(%rbp),%rax
mov    %cl,-0x1a(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116b <main+0x3b>
movslq -0x20(%rbp),%rax
movb   $0x0,-0x1a(%rbp,%rax,1)
mov    -0x20(%rbp),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    0xe(%rsp),%rsi
call   1050 <scanf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x1,%esi
cmp    $0xa,%eax
je     1208 <main+0xd8>
mov    %al,0xf(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x2,%esi
cmp    $0xa,%eax
je     1208 <main+0xd8>
mov    %al,0x10(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x3,%esi
cmp    $0xa,%eax
je     1208 <main+0xd8>
mov    %al,0x11(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x4,%esi
cmp    $0xa,%eax
je     1208 <main+0xd8>
mov    %al,0x12(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x5,%esi
cmp    $0xa,%eax
je     1208 <main+0xd8>
mov    %al,0x13(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x6,%esi
cmp    $0xa,%eax
je     1208 <main+0xd8>
mov    %al,0x14(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x7,%esi
cmp    $0xa,%eax
je     1208 <main+0xd8>
mov    %al,0x15(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x8,%esi
cmp    $0xa,%eax
je     1208 <main+0xd8>
mov    %al,0x16(%rsp)
mov    $0x9,%esi
mov    %esi,%eax
movb   $0x0,0xe(%rsp,%rax,1)
lea    0xe05(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Introduce una palabra: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [45 x i8] c"La longitud de la palabra introducida es: %d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %20, %2
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 9
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = call i32 (...) @getchar()
store i32 %16, i32* %8
%17 = icmp ne i32 %16, 10
br label %18
18: ; preds = %15, %12
%19 = phi i1 [ false, %12 ], [ %17, %15 ]
br i1 %19, label %20, label %28
20: ; preds = %18
%21 = load i32, i32* %8
%22 = trunc i32 %21 to i8
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 %24
store i8 %22, i8* %25
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %12
28: ; preds = %18
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 %30
store i8 0, i8* %31
%32 = load i32, i32* %7
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = load i32, i32* @EXIT_SUCCESS
ret i32 %34
}

LLVM IR (-O2):
@.str = [24 x i8] c"Introduce una palabra: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [45 x i8] c"La longitud de la palabra introducida es: %d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = call i32 (...) @getchar()
%8 = icmp eq i32 %7, 10
br i1 %8, label %47, label %9
9: ; preds = %2
%10 = trunc i32 %7 to i8
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 1
store i8 %10, i8* %11
%12 = call i32 (...) @getchar()
%13 = icmp eq i32 %12, 10
br i1 %13, label %47, label %14
14: ; preds = %9
%15 = trunc i32 %12 to i8
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 2
store i8 %15, i8* %16
%17 = call i32 (...) @getchar()
%18 = icmp eq i32 %17, 10
br i1 %18, label %47, label %19
19: ; preds = %14
%20 = trunc i32 %17 to i8
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 3
store i8 %20, i8* %21
%22 = call i32 (...) @getchar()
%23 = icmp eq i32 %22, 10
br i1 %23, label %47, label %24
24: ; preds = %19
%25 = trunc i32 %22 to i8
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 4
store i8 %25, i8* %26
%27 = call i32 (...) @getchar()
%28 = icmp eq i32 %27, 10
br i1 %28, label %47, label %29
29: ; preds = %24
%30 = trunc i32 %27 to i8
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 5
store i8 %30, i8* %31
%32 = call i32 (...) @getchar()
%33 = icmp eq i32 %32, 10
br i1 %33, label %47, label %34
34: ; preds = %29
%35 = trunc i32 %32 to i8
%36 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 6
store i8 %35, i8* %36
%37 = call i32 (...) @getchar()
%38 = icmp eq i32 %37, 10
br i1 %38, label %47, label %39
39: ; preds = %34
%40 = trunc i32 %37 to i8
%41 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 7
store i8 %40, i8* %41
%42 = call i32 (...) @getchar()
%43 = icmp eq i32 %42, 10
br i1 %43, label %47, label %44
44: ; preds = %39
%45 = trunc i32 %42 to i8
%46 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 8
store i8 %45, i8* %46
br label %47
47: ; preds = %44, %39, %34, %29, %24, %19, %14, %9, %2
%48 = phi i32 [ 1, %2 ], [ 2, %9 ], [ 3, %14 ], [ 4, %19 ], [ 5, %24 ], [ 6, %29 ], [ 7, %34 ], [ 8, %39 ], [ 9, %44 ]
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %49
store i8 0, i8* %50
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %48)
%52 = load i32, i32* @EXIT_SUCCESS
ret i32 %52
}