#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 longitud_string(char *);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(void) {
  char string1[] = "Hola a todos";
  char string2[200];
  char string3[] = "Hola a todos";
  int tamanio = 0;
  printf("a) \n");
  printf("cadena: %s\n", string1);
  printf("longitud cadena: %d\n", longitud_string(string1));
  strcpy(string2, "leer libros y revistas");
  printf("cadena2: %s\n", string2);
  printf("longitud cadena: %d\n", longitud_string(string2));
  printf("b) \n");
  while ((tamanio = scanf("%s", string3)) > 0)
    printf("Longitud %s: %d \n", string3, strlen(string3));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x11(%rbp)
mov    0xe95(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xe90(%rip),%al
mov    %al,-0x5(%rbp)
mov    0xe7a(%rip),%rax
mov    %rax,-0xed(%rbp)
mov    0xe75(%rip),%eax
mov    %eax,-0xe5(%rbp)
mov    0xe6d(%rip),%al
mov    %al,-0xe1(%rbp)
movl   $0x0,-0xf4(%rbp)
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x11(%rbp),%rsi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x11(%rbp),%rdi
call   1070 <longitud_string@plt>
mov    %eax,%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xe0(%rbp),%rdi
call   1070 <longitud_string@plt>
mov    %eax,%esi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xed(%rbp),%rsi
lea    0xe14(%rip),%rdi
call   1060 <scanf@plt>
mov    %eax,-0xf4(%rbp)
cmp    $0x0,%eax
jle    1292 <main+0x142>
lea    -0xed(%rbp),%rax
mov    %rax,-0x100(%rbp)
lea    -0xed(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x100(%rbp),%rsi
mov    %eax,%edx
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    123a <main+0xea>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xf0,%rsp
movabs $0x736f646f742061,%rax
mov    %rax,0x15(%rsp)
movabs $0x74206120616c6f48,%rcx
61 20 74
mov    %rcx,0x10(%rsp)
mov    %rax,0x5(%rsp)
mov    %rcx,(%rsp)
lea    0xecd(%rip),%rdi
call   1040 <puts@plt>
lea    0xe67(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1080 <longitud_string@plt>
lea    0xe55(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe57(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe5a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1080 <longitud_string@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe5b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe36(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
test   %eax,%eax
jle    1266 <main+0x106>
mov    %rsp,%rbx
lea    0xe23(%rip),%r14
lea    0xe19(%rip),%r15
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
test   %eax,%eax
jg     1240 <main+0xe0>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.string1 = [13 x i8] c"Hola a todos\00"
@__const.main.string3 = [13 x i8] c"Hola a todos\00"
@.str = [5 x i8] c"a) \0A\00"
@.str.1 = [12 x i8] c"cadena: %s\0A\00"
@.str.2 = [21 x i8] c"longitud cadena: %d\0A\00"
@.str.3 = [23 x i8] c"leer libros y revistas\00"
@.str.4 = [13 x i8] c"cadena2: %s\0A\00"
@.str.5 = [5 x i8] c"b) \0A\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [18 x i8] c"Longitud %s: %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [13 x i8]
%3 = alloca [200 x i8]
%4 = alloca [13 x i8]
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [13 x i8]* %2 to i8*
%7 = bitcast [13 x i8]* %4 to i8*
store i32 0, i32* %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%12 = call i32 @longitud_string(i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%19 = call i32 @longitud_string(i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %22
22: ; preds = %26, %0
%23 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %23)
store i32 %24, i32* %5
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%28 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%29 = call i32 @strlen(i8* %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %27, i32 %29)
br label %22
31: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
@__const.main.string3 = [13 x i8] c"Hola a todos\00"
@.str.1 = [12 x i8] c"cadena: %s\0A\00"
@.str.2 = [21 x i8] c"longitud cadena: %d\0A\00"
@.str.3 = [23 x i8] c"leer libros y revistas\00"
@.str.4 = [13 x i8] c"cadena2: %s\0A\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [18 x i8] c"Longitud %s: %d \0A\00"
@str = [4 x i8] c"a) \00"
@str.8 = [4 x i8] c"b) \00"
define i32 @main() {
%1 = alloca [13 x i8]
%2 = alloca [200 x i8]
%3 = alloca [13 x i8]
%4 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = call i32 @longitud_string(i8* %4)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%13 = call i32 @longitud_string(i8* %5)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.8, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %0, %18
%19 = call i32 @strlen(i8* %6)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %6, i32 %19)
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%22 = icmp sgt i32 %21, 0
br i1 %22, label %18, label %23
23: ; preds = %18, %0
ret i32 0
}