#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 O_CREAT;
int O_EXCL;
int O_RDWR;
int close(int);
int errno;
int ftruncate(int, int);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
char *strerror(int);
int SASSegStoreCreateByName(char *name) {
  int rc, fd;
  rc = open(name, (O_CREAT | O_EXCL | O_RDWR), (0766));
  if (rc != -1) {
    fd = rc;
    rc = ftruncate(fd, 0x000010000000L);
    if (rc == 0) {
      rc = close(fd);
      if (rc != 0) {
        printf("SASSegStoreCreateByName close failed; %s\n", strerror(errno));
        printf(" Store Name %s\n", name);
      }
    } else {
      printf("SASSegStoreCreateByName truncate failed with %s\n",
             strerror(errno));
      printf(" Store Name %s\n", name);
    }
  } else {
    printf("SASSegStoreCreateByName open failed with %d\n", errno);
    printf(" Store Name %s\n", name);
  }
  return rc;
}


x86 assembly (clang, -O0):
<SASSegStoreCreateByName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
mov    0x2e60(%rip),%rax
or     (%rax),%esi
mov    0x2e67(%rip),%rax
or     (%rax),%esi
mov    $0x1f6,%edx
call   1060 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
je     1233 <SASSegStoreCreateByName+0xe3>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    $0x10000000,%esi
call   1040 <ftruncate@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11fd <SASSegStoreCreateByName+0xad>
mov    -0x10(%rbp),%edi
call   1050 <close@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11f8 <SASSegStoreCreateByName+0xa8>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %rax,%rsi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122e <SASSegStoreCreateByName+0xde>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %rax,%rsi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125c <SASSegStoreCreateByName+0x10c>
mov    0x2d8e(%rip),%rax
mov    (%rax),%esi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SASSegStoreCreateByName>:
push   %rbp
push   %r14
push   %rbx
mov    0x2e9d(%rip),%rax
mov    0x2e6e(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %rdi,%r14
mov    0x2e70(%rip),%rax
or     (%rax),%esi
mov    $0x1f6,%edx
call   1060 <open@plt>
cmp    $0xffffffff,%eax
je     11ac <SASSegStoreCreateByName+0x5c>
mov    %eax,%ebx
mov    %eax,%edi
mov    $0x10000000,%esi
call   1040 <ftruncate@plt>
test   %eax,%eax
je     11ca <SASSegStoreCreateByName+0x7a>
mov    %eax,%ebp
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe90(%rip),%rdi
jmp    11ec <SASSegStoreCreateByName+0x9c>
mov    0x2e15(%rip),%rax
mov    (%rax),%esi
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%ebp
jmp    11f6 <SASSegStoreCreateByName+0xa6>
mov    %ebx,%edi
call   1050 <close@plt>
test   %eax,%eax
je     120e <SASSegStoreCreateByName+0xbe>
mov    %eax,%ebp
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe14(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe2d(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %ebp,%ebp
jmp    1207 <SASSegStoreCreateByName+0xb7>

LLVM IR (-O0):
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@O_RDWR = global i32 0
@.str = [42 x i8] c"SASSegStoreCreateByName close failed; %s\0A\00"
@errno = global i32 0
@.str.1 = [16 x i8] c" Store Name %s\0A\00"
@.str.2 = [49 x i8] c"SASSegStoreCreateByName truncate failed with %s\0A\00"
@.str.3 = [45 x i8] c"SASSegStoreCreateByName open failed with %d\0A\00"
define i32 @SASSegStoreCreateByName(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = load i32, i32* @O_CREAT
%7 = load i32, i32* @O_EXCL
%8 = or i32 %6, %7
%9 = load i32, i32* @O_RDWR
%10 = or i32 %8, %9
%11 = call i32 @open(i8* %5, i32 %10, i32 502)
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %39
14: ; preds = %1
%15 = load i32, i32* %3
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = call i32 @ftruncate(i32 %16, i32 268435456)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %32
20: ; preds = %14
%21 = load i32, i32* %4
%22 = call i32 @close(i32 %21)
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %20
%26 = load i32, i32* @errno
%27 = call i8* @strerror(i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = load i8*, i8** %2
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %25, %20
br label %38
32: ; preds = %14
%33 = load i32, i32* @errno
%34 = call i8* @strerror(i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = load i8*, i8** %2
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %32, %31
br label %44
39: ; preds = %1
%40 = load i32, i32* @errno
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = load i8*, i8** %2
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %39, %38
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@O_RDWR = global i32 0
@.str = [42 x i8] c"SASSegStoreCreateByName close failed; %s\0A\00"
@errno = global i32 0
@.str.1 = [16 x i8] c" Store Name %s\0A\00"
@.str.2 = [49 x i8] c"SASSegStoreCreateByName truncate failed with %s\0A\00"
@.str.3 = [45 x i8] c"SASSegStoreCreateByName open failed with %d\0A\00"
define i32 @SASSegStoreCreateByName(i8* %0) {
%2 = load i32, i32* @O_CREAT
%3 = load i32, i32* @O_EXCL
%4 = or i32 %3, %2
%5 = load i32, i32* @O_RDWR
%6 = or i32 %4, %5
%7 = tail call i32 @open(i8* %0, i32 %6, i32 502)
%8 = icmp eq i32 %7, -1
br i1 %8, label %23, label %9
9: ; preds = %1
%10 = tail call i32 @ftruncate(i32 %7, i32 268435456)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = tail call i32 @close(i32 %7)
%14 = icmp eq i32 %13, 0
br i1 %14, label %29, label %15
15: ; preds = %12
%16 = load i32, i32* @errno
%17 = tail call i8* @strerror(i32 %16)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %26
19: ; preds = %9
%20 = load i32, i32* @errno
%21 = tail call i8* @strerror(i32 %20)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %26
23: ; preds = %1
%24 = load i32, i32* @errno
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %23, %15, %19
%27 = phi i32 [ -1, %23 ], [ %10, %19 ], [ %13, %15 ]
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %29
29: ; preds = %26, %12
%30 = phi i32 [ 0, %12 ], [ %27, %26 ]
ret i32 %30
}