int main(void) {
  char string1[] = "Hola a todos";
  char string2[200];
  char *ap_string1, *ap_string2;
  ap_string1 = &string1;
  ap_string2 = &string2;
  printf("cadena: %s\n", string1);
  printf("longitud cadena: %d\n", longitud_string(ap_string1));
  strcpy(string2, "leer libros y revistas");
  printf("cadena2: %s\n", string2);
  printf("longitud cadena: %d\n", longitud_string(ap_string2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x11(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xeb0(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0x11(%rbp),%rax
mov    %rax,-0xe8(%rbp)
lea    -0xe0(%rbp),%rax
mov    %rax,-0xf0(%rbp)
lea    -0x11(%rbp),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xe8(%rbp),%rdi
mov    $0x0,%al
call   1050 <longitud_string@plt>
mov    %eax,%esi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xf0(%rbp),%rdi
mov    $0x0,%al
call   1050 <longitud_string@plt>
mov    %eax,%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xd8,%rsp
movabs $0x736f646f742061,%rax
mov    %rax,0x5(%rsp)
movabs $0x74206120616c6f48,%rax
61 20 74
mov    %rax,(%rsp)
lea    0xebf(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <longitud_string@plt>
lea    0xead(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movabs $0x73617473697665,%rax
mov    %rax,0x1f(%rsp)
movups 0xea0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xeab(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <longitud_string@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.string1 = [13 x i8] c"Hola a todos\00"
@.str = [12 x i8] c"cadena: %s\0A\00"
@.str.1 = [21 x i8] c"longitud cadena: %d\0A\00"
@.str.2 = [23 x i8] c"leer libros y revistas\00"
@.str.3 = [13 x i8] c"cadena2: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [13 x i8]
%3 = alloca [200 x i8]
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
%6 = bitcast [13 x i8]* %2 to i8*
%7 = bitcast [13 x i8]* %2 to i8*
store i8* %7, i8** %4
%8 = bitcast [200 x i8]* %3 to i8*
store i8* %8, i8** %5
%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, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %4
%12 = call i32 (i8*, ...) bitcast (i32 (...)* @longitud_string to i32 (i8*, ...)*)(i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%15 = call i8* @strcpy(i8* %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, 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.3, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %5
%19 = call i32 (i8*, ...) bitcast (i32 (...)* @longitud_string to i32 (i8*, ...)*)(i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %19)
ret i32 0
}

LLVM IR (-O2):
@__const.main.string1 = [13 x i8] c"Hola a todos\00"
@.str = [12 x i8] c"cadena: %s\0A\00"
@.str.1 = [21 x i8] c"longitud cadena: %d\0A\00"
@.str.2 = [23 x i8] c"leer libros y revistas\00"
@.str.3 = [13 x i8] c"cadena2: %s\0A\00"
define i32 @main() {
%1 = alloca [13 x i8]
%2 = alloca [200 x i8]
%3 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = call i32 (i8*, ...) bitcast (i32 (...)* @longitud_string to i32 (i8*, ...)*)(i8* %3)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%9 = call i32 (i8*, ...) bitcast (i32 (...)* @longitud_string to i32 (i8*, ...)*)(i8* %4)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %9)
ret i32 0
}