#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 */
typedef int int32_t;

/* Variables and functions */
long long LONG_MAX;
long long LONG_MIN;
int /*<<< orphan*/ convFail(char *, char *, char const *, char const *);
long long convNum(char *, char const *, int, char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
long convLong(const char *arg, int32_t flags, const char *varName) {
  register long long res = 0;
  res = convNum("convLong", arg, flags, varName);
  if (res > LONG_MAX || res < LONG_MIN) {
    if (flags & 0x20) {
      fprintf(stderr, "\nInteger was out of range\n");
      return 0;
    } else
      convFail("convLong", "integer out of range", arg, varName);
  }
  return (long)res;
}


x86 assembly (clang, -O0):
<convLong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0xea3(%rip),%rdi
call   1050 <convNum@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2e5f(%rip),%rcx
cmp    (%rcx),%rax
jg     118e <convLong+0x5e>
mov    -0x28(%rbp),%rax
mov    0x2e63(%rip),%rcx
cmp    (%rcx),%rax
jge    11df <convLong+0xaf>
mov    -0x14(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     11bf <convLong+0x8f>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11e7 <convLong+0xb7>
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe32(%rip),%rdi
lea    0xe4f(%rip),%rsi
call   1030 <convFail@plt>
jmp    11df <convLong+0xaf>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convLong>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%r15
lea    0xeba(%rip),%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %r14,%rcx
call   1050 <convNum@plt>
mov    %rax,%rbx
mov    0x2e73(%rip),%rax
cmp    (%rax),%rbx
jg     116e <convLong+0x3e>
mov    0x2e7f(%rip),%rax
cmp    (%rax),%rbx
jge    11a6 <convLong+0x76>
test   $0x20,%bpl
jne    118f <convLong+0x5f>
lea    0xe85(%rip),%rdi
lea    0xea2(%rip),%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <convFail@plt>
jmp    11a6 <convLong+0x76>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
call   1040 <fprintf@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"convLong\00"
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@stderr = global i32 0
@.str.1 = [27 x i8] c"\0AInteger was out of range\0A\00"
@.str.2 = [21 x i8] c"integer out of range\00"
define i64 @convLong(i8* %0, i32 %1, i8* %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i64 0, i64* %8
%9 = load i8*, i8** %5
%10 = load i32, i32* %6
%11 = load i8*, i8** %7
%12 = call i64 @convNum(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %10, i8* %11)
store i64 %12, i64* %8
%13 = load i64, i64* %8
%14 = load i64, i64* @LONG_MAX
%15 = icmp sgt i64 %13, %14
br i1 %15, label %20, label %16
16: ; preds = %3
%17 = load i64, i64* %8
%18 = load i64, i64* @LONG_MIN
%19 = icmp slt i64 %17, %18
br i1 %19, label %20, label %32
20: ; preds = %16, %3
%21 = load i32, i32* %6
%22 = and i32 %21, 32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i64 0, i64* %4
br label %34
27: ; preds = %20
%28 = load i8*, i8** %5
%29 = load i8*, i8** %7
%30 = call i32 @convFail(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %28, i8* %29)
br label %31
31: ; preds = %27
br label %32
32: ; preds = %31, %16
%33 = load i64, i64* %8
store i64 %33, i64* %4
br label %34
34: ; preds = %32, %24
%35 = load i64, i64* %4
ret i64 %35
}

LLVM IR (-O2):
@.str = [9 x i8] c"convLong\00"
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@stderr = global i32 0
@.str.1 = [27 x i8] c"\0AInteger was out of range\0A\00"
@.str.2 = [21 x i8] c"integer out of range\00"
define i64 @convLong(i8* %0, i32 %1, i8* %2) {
%4 = tail call i64 @convNum(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, i8* %2)
%5 = load i64, i64* @LONG_MAX
%6 = icmp sgt i64 %4, %5
%7 = load i64, i64* @LONG_MIN
%8 = icmp slt i64 %4, %7
%9 = select i1 %6, i1 true, i1 %8
br i1 %9, label %10, label %18
10: ; preds = %3
%11 = and i32 %1, 32
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %18
16: ; preds = %10
%17 = tail call i32 @convFail(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %2)
br label %18
18: ; preds = %16, %3, %13
%19 = phi i64 [ 0, %13 ], [ %4, %3 ], [ %4, %16 ]
ret i64 %19
}