#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*/ GetLongCfgValue(char *, long *, int);
int /*<<< orphan*/ printf(char *, int, char *);
int GetCharCfgValue(char *str, char *value, int lineCnt) {
  long longval;
  if (!GetLongCfgValue(str, &longval, lineCnt)) {
    return 0;
  }
  if (longval < -128 || longval > 127) {
    printf("Invalid config line %d, value must be between -128 and 127: %s\n",
           lineCnt, str);
    return 0;
  }
  *value = longval;
  return 1;
}


x86 assembly (clang, -O0):
<GetCharCfgValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    -0x28(%rbp),%rsi
call   1030 <GetLongCfgValue@plt>
cmp    $0x0,%eax
jne    1158 <GetCharCfgValue+0x38>
movl   $0x0,-0x4(%rbp)
jmp    11a0 <GetCharCfgValue+0x80>
cmpq   $0xffffffffffffff80,-0x28(%rbp)
jl     116e <GetCharCfgValue+0x4e>
cmpq   $0x7f,-0x28(%rbp)
jle    118d <GetCharCfgValue+0x6d>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11a0 <GetCharCfgValue+0x80>
mov    -0x28(%rbp),%rax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetCharCfgValue>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsp,%rsi
call   1030 <GetLongCfgValue@plt>
xor    %r14d,%r14d
test   %eax,%eax
je     1167 <GetCharCfgValue+0x47>
mov    (%rsp),%rax
movsbq %al,%rcx
cmp    %rax,%rcx
je     115e <GetCharCfgValue+0x3e>
lea    0xeae(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1040 <printf@plt>
jmp    1167 <GetCharCfgValue+0x47>
mov    %al,(%r15)
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [64 x i8] c"Invalid config line %d, value must be between -128 and 127: %s\0A\00"
define i32 @GetCharCfgValue(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i8*, i8** %5
%10 = load i32, i32* %7
%11 = call i32 @GetLongCfgValue(i8* %9, i64* %8, i32 %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %3
store i32 0, i32* %4
br label %28
14: ; preds = %3
%15 = load i64, i64* %8
%16 = icmp slt i64 %15, -128
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i64, i64* %8
%19 = icmp sgt i64 %18, 127
br i1 %19, label %20, label %24
20: ; preds = %17, %14
%21 = load i32, i32* %7
%22 = load i8*, i8** %5
%23 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32 %21, i8* %22)
store i32 0, i32* %4
br label %28
24: ; preds = %17
%25 = load i64, i64* %8
%26 = trunc i64 %25 to i8
%27 = load i8*, i8** %6
store i8 %26, i8* %27
store i32 1, i32* %4
br label %28
28: ; preds = %24, %20, %13
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
@.str = [64 x i8] c"Invalid config line %d, value must be between -128 and 127: %s\0A\00"
define i32 @GetCharCfgValue(i8* %0, i8* nocapture writeonly %1, i32 %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
%6 = call i32 @GetLongCfgValue(i8* %0, i64* %4, i32 %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %3
%9 = load i64, i64* %4
%10 = add i64 %9, -128
%11 = icmp ult i64 %10, -256
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32 %2, i8* %0)
br label %16
14: ; preds = %8
%15 = trunc i64 %9 to i8
store i8 %15, i8* %1
br label %16
16: ; preds = %3, %14, %12
%17 = phi i32 [ 0, %12 ], [ 1, %14 ], [ 0, %3 ]
ret i32 %17
}