#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 strlen(char *);
void pack(unsigned char *s) {
  int pos = strlen((char *)s);
  for (; --pos >= 0;) {
    if (s[pos] == '/') {
      if (pos < 2 && s[0] == '/')
        break;
      s[pos] = 0;
      break;
    }
    if (s[pos] == ' ')
      s[pos] = 0;
    else
      break;
  }
}


x86 assembly (clang, -O0):
<pack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jl     11af <pack+0x9f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    117f <pack+0x6f>
cmpl   $0x2,-0xc(%rbp)
jge    116e <pack+0x5e>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x2f,%eax
jne    116e <pack+0x5e>
jmp    11af <pack+0x9f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11af <pack+0x9f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    11a5 <pack+0x95>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11aa <pack+0x9a>
jmp    11af <pack+0x9f>
jmp    1128 <pack+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pack>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
jle    1169 <pack+0x59>
mov    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x1(%rax),%rdx
mov    %edx,%ecx
movzbl (%r14,%rcx,1),%ebx
cmp    $0x20,%bl
jne    1154 <pack+0x44>
movb   $0x0,(%r14,%rcx,1)
lea    0x1(%rdx),%rcx
mov    %rdx,%rax
cmp    $0x1,%rcx
ja     1130 <pack+0x20>
jmp    1169 <pack+0x59>
cmp    $0x2f,%bl
jne    1169 <pack+0x59>
cmp    $0x2,%eax
ja     1164 <pack+0x54>
cmpb   $0x2f,(%r14)
je     1169 <pack+0x59>
movb   $0x0,(%r14,%rcx,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @pack(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %21
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %6
6: ; preds = %4, %19
%7 = phi i64 [ %5, %4 ], [ %8, %19 ]
%8 = add nsw i64 %7, -1
%9 = and i64 %8, 4294967295
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
switch i8 %11, label %21 [
i8 47, label %12
i8 32, label %19
]
12: ; preds = %6
%13 = trunc i64 %7 to i32
%14 = icmp ult i32 %13, 3
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i8, i8* %0
%17 = icmp eq i8 %16, 47
br i1 %17, label %21, label %18
18: ; preds = %15, %12
store i8 0, i8* %10
br label %21
19: ; preds = %6
store i8 0, i8* %10
%20 = icmp ugt i64 %7, 1
br i1 %20, label %6, label %21
21: ; preds = %19, %6, %1, %15, %18
ret void
}