#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*/ printf(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void strplc_a(int x, int y, int size, char array[size][size], char *str,
              int strbytes) {
  if ((y + strbytes) < size)
    strncpy(array[y] + x, str, strbytes);
  else {
    printf("error: placement\n");
  }
}


x86 assembly (clang, -O0):
<strplc_a>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%eax
add    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117e <strplc_a+0x5e>
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rdi
movslq -0x8(%rbp),%rax
imul   %rcx,%rax
add    %rax,%rdi
movslq -0x4(%rbp),%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncpy@plt>
jmp    118a <strplc_a+0x6a>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strplc_a>:
lea    (%r9,%rsi,1),%eax
cmp    %edx,%eax
jge    1145 <strplc_a+0x25>
mov    %edx,%eax
movslq %esi,%rdx
imul   %rax,%rdx
add    %rdx,%rcx
movslq %edi,%rdi
add    %rcx,%rdi
mov    %r8,%rsi
mov    %r9d,%edx
jmp    1030 <strncpy@plt>
lea    0xeb4(%rip),%rdi
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"error: placement\0A\00"
define void @strplc_a(i32 %0, i32 %1, i32 %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%13 = load i32, i32* %9
%14 = zext i32 %13 to i64
%15 = load i32, i32* %9
%16 = zext i32 %15 to i64
%17 = load i32, i32* %8
%18 = load i32, i32* %12
%19 = add nsw i32 %17, %18
%20 = load i32, i32* %9
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %34
22: ; preds = %6
%23 = load i8*, i8** %10
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = mul nsw i64 %25, %16
%27 = getelementptr inbounds i8, i8* %23, i64 %26
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8*, i8** %11
%32 = load i32, i32* %12
%33 = call i32 @strncpy(i8* %30, i8* %31, i32 %32)
br label %36
34: ; preds = %6
%35 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %36
36: ; preds = %34, %22
ret void
}

LLVM IR (-O2):
@str = [17 x i8] c"error: placement\00"
define void @strplc_a(i32 %0, i32 %1, i32 %2, i8* %3, i8* %4, i32 %5) {
%7 = add nsw i32 %5, %1
%8 = icmp slt i32 %7, %2
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = zext i32 %2 to i64
%11 = sext i32 %1 to i64
%12 = mul nsw i64 %10, %11
%13 = getelementptr inbounds i8, i8* %3, i64 %12
%14 = sext i32 %0 to i64
%15 = getelementptr inbounds i8, i8* %13, i64 %14
%16 = tail call i32 @strncpy(i8* %15, i8* %4, i32 %5)
br label %19
17: ; preds = %6
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %19
19: ; preds = %17, %9
ret void
}