#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*/ btp_skip_char(char const **, char);
int btp_skip_string(char const **, char *);
int btp_skip_unsigned_integer(char const **);
int btp_thread_skip_lwp(const char **input) {
  const char *local_input = *input;
  int count = btp_skip_string(&local_input, "(LWP ");
  if (0 == count)
    return 0;
  int digits = btp_skip_unsigned_integer(&local_input);
  if (0 == digits)
    return 0;
  count += digits;
  if (!btp_skip_char(&local_input, ')'))
    return 0;
  *input = local_input;
  return count + 1;
}


x86 assembly (clang, -O0):
<btp_thread_skip_lwp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xeae(%rip),%rsi
call   1040 <btp_skip_string@plt>
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
cmp    -0x1c(%rbp),%eax
jne    1171 <btp_thread_skip_lwp+0x41>
movl   $0x0,-0x4(%rbp)
jmp    11d4 <btp_thread_skip_lwp+0xa4>
lea    -0x18(%rbp),%rdi
call   1050 <btp_skip_unsigned_integer@plt>
mov    %eax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%eax
jne    1194 <btp_thread_skip_lwp+0x64>
movl   $0x0,-0x4(%rbp)
jmp    11d4 <btp_thread_skip_lwp+0xa4>
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    -0x18(%rbp),%rdi
mov    $0x29,%esi
call   1030 <btp_skip_char@plt>
cmp    $0x0,%eax
jne    11c0 <btp_thread_skip_lwp+0x90>
movl   $0x0,-0x4(%rbp)
jmp    11d4 <btp_thread_skip_lwp+0xa4>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<btp_thread_skip_lwp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%rax
mov    %rax,(%rsp)
lea    0xeb8(%rip),%rsi
mov    %rsp,%rdi
call   1040 <btp_skip_string@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1186 <btp_thread_skip_lwp+0x56>
mov    %eax,%ebx
mov    %rsp,%rdi
call   1050 <btp_skip_unsigned_integer@plt>
test   %eax,%eax
je     1186 <btp_thread_skip_lwp+0x56>
mov    %eax,%r15d
mov    %rsp,%rdi
mov    $0x29,%esi
call   1030 <btp_skip_char@plt>
test   %eax,%eax
je     1186 <btp_thread_skip_lwp+0x56>
mov    (%rsp),%rax
mov    %rax,(%r14)
lea    (%rbx,%r15,1),%ebp
add    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"(LWP \00"
define i32 @btp_thread_skip_lwp(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8** %0, i8*** %3
%7 = load i8**, i8*** %3
%8 = load i8*, i8** %7
store i8* %8, i8** %4
%9 = call i32 @btp_skip_string(i8** %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = icmp eq i32 0, %10
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 0, i32* %2
br label %30
13: ; preds = %1
%14 = call i32 @btp_skip_unsigned_integer(i8** %4)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = icmp eq i32 0, %15
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 0, i32* %2
br label %30
18: ; preds = %13
%19 = load i32, i32* %6
%20 = load i32, i32* %5
%21 = add nsw i32 %20, %19
store i32 %21, i32* %5
%22 = call i32 @btp_skip_char(i8** %4, i8 signext 41)
%23 = icmp ne i32 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %18
store i32 0, i32* %2
br label %30
25: ; preds = %18
%26 = load i8*, i8** %4
%27 = load i8**, i8*** %3
store i8* %26, i8** %27
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %30
30: ; preds = %25, %24, %17, %12
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [6 x i8] c"(LWP \00"
define i32 @btp_thread_skip_lwp(i8** nocapture %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = load i8*, i8** %0
store i8* %4, i8** %2
%5 = call i32 @btp_skip_string(i8** %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %1
%8 = call i32 @btp_skip_unsigned_integer(i8** %2)
%9 = icmp eq i32 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %7
%11 = call i32 @btp_skip_char(i8** %2, i8 signext 41)
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = load i8*, i8** %2
store i8* %14, i8** %0
%15 = add i32 %5, 1
%16 = add i32 %15, %8
br label %17
17: ; preds = %13, %7, %10, %1
%18 = phi i32 [ 0, %1 ], [ %16, %13 ], [ 0, %7 ], [ 0, %10 ]
ret i32 %18
}