#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 */
scalar_t__ ENOENT;
int create(char *, unsigned short);
scalar_t__ errno;
scalar_t__ mkparent(char *);
int /*<<< orphan*/ warn(char *, char *);
int recreate(char *pathname, unsigned short mode) {
  int fd;
  if ((fd = create(pathname, mode)) < 0 &&
      (errno != ENOENT ||
       mkparent(pathname) == 0 && (fd = create(pathname, mode)) < 0))
    warn("Tar: 8: %s", pathname);
  errno = 0;
  return (fd);
}


x86 assembly (clang, -O0):
<recreate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    -0x8(%rbp),%rdi
movzwl -0xa(%rbp),%esi
call   1050 <create@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    11b2 <recreate+0x82>
mov    0x2e7d(%rip),%rax
mov    (%rax),%rax
mov    0x2e63(%rip),%rcx
cmp    (%rcx),%rax
jne    11a2 <recreate+0x72>
mov    -0x8(%rbp),%rdi
call   1040 <mkparent@plt>
cmp    $0x0,%rax
jne    11b2 <recreate+0x82>
mov    -0x8(%rbp),%rdi
movzwl -0xa(%rbp),%esi
call   1050 <create@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    11b2 <recreate+0x82>
mov    -0x8(%rbp),%rsi
lea    0xe53(%rip),%rdi
call   1030 <warn@plt>
mov    0x2e27(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recreate>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
call   1050 <create@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1187 <recreate+0x57>
mov    0x2e95(%rip),%rax
mov    (%rax),%rax
mov    0x2e7b(%rip),%rcx
cmp    (%rcx),%rax
jne    1178 <recreate+0x48>
mov    %r14,%rdi
call   1040 <mkparent@plt>
test   %rax,%rax
jne    1187 <recreate+0x57>
movzwl %bx,%esi
mov    %r14,%rdi
call   1050 <create@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1187 <recreate+0x57>
lea    0xe81(%rip),%rdi
mov    %r14,%rsi
call   1030 <warn@plt>
mov    0x2e52(%rip),%rax
movq   $0x0,(%rax)
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i64 0
@ENOENT = global i64 0
@.str = [11 x i8] c"Tar: 8: %s\00"
define i32 @recreate(i8* %0, i16 zeroext %1) {
%3 = alloca i8*
%4 = alloca i16
%5 = alloca i32
store i8* %0, i8** %3
store i16 %1, i16* %4
%6 = load i8*, i8** %3
%7 = load i16, i16* %4
%8 = call i32 @create(i8* %6, i16 zeroext %7)
store i32 %8, i32* %5
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %26
10: ; preds = %2
%11 = load i64, i64* @errno
%12 = load i64, i64* @ENOENT
%13 = icmp ne i64 %11, %12
br i1 %13, label %23, label %14
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = call i64 @mkparent(i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i8*, i8** %3
%20 = load i16, i16* %4
%21 = call i32 @create(i8* %19, i16 zeroext %20)
store i32 %21, i32* %5
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %18, %10
%24 = load i8*, i8** %3
%25 = call i32 @warn(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %23, %18, %14, %2
store i64 0, i64* @errno
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
@errno = global i64 0
@ENOENT = global i64 0
@.str = [11 x i8] c"Tar: 8: %s\00"
define i32 @recreate(i8* %0, i16 zeroext %1) {
%3 = tail call i32 @create(i8* %0, i16 zeroext %1)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %18
5: ; preds = %2
%6 = load i64, i64* @errno
%7 = load i64, i64* @ENOENT
%8 = icmp eq i64 %6, %7
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = tail call i64 @mkparent(i8* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = tail call i32 @create(i8* %0, i16 zeroext %1)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12, %5
%16 = phi i32 [ %3, %5 ], [ %13, %12 ]
%17 = tail call i32 @warn(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %18
18: ; preds = %15, %12, %9, %2
%19 = phi i32 [ %16, %15 ], [ %13, %12 ], [ %3, %9 ], [ %3, %2 ]
store i64 0, i64* @errno
ret i32 %19
}