#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 *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, scalar_t__);
scalar_t__ strspn(char *, char *);
int GetWait(char *line) {
  int offset = 0;
  if ((strlen(line) <= strlen("waitXXX")) &&
      !strncmp(&line[offset], "wait", strlen("wait"))) {
    offset += strlen("wait");
    if (strspn(&line[offset], "0123456789") > 0) {
      return atoi(&line[offset]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<GetWait>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
lea    0xe99(%rip),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jg     120a <GetWait+0xca>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
lea    0xe76(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rdx
lea    0xe63(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    120a <GetWait+0xca>
lea    0xe4e(%rip),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
lea    0xe2f(%rip),%rsi
call   1050 <strspn@plt>
cmp    $0x0,%rax
jle    1205 <GetWait+0xc5>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,-0x4(%rbp)
jmp    1211 <GetWait+0xd1>
jmp    120a <GetWait+0xca>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetWait>:
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0x7,%rax
jg     1167 <GetWait+0x27>
lea    0xeaa(%rip),%rsi
mov    $0x4,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     116b <GetWait+0x2b>
xor    %eax,%eax
pop    %rbx
ret
add    $0x4,%rbx
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strspn@plt>
test   %rax,%rax
jle    1167 <GetWait+0x27>
mov    %rbx,%rdi
pop    %rbx
jmp    1060 <atoi@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"waitXXX\00"
@.str.1 = [5 x i8] c"wait\00"
@.str.2 = [11 x i8] c"0123456789\00"
define i32 @GetWait(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
%5 = load i8*, i8** %3
%6 = call i64 @strlen(i8* %5)
%7 = call i64 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%8 = icmp sle i64 %6, %7
br i1 %8, label %9, label %36
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = call i64 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %36, label %17
17: ; preds = %9
%18 = call i64 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = add nsw i64 %20, %18
%22 = trunc i64 %21 to i32
store i32 %22, i32* %4
%23 = load i8*, i8** %3
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = call i64 @strspn(i8* %26, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp sgt i64 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %17
%30 = load i8*, i8** %3
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = call i32 @atoi(i8* %33)
store i32 %34, i32* %2
br label %37
35: ; preds = %17
br label %36
36: ; preds = %35, %9, %1
store i32 0, i32* %2
br label %37
37: ; preds = %36, %29
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"wait\00"
@.str.2 = [11 x i8] c"0123456789\00"
define i32 @GetWait(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = icmp slt i64 %2, 8
br i1 %3, label %4, label %13
4: ; preds = %1
%5 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 4
%9 = tail call i64 @strspn(i8* %8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @atoi(i8* %8)
br label %13
13: ; preds = %1, %4, %7, %11
%14 = phi i32 [ %12, %11 ], [ 0, %7 ], [ 0, %4 ], [ 0, %1 ]
ret i32 %14
}