#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*/ getwd(char *);
int /*<<< orphan*/ strcat(char *, char *);
void Q_getwd(char *out) {
  int i = 0;
  getwd(out);
  strcat(out, "/");
  while (out[i] != 0) {
    if (out[i] == '\\')
      out[i] = '/';
    i++;
  }
}


x86 assembly (clang, -O0):
<Q_getwd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <getwd@plt>
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1190 <Q_getwd+0x70>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    1182 <Q_getwd+0x62>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114c <Q_getwd+0x2c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Q_getwd>:
push   %rbx
mov    %rdi,%rbx
call   1030 <getwd@plt>
lea    0xed0(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
jmp    1147 <Q_getwd+0x27>
nopw   0x0(%rax,%rax,1)
movb   $0x2f,(%rbx)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x5c,%al
je     1140 <Q_getwd+0x20>
test   %al,%al
jne    1143 <Q_getwd+0x23>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define void @Q_getwd(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = load i8*, i8** %2
%5 = call i32 @getwd(i8* %4)
%6 = load i8*, i8** %2
%7 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %29, %1
%9 = load i8*, i8** %2
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %32
16: ; preds = %8
%17 = load i8*, i8** %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 92
br i1 %23, label %24, label %29
24: ; preds = %16
%25 = load i8*, i8** %2
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
store i8 47, i8* %28
br label %29
29: ; preds = %24, %16
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %8
32: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define void @Q_getwd(i8* %0) {
%2 = tail call i32 @getwd(i8* %0)
%3 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %9, %1
%5 = phi i64 [ %10, %9 ], [ 0, %1 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
switch i8 %7, label %9 [
i8 0, label %11
i8 92, label %8
]
8: ; preds = %4
store i8 47, i8* %6
br label %9
9: ; preds = %4, %8
%10 = add nuw i64 %5, 1
br label %4
11: ; preds = %4
ret void
}