#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 */
long GetLongSetting(char const *, int);
int /*<<< orphan*/ Log(char *, char const *, int);
int GetIntSetting(const char *name, int def) {
  long lnumber = GetLongSetting(name, def);
  int number = (int)lnumber;
  if (lnumber != (long)number) {
    Log("Ignoring out-of-range value of %s: %d", name, number);
    return def;
  }
  return number;
}


x86 assembly (clang, -O0):
<GetIntSetting>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <GetLongSetting@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmp    %rcx,%rax
je     1175 <GetIntSetting+0x55>
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    0xe9b(%rip),%rdi
call   1040 <Log@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117b <GetIntSetting+0x5b>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetIntSetting>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
call   1030 <GetLongSetting@plt>
movslq %eax,%rcx
cmp    %rax,%rcx
jne    113a <GetIntSetting+0x1a>
mov    %eax,%ebx
jmp    114b <GetIntSetting+0x2b>
lea    0xebf(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <Log@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Ignoring out-of-range value of %s: %d\00"
define i32 @GetIntSetting(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = load i8*, i8** %4
%9 = load i32, i32* %5
%10 = call i64 @GetLongSetting(i8* %8, i32 %9)
store i64 %10, i64* %6
%11 = load i64, i64* %6
%12 = trunc i64 %11 to i32
store i32 %12, i32* %7
%13 = load i64, i64* %6
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = icmp ne i64 %13, %15
br i1 %16, label %17, label %22
17: ; preds = %2
%18 = load i8*, i8** %4
%19 = load i32, i32* %7
%20 = call i32 @Log(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %18, i32 %19)
%21 = load i32, i32* %5
store i32 %21, i32* %3
br label %24
22: ; preds = %2
%23 = load i32, i32* %7
store i32 %23, i32* %3
br label %24
24: ; preds = %22, %17
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [38 x i8] c"Ignoring out-of-range value of %s: %d\00"
define i32 @GetIntSetting(i8* %0, i32 %1) {
%3 = tail call i64 @GetLongSetting(i8* %0, i32 %1)
%4 = trunc i64 %3 to i32
%5 = add i64 %3, 2147483648
%6 = icmp ult i64 %5, 4294967296
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @Log(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %4)
br label %9
9: ; preds = %2, %7
%10 = phi i32 [ %1, %7 ], [ %4, %2 ]
ret i32 %10
}