#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
scalar_t__ serd_uri_to_path(int /*<<< orphan*/ const *);
int /*<<< orphan*/ strcmp(char const *, char *);
void test_uri_to_path(void) {
  const uint8_t *uri = (const uint8_t *)"file:///home/user/foo.ttl";
  assert(!strcmp((const char *)serd_uri_to_path(uri), "/home/user/foo.ttl"));
  uri = (const uint8_t *)"file://localhost/home/user/foo.ttl";
  assert(!strcmp((const char *)serd_uri_to_path(uri), "/home/user/foo.ttl"));
  uri = (const uint8_t *)"file:illegal/file/uri";
  assert(!serd_uri_to_path(uri));
  uri = (const uint8_t *)"file:///c:/awful/system";
  assert(!strcmp((const char *)serd_uri_to_path(uri), "c:/awful/system"));
  uri = (const uint8_t *)"file:///c:awful/system";
  assert(!strcmp((const char *)serd_uri_to_path(uri), "/c:awful/system"));
  uri = (const uint8_t *)"file:///0/1";
  assert(!strcmp((const char *)serd_uri_to_path(uri), "/0/1"));
  uri = (const uint8_t *)"C:\\Windows\\Sucks";
  assert(!strcmp((const char *)serd_uri_to_path(uri), "C:\\Windows\\Sucks"));
  uri = (const uint8_t *)"C|/Windows/Sucks";
  assert(!strcmp((const char *)serd_uri_to_path(uri), "C|/Windows/Sucks"));
  uri = (const uint8_t *)"http://example.org/path";
  assert(!serd_uri_to_path(uri));
}


