#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 /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
char *getenv(char const *);
int /*<<< orphan*/ stderr;
long strtol(char *, char **, int);
int /*<<< orphan*/ unsetenv(char const *);
int _buildah_unshare_parse_envint(const char *envname) {
  char *p, *q;
  long l;
  p = getenv(envname);
  if (p == NULL) {
    return -1;
  }
  q = NULL;
  l = strtol(p, &q, 10);
  if ((q == NULL) || (*q != '\0')) {
    fprintf(stderr, "Error parsing \"%s\"=\"%s\"!\n", envname, p);
    _exit(1);
  }
  unsetenv(envname);
  return l;
}


x86 assembly (clang, -O0):
<_buildah_unshare_parse_envint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1180 <_buildah_unshare_parse_envint+0x30>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f0 <_buildah_unshare_parse_envint+0xa0>
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11b9 <_buildah_unshare_parse_envint+0x69>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11e0 <_buildah_unshare_parse_envint+0x90>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe2f(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1040 <_exit@plt>
mov    -0x10(%rbp),%rdi
call   1070 <unsetenv@plt>
mov    -0x28(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_buildah_unshare_parse_envint>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
call   1030 <getenv@plt>
test   %rax,%rax
je     11a0 <_buildah_unshare_parse_envint+0x50>
mov    %rax,%rbx
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,%r15
mov    0x8(%rsp),%rax
test   %rax,%rax
je     11b3 <_buildah_unshare_parse_envint+0x63>
cmpb   $0x0,(%rax)
jne    11b3 <_buildah_unshare_parse_envint+0x63>
mov    %r14,%rdi
call   1070 <unsetenv@plt>
jmp    11a6 <_buildah_unshare_parse_envint+0x56>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1040 <_exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"Error parsing \22%s\22=\22%s\22!\0A\00"
define i32 @_buildah_unshare_parse_envint(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i8* @getenv(i8* %7)
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 -1, i32* %2
br label %33
12: ; preds = %1
store i8* null, i8** %5
%13 = load i8*, i8** %4
%14 = call i64 @strtol(i8* %13, i8** %5, i32 10)
store i64 %14, i64* %6
%15 = load i8*, i8** %5
%16 = icmp eq i8* %15, null
br i1 %16, label %22, label %17
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %17, %12
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %3
%25 = load i8*, i8** %4
%26 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %24, i8* %25)
%27 = call i32 @_exit(i32 1)
unreachable
28: ; preds = %17
%29 = load i8*, i8** %3
%30 = call i32 @unsetenv(i8* %29)
%31 = load i64, i64* %6
%32 = trunc i64 %31 to i32
store i32 %32, i32* %2
br label %33
33: ; preds = %28, %11
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"Error parsing \22%s\22=\22%s\22!\0A\00"
define i32 @_buildah_unshare_parse_envint(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = tail call i8* @getenv(i8* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %20, label %6
6: ; preds = %1
store i8* null, i8** %2
%7 = call i64 @strtol(i8* %4, i8** %2, i32 10)
%8 = load i8*, i8** %2
%9 = icmp eq i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = load i8, i8* %8
%12 = icmp eq i8 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10, %6
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %4)
%16 = tail call i32 @_exit(i32 1)
unreachable
17: ; preds = %10
%18 = tail call i32 @unsetenv(i8* %0)
%19 = trunc i64 %7 to i32
br label %20
20: ; preds = %1, %17
%21 = phi i32 [ %19, %17 ], [ -1, %1 ]
ret i32 %21
}