void xlocaledir(path) char *path;
{
  char *dir, *p = path;
  int len;
  dir = getenv("XLOCALEDIR");
  if (dir != 0) {
    len = strlen(dir);
    strcpy(p, dir);
    p[len++] = ':';
    p += len;
  }
  strcpy(p, "/usr/lib/X11/locale");
}


x86 assembly (clang, -O0):
<xlocaledir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <getenv@plt>
cltq
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a3 <xlocaledir+0x73>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
movb   $0x3a,(%rax,%rcx,1)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1040 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xlocaledir>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1030 <getenv@plt>
test   %eax,%eax
je     1172 <xlocaledir+0x42>
movslq %eax,%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
movslq %r15d,%rax
movb   $0x3a,(%rbx,%rax,1)
add    $0x1,%eax
cltq
add    %rax,%rbx
movups 0xe92(%rip),%xmm0
movups %xmm0,(%rbx)
movl   $0x656c61,0x10(%rbx)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"XLOCALEDIR\00"
@.str.1 = [20 x i8] c"/usr/lib/X11/locale\00"
define void @xlocaledir(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
store i8* %6, i8** %4
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @getenv to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %28
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i64 @strlen(i8* %13)
%15 = trunc i64 %14 to i32
store i32 %15, i32* %5
%16 = load i8*, i8** %4
%17 = load i8*, i8** %3
%18 = call i8* @strcpy(i8* %16, i8* %17)
%19 = load i8*, i8** %4
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
%22 = sext i32 %20 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
store i8 58, i8* %23
%24 = load i32, i32* %5
%25 = load i8*, i8** %4
%26 = sext i32 %24 to i64
%27 = getelementptr inbounds i8, i8* %25, i64 %26
store i8* %27, i8** %4
br label %28
28: ; preds = %12, %1
%29 = load i8*, i8** %4
%30 = call i8* @strcpy(i8* %29, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"XLOCALEDIR\00"
@.str.1 = [20 x i8] c"/usr/lib/X11/locale\00"
define void @xlocaledir(i8* %0) {
%2 = tail call i32 (i8*, ...) bitcast (i32 (...)* @getenv to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%3 = sext i32 %2 to i64
%4 = inttoptr i64 %3 to i8*
%5 = icmp eq i32 %2, 0
br i1 %5, label %15, label %6
6: ; preds = %1
%7 = tail call i64 @strlen(i8* %4)
%8 = tail call i8* @strcpy(i8* dereferenceable(1) %0, i8* %4)
%9 = shl i64 %7, 32
%10 = ashr exact i64 %9, 32
%11 = getelementptr inbounds i8, i8* %0, i64 %10
store i8 58, i8* %11
%12 = add i64 %9, 4294967296
%13 = ashr exact i64 %12, 32
%14 = getelementptr inbounds i8, i8* %0, i64 %13
br label %15
15: ; preds = %6, %1
%16 = phi i8* [ %14, %6 ], [ %0, %1 ]
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(20) %16, i8* align 1 dereferenceable(20) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64 20, i1 false)
ret void
}