#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 */
char *mystrcpy(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
void test2() {
  char a[200];
  char *b;
  b = mystrcpy(a, "Hello world");
  printf("\"%s\"\n", a);
  printf("\"%s\"\n", b);
  b = mystrcpy(a, "");
  printf("\"%s\"\n", a);
  printf("\"%s\"\n", b);
}


x86 assembly (clang, -O0):
<test2>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
lea    -0xd0(%rbp),%rdi
lea    0xec7(%rip),%rsi
call   1040 <mystrcpy@plt>
mov    %rax,-0xd8(%rbp)
lea    -0xd0(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    -0xd8(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
lea    -0xd0(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1040 <mystrcpy@plt>
mov    %rax,-0xd8(%rbp)
lea    -0xd0(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
mov    -0xd8(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test2>:
push   %r15
push   %r14
push   %rbx
sub    $0xd0,%rsp
lea    0xecd(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <mystrcpy@plt>
mov    %rax,%rbx
lea    0xec4(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xeac(%rip),%rsi
mov    %r14,%rdi
call   1040 <mystrcpy@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Hello world\00"
@.str.1 = [6 x i8] c"\22%s\22\0A\00"
@.str.2 = [1 x i8] zeroinitializer
define void @test2() {
%1 = alloca [200 x i8]
%2 = alloca i8*
%3 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%4 = call i8* @mystrcpy(i8* %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %2
%5 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%6 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = load i8*, i8** %2
%8 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%10 = call i8* @mystrcpy(i8* %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
store i8* %10, i8** %2
%11 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%12 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %2
%14 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %13)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Hello world\00"
@.str.1 = [6 x i8] c"\22%s\22\0A\00"
@.str.2 = [1 x i8] zeroinitializer
define void @test2() {
%1 = alloca [200 x i8]
%2 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%3 = call i8* @mystrcpy(i8* %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%6 = call i8* @mystrcpy(i8* %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%8 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %6)
ret void
}