#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *, char *);
scalar_t__ realloc(char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char *str;
  str = (char *)malloc(15);
  strcpy(str, "tutorialspoint");
  printf("String = %s,  Address = %p\n", str, str);
  str = (char *)realloc(str, 25);
  strcat(str, ".com");
  printf("String = %s,  Address = %p\n", str, str);
  free(str);
  str = NULL;
  printf("String = %s,  Address = %p\n", str, str);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xf,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe73(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x19,%esi
call   1070 <realloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe3d(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe18(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0xf,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe88(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
lea    0xe88(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x19,%esi
call   1070 <realloc@plt>
mov    %rax,%rbx
lea    0xe7f(%rip),%rsi
mov    %rax,%rdi
call   1080 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"tutorialspoint\00"
@.str.1 = [28 x i8] c"String = %s, Address = %p\0A\00"
@.str.2 = [5 x i8] c".com\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i64 @malloc(i32 15)
%4 = inttoptr i64 %3 to i8*
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* %8)
%10 = load i8*, i8** %2
%11 = call i64 @realloc(i8* %10, i32 25)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %2
%13 = load i8*, i8** %2
%14 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = load i8*, i8** %2
%16 = load i8*, i8** %2
%17 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %16)
%18 = load i8*, i8** %2
%19 = call i32 @free(i8* %18)
store i8* null, i8** %2
%20 = load i8*, i8** %2
%21 = load i8*, i8** %2
%22 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %20, i8* %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"tutorialspoint\00"
@.str.1 = [28 x i8] c"String = %s, Address = %p\0A\00"
@.str.2 = [5 x i8] c".com\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 15)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %2)
%5 = tail call i64 @realloc(i8* %2, i32 25)
%6 = inttoptr i64 %5 to i8*
%7 = tail call i32 @strcat(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %6)
%9 = tail call i32 @free(i8* %6)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* null, i8* null)
ret i32 0
}