#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*/ memcpy(char *, char const *, int);
size_t strlen(char const *);
size_t gen_fn(char *buf, const char *prefix, size_t pl, const char *tmpdir) {
  size_t tl = strlen(tmpdir);
  size_t a = 0;
  memcpy(buf + a, tmpdir, tl);
  a += tl;
  memcpy(buf + a, prefix, pl);
  a += pl;
  memcpy(buf + a, "XXXXXX", 7);
  return a + 6;
}


x86 assembly (clang, -O0):
<gen_fn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
add    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x28(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
add    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
add    -0x30(%rbp),%rdi
lea    0xe5e(%rip),%rsi
mov    $0x7,%edx
call   1040 <memcpy@plt>
mov    -0x30(%rbp),%rax
add    $0x6,%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_fn>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
mov    %rcx,%rdi
call   1030 <strlen@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1040 <memcpy@plt>
lea    (%rbx,%r13,1),%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1040 <memcpy@plt>
lea    (%rbx,%r14,1),%rdi
add    %r13,%rdi
lea    0xe96(%rip),%rsi
mov    $0x7,%edx
call   1040 <memcpy@plt>
lea    (%rbx,%r14,1),%rax
add    $0x6,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"XXXXXX\00"
define i64 @gen_fn(i8* %0, i8* %1, i64 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i8* %3, i8** %8
%11 = load i8*, i8** %8
%12 = call i64 @strlen(i8* %11)
store i64 %12, i64* %9
store i64 0, i64* %10
%13 = load i8*, i8** %5
%14 = load i64, i64* %10
%15 = getelementptr inbounds i8, i8* %13, i64 %14
%16 = load i8*, i8** %8
%17 = load i64, i64* %9
%18 = trunc i64 %17 to i32
%19 = call i32 @memcpy(i8* %15, i8* %16, i32 %18)
%20 = load i64, i64* %9
%21 = load i64, i64* %10
%22 = add i64 %21, %20
store i64 %22, i64* %10
%23 = load i8*, i8** %5
%24 = load i64, i64* %10
%25 = getelementptr inbounds i8, i8* %23, i64 %24
%26 = load i8*, i8** %6
%27 = load i64, i64* %7
%28 = trunc i64 %27 to i32
%29 = call i32 @memcpy(i8* %25, i8* %26, i32 %28)
%30 = load i64, i64* %7
%31 = load i64, i64* %10
%32 = add i64 %31, %30
store i64 %32, i64* %10
%33 = load i8*, i8** %5
%34 = load i64, i64* %10
%35 = getelementptr inbounds i8, i8* %33, i64 %34
%36 = call i32 @memcpy(i8* %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 7)
%37 = load i64, i64* %10
%38 = add i64 %37, 6
ret i64 %38
}

LLVM IR (-O2):
@.str = [7 x i8] c"XXXXXX\00"
define i64 @gen_fn(i8* %0, i8* %1, i64 %2, i8* %3) {
%5 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%6 = trunc i64 %5 to i32
%7 = tail call i32 @memcpy(i8* %0, i8* %3, i32 %6)
%8 = getelementptr inbounds i8, i8* %0, i64 %5
%9 = trunc i64 %2 to i32
%10 = tail call i32 @memcpy(i8* %8, i8* %1, i32 %9)
%11 = add i64 %5, %2
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = tail call i32 @memcpy(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 7)
%14 = add i64 %11, 6
ret i64 %14
}