#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);
char *strpbrk(char *, char *);
int /*<<< orphan*/ trim_whitespace(char **, char **);
int find_optional_argument(char *line, char **bp, char **ep) {
  *bp = line = strpbrk(line, " \t\r\n");
  if (line == NULL)
    return 0;
  *ep = strchr(*bp, '\0');
  trim_whitespace(bp, ep);
  return *bp != *ep;
}


x86 assembly (clang, -O0):
<find_optional_argument>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1050 <strpbrk@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x10(%rbp)
jne    1179 <find_optional_argument+0x49>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <find_optional_argument+0x87>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
xor    %esi,%esi
call   1030 <strchr@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <trim_whitespace@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_optional_argument>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
lea    0xebe(%rip),%rsi
call   1050 <strpbrk@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     1178 <find_optional_argument+0x48>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <strlen@plt>
add    %rbx,%rax
mov    %rax,(%r14)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <trim_whitespace@plt>
mov    (%r15),%rcx
xor    %eax,%eax
cmp    (%r14),%rcx
setne  %al
jmp    117a <find_optional_argument+0x4a>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c" \09\0D\0A\00"
define i32 @find_optional_argument(i8* %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8**
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%8 = load i8*, i8** %5
%9 = call i8* @strpbrk(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %5
%10 = load i8**, i8*** %6
store i8* %9, i8** %10
%11 = load i8*, i8** %5
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 0, i32* %4
br label %28
14: ; preds = %3
%15 = load i8**, i8*** %6
%16 = load i8*, i8** %15
%17 = call i8* @strchr(i8* %16, i8 signext 0)
%18 = load i8**, i8*** %7
store i8* %17, i8** %18
%19 = load i8**, i8*** %6
%20 = load i8**, i8*** %7
%21 = call i32 @trim_whitespace(i8** %19, i8** %20)
%22 = load i8**, i8*** %6
%23 = load i8*, i8** %22
%24 = load i8**, i8*** %7
%25 = load i8*, i8** %24
%26 = icmp ne i8* %23, %25
%27 = zext i1 %26 to i32
store i32 %27, i32* %4
br label %28
28: ; preds = %14, %13
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
@.str = [5 x i8] c" \09\0D\0A\00"
define i32 @find_optional_argument(i8* %0, i8** %1, i8** %2) {
%4 = tail call i8* @strpbrk(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %1
%5 = icmp eq i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %3
%7 = tail call i64 @strlen(i8* %4)
%8 = getelementptr i8, i8* %4, i64 %7
store i8* %8, i8** %2
%9 = tail call i32 @trim_whitespace(i8** %1, i8** %2)
%10 = load i8*, i8** %1
%11 = load i8*, i8** %2
%12 = icmp ne i8* %10, %11
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %3, %6
%15 = phi i32 [ %13, %6 ], [ 0, %3 ]
ret i32 %15
}