#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 getConfigInt(char *, int);
int /*<<< orphan*/ logMsg(int, char *, char *, int, int);
int getPort() {
  int configValue;
  if ((configValue = getConfigInt("web.port", 1)) < 0) {
    return 2605;
  } else {
    if (configValue >= 1 && configValue <= 65535) {
      return configValue;
    } else {
      logMsg(4,
             "The db config value %s contained an invalid port number of %s, "
             "using default of %d instead.",
             "web.port", configValue, 2605);
      return 2605;
    }
  }
}


x86 assembly (clang, -O0):
<getPort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x1,%esi
call   1030 <getConfigInt@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    1151 <getPort+0x31>
movl   $0xa2d,-0x4(%rbp)
jmp    119b <getPort+0x7b>
cmpl   $0x1,-0x8(%rbp)
jl     1173 <getPort+0x53>
cmpl   $0xffff,-0x8(%rbp)
jg     1173 <getPort+0x53>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    119b <getPort+0x7b>
mov    -0x8(%rbp),%ecx
mov    $0x4,%edi
lea    0xe87(%rip),%rsi
lea    0xe77(%rip),%rdx
mov    $0xa2d,%r8d
call   1040 <logMsg@plt>
movl   $0xa2d,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getPort>:
push   %rax
lea    0xed8(%rip),%rdi
mov    $0x1,%esi
call   1030 <getConfigInt@plt>
test   %eax,%eax
js     1163 <getPort+0x43>
mov    %eax,%ecx
add    $0xffffffff,%ecx
cmp    $0xffff,%ecx
jb     1168 <getPort+0x48>
lea    0xebf(%rip),%rsi
lea    0xeaf(%rip),%rdx
mov    $0x4,%edi
mov    %eax,%ecx
mov    $0xa2d,%r8d
call   1040 <logMsg@plt>
mov    $0xa2d,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"web.port\00"
@.str.1 = [92 x i8] c"The db config value %s contained an invalid port number of %s, using default of %d instead.\00"
define i32 @getPort() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @getConfigInt(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1)
store i32 %3, i32* %2
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 2605, i32* %1
br label %17
6: ; preds = %0
%7 = load i32, i32* %2
%8 = icmp sge i32 %7, 1
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load i32, i32* %2
%11 = icmp sle i32 %10, 65535
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = load i32, i32* %2
store i32 %13, i32* %1
br label %17
14: ; preds = %9, %6
%15 = load i32, i32* %2
%16 = call i32 @logMsg(i32 4, i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %15, i32 2605)
store i32 2605, i32* %1
br label %17
17: ; preds = %14, %12, %5
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str = [9 x i8] c"web.port\00"
@.str.1 = [92 x i8] c"The db config value %s contained an invalid port number of %s, using default of %d instead.\00"
define i32 @getPort() {
%1 = tail call i32 @getConfigInt(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1)
%2 = icmp slt i32 %1, 0
br i1 %2, label %8, label %3
3: ; preds = %0
%4 = add nsw i32 %1, -1
%5 = icmp ult i32 %4, 65535
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @logMsg(i32 4, i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %1, i32 2605)
br label %8
8: ; preds = %3, %0, %6
%9 = phi i32 [ 2605, %6 ], [ 2605, %0 ], [ %1, %3 ]
ret i32 %9
}