#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 *strip(char *, char);
scalar_t__ strlen(char *);
char *strpbrk(char *, char *);
void parse_option_and_arg(char *str, char **opt, char **arg) {
  char *p;
  if ((p = strpbrk(str, "#\n")) != NULL) {
    *p = '\0';
  }
  if (strlen(str) > 0) {
    if ((p = strchr(str, '=')) != NULL) {
      *p = '\0';
      p++;
    } else {
      p = NULL;
    }
    *opt = strip(str, ' ');
    *arg = strip(p, ' ');
  } else {
    *opt = NULL;
    *arg = NULL;
  }
}


x86 assembly (clang, -O0):
<parse_option_and_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1060 <strpbrk@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1179 <parse_option_and_arg+0x39>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jle    11fd <parse_option_and_arg+0xbd>
mov    -0x8(%rbp),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11c0 <parse_option_and_arg+0x80>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11c8 <parse_option_and_arg+0x88>
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1050 <strip@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1050 <strip@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1213 <parse_option_and_arg+0xd3>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_option_and_arg>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    0xea8(%rip),%rsi
call   1060 <strpbrk@plt>
test   %rax,%rax
je     1165 <parse_option_and_arg+0x25>
movb   $0x0,(%rax)
mov    %r12,%rdi
call   1030 <strlen@plt>
test   %rax,%rax
jle    1190 <parse_option_and_arg+0x50>
mov    %r12,%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     119b <parse_option_and_arg+0x5b>
mov    %rax,%rbx
movb   $0x0,(%rax)
add    $0x1,%rbx
jmp    119d <parse_option_and_arg+0x5d>
movq   $0x0,(%r15)
xor    %eax,%eax
jmp    11ba <parse_option_and_arg+0x7a>
xor    %ebx,%ebx
mov    %r12,%rdi
mov    $0x20,%esi
call   1050 <strip@plt>
mov    %rax,(%r15)
mov    %rbx,%rdi
mov    $0x20,%esi
call   1050 <strip@plt>
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"#\0A\00"
define void @parse_option_and_arg(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%8 = load i8*, i8** %4
%9 = call i8* @strpbrk(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %7
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = load i8*, i8** %7
store i8 0, i8* %12
br label %13
13: ; preds = %11, %3
%14 = load i8*, i8** %4
%15 = call i64 @strlen(i8* %14)
%16 = icmp sgt i64 %15, 0
br i1 %16, label %17, label %33
17: ; preds = %13
%18 = load i8*, i8** %4
%19 = call i8* @strchr(i8* %18, i8 signext 61)
store i8* %19, i8** %7
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i8*, i8** %7
store i8 0, i8* %22
%23 = load i8*, i8** %7
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %7
br label %26
25: ; preds = %17
store i8* null, i8** %7
br label %26
26: ; preds = %25, %21
%27 = load i8*, i8** %4
%28 = call i8* @strip(i8* %27, i8 signext 32)
%29 = load i8**, i8*** %5
store i8* %28, i8** %29
%30 = load i8*, i8** %7
%31 = call i8* @strip(i8* %30, i8 signext 32)
%32 = load i8**, i8*** %6
store i8* %31, i8** %32
br label %36
33: ; preds = %13
%34 = load i8**, i8*** %5
store i8* null, i8** %34
%35 = load i8**, i8*** %6
store i8* null, i8** %35
br label %36
36: ; preds = %33, %26
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"#\0A\00"
define void @parse_option_and_arg(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = tail call i8* @strpbrk(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %7, label %6
6: ; preds = %3
store i8 0, i8* %4
br label %7
7: ; preds = %6, %3
%8 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 61)
%12 = icmp eq i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %10
store i8 0, i8* %11
%14 = getelementptr inbounds i8, i8* %11, i64 1
br label %15
15: ; preds = %10, %13
%16 = phi i8* [ %14, %13 ], [ null, %10 ]
%17 = tail call i8* @strip(i8* %0, i8 signext 32)
store i8* %17, i8** %1
%18 = tail call i8* @strip(i8* %16, i8 signext 32)
br label %20
19: ; preds = %7
store i8* null, i8** %1
br label %20
20: ; preds = %19, %15
%21 = phi i8* [ null, %19 ], [ %18, %15 ]
store i8* %21, i8** %2
ret void
}