#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 */
struct sctptest_scriptCommand {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned int,
                           char const *, ...);
char *getStrParam(struct sctptest_scriptCommand *, char const *, unsigned int *,
                  int, unsigned int);
int /*<<< orphan*/ stderr;
unsigned long strtoul(char *, char **, int);
unsigned long getIntParam(struct sctptest_scriptCommand *sc, const char *key,
                          unsigned long lowLimit, unsigned long highLimit,
                          int base, unsigned int *err, int paramType,
                          unsigned int lineNum) {
  char *str, *endp;
  unsigned long res;
  str = getStrParam(sc, key, err, paramType, lineNum);
  if (str == NULL)
    return 0;
  res = strtoul(str, &endp, (base == 10) ? 10 : 16);
  if (*endp != '\0') {
    fprintf(stderr, "Line %u: Parameter %s must have an integer value%s.\n",
            lineNum, key, (base == 16) ? " in hexadecimal format" : "");
    (*err)++;
    return 0;
  } else if (res < lowLimit) {
    fprintf(stderr,
            "Line %u: The value of parameter %s must be greater than %lu\n",
            lineNum, key, lowLimit - 1);
    (*err)++;
    return 0;
  } else if ((res > highLimit) && (highLimit > lowLimit)) {
    fprintf(stderr,
            "Line %u: The value of parameter %s cannot be greater than %lu\n",
            lineNum, key, highLimit);
    (*err)++;
    return 0;
  }
  return res;
}


