#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*/ bcopy(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *resource_name(char *left, char *right) {
  static char bufs[8][256];
  static int buf_pos = 0;
  int len = strlen(left);
  if (len)
    bcopy(left, bufs[buf_pos], len);
  bufs[buf_pos][len] = '.';
  strcpy(bufs[buf_pos] + len + 1, right);
  return bufs[buf_pos++];
}


x86 assembly (clang, -O0):
<resource_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1177 <resource_name+0x47>
mov    -0x8(%rbp),%rdi
movslq 0x36ef(%rip),%rax
lea    0x2ee8(%rip),%rsi
shl    $0x8,%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
call   1050 <bcopy@plt>
movslq 0x36d2(%rip),%rcx
lea    0x2ecb(%rip),%rax
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movb   $0x2e,(%rax,%rcx,1)
movslq 0x36b5(%rip),%rax
lea    0x2eae(%rip),%rdi
shl    $0x8,%rax
add    %rax,%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    0x368d(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x3682(%rip)
movslq %eax,%rcx
lea    0x2e78(%rip),%rax
shl    $0x8,%rcx
add    %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<resource_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%r12d
movslq 0x3703(%rip),%rbx
test   %eax,%eax
je     116d <resource_name+0x3d>
mov    %rbx,%rax
shl    $0x8,%rax
lea    0x2ef1(%rip),%rdi
add    %rax,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <memmove@plt>
movslq %r12d,%rax
shl    $0x8,%rbx
lea    0x2ed5(%rip),%r15
add    %r15,%rbx
movb   $0x2e,(%rax,%rbx,1)
lea    (%rax,%rbx,1),%rdi
add    $0x1,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
movslq 0x36b7(%rip),%rax
lea    0x1(%rax),%ecx
mov    %ecx,0x36ae(%rip)
shl    $0x8,%rax
add    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@resource_name.bufs = internal global [8 x [256 x i8]] zeroinitializer
@resource_name.buf_pos = internal global i32 0
define i8* @resource_name(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = load i32, i32* @resource_name.buf_pos
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [8 x [256 x i8]], [8 x [256 x i8]]* @resource_name.bufs, i64 0, i64 %13
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%16 = load i32, i32* %5
%17 = call i32 @bcopy(i8* %11, i8* %15, i32 %16)
br label %18
18: ; preds = %10, %2
%19 = load i32, i32* @resource_name.buf_pos
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [8 x [256 x i8]], [8 x [256 x i8]]* @resource_name.bufs, i64 0, i64 %20
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 %23
store i8 46, i8* %24
%25 = load i32, i32* @resource_name.buf_pos
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [8 x [256 x i8]], [8 x [256 x i8]]* @resource_name.bufs, i64 0, i64 %26
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %27, i64 0, i64 0
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = load i8*, i8** %4
%34 = call i32 @strcpy(i8* %32, i8* %33)
%35 = load i32, i32* @resource_name.buf_pos
%36 = add nsw i32 %35, 1
store i32 %36, i32* @resource_name.buf_pos
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds [8 x [256 x i8]], [8 x [256 x i8]]* @resource_name.bufs, i64 0, i64 %37
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %38, i64 0, i64 0
ret i8* %39
}

LLVM IR (-O2):
@resource_name.bufs = internal global [8 x [256 x i8]] zeroinitializer
@resource_name.buf_pos = internal unnamed_addr global i32 0
define i8* @resource_name(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp eq i32 %3, 0
%5 = load i32, i32* @resource_name.buf_pos
%6 = sext i32 %5 to i64
br i1 %4, label %9, label %7
7: ; preds = %2
%8 = getelementptr inbounds [8 x [256 x i8]], [8 x [256 x i8]]* @resource_name.bufs, i64 0, i64 %6, i64 0
tail call void @llvm.memmove.p0i8.p0i8.i32(i8* align 16 %8, i8* align 1 %0, i32 %3, i1 false)
br label %9
9: ; preds = %2, %7
%10 = sext i32 %3 to i64
%11 = getelementptr inbounds [8 x [256 x i8]], [8 x [256 x i8]]* @resource_name.bufs, i64 0, i64 %6, i64 %10
store i8 46, i8* %11
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = tail call i32 @strcpy(i8* %12, i8* %1)
%14 = load i32, i32* @resource_name.buf_pos
%15 = add nsw i32 %14, 1
store i32 %15, i32* @resource_name.buf_pos
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds [8 x [256 x i8]], [8 x [256 x i8]]* @resource_name.bufs, i64 0, i64 %16, i64 0
ret i8* %17
}