#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 *DWBhome();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
void DWBprefix(char *prog, char *path, int length) {
  char *home;
  char buf[512];
  int len = strlen("\\*(.P");
  if (strncmp(path, "\\*(.P", len) == 0) {
    if ((home = DWBhome()) != NULL) {
      if (strlen(home) + strlen(path + len) < length) {
        sprintf(buf, "%s%s", home, path + len);
        strcpy(path, buf);
      } else
        fprintf(stderr, "%s: no room to grow path %s", prog, path);
    }
  }
}


x86 assembly (clang, -O0):
<DWBprefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    0xe83(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x224(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x224(%rbp),%edx
lea    0xe67(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1253 <DWBprefix+0xf3>
mov    $0x0,%al
call   1070 <DWBhome@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     124e <DWBprefix+0xee>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x228(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x224(%rbp),%rax
add    %rax,%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x228(%rbp),%eax
add    %ecx,%eax
cmp    -0x14(%rbp),%eax
jge    122c <DWBprefix+0xcc>
lea    -0x220(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rcx
movslq -0x224(%rbp),%rax
add    %rax,%rcx
lea    0xdf4(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x220(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    1249 <DWBprefix+0xe9>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xdc7(%rip),%rsi
call   1060 <fprintf@plt>
jmp    124e <DWBprefix+0xee>
jmp    1253 <DWBprefix+0xf3>
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DWBprefix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %edx,%r15d
mov    %rsi,%r13
mov    %rdi,%r14
lea    0xe7f(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11af <DWBprefix+0x4f>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1070 <DWBhome@plt>
test   %rax,%rax
je     119d <DWBprefix+0x3d>
mov    %rax,%r12
mov    %rax,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
movslq %ebp,%rbp
add    %r13,%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
add    %ebx,%eax
cmp    %r15d,%eax
jge    1202 <DWBprefix+0xa2>
lea    0xe22(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r12,%rdx
mov    %rbp,%rcx
call   1080 <sprintf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
jmp    119d <DWBprefix+0x3d>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
lea    0xdf9(%rip),%rsi
mov    %r14,%rdx
mov    %r13,%rcx
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fprintf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"\\*(.P\00"
@.str.1 = [5 x i8] c"%s%s\00"
@stderr = global i32 0
@.str.2 = [28 x i8] c"%s: no room to grow path %s\00"
define void @DWBprefix(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [512 x i8]
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %9
%11 = load i8*, i8** %5
%12 = load i32, i32* %9
%13 = call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %47
15: ; preds = %3
%16 = call i8* (...) @DWBhome()
store i8* %16, i8** %7
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %46
18: ; preds = %15
%19 = load i8*, i8** %7
%20 = call i32 @strlen(i8* %19)
%21 = load i8*, i8** %5
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = call i32 @strlen(i8* %24)
%26 = add nsw i32 %20, %25
%27 = load i32, i32* %6
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %40
29: ; preds = %18
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%31 = load i8*, i8** %7
%32 = load i8*, i8** %5
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %31, i8* %35)
%37 = load i8*, i8** %5
%38 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%39 = call i32 @strcpy(i8* %37, i8* %38)
br label %45
40: ; preds = %18
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %4
%43 = load i8*, i8** %5
%44 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %42, i8* %43)
br label %45
45: ; preds = %40, %29
br label %46
46: ; preds = %45, %15
br label %47
47: ; preds = %46, %3
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"\\*(.P\00"
@.str.1 = [5 x i8] c"%s%s\00"
@stderr = global i32 0
@.str.2 = [28 x i8] c"%s: no room to grow path %s\00"
define void @DWBprefix(i8* %0, i8* %1, i32 %2) {
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %3
%10 = tail call i8* (...) @DWBhome()
%11 = icmp eq i8* %10, null
br i1 %11, label %25, label %12
12: ; preds = %9
%13 = tail call i32 @strlen(i8* %10)
%14 = sext i32 %6 to i64
%15 = getelementptr inbounds i8, i8* %1, i64 %14
%16 = tail call i32 @strlen(i8* %15)
%17 = add nsw i32 %16, %13
%18 = icmp slt i32 %17, %2
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %10, i8* %15)
%21 = call i32 @strcpy(i8* %1, i8* %5)
br label %25
22: ; preds = %12
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1)
br label %25
25: ; preds = %9, %22, %19, %3
ret void
}