#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 *);
char *jid_resource(char *jid, int *len) {
  int n;
  for (n = 0; jid[n] && jid[n] != '/'; n++) {
  }
  if (!jid[n])
    return 0;
  jid += n + 1;
  *len = strlen(jid);
  return jid;
}


x86 assembly (clang, -O0):
<jid_resource>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
je     1156 <jid_resource+0x46>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1166 <jid_resource+0x56>
jmp    1179 <jid_resource+0x69>
jmp    116b <jid_resource+0x5b>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <jid_resource+0x17>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
jne    1198 <jid_resource+0x88>
movq   $0x0,-0x8(%rbp)
jmp    11c5 <jid_resource+0xb5>
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jid_resource>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x1,%eax
nop
movzbl -0x1(%rbx,%rax,1),%ecx
test   %cl,%cl
je     1134 <jid_resource+0x24>
cmp    $0x2f,%cl
je     1138 <jid_resource+0x28>
add    $0x1,%rax
jmp    1120 <jid_resource+0x10>
xor    %ebx,%ebx
jmp    1148 <jid_resource+0x38>
mov    %eax,%eax
add    %rax,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @jid_resource(i8* %0, i32* nocapture writeonly %1) {
br label %3
3: ; preds = %7, %2
%4 = phi i64 [ %8, %7 ], [ 0, %2 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
switch i8 %6, label %7 [
i8 0, label %14
i8 47, label %9
]
7: ; preds = %3
%8 = add nuw i64 %4, 1
br label %3
9: ; preds = %3
%10 = add i64 %4, 1
%11 = and i64 %10, 4294967295
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = tail call i32 @strlen(i8* %12)
store i32 %13, i32* %1
br label %14
14: ; preds = %3, %9
%15 = phi i8* [ %12, %9 ], [ null, %3 ]
ret i8* %15
}