#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 */
scalar_t__ isdigit(char const);
int /*<<< orphan*/ sscanf(char const *, char *, unsigned long *);
int /*<<< orphan*/ strcasecmp(char const *, char *);
int /*<<< orphan*/ strncasecmp(char const *, char *, int);
int assign_long(unsigned long *piMember, char const *sValue) {
  if (!strncasecmp(sValue, "0x", 2))
    sscanf(sValue + 2, "%lx", piMember);
  else if (*sValue == '$')
    sscanf(sValue + 1, "%lx", piMember);
  else if (*sValue == '-')
    sscanf(sValue, "%ld", piMember);
  else if (isdigit(*sValue))
    sscanf(sValue, "%lu", piMember);
  else
    *piMember = (!strcasecmp(sValue, "enabled") || !strcasecmp(sValue, "on") ||
                 !strcasecmp(sValue, "true"));
  return (1);
}


x86 assembly (clang, -O0):
<assign_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
mov    $0x2,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%eax
jne    118b <assign_long+0x4b>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
mov    -0x8(%rbp),%rdx
lea    0xe82(%rip),%rsi
call   1060 <sscanf@plt>
jmp    128c <assign_long+0x14c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
jne    11b8 <assign_long+0x78>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x8(%rbp),%rdx
lea    0xe55(%rip),%rsi
call   1060 <sscanf@plt>
jmp    1287 <assign_long+0x147>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11e1 <assign_long+0xa1>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe30(%rip),%rsi
call   1060 <sscanf@plt>
jmp    1282 <assign_long+0x142>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     1210 <assign_long+0xd0>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe05(%rip),%rsi
call   1060 <sscanf@plt>
jmp    127d <assign_long+0x13d>
mov    -0x10(%rbp),%rdi
lea    0xdf4(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     126b <assign_long+0x12b>
mov    -0x10(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     126b <assign_long+0x12b>
mov    -0x10(%rbp),%rdi
lea    0xdbf(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    1282 <assign_long+0x142>
jmp    1287 <assign_long+0x147>
jmp    128c <assign_long+0x14c>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assign_long>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1050 <strncasecmp@plt>
test   %eax,%eax
je     1173 <assign_long+0x33>
mov    (%rbx),%al
cmp    $0x2d,%al
je     1180 <assign_long+0x40>
cmp    $0x24,%al
jne    1189 <assign_long+0x49>
add    $0x1,%rbx
jmp    1177 <assign_long+0x37>
add    $0x2,%rbx
lea    0xe85(%rip),%rsi
jmp    119d <assign_long+0x5d>
lea    0xe80(%rip),%rsi
jmp    119d <assign_long+0x5d>
movsbl %al,%edi
call   1040 <isdigit@plt>
test   %rax,%rax
je     11b3 <assign_long+0x73>
lea    0xe6e(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1060 <sscanf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe55(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
mov    $0x1,%r15d
test   %eax,%eax
je     11f7 <assign_long+0xb7>
lea    0xe44(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11f7 <assign_long+0xb7>
lea    0xe34(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
xor    %r15d,%r15d
test   %eax,%eax
sete   %r15b
mov    %r15,(%r14)
jmp    11a8 <assign_long+0x68>

LLVM IR (-O0):
@.str = [3 x i8] c"0x\00"
@.str.1 = [4 x i8] c"%lx\00"
@.str.2 = [4 x i8] c"%ld\00"
@.str.3 = [4 x i8] c"%lu\00"
@.str.4 = [8 x i8] c"enabled\00"
@.str.5 = [3 x i8] c"on\00"
@.str.6 = [5 x i8] c"true\00"
define i32 @assign_long(i64* %0, i8* %1) {
%3 = alloca i64*
%4 = alloca i8*
store i64* %0, i64** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = call i32 @strncasecmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%7 = icmp ne i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i64 2
%11 = load i64*, i64** %3
%12 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %11)
br label %62
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 36
br i1 %17, label %18, label %23
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i64*, i64** %3
%22 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %21)
br label %61
23: ; preds = %13
%24 = load i8*, i8** %4
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 45
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i8*, i8** %4
%30 = load i64*, i64** %3
%31 = call i32 @sscanf(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %30)
br label %60
32: ; preds = %23
%33 = load i8*, i8** %4
%34 = load i8, i8* %33
%35 = call i64 @isdigit(i8 signext %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %32
%38 = load i8*, i8** %4
%39 = load i64*, i64** %3
%40 = call i32 @sscanf(i8* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64* %39)
br label %59
41: ; preds = %32
%42 = load i8*, i8** %4
%43 = call i32 @strcasecmp(i8* %42, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %54
45: ; preds = %41
%46 = load i8*, i8** %4
%47 = call i32 @strcasecmp(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %45
%50 = load i8*, i8** %4
%51 = call i32 @strcasecmp(i8* %50, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%52 = icmp ne i32 %51, 0
%53 = xor i1 %52, true
br label %54
54: ; preds = %49, %45, %41
%55 = phi i1 [ true, %45 ], [ true, %41 ], [ %53, %49 ]
%56 = zext i1 %55 to i32
%57 = sext i32 %56 to i64
%58 = load i64*, i64** %3
store i64 %57, i64* %58
br label %59
59: ; preds = %54, %37
br label %60
60: ; preds = %59, %28
br label %61
61: ; preds = %60, %18
br label %62
62: ; preds = %61, %8
ret i32 1
}

LLVM IR (-O2):
@.str = [3 x i8] c"0x\00"
@.str.1 = [4 x i8] c"%lx\00"
@.str.2 = [4 x i8] c"%ld\00"
@.str.3 = [4 x i8] c"%lu\00"
@.str.4 = [8 x i8] c"enabled\00"
@.str.5 = [3 x i8] c"on\00"
@.str.6 = [5 x i8] c"true\00"
define i32 @assign_long(i64* %0, i8* nocapture %1) {
%3 = tail call i32 @strncasecmp(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %1, i64 2
%7 = tail call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %0)
br label %32
8: ; preds = %2
%9 = load i8, i8* %1
switch i8 %9, label %15 [
i8 36, label %10
i8 45, label %13
]
10: ; preds = %8
%11 = getelementptr inbounds i8, i8* %1, i64 1
%12 = tail call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %0)
br label %32
13: ; preds = %8
%14 = tail call i32 @sscanf(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %0)
br label %32
15: ; preds = %8
%16 = tail call i64 @isdigit(i8 signext %9)
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 @sscanf(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64* %0)
br label %32
20: ; preds = %15
%21 = tail call i32 @strcasecmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %30, label %23
23: ; preds = %20
%24 = tail call i32 @strcasecmp(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %23
%27 = tail call i32 @strcasecmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%28 = icmp eq i32 %27, 0
%29 = zext i1 %28 to i64
br label %30
30: ; preds = %26, %23, %20
%31 = phi i64 [ 1, %23 ], [ 1, %20 ], [ %29, %26 ]
store i64 %31, i64* %0
br label %32
32: ; preds = %10, %18, %30, %13, %5
ret i32 1
}