#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 *CFCUtil_strdup(char const *);
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
scalar_t__ memcmp(char const *, char const *, size_t);
int /*<<< orphan*/ stderr;
size_t strlen(char const *);
int S_parse_string_argument(const char *arg, const char *name, char **result) {
  size_t arg_len = strlen(arg);
  size_t name_len = strlen(name);
  if (arg_len < name_len || memcmp(arg, name, name_len) != 0 ||
      arg[name_len] != '=') {
    return 0;
  }
  if (*result != NULL) {
    fprintf(stderr, "Duplicate %s argument\n", name);
    exit(EXIT_FAILURE);
  }
  *result = CFCUtil_strdup(arg + name_len + 1);
  return 1;
}


x86 assembly (clang, -O0):
<S_parse_string_argument>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jb     11bc <S_parse_string_argument+0x6c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    11bc <S_parse_string_argument+0x6c>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
je     11c8 <S_parse_string_argument+0x78>
movl   $0x0,-0x4(%rbp)
jmp    121f <S_parse_string_argument+0xcf>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11fd <S_parse_string_argument+0xad>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe16(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rdi
add    -0x30(%rbp),%rdi
add    $0x1,%rdi
call   1030 <CFCUtil_strdup@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<S_parse_string_argument>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
xor    %r12d,%r12d
cmp    %rax,%rbx
jb     11b8 <S_parse_string_argument+0x68>
mov    %rax,%rbp
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    11b8 <S_parse_string_argument+0x68>
cmpb   $0x3d,0x0(%r13,%rbp,1)
jne    11b8 <S_parse_string_argument+0x68>
cmpq   $0x0,(%r14)
jne    11ca <S_parse_string_argument+0x7a>
add    %rbp,%r13
add    $0x1,%r13
mov    %r13,%rdi
call   1030 <CFCUtil_strdup@plt>
mov    %rax,(%r14)
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
mov    %r15,%rdx
call   1060 <fprintf@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"Duplicate %s argument\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @S_parse_string_argument(i8* %0, i8* %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i64
%9 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8** %2, i8*** %7
%10 = load i8*, i8** %5
%11 = call i64 @strlen(i8* %10)
store i64 %11, i64* %8
%12 = load i8*, i8** %6
%13 = call i64 @strlen(i8* %12)
store i64 %13, i64* %9
%14 = load i64, i64* %8
%15 = load i64, i64* %9
%16 = icmp ult i64 %14, %15
br i1 %16, label %30, label %17
17: ; preds = %3
%18 = load i8*, i8** %5
%19 = load i8*, i8** %6
%20 = load i64, i64* %9
%21 = call i64 @memcmp(i8* %18, i8* %19, i64 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %30, label %23
23: ; preds = %17
%24 = load i8*, i8** %5
%25 = load i64, i64* %9
%26 = getelementptr inbounds i8, i8* %24, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 61
br i1 %29, label %30, label %31
30: ; preds = %23, %17, %3
store i32 0, i32* %4
br label %48
31: ; preds = %23
%32 = load i8**, i8*** %7
%33 = load i8*, i8** %32
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %41
35: ; preds = %31
%36 = load i32, i32* @stderr
%37 = load i8*, i8** %6
%38 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %37)
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %31
%42 = load i8*, i8** %5
%43 = load i64, i64* %9
%44 = getelementptr inbounds i8, i8* %42, i64 %43
%45 = getelementptr inbounds i8, i8* %44, i64 1
%46 = call i8* @CFCUtil_strdup(i8* %45)
%47 = load i8**, i8*** %7
store i8* %46, i8** %47
store i32 1, i32* %4
br label %48
48: ; preds = %41, %30
%49 = load i32, i32* %4
ret i32 %49
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"Duplicate %s argument\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @S_parse_string_argument(i8* %0, i8* %1, i8** nocapture %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%6 = icmp ult i64 %4, %5
br i1 %6, label %25, label %7
7: ; preds = %3
%8 = tail call i64 @memcmp(i8* %0, i8* %1, i64 %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %0, i64 %5
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 61
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = load i8*, i8** %2
%16 = icmp eq i8* %15, null
br i1 %16, label %22, label %17
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %1)
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %14
%23 = getelementptr inbounds i8, i8* %11, i64 1
%24 = tail call i8* @CFCUtil_strdup(i8* %23)
store i8* %24, i8** %2
br label %25
25: ; preds = %3, %7, %10, %22
%26 = phi i32 [ 1, %22 ], [ 0, %10 ], [ 0, %7 ], [ 0, %3 ]
ret i32 %26
}