#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*/ LOG_ERR;
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char *);
int parse_pair(const char *str, char *name, char *value) {
  int len = strlen(str);
  if (!len)
    return 0;
  char s[len + 10];
  strcpy(s, str);
  if (s[len - 1] == '\n')
    s[len - 1] = '\0';
  char *eq = strchr(s, '=');
  if (!eq || eq == s) {
    syslog(LOG_ERR, "Error: can't parse: %s", s);
    return 0;
  }
  eq[0] = '\0';
  strcpy(name, s);
  strcpy(value, eq + 1);
  return 1;
}


x86 assembly (clang, -O0):
<parse_pair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1176 <parse_pair+0x36>
movl   $0x0,-0x4(%rbp)
jmp    1264 <parse_pair+0x124>
mov    -0x24(%rbp),%eax
add    $0xa,%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x50(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x50(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11d3 <parse_pair+0x93>
mov    -0x50(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x50(%rbp),%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     11fe <parse_pair+0xbe>
mov    -0x50(%rbp),%rax
cmp    %rax,-0x40(%rbp)
jne    122a <parse_pair+0xea>
mov    -0x50(%rbp),%rdx
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
lea    0xdee(%rip),%rsi
call   1060 <syslog@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    125d <parse_pair+0x11d>
mov    -0x50(%rbp),%rsi
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_pair>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
call   1040 <strlen@plt>
test   %eax,%eax
je     11d6 <parse_pair+0x96>
mov    %eax,%r13d
mov    %rsp,-0x30(%rbp)
lea    0xa(%r13),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
movslq %r13d,%rax
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    1196 <parse_pair+0x56>
movb   $0x0,-0x1(%rbx,%rax,1)
mov    %rbx,%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11da <parse_pair+0x9a>
mov    %rax,%r12
cmp    %rbx,%rax
je     11da <parse_pair+0x9a>
movb   $0x0,(%r12)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
add    $0x1,%r12
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    $0x1,%eax
jmp    11f4 <parse_pair+0xb4>
xor    %eax,%eax
jmp    11fb <parse_pair+0xbb>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
lea    0xe16(%rip),%rsi
mov    %rbx,%rdx
call   1060 <syslog@plt>
xor    %eax,%eax
mov    -0x30(%rbp),%rcx
mov    %rcx,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@LOG_ERR = global i32 0
@.str = [23 x i8] c"Error: can't parse: %s\00"
define i32 @parse_pair(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %32, label %6
6: ; preds = %3
%7 = add nsw i32 %4, 10
%8 = zext i32 %7 to i64
%9 = tail call i8* @llvm.stacksave()
%10 = alloca i8, i64 %8
%11 = call i32 @strcpy(i8* %10, i8* %0)
%12 = add nsw i32 %4, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 10
br i1 %16, label %17, label %18
17: ; preds = %6
store i8 0, i8* %14
br label %18
18: ; preds = %17, %6
%19 = call i8* @strchr(i8* %10, i8 signext 61)
%20 = icmp eq i8* %19, null
%21 = icmp eq i8* %19, %10
%22 = or i1 %20, %21
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i32, i32* @LOG_ERR
%25 = call i32 @syslog(i32 %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %30
26: ; preds = %18
store i8 0, i8* %19
%27 = call i32 @strcpy(i8* %1, i8* %10)
%28 = getelementptr inbounds i8, i8* %19, i64 1
%29 = call i32 @strcpy(i8* %2, i8* %28)
br label %30
30: ; preds = %26, %23
%31 = phi i32 [ 0, %23 ], [ 1, %26 ]
br label %32
32: ; preds = %3, %30
%33 = phi i32 [ %31, %30 ], [ 0, %3 ]
ret i32 %33
}