#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 *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void get_path(char *str, char *path) {
  register int i;
  strcpy(path, str);
  for (i = strlen(path) - 1; i > -1; --i) {
    if (str[i] == '\\') {
      i = -1;
      break;
    }
    if (str[i] == '.')
      break;
  }
  if (i < 0)
    strcat(path, ".");
  else
    path[i + 1] = '\0';
}


x86 assembly (clang, -O0):
<get_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jle    11b4 <get_path+0x84>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    1187 <get_path+0x57>
movl   $0xffffffff,-0x14(%rbp)
jmp    11b4 <get_path+0x84>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    11a1 <get_path+0x71>
jmp    11b4 <get_path+0x84>
jmp    11a6 <get_path+0x76>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    115c <get_path+0x2c>
cmpl   $0x0,-0x14(%rbp)
jge    11d3 <get_path+0xa3>
mov    -0x10(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1050 <strcat@plt>
jmp    11e4 <get_path+0xb4>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_path>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
nop
test   %eax,%eax
jle    1167 <get_path+0x37>
movzbl -0x1(%rbx,%rax,1),%ecx
add    $0xffffffffffffffff,%rax
cmp    $0x2e,%cl
je     117d <get_path+0x4d>
cmp    $0x5c,%cl
jne    1150 <get_path+0x20>
lea    0xe92(%rip),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <strcat@plt>
movb   $0x0,0x1(%r14,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
define void @get_path(i8* %0, i8* %1) {
%3 = tail call i32 @strcpy(i8* %1, i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = zext i32 %4 to i64
br label %6
6: ; preds = %11, %2
%7 = phi i64 [ %8, %11 ], [ %5, %2 ]
%8 = add nsw i64 %7, -1
%9 = trunc i64 %7 to i32
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %0, i64 %8
%13 = load i8, i8* %12
switch i8 %13, label %6 [
i8 92, label %14
i8 46, label %16
]
14: ; preds = %6, %11
%15 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %19
16: ; preds = %11
%17 = and i64 %7, 4294967295
%18 = getelementptr inbounds i8, i8* %1, i64 %17
store i8 0, i8* %18
br label %19
19: ; preds = %16, %14
ret void
}