#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 */
char *alloca(scalar_t__);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
int main(void) {
  const char *etc = "/etc/";
  const char *file = "passwd";
  char *name;
  name = alloca(strlen(etc) + strlen(file) + 1);
  strcpy(name, etc);
  strcat(name, file);
  printf("%s\n", name);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe95(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1060 <alloca@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x20(%rbp),%rsi
lea    0xe49(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xc,%edi
call   1050 <alloca@plt>
mov    %rax,%rbx
lea    0xeab(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
lea    0xea2(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xe9a(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"/etc/\00"
@.str.1 = [7 x i8] c"passwd\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %3
%5 = load i8*, i8** %2
%6 = call i64 @strlen(i8* %5)
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = add nsw i64 %6, %8
%10 = add nsw i64 %9, 1
%11 = call i8* @alloca(i64 %10)
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = load i8*, i8** %2
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = load i8*, i8** %4
%16 = load i8*, i8** %3
%17 = call i32 @strcat(i8* %15, i8* %16)
%18 = load i8*, i8** %4
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"/etc/\00"
@.str.1 = [7 x i8] c"passwd\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = tail call i8* @alloca(i64 12)
%2 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %1)
ret i32 0
}