#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 checkbadstring(char *buf) {
  size_t i;
  int rv = 0;
  for (i = 0; buf[i]; i++) {
    if (buf[i] == ':' || buf[i] == '/') {
      buf[i] = '_';
      rv = 1;
    }
  }
  return rv;
}


x86 assembly (clang, -O0):
<checkbadstring>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     117c <checkbadstring+0x7c>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
je     1153 <checkbadstring+0x53>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1166 <checkbadstring+0x66>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movb   $0x5f,(%rax,%rcx,1)
movl   $0x1,-0x14(%rbp)
jmp    116b <checkbadstring+0x6b>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1117 <checkbadstring+0x17>
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkbadstring>:
xor    %eax,%eax
jmp    111c <checkbadstring+0x1c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x5f,(%rdi)
mov    $0x1,%eax
add    $0x1,%rdi
movzbl (%rdi),%ecx
cmp    $0x2f,%cl
je     1110 <checkbadstring+0x10>
cmp    $0x3a,%cl
je     1110 <checkbadstring+0x10>
test   %cl,%cl
jne    1118 <checkbadstring+0x18>
ret

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

LLVM IR (-O2):
define i32 @checkbadstring(i8* nocapture %0) {
br label %2
2: ; preds = %8, %1
%3 = phi i64 [ 0, %1 ], [ %10, %8 ]
%4 = phi i32 [ 0, %1 ], [ %9, %8 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %3
%6 = load i8, i8* %5
switch i8 %6, label %8 [
i8 0, label %11
i8 58, label %7
i8 47, label %7
]
7: ; preds = %2, %2
store i8 95, i8* %5
br label %8
8: ; preds = %2, %7
%9 = phi i32 [ 1, %7 ], [ %4, %2 ]
%10 = add i64 %3, 1
br label %2
11: ; preds = %2
ret i32 %4
}