#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  char a[80 + 1];
  int i;
  printf("Introduce una cadena (max %d cars.): ", 80);
  gets(a);
  i = 0;
  while (a[i++])
    ;
  printf("Longituid de la cadena: %d\n", i - 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x50,%esi
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1040 <gets@plt>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x64(%rbp)
cltq
cmpb   $0x0,-0x60(%rbp,%rax,1)
je     116d <main+0x4d>
jmp    1150 <main+0x30>
mov    -0x64(%rbp),%esi
sub    $0x1,%esi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
lea    0xed4(%rip),%rdi
mov    $0x50,%esi
call   1030 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <gets@plt>
mov    $0xffffffff,%esi
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%esi
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1150 <main+0x30>
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Introduce una cadena (max %d cars.): \00"
@.str.1 = [28 x i8] c"Longituid de la cadena: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [81 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 80)
%5 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%6 = call i32 @gets(i8* %5)
store i32 0, i32* %3
br label %7
7: ; preds = %14, %0
%8 = load i32, i32* %3
%9 = add nsw i32 %8, 1
store i32 %9, i32* %3
%10 = sext i32 %8 to i64
%11 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %7
br label %7
15: ; preds = %7
%16 = load i32, i32* %3
%17 = sub nsw i32 %16, 1
%18 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"Introduce una cadena (max %d cars.): \00"
@.str.1 = [28 x i8] c"Longituid de la cadena: %d\0A\00"
define i32 @main() {
%1 = alloca [81 x i8]
%2 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 80)
%4 = call i32 @gets(i8* %2)
br label %5
5: ; preds = %5, %0
%6 = phi i64 [ %7, %5 ], [ 0, %0 ]
%7 = add nuw i64 %6, 1
%8 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 %6
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %5
11: ; preds = %5
%12 = trunc i64 %6 to i32
%13 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %12)
ret i32 0
}