#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*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
char *strdup(char const *);
char *strerror(int /*<<< orphan*/);
char *xconfigStrdup(const char *s) {
  char *m;
  if (!s)
    return NULL;
  m = strdup(s);
  if (!m) {
    fprintf(stderr, "memory allocation failure during strdup (%s)! \n",
            strerror(errno));
    exit(1);
  }
  return m;
}


x86 assembly (clang, -O0):
<xconfigStrdup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1164 <xconfigStrdup+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11ba <xconfigStrdup+0x7a>
mov    -0x10(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b2 <xconfigStrdup+0x72>
mov    0x2e5d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe5d(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xconfigStrdup>:
push   %rbx
test   %rdi,%rdi
je     1152 <xconfigStrdup+0x12>
call   1050 <strdup@plt>
test   %rax,%rax
je     1156 <xconfigStrdup+0x16>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e83(%rip),%rax
mov    (%rax),%ebx
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe8c(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [48 x i8] c"memory allocation failure during strdup (%s)! \0A\00"
@errno = global i32 0
define i8* @xconfigStrdup(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i8* null, i8** %2
br label %21
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i8* @strdup(i8* %9)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %19, label %13
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = load i32, i32* @errno
%16 = call i8* @strerror(i32 %15)
%17 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %8
%20 = load i8*, i8** %4
store i8* %20, i8** %2
br label %21
21: ; preds = %19, %7
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [48 x i8] c"memory allocation failure during strdup (%s)! \0A\00"
@errno = global i32 0
define noalias i8* @xconfigStrdup(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %12, label %3
3: ; preds = %1
%4 = tail call i8* @strdup(i8* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = tail call i8* @strerror(i32 %8)
%10 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %3, %1
%13 = phi i8* [ null, %1 ], [ %4, %3 ]
ret i8* %13
}