#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 *);
scalar_t__ is_not_null_or_whitespace(char *);
int /*<<< orphan*/ stderr;
char *value;
char *get_env_or_default(char *name, char *def) {
  char *value = is_not_null_or_whitespace(value = getenv(name)) ? 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"
              ":"
              "96"
              ": "
              "%s is NULL (def=%s)",
              (name), (def));
      exit(EXIT_FAILURE);
    }
  } while (0);
  return value;
}


x86 assembly (clang, -O0):
<get_env_or_default>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
mov    %rdi,-0x18(%rbp)
call   1040 <is_not_null_or_whitespace@plt>
cmp    $0x0,%rax
je     117c <get_env_or_default+0x3c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1184 <get_env_or_default+0x44>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c2 <get_env_or_default+0x82>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe51(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jmp    11c7 <get_env_or_default+0x87>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_env_or_default>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <getenv@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <is_not_null_or_whitespace@plt>
test   %rax,%rax
cmove  %r14,%rbx
test   %rbx,%rbx
je     1170 <get_env_or_default+0x30>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <fprintf@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [171 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:96: %s is NULL (def=%s)\00"
@EXIT_FAILURE = global i32 0
@value = global i8* null
define i8* @get_env_or_default(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i8* @getenv(i8* %6)
store i8* %7, i8** %5
%8 = call i64 @is_not_null_or_whitespace(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = load i8*, i8** %5
br label %14
12: ; preds = %2
%13 = load i8*, i8** %4
br label %14
14: ; preds = %12, %10
%15 = phi i8* [ %11, %10 ], [ %13, %12 ]
store i8* %15, i8** %5
br label %16
16: ; preds = %14
%17 = load i8*, i8** %5
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %3
%22 = load i8*, i8** %4
%23 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %16
br label %27
27: ; preds = %26
%28 = load i8*, i8** %5
ret i8* %28
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [171 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:96: %s is NULL (def=%s)\00"
@EXIT_FAILURE = global i32 0
@value = global i8* null
define i8* @get_env_or_default(i8* %0, i8* %1) {
%3 = tail call i8* @getenv(i8* %0)
%4 = tail call i64 @is_not_null_or_whitespace(i8* %3)
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i8* %1, i8* %3
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
ret i8* %6
}