x86 assembly (clang, -O0):
<test_uri_to_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <serd_uri_to_path@plt>
mov    %rax,%rdi
lea    0xeb1(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xea6(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <serd_uri_to_path@plt>
mov    %rax,%rdi
lea    0xe7c(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe94(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <serd_uri_to_path@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe83(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <serd_uri_to_path@plt>
mov    %rax,%rdi
lea    0xe74(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe66(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <serd_uri_to_path@plt>
mov    %rax,%rdi
lea    0xe56(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe48(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <serd_uri_to_path@plt>
mov    %rax,%rdi
lea    0xe38(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe1f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <serd_uri_to_path@plt>
mov    %rax,%rdi
lea    0xe08(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xdfb(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <serd_uri_to_path@plt>
mov    %rax,%rdi
lea    0xde4(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xdd7(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <serd_uri_to_path@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_uri_to_path>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1050 <serd_uri_to_path@plt>
lea    0xec3(%rip),%rbx
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xeb7(%rip),%rdi
call   1050 <serd_uri_to_path@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xeb6(%rip),%rdi
call   1050 <serd_uri_to_path@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
lea    0xeb2(%rip),%rdi
call   1050 <serd_uri_to_path@plt>
lea    0xeae(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xea2(%rip),%rdi
call   1050 <serd_uri_to_path@plt>
lea    0xe9d(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xe91(%rip),%rdi
call   1050 <serd_uri_to_path@plt>
lea    0xe8c(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xe75(%rip),%rbx
mov    %rbx,%rdi
call   1050 <serd_uri_to_path@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xe5f(%rip),%rbx
mov    %rbx,%rdi
call   1050 <serd_uri_to_path@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xe49(%rip),%rdi
call   1050 <serd_uri_to_path@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
pop    %rbx
jmp    1040 <assert@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"file:///home/user/foo.ttl\00"
@.str.1 = [19 x i8] c"/home/user/foo.ttl\00"
@.str.2 = [35 x i8] c"file://localhost/home/user/foo.ttl\00"
@.str.3 = [22 x i8] c"file:illegal/file/uri\00"
@.str.4 = [24 x i8] c"file:///c:/awful/system\00"
@.str.5 = [16 x i8] c"c:/awful/system\00"
@.str.6 = [23 x i8] c"file:///c:awful/system\00"
@.str.7 = [16 x i8] c"/c:awful/system\00"
@.str.8 = [12 x i8] c"file:///0/1\00"
@.str.9 = [5 x i8] c"/0/1\00"
@.str.10 = [17 x i8] c"C:\\Windows\\Sucks\00"
@.str.11 = [17 x i8] c"C|/Windows/Sucks\00"
@.str.12 = [24 x i8] c"http://example.org/path\00"
define void @test_uri_to_path() {
%1 = alloca i32*
store i32* bitcast ([26 x i8]* @.str to i32*), i32** %1
%2 = load i32*, i32** %1
%3 = call i64 @serd_uri_to_path(i32* %2)
%4 = inttoptr i64 %3 to i8*
%5 = call i32 @strcmp(i8* %4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp ne i32 %5, 0
%7 = xor i1 %6, true
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
store i32* bitcast ([35 x i8]* @.str.2 to i32*), i32** %1
%10 = load i32*, i32** %1
%11 = call i64 @serd_uri_to_path(i32* %10)
%12 = inttoptr i64 %11 to i8*
%13 = call i32 @strcmp(i8* %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
store i32* bitcast ([22 x i8]* @.str.3 to i32*), i32** %1
%18 = load i32*, i32** %1
%19 = call i64 @serd_uri_to_path(i32* %18)
%20 = icmp ne i64 %19, 0
%21 = xor i1 %20, true
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
store i32* bitcast ([24 x i8]* @.str.4 to i32*), i32** %1
%24 = load i32*, i32** %1
%25 = call i64 @serd_uri_to_path(i32* %24)
%26 = inttoptr i64 %25 to i8*
%27 = call i32 @strcmp(i8* %26, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
%29 = xor i1 %28, true
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
store i32* bitcast ([23 x i8]* @.str.6 to i32*), i32** %1
%32 = load i32*, i32** %1
%33 = call i64 @serd_uri_to_path(i32* %32)
%34 = inttoptr i64 %33 to i8*
%35 = call i32 @strcmp(i8* %34, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%36 = icmp ne i32 %35, 0
%37 = xor i1 %36, true
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
store i32* bitcast ([12 x i8]* @.str.8 to i32*), i32** %1
%40 = load i32*, i32** %1
%41 = call i64 @serd_uri_to_path(i32* %40)
%42 = inttoptr i64 %41 to i8*
%43 = call i32 @strcmp(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%44 = icmp ne i32 %43, 0
%45 = xor i1 %44, true
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
store i32* bitcast ([17 x i8]* @.str.10 to i32*), i32** %1
%48 = load i32*, i32** %1
%49 = call i64 @serd_uri_to_path(i32* %48)
%50 = inttoptr i64 %49 to i8*
%51 = call i32 @strcmp(i8* %50, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
%52 = icmp ne i32 %51, 0
%53 = xor i1 %52, true
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
store i32* bitcast ([17 x i8]* @.str.11 to i32*), i32** %1
%56 = load i32*, i32** %1
%57 = call i64 @serd_uri_to_path(i32* %56)
%58 = inttoptr i64 %57 to i8*
%59 = call i32 @strcmp(i8* %58, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0))
%60 = icmp ne i32 %59, 0
%61 = xor i1 %60, true
%62 = zext i1 %61 to i32
%63 = call i32 @assert(i32 %62)
store i32* bitcast ([24 x i8]* @.str.12 to i32*), i32** %1
%64 = load i32*, i32** %1
%65 = call i64 @serd_uri_to_path(i32* %64)
%66 = icmp ne i64 %65, 0
%67 = xor i1 %66, true
%68 = zext i1 %67 to i32
%69 = call i32 @assert(i32 %68)
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"file:///home/user/foo.ttl\00"
@.str.1 = [19 x i8] c"/home/user/foo.ttl\00"
@.str.2 = [35 x i8] c"file://localhost/home/user/foo.ttl\00"
@.str.3 = [22 x i8] c"file:illegal/file/uri\00"
@.str.4 = [24 x i8] c"file:///c:/awful/system\00"
@.str.5 = [16 x i8] c"c:/awful/system\00"
@.str.6 = [23 x i8] c"file:///c:awful/system\00"
@.str.7 = [16 x i8] c"/c:awful/system\00"
@.str.8 = [12 x i8] c"file:///0/1\00"
@.str.9 = [5 x i8] c"/0/1\00"
@.str.10 = [17 x i8] c"C:\\Windows\\Sucks\00"
@.str.11 = [17 x i8] c"C|/Windows/Sucks\00"
@.str.12 = [24 x i8] c"http://example.org/path\00"
define void @test_uri_to_path() {
%1 = tail call i64 @serd_uri_to_path(i32* bitcast ([26 x i8]* @.str to i32*))
%2 = inttoptr i64 %1 to i8*
%3 = tail call i32 @strcmp(i8* dereferenceable(1) %2, i8* dereferenceable(19) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i64 @serd_uri_to_path(i32* bitcast ([35 x i8]* @.str.2 to i32*))
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(19) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i64 @serd_uri_to_path(i32* bitcast ([22 x i8]* @.str.3 to i32*))
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = tail call i64 @serd_uri_to_path(i32* bitcast ([24 x i8]* @.str.4 to i32*))
%18 = inttoptr i64 %17 to i8*
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %18, i8* dereferenceable(16) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
%22 = tail call i32 @assert(i32 %21)
%23 = tail call i64 @serd_uri_to_path(i32* bitcast ([23 x i8]* @.str.6 to i32*))
%24 = inttoptr i64 %23 to i8*
%25 = tail call i32 @strcmp(i8* dereferenceable(1) %24, i8* dereferenceable(16) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
%27 = zext i1 %26 to i32
%28 = tail call i32 @assert(i32 %27)
%29 = tail call i64 @serd_uri_to_path(i32* bitcast ([12 x i8]* @.str.8 to i32*))
%30 = inttoptr i64 %29 to i8*
%31 = tail call i32 @strcmp(i8* dereferenceable(1) %30, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%32 = icmp eq i32 %31, 0
%33 = zext i1 %32 to i32
%34 = tail call i32 @assert(i32 %33)
%35 = tail call i64 @serd_uri_to_path(i32* bitcast ([17 x i8]* @.str.10 to i32*))
%36 = inttoptr i64 %35 to i8*
%37 = tail call i32 @strcmp(i8* dereferenceable(1) %36, i8* dereferenceable(17) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
%38 = icmp eq i32 %37, 0
%39 = zext i1 %38 to i32
%40 = tail call i32 @assert(i32 %39)
%41 = tail call i64 @serd_uri_to_path(i32* bitcast ([17 x i8]* @.str.11 to i32*))
%42 = inttoptr i64 %41 to i8*
%43 = tail call i32 @strcmp(i8* dereferenceable(1) %42, i8* dereferenceable(17) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0))
%44 = icmp eq i32 %43, 0
%45 = zext i1 %44 to i32
%46 = tail call i32 @assert(i32 %45)
%47 = tail call i64 @serd_uri_to_path(i32* bitcast ([24 x i8]* @.str.12 to i32*))
%48 = icmp eq i64 %47, 0
%49 = zext i1 %48 to i32
%50 = tail call i32 @assert(i32 %49)
ret void
}