#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
char *parse_arg_tag(int *, int, char const **, char const *, char const *,
                    char *);
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char const *);
const char *get_arg_value_str(int *arg, int argc, const char **argv, int opos,
                              const char *stag, const char *ltag) {
  const char *tmp_str = NULL;
  if ((tmp_str = parse_arg_tag(arg, argc, argv, stag, ltag, "="))) {
    if (strlen(tmp_str) > 0) {
      return tmp_str;
    } else {
      fprintf(stderr, "Missing value after '%s'\n", tmp_str);
    }
  } else if ((*arg == opos) && (argv[*arg][0] != '-')) {
    return argv[*arg];
  }
  return NULL;
}


x86 assembly (clang, -O0):
<get_arg_value_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
lea    0xe90(%rip),%r9
call   1050 <parse_arg_tag@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
je     11c1 <get_arg_value_str+0x91>
mov    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jle    11a3 <get_arg_value_str+0x73>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1210 <get_arg_value_str+0xe0>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rdx
lea    0xe4b(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1208 <get_arg_value_str+0xd8>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
cmp    -0x24(%rbp),%eax
jne    1203 <get_arg_value_str+0xd3>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     1203 <get_arg_value_str+0xd3>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
jmp    1210 <get_arg_value_str+0xe0>
jmp    1208 <get_arg_value_str+0xd8>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_arg_value_str>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r9,%rax
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %rdi,%rbp
lea    0xeb6(%rip),%r9
mov    %r8,%rcx
mov    %rax,%r8
call   1050 <parse_arg_tag@plt>
test   %rax,%rax
je     1184 <get_arg_value_str+0x54>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <strlen@plt>
test   %rax,%rax
jg     1198 <get_arg_value_str+0x68>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
jmp    1196 <get_arg_value_str+0x66>
cmp    %r15d,0x0(%rbp)
jne    1196 <get_arg_value_str+0x66>
movslq %r15d,%rax
mov    (%r14,%rax,8),%rbx
cmpb   $0x2d,(%rbx)
jne    1198 <get_arg_value_str+0x68>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"=\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"Missing value after '%s'\0A\00"
define i8* @get_arg_value_str(i32* %0, i32 %1, i8** %2, i32 %3, i8* %4, i8* %5) {
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
store i32* %0, i32** %8
store i32 %1, i32* %9
store i8** %2, i8*** %10
store i32 %3, i32* %11
store i8* %4, i8** %12
store i8* %5, i8** %13
store i8* null, i8** %14
%15 = load i32*, i32** %8
%16 = load i32, i32* %9
%17 = load i8**, i8*** %10
%18 = load i8*, i8** %12
%19 = load i8*, i8** %13
%20 = call i8* @parse_arg_tag(i32* %15, i32 %16, i8** %17, i8* %18, i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** %14
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %33
22: ; preds = %6
%23 = load i8*, i8** %14
%24 = call i64 @strlen(i8* %23)
%25 = icmp sgt i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = load i8*, i8** %14
store i8* %27, i8** %7
br label %58
28: ; preds = %22
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %14
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %28
br label %57
33: ; preds = %6
%34 = load i32*, i32** %8
%35 = load i32, i32* %34
%36 = load i32, i32* %11
%37 = icmp eq i32 %35, %36
br i1 %37, label %38, label %56
38: ; preds = %33
%39 = load i8**, i8*** %10
%40 = load i32*, i32** %8
%41 = load i32, i32* %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %39, i64 %42
%44 = load i8*, i8** %43
%45 = getelementptr inbounds i8, i8* %44, i64 0
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 45
br i1 %48, label %49, label %56
49: ; preds = %38
%50 = load i8**, i8*** %10
%51 = load i32*, i32** %8
%52 = load i32, i32* %51
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %50, i64 %53
%55 = load i8*, i8** %54
store i8* %55, i8** %7
br label %58
56: ; preds = %38, %33
br label %57
57: ; preds = %56, %32
store i8* null, i8** %7
br label %58
58: ; preds = %57, %49, %26
%59 = load i8*, i8** %7
ret i8* %59
}

LLVM IR (-O2):
@.str = [2 x i8] c"=\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"Missing value after '%s'\0A\00"
define i8* @get_arg_value_str(i32* %0, i32 %1, i8** %2, i32 %3, i8* %4, i8* %5) {
%7 = tail call i8* @parse_arg_tag(i32* %0, i32 %1, i8** %2, i8* %4, i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %15, label %9
9: ; preds = %6
%10 = tail call i64 @strlen(i8* %7)
%11 = icmp sgt i64 %10, 0
br i1 %11, label %25, label %12
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %24
15: ; preds = %6
%16 = load i32, i32* %0
%17 = icmp eq i32 %16, %3
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = sext i32 %3 to i64
%20 = getelementptr inbounds i8*, i8** %2, i64 %19
%21 = load i8*, i8** %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 45
br i1 %23, label %24, label %25
24: ; preds = %15, %18, %12
br label %25
25: ; preds = %18, %9, %24
%26 = phi i8* [ null, %24 ], [ %7, %9 ], [ %21, %18 ]
ret i8* %26
}