int main() {
  char a[20] = "hola ";
  char b[] = {'m', 'u', 'n', 'd', 'o', '!', '\0'};
  a[0] = 'H';
  char *c = strcat(a, b);
  printf("El string c es: %s\n", c);
  printf("La longitud de c es: %d\n", strlen(c));
  char *p = strchr(c, 'm');
  *p = 'M';
  printf("Ahora c es: %s\n", c);
  if (strcmp("hola", "mundo") <= 0) {
    printf("primero digo hola y luego mundo\n");
  }
  char *d = "a todo el ";
  char *cd = malloc(strlen(c) + strlen(d));
  memcpy(cd, c, 5);
  memcpy(cd + 5, d, strlen(d));
  memcpy(cd + 5 + strlen(d), c + 5, 6);
  printf("El string c finalmente dice: %s\n", cd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe85(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xe80(%rip),%eax
mov    %eax,-0x27(%rbp)
mov    0xe7a(%rip),%ax
mov    %ax,-0x23(%rbp)
mov    0xe72(%rip),%al
mov    %al,-0x21(%rbp)
movb   $0x48,-0x20(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x27(%rbp),%rsi
call   1080 <strcat@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rsi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    $0x6d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movb   $0x4d,(%rax)
mov    -0x30(%rbp),%rsi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe4d(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x68(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x68(%rbp),%rdi
add    %rax,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%edx
mov    %edx,(%rax)
mov    0x4(%rcx),%cl
mov    %cl,0x4(%rax)
mov    -0x48(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x60(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    %rax,%rdx
call   1060 <memcpy@plt>
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
mov    -0x30(%rbp),%rdx
mov    0x5(%rdx),%esi
mov    %esi,0x5(%rax,%rcx,1)
mov    0x9(%rdx),%dx
mov    %dx,0x9(%rax,%rcx,1)
mov    -0x48(%rbp),%rsi
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movaps 0xe94(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x216f64,0xb(%rsp)
movl   $0x646e756d,0x8(%rsp)
64
movb   $0x48,0x10(%rsp)
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
lea    0xe74(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xe6f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x6d,%esi
call   1050 <strchr@plt>
movb   $0x4d,(%rax)
lea    0xe67(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xa(%rax),%rdi
call   1070 <malloc@plt>
mov    0x10(%rsp),%ecx
mov    %ecx,(%rax)
mov    0x14(%rsp),%cl
mov    %cl,0x4(%rax)
movabs $0x65206f646f742061,%rcx
6f 20 65
mov    %rcx,0x5(%rax)
movw   $0x206c,0xd(%rax)
mov    0x15(%rsp),%ecx
mov    %ecx,0xf(%rax)
movzwl 0x19(%rsp),%ecx
mov    %cx,0x13(%rax)
lea    0xe23(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.a = [20 x i8] c"hola \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.b = [7 x i8] c"mundo!\00"
@.str = [20 x i8] c"El string c es: %s\0A\00"
@.str.1 = [25 x i8] c"La longitud de c es: %d\0A\00"
@.str.2 = [16 x i8] c"Ahora c es: %s\0A\00"
@.str.3 = [33 x i8] c"primero digo hola y luego mundo\0A\00"
@.str.4 = [11 x i8] c"a todo el \00"
@.str.5 = [33 x i8] c"El string c finalmente dice: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca [7 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %1
%8 = bitcast [20 x i8]* %2 to i8*
%9 = bitcast [7 x i8]* %3 to i8*
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
store i8 72, i8* %10
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%13 = call i8* @strcat(i8* %11, i8* %12)
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %4
%17 = call i64 @strlen(i8* %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 %17)
%19 = load i8*, i8** %4
%20 = call i8* @strchr(i8* %19, i32 109)
store i8* %20, i8** %5
%21 = load i8*, i8** %5
store i8 77, i8* %21
%22 = load i8*, i8** %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8** %6
%25 = load i8*, i8** %4
%26 = call i64 @strlen(i8* %25)
%27 = load i8*, i8** %6
%28 = call i64 @strlen(i8* %27)
%29 = add i64 %26, %28
%30 = call i8* @malloc(i64 %29)
store i8* %30, i8** %7
%31 = load i8*, i8** %7
%32 = load i8*, i8** %4
%33 = load i8*, i8** %7
%34 = getelementptr inbounds i8, i8* %33, i64 5
%35 = load i8*, i8** %6
%36 = load i8*, i8** %6
%37 = call i64 @strlen(i8* %36)
%38 = load i8*, i8** %7
%39 = getelementptr inbounds i8, i8* %38, i64 5
%40 = load i8*, i8** %6
%41 = call i64 @strlen(i8* %40)
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i64 5
%45 = load i8*, i8** %7
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %45)
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [20 x i8] c"hola \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.b = [7 x i8] c"mundo!\00"
@.str = [20 x i8] c"El string c es: %s\0A\00"
@.str.1 = [25 x i8] c"La longitud de c es: %d\0A\00"
@.str.2 = [16 x i8] c"Ahora c es: %s\0A\00"
@.str.4 = [11 x i8] c"a todo el \00"
@.str.5 = [33 x i8] c"El string c finalmente dice: %s\0A\00"
@str = [32 x i8] c"primero digo hola y luego mundo\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [7 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
store i8 72, i8* %3
%5 = call i8* @strcat(i8* %3, i8* %4)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %3)
%7 = call i64 @strlen(i8* %3)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 %7)
%9 = call i8* @strchr(i8* %3, i32 109)
store i8 77, i8* %9
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%12 = call i64 @strlen(i8* %3)
%13 = add i64 %12, 10
%14 = call i8* @malloc(i64 %13)
%15 = getelementptr inbounds i8, i8* %14, i64 5
%16 = getelementptr inbounds i8, i8* %14, i64 15
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 5
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %14)
ret i32 0
}