x86 assembly (clang, -O0):
<getIntParam>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    0x10(%rbp),%ecx
mov    0x18(%rbp),%r8d
call   1040 <getStrParam@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    118a <getIntParam+0x5a>
movq   $0x0,-0x8(%rbp)
jmp    12c0 <getIntParam+0x190>
mov    -0x40(%rbp),%rdi
mov    -0x2c(%rbp),%ecx
mov    $0x10,%edx
mov    $0xa,%eax
cmp    $0xa,%ecx
cmove  %eax,%edx
lea    -0x48(%rbp),%rsi
call   1050 <strtoul@plt>
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     120c <getIntParam+0xdc>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x2c(%rbp),%esi
lea    0xe5c(%rip),%r8
lea    0xe56(%rip),%rax
cmp    $0x10,%esi
cmove  %rax,%r8
lea    0xe13(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    12c0 <getIntParam+0x190>
mov    -0x50(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1258 <getIntParam+0x128>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
sub    $0x1,%r8
lea    0xe13(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    12c0 <getIntParam+0x190>
mov    -0x50(%rbp),%rax
cmp    -0x28(%rbp),%rax
jbe    12ae <getIntParam+0x17e>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    12ae <getIntParam+0x17e>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xdfa(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    12c0 <getIntParam+0x190>
jmp    12b3 <getIntParam+0x183>
jmp    12b8 <getIntParam+0x188>
mov    -0x50(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getIntParam>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8d,%ebp
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbx
mov    0x48(%rsp),%r15d
mov    0x40(%rsp),%ecx
mov    %r9,%rdx
mov    %r15d,%r8d
call   1040 <getStrParam@plt>
test   %rax,%rax
je     1205 <getIntParam+0xd5>
cmp    $0xa,%ebp
mov    $0x10,%edx
cmove  %ebp,%edx
mov    %rsp,%rsi
mov    %rax,%rdi
call   1050 <strtoul@plt>
mov    (%rsp),%rcx
cmpb   $0x0,(%rcx)
je     11b3 <getIntParam+0x83>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
cmp    $0x10,%ebp
lea    0xe9c(%rip),%rax
lea    0xe94(%rip),%r8
cmove  %rax,%r8
lea    0xe55(%rip),%rsi
mov    %r15d,%edx
mov    %rbx,%rcx
jmp    11fa <getIntParam+0xca>
cmp    %r13,%rax
jae    11d7 <getIntParam+0xa7>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
add    $0xffffffffffffffff,%r13
lea    0xe80(%rip),%rsi
mov    %r15d,%edx
mov    %rbx,%rcx
mov    %r13,%r8
jmp    11fa <getIntParam+0xca>
cmp    %r13,%r12
jbe    1207 <getIntParam+0xd7>
cmp    %r12,%rax
jbe    1207 <getIntParam+0xd7>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
mov    %r15d,%edx
mov    %rbx,%rcx
mov    %r12,%r8
xor    %eax,%eax
call   1030 <fprintf@plt>
addl   $0x1,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sctptest_scriptCommand = type { i32 }
@stderr = global i32 0
@.str = [53 x i8] c"Line %u: Parameter %s must have an integer value%s.\0A\00"
@.str.1 = [23 x i8] c" in hexadecimal format\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [61 x i8] c"Line %u: The value of parameter %s must be greater than %lu\0A\00"
@.str.4 = [63 x i8] c"Line %u: The value of parameter %s cannot be greater than %lu\0A\00"
define i64 @getIntParam(%struct.sctptest_scriptCommand* %0, i8* %1, i64 %2, i64 %3, i32 %4, i32* %5, i32 %6, i32 %7) {
%9 = alloca i64
%10 = alloca %struct.sctptest_scriptCommand*
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i64
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i64
store %struct.sctptest_scriptCommand* %0, %struct.sctptest_scriptCommand** %10
store i8* %1, i8** %11
store i64 %2, i64* %12
store i64 %3, i64* %13
store i32 %4, i32* %14
store i32* %5, i32** %15
store i32 %6, i32* %16
store i32 %7, i32* %17
%21 = load %struct.sctptest_scriptCommand*, %struct.sctptest_scriptCommand** %10
%22 = load i8*, i8** %11
%23 = load i32*, i32** %15
%24 = load i32, i32* %16
%25 = load i32, i32* %17
%26 = call i8* @getStrParam(%struct.sctptest_scriptCommand* %21, i8* %22, i32* %23, i32 %24, i32 %25)
store i8* %26, i8** %18
%27 = load i8*, i8** %18
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %30
29: ; preds = %8
store i64 0, i64* %9
br label %88
30: ; preds = %8
%31 = load i8*, i8** %18
%32 = load i32, i32* %14
%33 = icmp eq i32 %32, 10
%34 = zext i1 %33 to i64
%35 = select i1 %33, i32 10, i32 16
%36 = call i64 @strtoul(i8* %31, i8** %19, i32 %35)
store i64 %36, i64* %20
%37 = load i8*, i8** %19
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %53
41: ; preds = %30
%42 = load i32, i32* @stderr
%43 = load i32, i32* %17
%44 = load i8*, i8** %11
%45 = load i32, i32* %14
%46 = icmp eq i32 %45, 16
%47 = zext i1 %46 to i64
%48 = select i1 %46, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%49 = call i32 (i32, i8*, i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i32 %43, i8* %44, i8* %48)
%50 = load i32*, i32** %15
%51 = load i32, i32* %50
%52 = add i32 %51, 1
store i32 %52, i32* %50
store i64 0, i64* %9
br label %88
53: ; preds = %30
%54 = load i64, i64* %20
%55 = load i64, i64* %12
%56 = icmp ult i64 %54, %55
br i1 %56, label %57, label %67
57: ; preds = %53
%58 = load i32, i32* @stderr
%59 = load i32, i32* %17
%60 = load i8*, i8** %11
%61 = load i64, i64* %12
%62 = sub i64 %61, 1
%63 = call i32 (i32, i8*, i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.3, i64 0, i64 0), i32 %59, i8* %60, i64 %62)
%64 = load i32*, i32** %15
%65 = load i32, i32* %64
%66 = add i32 %65, 1
store i32 %66, i32* %64
store i64 0, i64* %9
br label %88
67: ; preds = %53
%68 = load i64, i64* %20
%69 = load i64, i64* %13
%70 = icmp ugt i64 %68, %69
br i1 %70, label %71, label %84
71: ; preds = %67
%72 = load i64, i64* %13
%73 = load i64, i64* %12
%74 = icmp ugt i64 %72, %73
br i1 %74, label %75, label %84
75: ; preds = %71
%76 = load i32, i32* @stderr
%77 = load i32, i32* %17
%78 = load i8*, i8** %11
%79 = load i64, i64* %13
%80 = call i32 (i32, i8*, i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.4, i64 0, i64 0), i32 %77, i8* %78, i64 %79)
%81 = load i32*, i32** %15
%82 = load i32, i32* %81
%83 = add i32 %82, 1
store i32 %83, i32* %81
store i64 0, i64* %9
br label %88
84: ; preds = %71, %67
br label %85
85: ; preds = %84
br label %86
86: ; preds = %85
%87 = load i64, i64* %20
store i64 %87, i64* %9
br label %88
88: ; preds = %86, %75, %57, %41, %29
%89 = load i64, i64* %9
ret i64 %89
}

LLVM IR (-O2):
%struct.sctptest_scriptCommand = type { i32 }
@stderr = global i32 0
@.str = [53 x i8] c"Line %u: Parameter %s must have an integer value%s.\0A\00"
@.str.1 = [23 x i8] c" in hexadecimal format\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [61 x i8] c"Line %u: The value of parameter %s must be greater than %lu\0A\00"
@.str.4 = [63 x i8] c"Line %u: The value of parameter %s cannot be greater than %lu\0A\00"
define i64 @getIntParam(%struct.sctptest_scriptCommand* %0, i8* %1, i64 %2, i64 %3, i32 %4, i32* %5, i32 %6, i32 %7) {
%9 = alloca i8*
%10 = bitcast i8** %9 to i8*
%11 = tail call i8* @getStrParam(%struct.sctptest_scriptCommand* %0, i8* %1, i32* %5, i32 %6, i32 %7)
%12 = icmp eq i8* %11, null
br i1 %12, label %41, label %13
13: ; preds = %8
%14 = icmp eq i32 %4, 10
%15 = select i1 %14, i32 10, i32 16
%16 = call i64 @strtoul(i8* %11, i8** %9, i32 %15)
%17 = load i8*, i8** %9
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %13
%21 = load i32, i32* @stderr
%22 = icmp eq i32 %4, 16
%23 = select i1 %22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%24 = tail call i32 (i32, i8*, i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i32 %7, i8* %1, i8* %23)
br label %38
25: ; preds = %13
%26 = icmp ult i64 %16, %2
br i1 %26, label %27, label %31
27: ; preds = %25
%28 = load i32, i32* @stderr
%29 = add i64 %2, -1
%30 = tail call i32 (i32, i8*, i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.3, i64 0, i64 0), i32 %7, i8* %1, i64 %29)
br label %38
31: ; preds = %25
%32 = icmp ugt i64 %16, %3
%33 = icmp ugt i64 %3, %2
%34 = and i1 %33, %32
br i1 %34, label %35, label %41
35: ; preds = %31
%36 = load i32, i32* @stderr
%37 = tail call i32 (i32, i8*, i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.4, i64 0, i64 0), i32 %7, i8* %1, i64 %3)
br label %38
38: ; preds = %20, %27, %35
%39 = load i32, i32* %5
%40 = add i32 %39, 1
store i32 %40, i32* %5
br label %41
41: ; preds = %38, %31, %8
%42 = phi i64 [ 0, %8 ], [ %16, %31 ], [ 0, %38 ]
ret i64 %42
}