#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 */
scalar_t__ csc_isdelim(char *, char);
scalar_t__ strtol(char *, char **, int /*<<< orphan*/);
int csc_strbival_int(char *s, char *delim, int *opt) {
  char *next, defdlm[] = " ";
  int val;
  val = (int)strtol(s, &next, 0);
  if (delim == NULL) {
    delim = defdlm;
  }
  while (*next && csc_isdelim(delim, *next))
    next++;
  if (opt) {
    *opt = (int)strtol(next, NULL, 0);
  }
  return val;
}


x86 assembly (clang, -O0):
<csc_strbival_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0xec5(%rip),%ax
mov    %ax,-0x22(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %eax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1164 <csc_strbival_int+0x44>
lea    -0x22(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1169 <csc_strbival_int+0x49>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     1198 <csc_strbival_int+0x78>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
movsbl (%rax),%esi
call   1040 <csc_isdelim@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11a8 <csc_strbival_int+0x88>
jmp    11b9 <csc_strbival_int+0x99>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1169 <csc_strbival_int+0x49>
cmpq   $0x0,-0x18(%rbp)
je     11db <csc_strbival_int+0xbb>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csc_strbival_int>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
movw   $0x20,0xe(%rsp)
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
test   %rbx,%rbx
lea    0xe(%rsp),%r12
cmovne %rbx,%r12
mov    %rax,%r14
mov    0x10(%rsp),%rbx
mov    (%rbx),%al
test   %al,%al
je     117c <csc_strbival_int+0x5c>
xchg   %ax,%ax
movsbl %al,%esi
mov    %r12,%rdi
call   1040 <csc_isdelim@plt>
test   %rax,%rax
je     117c <csc_strbival_int+0x5c>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <csc_strbival_int+0x40>
mov    %rbx,0x10(%rsp)
test   %r15,%r15
je     1195 <csc_strbival_int+0x75>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %eax,(%r15)
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.csc_strbival_int.defdlm = [2 x i8] c" \00"
define i32 @csc_strbival_int(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca [2 x i8]
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%10 = bitcast [2 x i8]* %8 to i8*
%11 = load i8*, i8** %4
%12 = call i64 @strtol(i8* %11, i8** %7, i32 0)
%13 = trunc i64 %12 to i32
store i32 %13, i32* %9
%14 = load i8*, i8** %5
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
store i8* %17, i8** %5
br label %18
18: ; preds = %16, %3
br label %19
19: ; preds = %32, %18
%20 = load i8*, i8** %7
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %19
%25 = load i8*, i8** %5
%26 = load i8*, i8** %7
%27 = load i8, i8* %26
%28 = call i64 @csc_isdelim(i8* %25, i8 signext %27)
%29 = icmp ne i64 %28, 0
br label %30
30: ; preds = %24, %19
%31 = phi i1 [ false, %19 ], [ %29, %24 ]
br i1 %31, label %32, label %35
32: ; preds = %30
%33 = load i8*, i8** %7
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %7
br label %19
35: ; preds = %30
%36 = load i32*, i32** %6
%37 = icmp ne i32* %36, null
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i8*, i8** %7
%40 = call i64 @strtol(i8* %39, i8** null, i32 0)
%41 = trunc i64 %40 to i32
%42 = load i32*, i32** %6
store i32 %41, i32* %42
br label %43
43: ; preds = %38, %35
%44 = load i32, i32* %9
ret i32 %44
}

LLVM IR (-O2):
define i32 @csc_strbival_int(i8* %0, i8* %1, i32* writeonly %2) {
%4 = alloca i8*
%5 = alloca i16
%6 = bitcast i8** %4 to i8*
%7 = bitcast i16* %5 to i8*
store i16 32, i16* %5
%8 = call i64 @strtol(i8* %0, i8** %4, i32 0)
%9 = icmp eq i8* %1, null
%10 = select i1 %9, i8* %7, i8* %1
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %23, label %14
14: ; preds = %3, %19
%15 = phi i8 [ %21, %19 ], [ %12, %3 ]
%16 = phi i8* [ %20, %19 ], [ %11, %3 ]
%17 = call i64 @csc_isdelim(i8* %10, i8 signext %15)
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %14
%20 = getelementptr inbounds i8, i8* %16, i64 1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %14
23: ; preds = %14, %19, %3
%24 = phi i8* [ %11, %3 ], [ %20, %19 ], [ %16, %14 ]
store i8* %24, i8** %4
%25 = icmp eq i32* %2, null
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = call i64 @strtol(i8* nocapture %24, i8** null, i32 0)
%28 = trunc i64 %27 to i32
store i32 %28, i32* %2
br label %29
29: ; preds = %26, %23
%30 = trunc i64 %8 to i32
ret i32 %30
}