#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 */
int /*<<< orphan*/ memmove(char *, char *, scalar_t__);
char *safestrdup(char const *, char *, int);
char *safestrdup2(char *, char const *, char *, int);
char *safestrdup3(char const *, char *, char const *, char *, int);
scalar_t__ safestrlen(char *);
char *strstr(char *, char *);
char *Make_pathname(const char *dir, const char *file) {
  char *s, *path;
  if (file == 0) {
    path = 0;
  } else if (file[0] == '/') {
    path = safestrdup(
        file,
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/AndreyPopovNew/asuswrt-merlin-rt-n/refs/"
        "heads/374.43_2-update/release/src/router/LPRng/src/common/linelist.c",
        3655);
  } else if (dir) {
    path = safestrdup3(
        dir, "/", file,
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/AndreyPopovNew/asuswrt-merlin-rt-n/refs/"
        "heads/374.43_2-update/release/src/router/LPRng/src/common/linelist.c",
        3657);
  } else {
    path = safestrdup2(
        "./", file,
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/AndreyPopovNew/asuswrt-merlin-rt-n/refs/"
        "heads/374.43_2-update/release/src/router/LPRng/src/common/linelist.c",
        3659);
  }
  if ((s = path))
    while ((s = strstr(s, "//")))
      memmove(s, s + 1, safestrlen(s) + 1);
  return (path);
}


