#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 atoi(char const *);
int /*<<< orphan*/ die(char *, char const *);
char *getenv(char *);
int /*<<< orphan*/ isposnum(char const *);
int parsenbcoreenv(void) {
  const char *str = getenv("NBCORE");
  if (!str)
    return 0;
  if (!isposnum(str))
    die("invalid value '%s' for environment variable NBCORE", str);
  return atoi(str);
}


x86 assembly (clang, -O0):
<parsenbcoreenv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xedd(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116f <parsenbcoreenv+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    119d <parsenbcoreenv+0x5d>
mov    -0x10(%rbp),%rdi
call   1040 <isposnum@plt>
cmp    $0x0,%eax
jne    1191 <parsenbcoreenv+0x51>
mov    -0x10(%rbp),%rsi
lea    0xe74(%rip),%rdi
call   1050 <die@plt>
mov    -0x10(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsenbcoreenv>:
push   %rbx
lea    0xee4(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1179 <parsenbcoreenv+0x39>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <isposnum@plt>
test   %eax,%eax
jne    1170 <parsenbcoreenv+0x30>
lea    0xe98(%rip),%rdi
mov    %rbx,%rsi
call   1050 <die@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1060 <atoi@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"NBCORE\00"
@.str.1 = [51 x i8] c"invalid value '%s' for environment variable NBCORE\00"
define i32 @parsenbcoreenv() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %7, label %6
6: ; preds = %0
store i32 0, i32* %1
br label %17
7: ; preds = %0
%8 = load i8*, i8** %2
%9 = call i32 @isposnum(i8* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = load i8*, i8** %2
%13 = call i32 @die(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %7
%15 = load i8*, i8** %2
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %1
br label %17
17: ; preds = %14, %6
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str = [7 x i8] c"NBCORE\00"
@.str.1 = [51 x i8] c"invalid value '%s' for environment variable NBCORE\00"
define i32 @parsenbcoreenv() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %10, label %3
3: ; preds = %0
%4 = tail call i32 @isposnum(i8* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @die(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %8
8: ; preds = %6, %3
%9 = tail call i32 @atoi(i8* %1)
br label %10
10: ; preds = %0, %8
%11 = phi i32 [ %9, %8 ], [ 0, %0 ]
ret i32 %11
}