#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*/ sink(char *);
int /*<<< orphan*/ strcpy(char *, char const *);
void test_strcpy(const char *src) {
  struct A {
    char a[2];
    char b[3];
  } a;
  (strcpy((a.a), (src)), sink((a.a)));
  (strcpy((a.a + 1), (src)), sink((a.a + 1)));
  (strcpy((a.a + 2), (src)), sink((a.a + 2)));
  (strcpy((a.a + 5), (src)), sink((a.a + 5)));
  (strcpy((a.a + 17), (src)), sink((a.a + 17)));
}


x86 assembly (clang, -O0):
<test_strcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x10(%rbp),%rdi
call   1040 <sink@plt>
lea    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1040 <sink@plt>
lea    -0x10(%rbp),%rdi
add    $0x2,%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x10(%rbp),%rdi
add    $0x2,%rdi
call   1040 <sink@plt>
lea    -0x10(%rbp),%rdi
add    $0x5,%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x10(%rbp),%rdi
add    $0x5,%rdi
call   1040 <sink@plt>
lea    -0x10(%rbp),%rdi
add    $0x11,%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x10(%rbp),%rdi
add    $0x11,%rdi
call   1040 <sink@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strcpy>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <sink@plt>
lea    0x1(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <sink@plt>
lea    0x2(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <sink@plt>
lea    0x5(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <sink@plt>
lea    0x11(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <sink@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.A = type { [2 x i8], [3 x i8] }
define void @test_strcpy(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.A
store i8* %0, i8** %2
%4 = getelementptr inbounds %struct.A, %struct.A* %3, i32 0, i32 0
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%6 = load i8*, i8** %2
%7 = call i32 @strcpy(i8* %5, i8* %6)
%8 = getelementptr inbounds %struct.A, %struct.A* %3, i32 0, i32 0
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%10 = call i32 @sink(i8* %9)
%11 = getelementptr inbounds %struct.A, %struct.A* %3, i32 0, i32 0
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %11, i64 0, i64 0
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8*, i8** %2
%15 = call i32 @strcpy(i8* %13, i8* %14)
%16 = getelementptr inbounds %struct.A, %struct.A* %3, i32 0, i32 0
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %16, i64 0, i64 0
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = call i32 @sink(i8* %18)
%20 = getelementptr inbounds %struct.A, %struct.A* %3, i32 0, i32 0
%21 = getelementptr inbounds [2 x i8], [2 x i8]* %20, i64 0, i64 0
%22 = getelementptr inbounds i8, i8* %21, i64 2
%23 = load i8*, i8** %2
%24 = call i32 @strcpy(i8* %22, i8* %23)
%25 = getelementptr inbounds %struct.A, %struct.A* %3, i32 0, i32 0
%26 = getelementptr inbounds [2 x i8], [2 x i8]* %25, i64 0, i64 0
%27 = getelementptr inbounds i8, i8* %26, i64 2
%28 = call i32 @sink(i8* %27)
%29 = getelementptr inbounds %struct.A, %struct.A* %3, i32 0, i32 0
%30 = getelementptr inbounds [2 x i8], [2 x i8]* %29, i64 0, i64 0
%31 = getelementptr inbounds i8, i8* %30, i64 5
%32 = load i8*, i8** %2
%33 = call i32 @strcpy(i8* %31, i8* %32)
%34 = getelementptr inbounds %struct.A, %struct.A* %3, i32 0, i32 0
%35 = getelementptr inbounds [2 x i8], [2 x i8]* %34, i64 0, i64 0
%36 = getelementptr inbounds i8, i8* %35, i64 5
%37 = call i32 @sink(i8* %36)
%38 = getelementptr inbounds %struct.A, %struct.A* %3, i32 0, i32 0
%39 = getelementptr inbounds [2 x i8], [2 x i8]* %38, i64 0, i64 0
%40 = getelementptr inbounds i8, i8* %39, i64 17
%41 = load i8*, i8** %2
%42 = call i32 @strcpy(i8* %40, i8* %41)
%43 = getelementptr inbounds %struct.A, %struct.A* %3, i32 0, i32 0
%44 = getelementptr inbounds [2 x i8], [2 x i8]* %43, i64 0, i64 0
%45 = getelementptr inbounds i8, i8* %44, i64 17
%46 = call i32 @sink(i8* %45)
ret void
}

LLVM IR (-O2):
%struct.A = type { [2 x i8], [3 x i8] }
define void @test_strcpy(i8* %0) {
%2 = alloca %struct.A
%3 = getelementptr inbounds %struct.A, %struct.A* %2, i64 0, i32 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* %0)
%5 = call i32 @sink(i8* %3)
%6 = getelementptr inbounds %struct.A, %struct.A* %2, i64 0, i32 0, i64 1
%7 = call i32 @strcpy(i8* %6, i8* %0)
%8 = call i32 @sink(i8* %6)
%9 = getelementptr inbounds %struct.A, %struct.A* %2, i64 0, i32 0, i64 2
%10 = call i32 @strcpy(i8* %9, i8* %0)
%11 = call i32 @sink(i8* %9)
%12 = getelementptr inbounds %struct.A, %struct.A* %2, i64 0, i32 0, i64 5
%13 = call i32 @strcpy(i8* %12, i8* %0)
%14 = call i32 @sink(i8* %12)
%15 = getelementptr inbounds %struct.A, %struct.A* %2, i64 0, i32 0, i64 17
%16 = call i32 @strcpy(i8* %15, i8* %0)
%17 = call i32 @sink(i8* %15)
ret void
}