#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 */
int strlen(unsigned char const *);
scalar_t__ strncmp(unsigned char const *, unsigned char const *, int);
const unsigned char *check_option(const unsigned char *opt_name,
                                  const unsigned char *opt) {
  int opt_len = strlen(opt_name);
  if (strncmp(opt_name, opt, opt_len) != 0)
    return NULL;
  if (opt[opt_len] != '=')
    return NULL;
  return opt + opt_len + 1;
}


x86 assembly (clang, -O0):
<check_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1163 <check_option+0x43>
movq   $0x0,-0x8(%rbp)
jmp    1198 <check_option+0x78>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
je     1185 <check_option+0x65>
movq   $0x0,-0x8(%rbp)
jmp    1198 <check_option+0x78>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_option>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1147 <check_option+0x27>
xor    %eax,%eax
jmp    115a <check_option+0x3a>
movslq %ebp,%rcx
xor    %eax,%eax
cmpb   $0x3d,(%r14,%rcx,1)
lea    0x1(%r14,%rcx,1),%rcx
cmove  %rcx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @check_option(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %6
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = load i32, i32* %6
%12 = call i64 @strncmp(i8* %9, i8* %10, i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %2
store i8* null, i8** %3
br label %30
15: ; preds = %2
%16 = load i8*, i8** %5
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = icmp ne i32 %21, 61
br i1 %22, label %23, label %24
23: ; preds = %15
store i8* null, i8** %3
br label %30
24: ; preds = %15
%25 = load i8*, i8** %5
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = getelementptr inbounds i8, i8* %28, i64 1
store i8* %29, i8** %3
br label %30
30: ; preds = %24, %23, %14
%31 = load i8*, i8** %3
ret i8* %31
}

LLVM IR (-O2):
define i8* @check_option(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i64 @strncmp(i8* %0, i8* %1, i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = sext i32 %3 to i64
%8 = getelementptr inbounds i8, i8* %1, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 61
%11 = getelementptr inbounds i8, i8* %8, i64 1
%12 = select i1 %10, i8* %11, i8* null
br label %13
13: ; preds = %6, %2
%14 = phi i8* [ null, %2 ], [ %12, %6 ]
ret i8* %14
}