#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__ is_in_str(char const, char const *);
int cal_args_num(const char *buffer, const char *divide) {
  int args_num = 0;
  int now_word = 0;
  while (*buffer) {
    if (now_word) {
      if (is_in_str(*buffer, divide)) {
        now_word = 0;
      }
    } else {
      if (!is_in_str(*buffer, divide)) {
        now_word = 1;
        args_num++;
      }
    }
    buffer++;
  }
  return args_num;
}


x86 assembly (clang, -O0):
<cal_args_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11af <cal_args_num+0x9f>
cmpl   $0x0,-0x18(%rbp)
je     116d <cal_args_num+0x5d>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1030 <is_in_str@plt>
cmp    $0x0,%rax
je     1168 <cal_args_num+0x58>
movl   $0x0,-0x18(%rbp)
jmp    119e <cal_args_num+0x8e>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1030 <is_in_str@plt>
cmp    $0x0,%rax
jne    1199 <cal_args_num+0x89>
movl   $0x1,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119e <cal_args_num+0x8e>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112e <cal_args_num+0x1e>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cal_args_num>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     1160 <cal_args_num+0x50>
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0x1,%rbx
xor    %r15d,%r15d
xor    %ebp,%ebp
nopl   0x0(%rax)
movsbl %al,%edi
mov    %r14,%rsi
call   1030 <is_in_str@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
test   %r15d,%r15d
mov    $0x0,%eax
cmove  %ecx,%eax
add    %eax,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
mov    %ecx,%r15d
test   %al,%al
jne    1130 <cal_args_num+0x20>
jmp    1162 <cal_args_num+0x52>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @cal_args_num(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %32, %2
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %35
11: ; preds = %7
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = load i8*, i8** %4
%18 = call i64 @is_in_str(i8 signext %16, i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 0, i32* %6
br label %21
21: ; preds = %20, %14
br label %32
22: ; preds = %11
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = load i8*, i8** %4
%26 = call i64 @is_in_str(i8 signext %24, i8* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %22
store i32 1, i32* %6
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %31
31: ; preds = %28, %22
br label %32
32: ; preds = %31, %21
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
br label %7
35: ; preds = %7
%36 = load i32, i32* %5
ret i32 %36
}

LLVM IR (-O2):
define i32 @cal_args_num(i8* nocapture %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %19, label %5
5: ; preds = %2, %5
%6 = phi i8 [ %17, %5 ], [ %3, %2 ]
%7 = phi i32 [ %13, %5 ], [ 0, %2 ]
%8 = phi i32 [ %15, %5 ], [ 0, %2 ]
%9 = phi i8* [ %16, %5 ], [ %0, %2 ]
%10 = icmp eq i32 %7, 0
%11 = tail call i64 @is_in_str(i8 signext %6, i8* %1)
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
%14 = select i1 %10, i32 %13, i32 0
%15 = add nuw nsw i32 %8, %14
%16 = getelementptr inbounds i8, i8* %9, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %5
19: ; preds = %5, %2
%20 = phi i32 [ 0, %2 ], [ %15, %5 ]
ret i32 %20
}