#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 GetFolderSeparator(char *path) {
  if (path == NULL)
    return '/';
  while (*path) {
    if (*path == '\\')
      return '\\';
    if (*path == '/')
      return '/';
    path++;
  }
  return '/';
}


x86 assembly (clang, -O0):
<GetFolderSeparator>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    111c <GetFolderSeparator+0x1c>
movb   $0x2f,-0x1(%rbp)
jmp    1175 <GetFolderSeparator+0x75>
jmp    1121 <GetFolderSeparator+0x21>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1171 <GetFolderSeparator+0x71>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1147 <GetFolderSeparator+0x47>
movb   $0x5c,-0x1(%rbp)
jmp    1175 <GetFolderSeparator+0x75>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1160 <GetFolderSeparator+0x60>
movb   $0x2f,-0x1(%rbp)
jmp    1175 <GetFolderSeparator+0x75>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1121 <GetFolderSeparator+0x21>
movb   $0x2f,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetFolderSeparator>:
mov    $0x2f,%al
test   %rdi,%rdi
je     1127 <GetFolderSeparator+0x27>
nopw   0x0(%rax,%rax,1)
movzbl (%rdi),%eax
test   %al,%al
je     1125 <GetFolderSeparator+0x25>
cmp    $0x2f,%al
je     1125 <GetFolderSeparator+0x25>
cmp    $0x5c,%al
je     1127 <GetFolderSeparator+0x27>
add    $0x1,%rdi
jmp    1110 <GetFolderSeparator+0x10>
mov    $0x2f,%al
ret

LLVM IR (-O0):
define signext i8 @GetFolderSeparator(i8* %0) {
%2 = alloca i8
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %7
6: ; preds = %1
store i8 47, i8* %2
br label %28
7: ; preds = %1
br label %8
8: ; preds = %24, %7
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 92
br i1 %16, label %17, label %18
17: ; preds = %12
store i8 92, i8* %2
br label %28
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 47
br i1 %22, label %23, label %24
23: ; preds = %18
store i8 47, i8* %2
br label %28
24: ; preds = %18
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
br label %8
27: ; preds = %8
store i8 47, i8* %2
br label %28
28: ; preds = %27, %23, %17, %6
%29 = load i8, i8* %2
ret i8 %29
}

LLVM IR (-O2):
define signext i8 @GetFolderSeparator(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %9, label %3
3: ; preds = %1, %6
%4 = phi i8* [ %7, %6 ], [ %0, %1 ]
%5 = load i8, i8* %4
switch i8 %5, label %6 [
i8 0, label %9
i8 92, label %8
i8 47, label %9
]
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
8: ; preds = %3
br label %9
9: ; preds = %3, %3, %8, %1
%10 = phi i8 [ 47, %1 ], [ %5, %8 ], [ 47, %3 ], [ 47, %3 ]
ret i8 %10
}