#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 */
scalar_t__ isdigit(char);
int strlen(char *);
int findDigit(char *episode, char *prefix) {
  int i, lenEp, lenPrefix;
  lenEp = strlen(episode) + 1;
  lenPrefix = strlen(prefix);
  for (i = lenPrefix; i < lenEp; i++)
    if (isdigit(episode[i]))
      return i;
  return -1;
}


x86 assembly (clang, -O0):
<findDigit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1196 <findDigit+0x76>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1183 <findDigit+0x63>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    119d <findDigit+0x7d>
jmp    1188 <findDigit+0x68>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1151 <findDigit+0x31>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findDigit>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    $0xffffffff,%r14d
cmp    %r15d,%eax
jg     117e <findDigit+0x5e>
mov    %eax,%ebp
cltq
add    $0x1,%r15d
add    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    117b <findDigit+0x5b>
add    $0x1,%ebp
add    $0x1,%rbx
cmp    %ebp,%r15d
jne    1160 <findDigit+0x40>
jmp    117e <findDigit+0x5e>
mov    %ebp,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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