#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ check_overflow(scalar_t__, int);
char *root_directory();
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
scalar_t__ strlen(char *);
char *sources_dir(void) {
  static char buf[1024];
  check_overflow(strlen(root_directory()) + strlen(".sources") + 10,
                 sizeof(buf));
  sprintf(buf, "%s/%s", root_directory(), ".sources");
  return buf;
}


x86 assembly (clang, -O0):
<sources_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <root_directory@plt>
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %rax,-0x8(%rbp)
lea    0xe9e(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x8(%rbp),%rdi
add    %rax,%rdi
add    $0xa,%rdi
mov    $0x400,%esi
call   1030 <check_overflow@plt>
mov    $0x0,%al
call   1050 <root_directory@plt>
mov    %rax,%rdx
lea    0x2ec3(%rip),%rdi
lea    0xe75(%rip),%rsi
lea    0xe65(%rip),%rcx
call   1060 <sprintf@plt>
lea    0x2ea9(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sources_dir>:
push   %rbx
xor    %eax,%eax
call   1050 <root_directory@plt>
mov    %rax,%rdi
call   1040 <strlen@plt>
lea    0x12(%rax),%rdi
mov    $0x400,%esi
call   1030 <check_overflow@plt>
xor    %eax,%eax
call   1050 <root_directory@plt>
lea    0x2ee4(%rip),%rbx
lea    0xe96(%rip),%rsi
lea    0xe86(%rip),%rcx
mov    %rbx,%rdi
mov    %rax,%rdx
call   1060 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@sources_dir.buf = internal global [1024 x i8] zeroinitializer
@.str = [9 x i8] c".sources\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define i8* @sources_dir() {
%1 = call i8* (...) @root_directory()
%2 = call i64 @strlen(i8* %1)
%3 = call i64 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%4 = add nsw i64 %2, %3
%5 = add nsw i64 %4, 10
%6 = call i32 @check_overflow(i64 %5, i32 1024)
%7 = call i8* (...) @root_directory()
%8 = call i32 @sprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @sources_dir.buf, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @sources_dir.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@sources_dir.buf = internal global [1024 x i8] zeroinitializer
@.str = [9 x i8] c".sources\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define i8* @sources_dir() {
%1 = tail call i8* (...) @root_directory()
%2 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%3 = add nsw i64 %2, 18
%4 = tail call i32 @check_overflow(i64 %3, i32 1024)
%5 = tail call i8* (...) @root_directory()
%6 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([1024 x i8], [1024 x i8]* @sources_dir.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @sources_dir.buf, i64 0, i64 0)
}