#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*/ basic(char *);
int /*<<< orphan*/ usb_printf(char *, char const);
void slashed(const char *p) {
  for (; *p; p++)
    if (*p == '/')
      basic("\n");
    else
      usb_printf("%c", *p);
}


x86 assembly (clang, -O0):
<slashed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1183 <slashed+0x63>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    115a <slashed+0x3a>
lea    0xeb0(%rip),%rdi
call   1040 <basic@plt>
jmp    116d <slashed+0x4d>
mov    -0x8(%rbp),%rax
lea    0xe9d(%rip),%rdi
movsbl (%rax),%esi
call   1030 <usb_printf@plt>
jmp    1172 <slashed+0x52>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112c <slashed+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<slashed>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xed1(%rip),%r14
lea    0xecc(%rip),%r15
jmp    114c <slashed+0x2c>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <basic@plt>
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x2f,%al
je     1140 <slashed+0x20>
test   %al,%al
je     1168 <slashed+0x48>
movsbl %al,%esi
mov    %r15,%rdi
call   1030 <usb_printf@plt>
add    $0x1,%rbx
jmp    114c <slashed+0x2c>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [3 x i8] c"%c\00"
define void @slashed(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %19, %1
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = icmp ne i8 %5, 0
br i1 %6, label %7, label %22
7: ; preds = %3
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 47
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 @basic(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %18
14: ; preds = %7
%15 = load i8*, i8** %2
%16 = load i8, i8* %15
%17 = call i32 @usb_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %16)
br label %18
18: ; preds = %14, %12
br label %19
19: ; preds = %18
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %2
br label %3
22: ; preds = %3
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [3 x i8] c"%c\00"
define void @slashed(i8* nocapture %0) {
br label %2
2: ; preds = %9, %1
%3 = phi i8* [ %0, %1 ], [ %10, %9 ]
%4 = load i8, i8* %3
switch i8 %4, label %7 [
i8 0, label %11
i8 47, label %5
]
5: ; preds = %2
%6 = tail call i32 @basic(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %9
7: ; preds = %2
%8 = tail call i32 @usb_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %4)
br label %9
9: ; preds = %5, %7
%10 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
11: ; preds = %2
ret void
}