#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 EXIT_SUCCESS;
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *, char *, int);
char *realloc(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(void) {
  char *email;
  char *backup;
  email = (char *)malloc(40);
  strcpy(email, "mymail@myhostname.org");
  backup = realloc(email, strlen(email) + 1);
  printf("e-mail value: %p [%s] %d byte\n", email, email, strlen(email));
  printf("backup value: %p [%s] %d byte\n", backup, backup, strlen(backup));
  free(backup);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x28,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
add    $0x1,%esi
call   1080 <realloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    %eax,%ecx
lea    0xe3c(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
lea    0xe2c(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2dc2(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x28,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe88(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%esi
mov    %rbx,%rdi
call   1080 <realloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0xe71(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1060 <printf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0xe74(%rip),%rdi
mov    %r14,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
call   1060 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"mymail@myhostname.org\00"
@.str.1 = [31 x i8] c"e-mail value: %p [%s] %d byte\0A\00"
@.str.2 = [31 x i8] c"backup value: %p [%s] %d byte\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i64 @malloc(i32 40)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = add nsw i32 %10, 1
%12 = call i8* @realloc(i8* %8, i32 %11)
store i8* %12, i8** %3
%13 = load i8*, i8** %2
%14 = load i8*, i8** %2
%15 = load i8*, i8** %2
%16 = call i32 @strlen(i8* %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* %14, i32 %16)
%18 = load i8*, i8** %3
%19 = load i8*, i8** %3
%20 = load i8*, i8** %3
%21 = call i32 @strlen(i8* %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %19, i32 %21)
%23 = load i8*, i8** %3
%24 = call i32 @free(i8* %23)
%25 = load i32, i32* @EXIT_SUCCESS
ret i32 %25
}

LLVM IR (-O2):
@.str = [22 x i8] c"mymail@myhostname.org\00"
@.str.1 = [31 x i8] c"e-mail value: %p [%s] %d byte\0A\00"
@.str.2 = [31 x i8] c"backup value: %p [%s] %d byte\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i64 @malloc(i32 40)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @strlen(i8* %2)
%5 = add nsw i32 %4, 1
%6 = tail call i8* @realloc(i8* %2, i32 %5)
%7 = tail call i32 @strlen(i8* %2)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %2, i32 %7)
%9 = tail call i32 @strlen(i8* %6)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* %6, i32 %9)
%11 = tail call i32 @free(i8* %6)
%12 = load i32, i32* @EXIT_SUCCESS
ret i32 %12
}