#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 /*<<< orphan*/ sscanf(char *, char *, int *);
int strlen(char *);
int strextract_int(char *in) {
  char temp[200];
  int i = 0;
  int ret = 0.0;
  int count = 0;
  for (i = 0; i < strlen(in); i++) {
    if ((in[i] > 47) && (in[i] < 58)) {
      temp[count] = in[i];
      count++;
    }
  }
  temp[count] = 0;
  sscanf(temp, "%ld", &ret);
  return ret;
}


x86 assembly (clang, -O0):
<strextract_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xd4(%rbp)
movl   $0x0,-0xd8(%rbp)
movl   $0x0,-0xdc(%rbp)
movl   $0x0,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
mov    %eax,-0xe0(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xe0(%rbp),%eax
cmp    %ecx,%eax
jge    11f0 <strextract_int+0xd0>
mov    -0x8(%rbp),%rax
movslq -0xd4(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jle    11d7 <strextract_int+0xb7>
mov    -0x8(%rbp),%rax
movslq -0xd4(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jge    11d7 <strextract_int+0xb7>
mov    -0x8(%rbp),%rax
movslq -0xd4(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0xdc(%rbp),%rax
mov    %cl,-0xd0(%rbp,%rax,1)
mov    -0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
jmp    11dc <strextract_int+0xbc>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    1157 <strextract_int+0x37>
movslq -0xdc(%rbp),%rax
movb   $0x0,-0xd0(%rbp,%rax,1)
lea    -0xd0(%rbp),%rdi
lea    0xdf3(%rip),%rsi
lea    -0xd8(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0xd8(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strextract_int>:
push   %r15
push   %r14
push   %rbx
sub    $0xe0,%rsp
mov    %rdi,%r14
movl   $0x0,0xc(%rsp)
call   1030 <strlen@plt>
test   %eax,%eax
jle    117e <strextract_int+0x5e>
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    1163 <strextract_int+0x43>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1181 <strextract_int+0x61>
movzbl (%r14,%rbx,1),%eax
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     1150 <strextract_int+0x30>
movslq %r15d,%r15
mov    %al,0x10(%rsp,%r15,1)
add    $0x1,%r15d
jmp    1150 <strextract_int+0x30>
xor    %r15d,%r15d
movslq %r15d,%rax
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xe70(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
mov    0xc(%rsp),%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
define i32 @strextract_int(i8* %0) {
%2 = alloca [200 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = tail call i32 @strlen(i8* %0)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %25
8: ; preds = %1, %19
%9 = phi i64 [ %21, %19 ], [ 0, %1 ]
%10 = phi i32 [ %20, %19 ], [ 0, %1 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %9
%12 = load i8, i8* %11
%13 = add i8 %12, -48
%14 = icmp ult i8 %13, 10
br i1 %14, label %15, label %19
15: ; preds = %8
%16 = sext i32 %10 to i64
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %16
store i8 %12, i8* %17
%18 = add nsw i32 %10, 1
br label %19
19: ; preds = %8, %15
%20 = phi i32 [ %18, %15 ], [ %10, %8 ]
%21 = add nuw nsw i64 %9, 1
%22 = tail call i32 @strlen(i8* %0)
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %21, %23
br i1 %24, label %8, label %25
25: ; preds = %19, %1
%26 = phi i32 [ 0, %1 ], [ %20, %19 ]
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %27
store i8 0, i8* %28
%29 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%30 = load i32, i32* %3
ret i32 %30
}