#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*/ atoll(char *);
char *getenv(char const *);
double strtod(char *, char **);
size_t get_env_size(const char *var_name, size_t default_size) {
  char *p;
  char *val;
  if (var_name == NULL)
    return default_size;
  val = getenv(var_name);
  if (val == NULL)
    return default_size;
  double dummy = strtod(val, &p);
  if (*p != '\0') {
    ((void)1);
    return default_size;
  }
  return (size_t)atoll(val);
}


x86 assembly (clang, -O0):
<get_env_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1158 <get_env_size+0x28>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11bb <get_env_size+0x8b>
mov    -0x10(%rbp),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    117d <get_env_size+0x4d>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11bb <get_env_size+0x8b>
mov    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ac <get_env_size+0x7c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11bb <get_env_size+0x8b>
mov    -0x28(%rbp),%rdi
call   1050 <atoll@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_env_size>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
test   %rdi,%rdi
je     1168 <get_env_size+0x38>
call   1030 <getenv@plt>
test   %rax,%rax
je     1168 <get_env_size+0x38>
mov    %rax,%rbx
mov    %rsp,%rsi
mov    %rax,%rdi
call   1040 <strtod@plt>
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
jne    1168 <get_env_size+0x38>
mov    %rbx,%rdi
call   1050 <atoll@plt>
movslq %eax,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @get_env_size(i8* %0, i64 %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca double
store i8* %0, i8** %4
store i64 %1, i64* %5
%9 = load i8*, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i64, i64* %5
store i64 %12, i64* %3
br label %33
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i8* @getenv(i8* %14)
store i8* %15, i8** %7
%16 = load i8*, i8** %7
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = load i64, i64* %5
store i64 %19, i64* %3
br label %33
20: ; preds = %13
%21 = load i8*, i8** %7
%22 = call double @strtod(i8* %21, i8** %6)
store double %22, double* %8
%23 = load i8*, i8** %6
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = load i64, i64* %5
store i64 %28, i64* %3
br label %33
29: ; preds = %20
%30 = load i8*, i8** %7
%31 = call i32 @atoll(i8* %30)
%32 = sext i32 %31 to i64
store i64 %32, i64* %3
br label %33
33: ; preds = %29, %27, %18, %11
%34 = load i64, i64* %3
ret i64 %34
}

LLVM IR (-O2):
define i64 @get_env_size(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp eq i8* %0, null
br i1 %5, label %17, label %6
6: ; preds = %2
%7 = tail call i8* @getenv(i8* %0)
%8 = icmp eq i8* %7, null
br i1 %8, label %17, label %9
9: ; preds = %6
%10 = call double @strtod(i8* %7, i8** %3)
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = tail call i32 @atoll(i8* %7)
%16 = sext i32 %15 to i64
br label %17
17: ; preds = %14, %9, %6, %2
%18 = phi i64 [ %1, %2 ], [ %1, %6 ], [ %16, %14 ], [ %1, %9 ]
ret i64 %18
}