#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;
int mkstemp(char *);
int /*<<< orphan*/ tap_error_errno_at(char *, int /*<<< orphan*/, char *, int);
int safe_mkstemp(char *tmplate) {
  int res = mkstemp(tmplate);
  if (res < 0) {
    tap_error_errno_at(
        ("mkstemp()"), (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",
        67);
    abort_safe_block();
  }
  return res;
}


x86 assembly (clang, -O0):
<safe_mkstemp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <mkstemp@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    117a <safe_mkstemp+0x4a>
mov    0x2e87(%rip),%rax
mov    (%rax),%esi
lea    0xe9e(%rip),%rdi
lea    0xea1(%rip),%rdx
mov    $0x43,%ecx
call   1040 <tap_error_errno_at@plt>
mov    $0x0,%al
call   1030 <abort_safe_block@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<safe_mkstemp>:
push   %rbx
call   1050 <mkstemp@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1164 <safe_mkstemp+0x34>
mov    0x2e9d(%rip),%rax
mov    (%rax),%esi
lea    0xeb4(%rip),%rdi
lea    0xeb7(%rip),%rdx
mov    $0x43,%ecx
call   1040 <tap_error_errno_at@plt>
xor    %eax,%eax
call   1030 <abort_safe_block@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"mkstemp()\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 i32 @safe_mkstemp(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @mkstemp(i8* %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %12
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 67)
%11 = call i32 (...) @abort_safe_block()
br label %12
12: ; preds = %8, %1
%13 = load i32, i32* %3
ret i32 %13
}

LLVM IR (-O2):
@.str = [10 x i8] c"mkstemp()\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 i32 @safe_mkstemp(i8* %0) {
%2 = tail call i32 @mkstemp(i8* %0)
%3 = icmp slt i32 %2, 0
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 67)
%7 = tail call i32 (...) @abort_safe_block()
br label %8
8: ; preds = %4, %1
ret i32 %2
}