// File: ef-gy[P]libefgy/src/test-case/std-optional.cpp
// Function: testOptional(std::ostream&)
bool testOptional(std::ostream &log) {
  optional<int> nothing;

  if (nothing) {
    log << "value should have been 'nothing'\n";
    return false;
  }

  optional<int> something = 42;

  if (!something) {
    log << "value should have been something other than 'nothing'\n";
    return false;
  }

  if (*something != 42) {
    log << "value should have been '43', but is '" << *something << "'\n";
    return false;
  }

  something = nothing;

  if (something) {
    log << "'something' was changed to 'nothing', but still thinks "
           "otherwise.\n";
    return false;
  }

  optional<double> somethingElse;

  if (somethingElse) {
    log << "value should have been 'nothing'\n";
    return false;
  }

  somethingElse = optional<double>(42);

  if (!somethingElse) {
    log << "value should have been something other than 'nothing'\n";
    return false;
  }

  if (*somethingElse != 42) {
    log << "value should have been '42', but is '" << *somethingElse << "'\n";
    return false;
  }

  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x6590
leaq -0x18(%rbp), %rdi
callq 0x65b0
testb $0x1, %al
jne 0x5bd4
jmp 0x5bed
movq -0x10(%rbp), %rdi
leaq 0x2d5f3(%rip), %rsi     # 0x331d2
callq 0x5350
movb $0x0, -0x1(%rbp)
jmp 0x5d7f
movl $0x2a, -0x24(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x65d0
leaq -0x20(%rbp), %rdi
callq 0x65b0
testb $0x1, %al
jne 0x5c27
movq -0x10(%rbp), %rdi
leaq 0x2d5db(%rip), %rsi     # 0x331f4
callq 0x5350
movb $0x0, -0x1(%rbp)
jmp 0x5d7f
leaq -0x20(%rbp), %rdi
callq 0x6600
cmpl $0x2a, (%rax)
je 0x5c75
movq -0x10(%rbp), %rdi
leaq 0x2d5eb(%rip), %rsi     # 0x3322b
callq 0x5350
movq %rax, -0x58(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x6600
movq -0x58(%rbp), %rdi
movl (%rax), %esi
callq 0x5580
movq %rax, %rdi
leaq 0x2d5c1(%rip), %rsi     # 0x33228
callq 0x5350
movb $0x0, -0x1(%rbp)
jmp 0x5d7f
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x65b0
testb $0x1, %al
jne 0x5c8c
jmp 0x5ca5
movq -0x10(%rbp), %rdi
leaq 0x2d5ba(%rip), %rsi     # 0x33251
callq 0x5350
movb $0x0, -0x1(%rbp)
jmp 0x5d7f
leaq -0x38(%rbp), %rdi
callq 0x6620
leaq -0x38(%rbp), %rdi
callq 0x6640
testb $0x1, %al
jne 0x5cbd
jmp 0x5cd6
movq -0x10(%rbp), %rdi
leaq 0x2d50a(%rip), %rsi     # 0x331d2
callq 0x5350
movb $0x0, -0x1(%rbp)
jmp 0x5d7f
movl $0x2a, -0x4c(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
callq 0x6660
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x6640
testb $0x1, %al
jne 0x5d1d
movq -0x10(%rbp), %rdi
leaq 0x2d4e2(%rip), %rsi     # 0x331f4
callq 0x5350
movb $0x0, -0x1(%rbp)
jmp 0x5d7f
leaq -0x38(%rbp), %rdi
callq 0x6690
movsd (%rax), %xmm0
movsd 0x2d2d6(%rip), %xmm1    # 0x33008
ucomisd %xmm1, %xmm0
jne 0x5d3c
jp 0x5d3c
jmp 0x5d7b
movq -0x10(%rbp), %rdi
leaq 0x2d54d(%rip), %rsi     # 0x33294
callq 0x5350
movq %rax, -0x60(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x6690
movq -0x60(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x5610
movq %rax, %rdi
leaq 0x2d4b8(%rip), %rsi     # 0x33228
callq 0x5350
movb $0x0, -0x1(%rbp)
jmp 0x5d7f
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)