#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 *realloc(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *NormalizeSourceName(char *Directory, char *Filename) {
  static char *NormalizedSourceName = NULL;
  int LengthDirectory, LengthFilename, LengthTotal;
  LengthDirectory = strlen(Directory);
  LengthFilename = strlen(Filename);
  LengthTotal = LengthFilename + 1;
  if (LengthDirectory > 0)
    LengthTotal += LengthDirectory + 1;
  NormalizedSourceName = realloc(NormalizedSourceName, LengthTotal);
  if (LengthDirectory > 0) {
    strcpy(NormalizedSourceName, Directory);
    NormalizedSourceName[LengthDirectory++] = '/';
  }
  strcpy(&NormalizedSourceName[LengthDirectory], Filename);
  return (NormalizedSourceName);
}


x86 assembly (clang, -O0):
<NormalizeSourceName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1177 <NormalizeSourceName+0x47>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2ec2(%rip),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <realloc@plt>
mov    %rax,0x2eb3(%rip)
cmpl   $0x0,-0x14(%rbp)
jle    11c0 <NormalizeSourceName+0x90>
mov    0x2ea2(%rip),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    0x2e92(%rip),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    0x2e79(%rip),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    0x2e62(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NormalizeSourceName>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rbx),%ebp
xor    %ecx,%ecx
test   %ebx,%ebx
cmovg  %ebp,%ecx
lea    (%rax,%rcx,1),%esi
add    $0x1,%esi
mov    0x2edd(%rip),%rdi
call   1050 <realloc@plt>
mov    %rax,0x2ed1(%rip)
test   %ebx,%ebx
jle    118d <NormalizeSourceName+0x5d>
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    0x2ebb(%rip),%rax
mov    %ebx,%ecx
movb   $0x2f,(%rax,%rcx,1)
jmp    118f <NormalizeSourceName+0x5f>
mov    %ebx,%ebp
movslq %ebp,%rdi
add    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    0x2e9c(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@NormalizeSourceName.NormalizedSourceName = internal global i8* null
define i8* @NormalizeSourceName(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %5
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = add nsw i32 %12, 1
store i32 %13, i32* %7
%14 = load i32, i32* %5
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
%19 = load i32, i32* %7
%20 = add nsw i32 %19, %18
store i32 %20, i32* %7
br label %21
21: ; preds = %16, %2
%22 = load i8*, i8** @NormalizeSourceName.NormalizedSourceName
%23 = load i32, i32* %7
%24 = call i8* @realloc(i8* %22, i32 %23)
store i8* %24, i8** @NormalizeSourceName.NormalizedSourceName
%25 = load i32, i32* %5
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %21
%28 = load i8*, i8** @NormalizeSourceName.NormalizedSourceName
%29 = load i8*, i8** %3
%30 = call i32 @strcpy(i8* %28, i8* %29)
%31 = load i8*, i8** @NormalizeSourceName.NormalizedSourceName
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
%34 = sext i32 %32 to i64
%35 = getelementptr inbounds i8, i8* %31, i64 %34
store i8 47, i8* %35
br label %36
36: ; preds = %27, %21
%37 = load i8*, i8** @NormalizeSourceName.NormalizedSourceName
%38 = load i32, i32* %5
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8*, i8** %4
%42 = call i32 @strcpy(i8* %40, i8* %41)
%43 = load i8*, i8** @NormalizeSourceName.NormalizedSourceName
ret i8* %43
}

LLVM IR (-O2):
@NormalizeSourceName.NormalizedSourceName = internal unnamed_addr global i8* null
define i8* @NormalizeSourceName(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = add nsw i32 %4, 1
%6 = icmp sgt i32 %3, 0
%7 = add nsw i32 %3, 1
%8 = select i1 %6, i32 %7, i32 0
%9 = add nsw i32 %5, %8
%10 = load i8*, i8** @NormalizeSourceName.NormalizedSourceName
%11 = tail call i8* @realloc(i8* %10, i32 %9)
store i8* %11, i8** @NormalizeSourceName.NormalizedSourceName
br i1 %6, label %12, label %17
12: ; preds = %2
%13 = tail call i32 @strcpy(i8* %11, i8* %0)
%14 = load i8*, i8** @NormalizeSourceName.NormalizedSourceName
%15 = zext i32 %3 to i64
%16 = getelementptr inbounds i8, i8* %14, i64 %15
store i8 47, i8* %16
br label %17
17: ; preds = %12, %2
%18 = phi i8* [ %14, %12 ], [ %11, %2 ]
%19 = phi i32 [ %7, %12 ], [ %3, %2 ]
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = tail call i32 @strcpy(i8* %21, i8* %1)
%23 = load i8*, i8** @NormalizeSourceName.NormalizedSourceName
ret i8* %23
}