#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 */
char *strchr(char const *, char);
int strlen(char const *);
int is_doubleslash(const char *uri) {
  const char *cp;
  if (!uri)
    return 0;
  cp = strchr(uri, '?');
  if (!cp)
    cp = uri + strlen(uri);
  cp -= 2;
  if (cp >= uri && cp[0] == '/' && cp[1] == '/')
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<is_doubleslash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <is_doubleslash+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11cf <is_doubleslash+0xaf>
mov    -0x10(%rbp),%rdi
mov    $0x3f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1181 <is_doubleslash+0x61>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0xfffffffffffffffe,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jb     11c8 <is_doubleslash+0xa8>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    11c8 <is_doubleslash+0xa8>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    11c8 <is_doubleslash+0xa8>
movl   $0x1,-0x4(%rbp)
jmp    11cf <is_doubleslash+0xaf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_doubleslash>:
push   %rbx
xor    %ecx,%ecx
test   %rdi,%rdi
je     1162 <is_doubleslash+0x42>
mov    %rdi,%rbx
mov    $0x3f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    1147 <is_doubleslash+0x27>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
add    %rbx,%rax
lea    -0x2(%rax),%rcx
cmp    %rbx,%rcx
jb     1160 <is_doubleslash+0x40>
cmpb   $0x2f,(%rcx)
jne    1160 <is_doubleslash+0x40>
mov    $0x1,%ecx
cmpb   $0x2f,-0x1(%rax)
je     1162 <is_doubleslash+0x42>
xor    %ecx,%ecx
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @is_doubleslash(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 0, i32* %2
br label %39
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i8* @strchr(i8* %9, i8 signext 63)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %19, label %13
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = load i8*, i8** %3
%16 = call i32 @strlen(i8* %15)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
store i8* %18, i8** %4
br label %19
19: ; preds = %13, %8
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i64 -2
store i8* %21, i8** %4
%22 = load i8*, i8** %4
%23 = load i8*, i8** %3
%24 = icmp uge i8* %22, %23
br i1 %24, label %25, label %38
25: ; preds = %19
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 47
br i1 %30, label %31, label %38
31: ; preds = %25
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 47
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 1, i32* %2
br label %39
38: ; preds = %31, %25, %19
store i32 0, i32* %2
br label %39
39: ; preds = %38, %37, %7
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
define i32 @is_doubleslash(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %22, label %3
3: ; preds = %1
%4 = tail call i8* @strchr(i8* %0, i8 signext 63)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %0)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
br label %10
10: ; preds = %6, %3
%11 = phi i8* [ %4, %3 ], [ %9, %6 ]
%12 = getelementptr inbounds i8, i8* %11, i64 -2
%13 = icmp ult i8* %12, %0
br i1 %13, label %21, label %14
14: ; preds = %10
%15 = load i8, i8* %12
%16 = icmp eq i8 %15, 47
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = getelementptr inbounds i8, i8* %11, i64 -1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 47
br i1 %20, label %22, label %21
21: ; preds = %17, %14, %10
br label %22
22: ; preds = %17, %1, %21
%23 = phi i32 [ 0, %21 ], [ 0, %1 ], [ 1, %17 ]
ret i32 %23
}