#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char cadena[15];
  int i;
  char c;
  printf("Introduce una cadena: ");
  while ((c = getchar()) != '\n') {
    cadena[i] = c;
    i++;
  }
  cadena[i] = '\0';
  printf("La cadena introducida es: %s\n", cadena);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     116c <main+0x4c>
mov    -0x19(%rbp),%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x13(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113d <main+0x1d>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x13(%rbp,%rax,1)
lea    -0x13(%rbp),%rsi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     1178 <main+0x58>
lea    0x1(%rsp),%rbx
movabs $0x100000000,%r15
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
add    %r15,%r14
mov    %al,(%rbx)
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0x1,%rbx
cmp    $0xa,%al
jne    1160 <main+0x40>
sar    $0x20,%r14
movb   $0x0,0x1(%rsp,%r14,1)
lea    0xe92(%rip),%rdi
lea    0x1(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Introduce una cadena: \00"
@.str.1 = [30 x i8] c"La cadena introducida es: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x i8]
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %10, %0
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %4
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 10
br i1 %9, label %10, label %17
10: ; preds = %6
%11 = load i8, i8* %4
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 %13
store i8 %11, i8* %14
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %6
17: ; preds = %6
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 %19
store i8 0, i8* %20
%21 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Introduce una cadena: \00"
@.str.1 = [30 x i8] c"La cadena introducida es: %s\0A\00"
define i32 @main() {
%1 = alloca [15 x i8]
%2 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = tail call signext i8 (...) @getchar()
%5 = icmp eq i8 %4, 10
br i1 %5, label %16, label %6
6: ; preds = %0, %6
%7 = phi i64 [ %10, %6 ], [ 0, %0 ]
%8 = phi i8 [ %11, %6 ], [ %4, %0 ]
%9 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 %7
store i8 %8, i8* %9
%10 = add i64 %7, 1
%11 = tail call signext i8 (...) @getchar()
%12 = icmp eq i8 %11, 10
br i1 %12, label %13, label %6
13: ; preds = %6
%14 = shl i64 %10, 32
%15 = ashr exact i64 %14, 32
br label %16
16: ; preds = %13, %0
%17 = phi i64 [ 0, %0 ], [ %15, %13 ]
%18 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 %17
store i8 0, i8* %18
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 0
}