#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 *FindStringCfgValue(char *);
int /*<<< orphan*/ IzDigit(char);
long atoi(char *);
int /*<<< orphan*/ printf(char *, int, char *);
int GetLongCfgValue(char *str, long *value, int lineCnt) {
  char *valstr, *tmp;
  if ((valstr = FindStringCfgValue(str)) == NULL) {
    return 0;
  }
  for (tmp = valstr; *tmp != '\0'; tmp++) {
    if (!IzDigit(*tmp) && *tmp != '-') {
      printf("Invalid config line %d, value must be only digits: %s\n", lineCnt,
             str);
      return 0;
    }
  }
  *value = atoi(valstr);
  return 1;
}


x86 assembly (clang, -O0):
<GetLongCfgValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <FindStringCfgValue@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1176 <GetLongCfgValue+0x36>
movl   $0x0,-0x4(%rbp)
jmp    1202 <GetLongCfgValue+0xc2>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11e8 <GetLongCfgValue+0xa8>
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   1050 <IzDigit@plt>
cmp    $0x0,%eax
jne    11d2 <GetLongCfgValue+0x92>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     11d2 <GetLongCfgValue+0x92>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1202 <GetLongCfgValue+0xc2>
jmp    11d7 <GetLongCfgValue+0x97>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    117e <GetLongCfgValue+0x3e>
mov    -0x28(%rbp),%rdi
call   1060 <atoi@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetLongCfgValue>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%r12
call   1040 <FindStringCfgValue@plt>
xor    %r13d,%r13d
test   %rax,%rax
je     11c3 <GetLongCfgValue+0x83>
mov    %rax,%rbx
mov    (%rax),%al
test   %al,%al
je     11b2 <GetLongCfgValue+0x72>
mov    %rbx,%rbp
add    $0x1,%rbp
jmp    118c <GetLongCfgValue+0x4c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
je     11b2 <GetLongCfgValue+0x72>
movsbl %al,%edi
call   1050 <IzDigit@plt>
test   %eax,%eax
jne    1180 <GetLongCfgValue+0x40>
cmpb   $0x2d,-0x1(%rbp)
je     1180 <GetLongCfgValue+0x40>
lea    0xe5b(%rip),%rdi
mov    %r15d,%esi
mov    %r12,%rdx
call   1030 <printf@plt>
jmp    11c3 <GetLongCfgValue+0x83>
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %rax,(%r14)
mov    $0x1,%r13d
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [55 x i8] c"Invalid config line %d, value must be only digits: %s\0A\00"
define i32 @GetLongCfgValue(i8* %0, i64* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i64* %1, i64** %6
store i32 %2, i32* %7
%10 = load i8*, i8** %5
%11 = call i8* @FindStringCfgValue(i8* %10)
store i8* %11, i8** %8
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 0, i32* %4
br label %43
14: ; preds = %3
%15 = load i8*, i8** %8
store i8* %15, i8** %9
br label %16
16: ; preds = %36, %14
%17 = load i8*, i8** %9
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %39
21: ; preds = %16
%22 = load i8*, i8** %9
%23 = load i8, i8* %22
%24 = call i32 @IzDigit(i8 signext %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %35, label %26
26: ; preds = %21
%27 = load i8*, i8** %9
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 45
br i1 %30, label %31, label %35
31: ; preds = %26
%32 = load i32, i32* %7
%33 = load i8*, i8** %5
%34 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %32, i8* %33)
store i32 0, i32* %4
br label %43
35: ; preds = %26, %21
br label %36
36: ; preds = %35
%37 = load i8*, i8** %9
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %9
br label %16
39: ; preds = %16
%40 = load i8*, i8** %8
%41 = call i64 @atoi(i8* %40)
%42 = load i64*, i64** %6
store i64 %41, i64* %42
store i32 1, i32* %4
br label %43
43: ; preds = %39, %31, %13
%44 = load i32, i32* %4
ret i32 %44
}

LLVM IR (-O2):
@.str = [55 x i8] c"Invalid config line %d, value must be only digits: %s\0A\00"
define i32 @GetLongCfgValue(i8* %0, i64* nocapture writeonly %1, i32 %2) {
%4 = tail call i8* @FindStringCfgValue(i8* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %25, label %6
6: ; preds = %3
%7 = load i8, i8* %4
%8 = icmp eq i8 %7, 0
br i1 %8, label %23, label %9
9: ; preds = %6, %19
%10 = phi i8 [ %21, %19 ], [ %7, %6 ]
%11 = phi i8* [ %20, %19 ], [ %4, %6 ]
%12 = tail call i32 @IzDigit(i8 signext %10)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = load i8, i8* %11
%16 = icmp eq i8 %15, 45
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = tail call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %2, i8* %0)
br label %25
19: ; preds = %9, %14
%20 = getelementptr inbounds i8, i8* %11, i64 1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %9
23: ; preds = %19, %6
%24 = tail call i64 @atoi(i8* %4)
store i64 %24, i64* %1
br label %25
25: ; preds = %3, %23, %17
%26 = phi i32 [ 0, %17 ], [ 1, %23 ], [ 0, %3 ]
ret i32 %26
}