x86 assembly (clang, -O0):
<Make_pathname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1188 <Make_pathname+0x28>
movq   $0x0,-0x20(%rbp)
jmp    1215 <Make_pathname+0xb5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    11b6 <Make_pathname+0x56>
mov    -0x10(%rbp),%rdi
lea    0xe5d(%rip),%rsi
mov    $0xe47,%edx
call   1030 <safestrdup@plt>
mov    %rax,-0x20(%rbp)
jmp    1210 <Make_pathname+0xb0>
cmpq   $0x0,-0x8(%rbp)
je     11eb <Make_pathname+0x8b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xef8(%rip),%rsi
lea    0xe29(%rip),%rcx
mov    $0xe49,%r8d
call   1040 <safestrdup3@plt>
mov    %rax,-0x20(%rbp)
jmp    120b <Make_pathname+0xab>
mov    -0x10(%rbp),%rsi
lea    0xed1(%rip),%rdi
lea    0xe03(%rip),%rdx
mov    $0xe4b,%ecx
call   1070 <safestrdup2@plt>
mov    %rax,-0x20(%rbp)
jmp    1210 <Make_pathname+0xb0>
jmp    1215 <Make_pathname+0xb5>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1285 <Make_pathname+0x125>
jmp    122c <Make_pathname+0xcc>
mov    -0x18(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1280 <Make_pathname+0x120>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <safestrlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1060 <memmove@plt>
jmp    122c <Make_pathname+0xcc>
jmp    1285 <Make_pathname+0x125>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Make_pathname>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1230 <Make_pathname+0xd0>
mov    %rsi,%rax
cmpb   $0x2f,(%rsi)
jne    118f <Make_pathname+0x2f>
lea    0xe80(%rip),%rsi
mov    %rax,%rdi
mov    $0xe47,%edx
call   1030 <safestrdup@plt>
jmp    11cd <Make_pathname+0x6d>
test   %rdi,%rdi
je     11b2 <Make_pathname+0x52>
lea    0xf2d(%rip),%rsi
lea    0xe5e(%rip),%rcx
mov    %rax,%rdx
mov    $0xe49,%r8d
call   1040 <safestrdup3@plt>
jmp    11cd <Make_pathname+0x6d>
lea    0xf0e(%rip),%rdi
lea    0xe40(%rip),%rdx
mov    %rax,%rsi
mov    $0xe4b,%ecx
call   1070 <safestrdup2@plt>
mov    %rax,%r14
test   %rax,%rax
je     1230 <Make_pathname+0xd0>
lea    0xeee(%rip),%rsi
mov    %r14,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     1233 <Make_pathname+0xd3>
mov    %rax,%rbx
lea    0xed7(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x1(%rbx),%r12
mov    %rbx,%rdi
call   1050 <safestrlen@plt>
lea    0x1(%rax),%rdx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <memmove@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1200 <Make_pathname+0xa0>
jmp    1233 <Make_pathname+0xd3>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [199 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AndreyPopovNew/asuswrt-merlin-rt-n/refs/heads/374.43_2-update/release/src/router/LPRng/src/common/linelist.c\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [3 x i8] c"./\00"
@.str.3 = [3 x i8] c"//\00"
define i8* @Make_pathname(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %2
store i8* null, i8** %6
br label %31
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 47
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load i8*, i8** %4
%18 = call i8* @safestrdup(i8* %17, i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str, i64 0, i64 0), i32 3655)
store i8* %18, i8** %6
br label %30
19: ; preds = %10
%20 = load i8*, i8** %3
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i8*, i8** %3
%24 = load i8*, i8** %4
%25 = call i8* @safestrdup3(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %24, i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str, i64 0, i64 0), i32 3657)
store i8* %25, i8** %6
br label %29
26: ; preds = %19
%27 = load i8*, i8** %4
%28 = call i8* @safestrdup2(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %27, i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str, i64 0, i64 0), i32 3659)
store i8* %28, i8** %6
br label %29
29: ; preds = %26, %22
br label %30
30: ; preds = %29, %16
br label %31
31: ; preds = %30, %9
%32 = load i8*, i8** %6
store i8* %32, i8** %5
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %48
34: ; preds = %31
br label %35
35: ; preds = %39, %34
%36 = load i8*, i8** %5
%37 = call i8* @strstr(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i8* %37, i8** %5
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %47
39: ; preds = %35
%40 = load i8*, i8** %5
%41 = load i8*, i8** %5
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = load i8*, i8** %5
%44 = call i64 @safestrlen(i8* %43)
%45 = add nsw i64 %44, 1
%46 = call i32 @memmove(i8* %40, i8* %42, i64 %45)
br label %35
47: ; preds = %35
br label %48
48: ; preds = %47, %31
%49 = load i8*, i8** %6
ret i8* %49
}

LLVM IR (-O2):
@.str = [199 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AndreyPopovNew/asuswrt-merlin-rt-n/refs/heads/374.43_2-update/release/src/router/LPRng/src/common/linelist.c\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [3 x i8] c"./\00"
@.str.3 = [3 x i8] c"//\00"
define i8* @Make_pathname(i8* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %29, label %4
4: ; preds = %2
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 47
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i8* @safestrdup(i8* %1, i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str, i64 0, i64 0), i32 3655)
br label %15
9: ; preds = %4
%10 = icmp eq i8* %0, null
br i1 %10, label %13, label %11
11: ; preds = %9
%12 = tail call i8* @safestrdup3(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str, i64 0, i64 0), i32 3657)
br label %15
13: ; preds = %9
%14 = tail call i8* @safestrdup2(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str, i64 0, i64 0), i32 3659)
br label %15
15: ; preds = %7, %13, %11
%16 = phi i8* [ %8, %7 ], [ %12, %11 ], [ %14, %13 ]
%17 = icmp eq i8* %16, null
br i1 %17, label %29, label %18
18: ; preds = %15
%19 = tail call i8* @strstr(i8* dereferenceable(1) %16, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %29, label %21
21: ; preds = %18, %21
%22 = phi i8* [ %27, %21 ], [ %19, %18 ]
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = tail call i64 @safestrlen(i8* %22)
%25 = add nsw i64 %24, 1
%26 = tail call i32 @memmove(i8* %22, i8* %23, i64 %25)
%27 = tail call i8* @strstr(i8* dereferenceable(1) %22, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %21
29: ; preds = %21, %18, %2, %15
%30 = phi i8* [ null, %15 ], [ null, %2 ], [ %16, %18 ], [ %16, %21 ]
ret i8* %30
}