#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*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char const *);
char *yasm__getcwd();
int /*<<< orphan*/ yasm_xfree(char *);
char *yasm_xmalloc(scalar_t__);
char *yasm__abspath_win(const char *path) {
  char *curdir, *abspath, *ch;
  static const char pathsep[2] = "\\";
  curdir = yasm__getcwd();
  abspath = yasm_xmalloc(strlen(curdir) + strlen(path) + 2);
  strcpy(abspath, curdir);
  strcat(abspath, pathsep);
  strcat(abspath, path);
  yasm_xfree(curdir);
  ch = abspath;
  while (*ch) {
    if (*ch == '/')
      *ch = '\\';
    ch++;
  }
  return abspath;
}


x86 assembly (clang, -O0):
<yasm__abspath_win>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1070 <yasm__getcwd@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1080 <yasm_xmalloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x10(%rbp),%rdi
call   1050 <yasm_xfree@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1211 <yasm__abspath_win+0xb1>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1200 <yasm__abspath_win+0xa0>
mov    -0x20(%rbp),%rax
movb   $0x5c,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11dc <yasm__abspath_win+0x7c>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yasm__abspath_win>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1070 <yasm__getcwd@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    (%rbx,%rax,1),%rdi
add    $0x2,%rdi
call   1080 <yasm_xmalloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe59(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
mov    %r15,%rdi
call   1050 <yasm_xfree@plt>
mov    %rbx,%rax
jmp    11d7 <yasm__abspath_win+0x77>
nopw   0x0(%rax,%rax,1)
movb   $0x5c,(%rax)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x2f,%cl
je     11d0 <yasm__abspath_win+0x70>
test   %cl,%cl
jne    11d3 <yasm__abspath_win+0x73>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@yasm__abspath_win.pathsep = internal constant [2 x i8] c"\\\00"
define i8* @yasm__abspath_win(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = call i8* (...) @yasm__getcwd()
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = load i8*, i8** %2
%10 = call i64 @strlen(i8* %9)
%11 = add nsw i64 %8, %10
%12 = add nsw i64 %11, 2
%13 = call i8* @yasm_xmalloc(i64 %12)
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = load i8*, i8** %3
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = load i8*, i8** %4
%18 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @yasm__abspath_win.pathsep, i64 0, i64 0))
%19 = load i8*, i8** %4
%20 = load i8*, i8** %2
%21 = call i32 @strcat(i8* %19, i8* %20)
%22 = load i8*, i8** %3
%23 = call i32 @yasm_xfree(i8* %22)
%24 = load i8*, i8** %4
store i8* %24, i8** %5
br label %25
25: ; preds = %36, %1
%26 = load i8*, i8** %5
%27 = load i8, i8* %26
%28 = icmp ne i8 %27, 0
br i1 %28, label %29, label %39
29: ; preds = %25
%30 = load i8*, i8** %5
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 47
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = load i8*, i8** %5
store i8 92, i8* %35
br label %36
36: ; preds = %34, %29
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %5
br label %25
39: ; preds = %25
%40 = load i8*, i8** %4
ret i8* %40
}

LLVM IR (-O2):
@yasm__abspath_win.pathsep = internal constant [2 x i8] c"\\\00"
define i8* @yasm__abspath_win(i8* %0) {
%2 = tail call i8* (...) @yasm__getcwd()
%3 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = add i64 %3, 2
%6 = add i64 %5, %4
%7 = tail call i8* @yasm_xmalloc(i64 %6)
%8 = tail call i32 @strcpy(i8* %7, i8* %2)
%9 = tail call i32 @strcat(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @yasm__abspath_win.pathsep, i64 0, i64 0))
%10 = tail call i32 @strcat(i8* %7, i8* %0)
%11 = tail call i32 @yasm_xfree(i8* %2)
br label %12
12: ; preds = %16, %1
%13 = phi i8* [ %7, %1 ], [ %17, %16 ]
%14 = load i8, i8* %13
switch i8 %14, label %16 [
i8 0, label %18
i8 47, label %15
]
15: ; preds = %12
store i8 92, i8* %13
br label %16
16: ; preds = %12, %15
%17 = getelementptr inbounds i8, i8* %13, i64 1
br label %12
18: ; preds = %12
ret i8* %7
}