#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 atoi(char const *);
unsigned int strlen(char const *);
scalar_t__ strncmp(char const *, char const *, unsigned int);
int startswithextractnum(const char *arg, const char *lookfor, int *numout) {
  const char *s = 0;
  unsigned prefixlen = strlen(lookfor);
  int v = 0;
  if (strncmp(arg, lookfor, prefixlen)) {
    return 0;
  }
  s = arg + prefixlen;
  v = atoi(s);
  *numout = v;
  return 1;
}


x86 assembly (clang, -O0):
<startswithextractnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1185 <startswithextractnum+0x55>
movl   $0x0,-0x4(%rbp)
jmp    11af <startswithextractnum+0x7f>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<startswithextractnum>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    1178 <startswithextractnum+0x48>
mov    %r15d,%eax
add    %rax,%rbx
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %eax,(%r14)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @startswithextractnum(i8* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i8* null, i8** %8
%11 = load i8*, i8** %6
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %9
store i32 0, i32* %10
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = load i32, i32* %9
%16 = call i64 @strncmp(i8* %13, i8* %14, i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %3
store i32 0, i32* %4
br label %28
19: ; preds = %3
%20 = load i8*, i8** %5
%21 = load i32, i32* %9
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8* %23, i8** %8
%24 = load i8*, i8** %8
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %10
%26 = load i32, i32* %10
%27 = load i32*, i32** %7
store i32 %26, i32* %27
store i32 1, i32* %4
br label %28
28: ; preds = %19, %18
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
define i32 @startswithextractnum(i8* %0, i8* %1, i32* nocapture writeonly %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i64 @strncmp(i8* %0, i8* %1, i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = zext i32 %4 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = tail call i32 @atoi(i8* %9)
store i32 %10, i32* %2
br label %11
11: ; preds = %3, %7
%12 = phi i32 [ 1, %7 ], [ 0, %3 ]
ret i32 %12
}