#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*/ die_(int, char *);
char *getenv(char const *);
int sscanf(char const *, char *, int *);
int sudo_env(const char *e) {
  int n;
  if ((e = getenv(e)) == NULL)
    die_(117, ("getenv"));
  if (sscanf(e, "%d", &n) != 1)
    die_(120, ("sscanf"));
  return n;
}


x86 assembly (clang, -O0):
<sudo_env>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    1164 <sudo_env+0x34>
mov    $0x75,%edi
lea    0xea1(%rip),%rsi
call   1050 <die_@plt>
mov    -0x8(%rbp),%rdi
lea    0xe98(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     1192 <sudo_env+0x62>
mov    $0x78,%edi
lea    0xe7d(%rip),%rsi
call   1050 <die_@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sudo_env>:
push   %rbx
sub    $0x10,%rsp
call   1030 <getenv@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1153 <sudo_env+0x23>
lea    0xeb7(%rip),%rsi
mov    $0x75,%edi
call   1050 <die_@plt>
lea    0xead(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     117d <sudo_env+0x4d>
lea    0xe97(%rip),%rsi
mov    $0x78,%edi
call   1050 <die_@plt>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"getenv\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"sscanf\00"
define i32 @sudo_env(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @getenv(i8* %4)
store i8* %5, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @die_(i32 117, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %1
%10 = load i8*, i8** %2
%11 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @die_(i32 120, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
@.str = [7 x i8] c"getenv\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"sscanf\00"
define i32 @sudo_env(i8* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i8* @getenv(i8* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @die_(i32 117, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = icmp eq i32 %9, 1
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = call i32 @die_(i32 120, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
%14 = load i32, i32* %2
ret i32 %14
}