#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 */
char *strchr(char *, char);
int at_tok_start_flag(char **p_cur, char flag) {
  if (*p_cur == NULL) {
    return -1;
  }
  *p_cur = strchr(*p_cur, flag);
  if (*p_cur == NULL) {
    return -1;
  }
  (*p_cur)++;
  return 0;
}


x86 assembly (clang, -O0):
<at_tok_start_flag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    113c <at_tok_start_flag+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1185 <at_tok_start_flag+0x75>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
movsbl -0x11(%rbp),%esi
call   1030 <strchr@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1170 <at_tok_start_flag+0x60>
movl   $0xffffffff,-0x4(%rbp)
jmp    1185 <at_tok_start_flag+0x75>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<at_tok_start_flag>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rdi
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     113d <at_tok_start_flag+0x2d>
movsbl %sil,%esi
call   1030 <strchr@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     113d <at_tok_start_flag+0x2d>
add    $0x1,%rax
mov    %rax,(%rbx)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @at_tok_start_flag(i8** %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8
store i8** %0, i8*** %4
store i8 %1, i8* %5
%6 = load i8**, i8*** %4
%7 = load i8*, i8** %6
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 -1, i32* %3
br label %24
10: ; preds = %2
%11 = load i8**, i8*** %4
%12 = load i8*, i8** %11
%13 = load i8, i8* %5
%14 = call i8* @strchr(i8* %12, i8 signext %13)
%15 = load i8**, i8*** %4
store i8* %14, i8** %15
%16 = load i8**, i8*** %4
%17 = load i8*, i8** %16
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %20
19: ; preds = %10
store i32 -1, i32* %3
br label %24
20: ; preds = %10
%21 = load i8**, i8*** %4
%22 = load i8*, i8** %21
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %21
store i32 0, i32* %3
br label %24
24: ; preds = %20, %19, %9
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
define i32 @at_tok_start_flag(i8** nocapture %0, i8 signext %1) {
%3 = load i8*, i8** %0
%4 = icmp eq i8* %3, null
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = tail call i8* @strchr(i8* %3, i8 signext %1)
store i8* %6, i8** %0
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %6, i64 1
store i8* %9, i8** %0
br label %10
10: ; preds = %5, %2, %8
%11 = phi i32 [ 0, %8 ], [ -1, %2 ], [ -1, %5 ]
ret i32 %11
}