#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);
int /*<<< orphan*/ *serd_file_uri_parse(int /*<<< orphan*/ const *,
                                        int /*<<< orphan*/ *);
int /*<<< orphan*/ serd_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcmp(char const *, char *);
int /*<<< orphan*/ test_file_uri(char *, char *, int, char *, char *);
void test_uri_parsing(void) {
  test_file_uri(NULL, "C:/My 100%", true, "file:///C:/My%20100%%", NULL);
  test_file_uri("ahost", "C:\\Pointless Space", true,
                "file://ahost/C:/Pointless%20Space", "C:/Pointless Space");
  test_file_uri(NULL, "/foo/bar", true, "file:///foo/bar", NULL);
  test_file_uri("bhost", "/foo/bar", true, "file://bhost/foo/bar", NULL);
  test_file_uri(NULL, "a/relative path", false, "a/relative path", NULL);
  test_file_uri(NULL, "a/relative <path>", true, "a/relative%20%3Cpath%3E",
                NULL);
  uint8_t *out_path =
      serd_file_uri_parse(((const uint8_t *)("file:///foo/%0Xbar")), NULL);
  assert(!strcmp((const char *)out_path, "/foo/bar"));
  serd_free(out_path);
}


x86 assembly (clang, -O0):
<test_uri_parsing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
mov    %eax,%r8d
lea    0xe9c(%rip),%rsi
mov    $0x1,%edx
lea    0xe9b(%rip),%rcx
mov    %r8,%rdi
call   1040 <test_file_uri@plt>
lea    0xea2(%rip),%rdi
lea    0xea1(%rip),%rsi
mov    $0x1,%edx
lea    0xea8(%rip),%rcx
lea    0xec3(%rip),%r8
call   1040 <test_file_uri@plt>
xor    %eax,%eax
mov    %eax,%r8d
lea    0xecc(%rip),%rsi
mov    $0x1,%edx
lea    0xeb9(%rip),%rcx
mov    %r8,%rdi
call   1040 <test_file_uri@plt>
lea    0xeba(%rip),%rdi
lea    0xeaa(%rip),%rsi
mov    $0x1,%edx
lea    0xead(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <test_file_uri@plt>
xor    %eax,%eax
mov    %eax,%r8d
lea    0xeac(%rip),%rcx
xor    %edx,%edx
mov    %r8,%rdi
mov    %rcx,%rsi
call   1040 <test_file_uri@plt>
xor    %eax,%eax
mov    %eax,%r8d
lea    0xea3(%rip),%rsi
mov    $0x1,%edx
lea    0xea9(%rip),%rcx
mov    %r8,%rdi
call   1040 <test_file_uri@plt>
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <serd_file_uri_parse@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1050 <serd_free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_uri_parsing>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rsi
lea    0xea9(%rip),%rcx
xor    %edi,%edi
mov    $0x1,%edx
xor    %r8d,%r8d
call   1040 <test_file_uri@plt>
lea    0xea9(%rip),%rdi
lea    0xea8(%rip),%rsi
lea    0xeb4(%rip),%rcx
lea    0xecf(%rip),%r8
mov    $0x1,%edx
call   1040 <test_file_uri@plt>
lea    0xed8(%rip),%r14
lea    0xeca(%rip),%rcx
xor    %edi,%edi
mov    %r14,%rsi
mov    $0x1,%edx
xor    %r8d,%r8d
call   1040 <test_file_uri@plt>
lea    0xec1(%rip),%rdi
lea    0xec0(%rip),%rcx
mov    %r14,%rsi
mov    $0x1,%edx
xor    %r8d,%r8d
call   1040 <test_file_uri@plt>
lea    0xebe(%rip),%rcx
xor    %edi,%edi
mov    %rcx,%rsi
xor    %edx,%edx
xor    %r8d,%r8d
call   1040 <test_file_uri@plt>
lea    0xeb8(%rip),%rsi
lea    0xec3(%rip),%rcx
xor    %edi,%edi
mov    $0x1,%edx
xor    %r8d,%r8d
call   1040 <test_file_uri@plt>
lea    0xec5(%rip),%rdi
xor    %esi,%esi
call   1030 <serd_file_uri_parse@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <serd_free@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"C:/My 100%\00"
@.str.1 = [22 x i8] c"file:///C:/My%20100%%\00"
@.str.2 = [6 x i8] c"ahost\00"
@.str.3 = [19 x i8] c"C:\\Pointless Space\00"
@.str.4 = [34 x i8] c"file://ahost/C:/Pointless%20Space\00"
@.str.5 = [19 x i8] c"C:/Pointless Space\00"
@.str.6 = [9 x i8] c"/foo/bar\00"
@.str.7 = [16 x i8] c"file:///foo/bar\00"
@.str.8 = [6 x i8] c"bhost\00"
@.str.9 = [21 x i8] c"file://bhost/foo/bar\00"
@.str.10 = [16 x i8] c"a/relative path\00"
@.str.11 = [18 x i8] c"a/relative <path>\00"
@.str.12 = [24 x i8] c"a/relative%20%3Cpath%3E\00"
@.str.13 = [19 x i8] c"file:///foo/%0Xbar\00"
define void @test_uri_parsing() {
%1 = alloca i32*
%2 = call i32 @test_file_uri(i8* null, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* null)
%3 = call i32 @test_file_uri(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%4 = call i32 @test_file_uri(i8* null, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* null)
%5 = call i32 @test_file_uri(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i8* null)
%6 = call i32 @test_file_uri(i8* null, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* null)
%7 = call i32 @test_file_uri(i8* null, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i8* null)
%8 = call i32* @serd_file_uri_parse(i32* bitcast ([19 x i8]* @.str.13 to i32*), i32* null)
store i32* %8, i32** %1
%9 = load i32*, i32** %1
%10 = bitcast i32* %9 to i8*
%11 = call i32 @strcmp(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i32*, i32** %1
%17 = call i32 @serd_free(i32* %16)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"C:/My 100%\00"
@.str.1 = [22 x i8] c"file:///C:/My%20100%%\00"
@.str.2 = [6 x i8] c"ahost\00"
@.str.3 = [19 x i8] c"C:\\Pointless Space\00"
@.str.4 = [34 x i8] c"file://ahost/C:/Pointless%20Space\00"
@.str.5 = [19 x i8] c"C:/Pointless Space\00"
@.str.6 = [9 x i8] c"/foo/bar\00"
@.str.7 = [16 x i8] c"file:///foo/bar\00"
@.str.8 = [6 x i8] c"bhost\00"
@.str.9 = [21 x i8] c"file://bhost/foo/bar\00"
@.str.10 = [16 x i8] c"a/relative path\00"
@.str.11 = [18 x i8] c"a/relative <path>\00"
@.str.12 = [24 x i8] c"a/relative%20%3Cpath%3E\00"
@.str.13 = [19 x i8] c"file:///foo/%0Xbar\00"
define void @test_uri_parsing() {
%1 = tail call i32 @test_file_uri(i8* null, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* null)
%2 = tail call i32 @test_file_uri(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%3 = tail call i32 @test_file_uri(i8* null, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* null)
%4 = tail call i32 @test_file_uri(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i8* null)
%5 = tail call i32 @test_file_uri(i8* null, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* null)
%6 = tail call i32 @test_file_uri(i8* null, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i8* null)
%7 = tail call i32* @serd_file_uri_parse(i32* bitcast ([19 x i8]* @.str.13 to i32*), i32* null)
%8 = bitcast i32* %7 to i8*
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, 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 i32 @serd_free(i32* %7)
ret void
}