#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 */
typedef int /*<<< orphan*/ full_path;

/* Variables and functions */
scalar_t__ strlen(char *);
scalar_t__ strncat(char *, char *, scalar_t__);
scalar_t__ strncpy2(char *, char *, int);
char *altpathspec(char *filename) {
  extern char alt_path[];
  static char full_path[127 + 1];
  (int)strncpy2(full_path, alt_path, sizeof(full_path) - 1);
  (int)strncat(full_path, filename, sizeof(full_path) - 1 - strlen(full_path));
  return full_path;
}


x86 assembly (clang, -O0):
<altpathspec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f0d(%rip),%rdi
mov    0x2e96(%rip),%rsi
mov    $0x7f,%edx
call   1050 <strncpy2@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    0x2eed(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x10(%rbp),%rsi
mov    $0x7f,%edx
sub    %rax,%rdx
lea    0x2ed5(%rip),%rdi
call   1040 <strncat@plt>
lea    0x2ec9(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<altpathspec>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0x2f12(%rip),%rbx
mov    0x2e9b(%rip),%rsi
mov    %rbx,%rdi
mov    $0x7f,%edx
call   1050 <strncpy2@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    $0x7f,%edx
sub    %rax,%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strncat@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@altpathspec.full_path = internal global [128 x i8] zeroinitializer
@alt_path = external global [0 x i8]
define i8* @altpathspec(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i64 @strncpy2(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @altpathspec.full_path, i64 0, i64 0), i8* getelementptr inbounds ([0 x i8], [0 x i8]* @alt_path, i64 0, i64 0), i32 127)
%4 = trunc i64 %3 to i32
%5 = load i8*, i8** %2
%6 = call i64 @strlen(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @altpathspec.full_path, i64 0, i64 0))
%7 = sub i64 127, %6
%8 = call i64 @strncat(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @altpathspec.full_path, i64 0, i64 0), i8* %5, i64 %7)
%9 = trunc i64 %8 to i32
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @altpathspec.full_path, i64 0, i64 0)
}

LLVM IR (-O2):
@altpathspec.full_path = internal global [128 x i8] zeroinitializer
@alt_path = external global [0 x i8]
define i8* @altpathspec(i8* %0) {
%2 = tail call i64 @strncpy2(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @altpathspec.full_path, i64 0, i64 0), i8* getelementptr inbounds ([0 x i8], [0 x i8]* @alt_path, i64 0, i64 0), i32 127)
%3 = tail call i64 @strlen(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @altpathspec.full_path, i64 0, i64 0))
%4 = sub i64 127, %3
%5 = tail call i64 @strncat(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @altpathspec.full_path, i64 0, i64 0), i8* %0, i64 %4)
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @altpathspec.full_path, i64 0, i64 0)
}