#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_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
char *getenv(char *);
int is_not_null_or_whitespace(char *);
int /*<<< orphan*/ stderr;
char *get_env_or_default2(char *name, char *def, int *has_value) {
  char *value;
  *has_value = is_not_null_or_whitespace(value = getenv(name));
  if (!*has_value) {
    value = def;
  }
  do {
    if ((value == NULL)) {
      fprintf(stderr,
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/sebgod/docker-mercury/refs/heads/"
              "master/src/mmc-docker.c"
              ":"
              "109"
              ": "
              "%s is NULL (def=%s)",
              (name), (def));
      exit(EXIT_FAILURE);
    }
  } while (0);
  return value;
}


x86 assembly (clang, -O0):
<get_env_or_default2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
mov    %rdi,-0x20(%rbp)
call   1040 <is_not_null_or_whitespace@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1186 <get_env_or_default2+0x46>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    118b <get_env_or_default2+0x4b>
cmpq   $0x0,-0x20(%rbp)
jne    11c1 <get_env_or_default2+0x81>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe52(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jmp    11c6 <get_env_or_default2+0x86>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_env_or_default2>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <getenv@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <is_not_null_or_whitespace@plt>
mov    %eax,(%r12)
test   %eax,%eax
cmove  %r14,%rbx
test   %rbx,%rbx
je     117f <get_env_or_default2+0x3f>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <fprintf@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/sebgod/docker-mercury/refs/heads/master/src/mmc-docker.c:109: %s is NULL (def=%s)\00"
@EXIT_FAILURE = global i32 0
define i8* @get_env_or_default2(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%8 = load i8*, i8** %4
%9 = call i8* @getenv(i8* %8)
store i8* %9, i8** %7
%10 = call i32 @is_not_null_or_whitespace(i8* %9)
%11 = load i32*, i32** %6
store i32 %10, i32* %11
%12 = load i32*, i32** %6
%13 = load i32, i32* %12
%14 = icmp ne i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %3
%16 = load i8*, i8** %5
store i8* %16, i8** %7
br label %17
17: ; preds = %15, %3
br label %18
18: ; preds = %17
%19 = load i8*, i8** %7
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %4
%24 = load i8*, i8** %5
%25 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0), i8* %23, i8* %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %18
br label %29
29: ; preds = %28
%30 = load i8*, i8** %7
ret i8* %30
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/sebgod/docker-mercury/refs/heads/master/src/mmc-docker.c:109: %s is NULL (def=%s)\00"
@EXIT_FAILURE = global i32 0
define i8* @get_env_or_default2(i8* %0, i8* %1, i32* nocapture writeonly %2) {
%4 = tail call i8* @getenv(i8* %0)
%5 = tail call i32 @is_not_null_or_whitespace(i8* %4)
store i32 %5, i32* %2
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i8* %1, i8* %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %14
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %3
ret i8* %7
}