#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 *);
char *strstr(char *, char *);
int scan_int(char *line, char *scan) {
  char *find;
  int res;
  res = 0;
  find = strstr(line, scan);
  if (find) {
    sscanf(find + strlen(scan) + 1, "%d", &res);
  }
  return res;
}


x86 assembly (clang, -O0):
<scan_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1191 <scan_int+0x61>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0x1,%rdi
lea    0xe78(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_int>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
movl   $0x0,0x4(%rsp)
call   1050 <strstr@plt>
test   %rax,%rax
je     1175 <scan_int+0x45>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
lea    0xe9b(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1040 <sscanf@plt>
mov    0x4(%rsp),%eax
jmp    1177 <scan_int+0x47>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @scan_int(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %6
%7 = load i8*, i8** %3
%8 = load i8*, i8** %4
%9 = call i8* @strstr(i8* %7, i8* %8)
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %20
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %13, i64 %16
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
br label %20
20: ; preds = %12, %2
%21 = load i32, i32* %6
ret i32 %21
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @scan_int(i8* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%6 = icmp eq i8* %5, null
br i1 %6, label %14, label %7
7: ; preds = %2
%8 = tail call i32 @strlen(i8* %1)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %5, i64 %9
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
br label %14
14: ; preds = %7, %2
%15 = phi i32 [ %13, %7 ], [ 0, %2 ]
ret i32 %15
}