#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*/ abort_safe_block();
int /*<<< orphan*/ errno;
char *mkdtemp(char *);
int /*<<< orphan*/ tap_error_errno_at(char *, int /*<<< orphan*/, char *, int);
char *safe_mkdtemp(char *tmplate) {
  char *path = mkdtemp(tmplate);
  if (!path) {
    tap_error_errno_at(
        ("mkdtemp()"), (errno),
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/picotm/picotm/refs/heads/master/tests/"
        "libsafeblk/safe_stdlib.c",
        55);
    abort_safe_block();
  }
  return path;
}


x86 assembly (clang, -O0):
<safe_mkdtemp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <mkdtemp@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117c <safe_mkdtemp+0x4c>
mov    0x2e85(%rip),%rax
mov    (%rax),%esi
lea    0xe9c(%rip),%rdi
lea    0xe9f(%rip),%rdx
mov    $0x37,%ecx
call   1040 <tap_error_errno_at@plt>
mov    $0x0,%al
call   1030 <abort_safe_block@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<safe_mkdtemp>:
push   %rbx
call   1050 <mkdtemp@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1166 <safe_mkdtemp+0x36>
mov    0x2e9b(%rip),%rax
mov    (%rax),%esi
lea    0xeb2(%rip),%rdi
lea    0xeb5(%rip),%rdx
mov    $0x37,%ecx
call   1040 <tap_error_errno_at@plt>
xor    %eax,%eax
call   1030 <abort_safe_block@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"mkdtemp()\00"
@errno = global i32 0
@.str.1 = [153 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/picotm/picotm/refs/heads/master/tests/libsafeblk/safe_stdlib.c\00"
define i8* @safe_mkdtemp(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @mkdtemp(i8* %4)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %12, label %8
8: ; preds = %1
%9 = load i32, i32* @errno
%10 = call i32 @tap_error_errno_at(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %9, i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 55)
%11 = call i32 (...) @abort_safe_block()
br label %12
12: ; preds = %8, %1
%13 = load i8*, i8** %3
ret i8* %13
}

LLVM IR (-O2):
@.str = [10 x i8] c"mkdtemp()\00"
@errno = global i32 0
@.str.1 = [153 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/picotm/picotm/refs/heads/master/tests/libsafeblk/safe_stdlib.c\00"
define i8* @safe_mkdtemp(i8* %0) {
%2 = tail call i8* @mkdtemp(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = load i32, i32* @errno
%6 = tail call i32 @tap_error_errno_at(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %5, i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 55)
%7 = tail call i32 (...) @abort_safe_block()
br label %8
8: ; preds = %4, %1
ret i8* %2
}