int main() {
  volatile char dst[100];
  volatile char *a = "";
  __builtin_strcpy((char *)dst, (char *)a);
  if (dst[0] != '\0') {
    return 1;
  }
  volatile char *b = "asdf";
  __builtin_strcpy((char *)dst, (char *)b);
  if (dst[0] != 'a' || dst[4] != '\0') {
    return 1;
  }
  volatile char *c = "asdf\0asdf";
  __builtin_strcpy((char *)dst, (char *)c);
  if (dst[0] != 'a' || dst[4] != '\0') {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xedb(%rip),%rax
mov    %rax,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x70(%rbp),%al
movsbl %al,%eax
cmp    $0x0,%eax
je     1155 <main+0x45>
movl   $0x1,-0x4(%rbp)
jmp    11e6 <main+0xd6>
lea    0xea4(%rip),%rax
mov    %rax,-0x80(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x80(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x70(%rbp),%al
movsbl %al,%eax
cmp    $0x61,%eax
jne    118b <main+0x7b>
mov    -0x6c(%rbp),%al
movsbl %al,%eax
cmp    $0x0,%eax
je     1197 <main+0x87>
movl   $0x1,-0x4(%rbp)
jmp    11e6 <main+0xd6>
lea    0xe67(%rip),%rax
mov    %rax,-0x88(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x88(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x70(%rbp),%al
movsbl %al,%eax
cmp    $0x61,%eax
jne    11d3 <main+0xc3>
mov    -0x6c(%rbp),%al
movsbl %al,%eax
cmp    $0x0,%eax
je     11df <main+0xcf>
movl   $0x1,-0x4(%rbp)
jmp    11e6 <main+0xd6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
movb   $0x0,-0x8(%rsp)
mov    $0x1,%eax
cmpb   $0x0,-0x8(%rsp)
je     1112 <main+0x12>
ret
movb   $0x61,-0x8(%rsp)
movb   $0x0,-0x4(%rsp)
mov    -0x8(%rsp),%cl
cmp    $0x61,%cl
jne    1111 <main+0x11>
cmpb   $0x0,-0x4(%rsp)
jne    1111 <main+0x11>
movb   $0x61,-0x8(%rsp)
movb   $0x0,-0x4(%rsp)
mov    -0x8(%rsp),%cl
cmp    $0x61,%cl
jne    1111 <main+0x11>
xor    %eax,%eax
cmpb   $0x0,-0x4(%rsp)
setne  %al
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"asdf\00"
@.str.2 = [10 x i8] c"asdf\00asdf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = load i8*, i8** %3
%8 = call i8* @strcpy(i8* %6, i8* %7)
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%10 = load volatile i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %0
store i32 1, i32* %1
br label %43
14: ; preds = %0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %4
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%16 = load i8*, i8** %4
%17 = call i8* @strcpy(i8* %15, i8* %16)
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%19 = load volatile i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 97
br i1 %21, label %27, label %22
22: ; preds = %14
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 4
%24 = load volatile i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22, %14
store i32 1, i32* %1
br label %43
28: ; preds = %22
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %5
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%30 = load i8*, i8** %5
%31 = call i8* @strcpy(i8* %29, i8* %30)
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%33 = load volatile i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 97
br i1 %35, label %41, label %36
36: ; preds = %28
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 4
%38 = load volatile i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %36, %28
store i32 1, i32* %1
br label %43
42: ; preds = %36
store i32 0, i32* %1
br label %43
43: ; preds = %42, %41, %27, %13
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i8
%2 = alloca i8
store i8 0, i8* %1
%3 = load volatile i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %5, label %18
5: ; preds = %0
store i8 97, i8* %1
store i8 0, i8* %2
%6 = load volatile i8, i8* %1
%7 = icmp eq i8 %6, 97
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load volatile i8, i8* %2
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %8
store i8 97, i8* %1
store i8 0, i8* %2
%12 = load volatile i8, i8* %1
%13 = icmp eq i8 %12, 97
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load volatile i8, i8* %2
%16 = icmp ne i8 %15, 0
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %14, %8, %5, %11, %0
%19 = phi i32 [ 1, %0 ], [ 1, %8 ], [ 1, %5 ], [ 1, %11 ], [ %17, %14 ]
ret i32 %19
}