#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 *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
char *stpcpy(char *, char *);
char *strcpy(char *, char *);
int main(void) {
  char *string_1, *string_one;
  char *string_2, *string_two;
  string_one = string_1 = malloc(100);
  string_two = string_2 = malloc(100);
  printf("string_1"
         " = [%p]\n",
         (string_1));
  string_1 = strcpy(string_1, "foo");
  printf("string_1"
         " = [%p]\n",
         (string_1));
  printf("string_2"
         " = [%p]\n",
         (string_2));
  string_2 = stpcpy(string_2, "bar");
  printf("string_2"
         " = [%p]\n",
         (string_2));
  free(string_one);
  free(string_two);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x64,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    %rax,-0x18(%rbp)
mov    $0x64,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe72(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1040 <strcpy@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe4e(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe53(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1050 <stpcpy@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe2f(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x64,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x64,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xeaa(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
movl   $0x6f6f66,(%r14)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
lea    0xe97(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0x3(%rbx),%rsi
movl   $0x726162,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"string_1 = [%p]\0A\00"
@.str.1 = [4 x i8] c"foo\00"
@.str.2 = [17 x i8] c"string_2 = [%p]\0A\00"
@.str.3 = [4 x i8] c"bar\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
%6 = call i8* @malloc(i32 100)
store i8* %6, i8** %2
store i8* %6, i8** %3
%7 = call i8* @malloc(i32 100)
store i8* %7, i8** %4
store i8* %7, i8** %5
%8 = load i8*, i8** %2
%9 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %2
%11 = call i8* @strcpy(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i8* %11, i8** %2
%12 = load i8*, i8** %2
%13 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %4
%15 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %4
%17 = call i8* @stpcpy(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %3
%21 = call i32 @free(i8* %20)
%22 = load i8*, i8** %5
%23 = call i32 @free(i8* %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"string_1 = [%p]\0A\00"
@.str.2 = [17 x i8] c"string_2 = [%p]\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%2 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %1)
%4 = bitcast i8* %1 to i32*
store i32 7303014, i32* %4
%5 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %1)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%7 = getelementptr i8, i8* %2, i64 3
%8 = bitcast i8* %2 to i32*
store i32 7496034, i32* %8
%9 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%10 = tail call i32 @free(i8* %1)
%11 = tail call i32 @free(i8* %2)
ret i32 0
}