#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 */
struct file_cache {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ cctools_debug(long long, char *, char const *, char *);
int /*<<< orphan*/ fchmod(int, int);
int mkstemp64(char *);
int /*<<< orphan*/ txn_name(struct file_cache *, char const *, char *);
int file_cache_begin(struct file_cache *f, const char *path, char *txn) {
  int result;
  txn_name(f, path, txn);
  result = mkstemp64(txn);
  if (result >= 0) {
    cctools_debug((1LL << 30), "begin %s %s", path, txn);
    fchmod(result, 0700);
  }
  return result;
}


x86 assembly (clang, -O0):
<file_cache_begin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <txn_name@plt>
mov    -0x18(%rbp),%rdi
call   1030 <mkstemp64@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     11a1 <file_cache_begin+0x61>
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x40000000,%edi
lea    0xe71(%rip),%rsi
call   1040 <cctools_debug@plt>
mov    -0x1c(%rbp),%edi
mov    $0x1c0,%esi
call   1060 <fchmod@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_cache_begin>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
call   1050 <txn_name@plt>
mov    %rbx,%rdi
call   1030 <mkstemp64@plt>
mov    %eax,%ebp
test   %eax,%eax
js     1180 <file_cache_begin+0x40>
lea    0xe9c(%rip),%rsi
mov    $0x40000000,%edi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1040 <cctools_debug@plt>
mov    %ebp,%edi
mov    $0x1c0,%esi
call   1060 <fchmod@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.file_cache = type { i32 }
@.str = [12 x i8] c"begin %s %s\00"
define i32 @file_cache_begin(%struct.file_cache* %0, i8* %1, i8* %2) {
%4 = alloca %struct.file_cache*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store %struct.file_cache* %0, %struct.file_cache** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load %struct.file_cache*, %struct.file_cache** %4
%9 = load i8*, i8** %5
%10 = load i8*, i8** %6
%11 = call i32 @txn_name(%struct.file_cache* %8, i8* %9, i8* %10)
%12 = load i8*, i8** %6
%13 = call i32 @mkstemp64(i8* %12)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %3
%17 = load i8*, i8** %5
%18 = load i8*, i8** %6
%19 = call i32 @cctools_debug(i64 1073741824, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18)
%20 = load i32, i32* %7
%21 = call i32 @fchmod(i32 %20, i32 448)
br label %22
22: ; preds = %16, %3
%23 = load i32, i32* %7
ret i32 %23
}

LLVM IR (-O2):
%struct.file_cache = type { i32 }
@.str = [12 x i8] c"begin %s %s\00"
define i32 @file_cache_begin(%struct.file_cache* %0, i8* %1, i8* %2) {
%4 = tail call i32 @txn_name(%struct.file_cache* %0, i8* %1, i8* %2)
%5 = tail call i32 @mkstemp64(i8* %2)
%6 = icmp sgt i32 %5, -1
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = tail call i32 @cctools_debug(i64 1073741824, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%9 = tail call i32 @fchmod(i32 %5, i32 448)
br label %10
10: ; preds = %7, %3
ret i32 %5
}