#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_TRUNC;
int O_WRONLY;
int close(int);
int errno;
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, int, ...);
int write(int, void *, int);
void store_second(void *step_second) {
  int f = open("../epoch.rta/second", O_WRONLY | O_TRUNC | O_CREAT, 0777);
  int x;
  if (f < 0)
    printf("epoch step not stored %d\n", errno);
  else {
    x = write(f, step_second, 8);
    if (x ^ 8)
      printf("%d epoch step not stored %d\n", x, errno);
    x = close(f);
    if (x < 0)
      printf("epoch step not secured %d\n", errno);
  }
}


x86 assembly (clang, -O0):
<store_second>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
mov    0x2e94(%rip),%rax
or     (%rax),%esi
mov    0x2e93(%rip),%rax
or     (%rax),%esi
lea    0xe92(%rip),%rdi
mov    $0x1ff,%edx
call   1060 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11a1 <store_second+0x61>
mov    0x2e44(%rip),%rax
mov    (%rax),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120f <store_second+0xcf>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   1030 <write@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
xor    $0x8,%eax
cmp    $0x0,%eax
je     11de <store_second+0x9e>
mov    -0x10(%rbp),%esi
mov    0x2e02(%rip),%rax
mov    (%rax),%edx
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    120a <store_second+0xca>
mov    0x2dd6(%rip),%rax
mov    (%rax),%esi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120f <store_second+0xcf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<store_second>:
push   %r14
push   %rbx
push   %rax
mov    0x2e75(%rip),%rax
mov    0x2e9e(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %rdi,%r14
mov    0x2e98(%rip),%rax
or     (%rax),%esi
lea    0xe97(%rip),%rdi
mov    $0x1ff,%edx
call   1060 <open@plt>
test   %eax,%eax
js     11b9 <store_second+0x79>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x8,%edx
call   1030 <write@plt>
cmp    $0x8,%eax
je     11a6 <store_second+0x66>
mov    0x2e3c(%rip),%rcx
mov    (%rcx),%edx
lea    0xe77(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1050 <close@plt>
test   %eax,%eax
js     11c2 <store_second+0x82>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe57(%rip),%rdi
jmp    11c9 <store_second+0x89>
lea    0xe68(%rip),%rdi
mov    0x2e00(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"../epoch.rta/second\00"
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@.str.1 = [26 x i8] c"epoch step not stored %d\0A\00"
@errno = global i32 0
@.str.2 = [29 x i8] c"%d epoch step not stored %d\0A\00"
@.str.3 = [27 x i8] c"epoch step not secured %d\0A\00"
define void @store_second(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i32, i32* @O_WRONLY
%6 = load i32, i32* @O_TRUNC
%7 = or i32 %5, %6
%8 = load i32, i32* @O_CREAT
%9 = or i32 %7, %8
%10 = call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %9, i32 511)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i32, i32* @errno
%15 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %36
16: ; preds = %1
%17 = load i32, i32* %3
%18 = load i8*, i8** %2
%19 = call i32 @write(i32 %17, i8* %18, i32 8)
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = xor i32 %20, 8
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %16
%24 = load i32, i32* %4
%25 = load i32, i32* @errno
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %25)
br label %27
27: ; preds = %23, %16
%28 = load i32, i32* %3
%29 = call i32 @close(i32 %28)
store i32 %29, i32* %4
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = load i32, i32* @errno
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %32, %27
br label %36
36: ; preds = %35, %13
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"../epoch.rta/second\00"
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@.str.1 = [26 x i8] c"epoch step not stored %d\0A\00"
@errno = global i32 0
@.str.2 = [29 x i8] c"%d epoch step not stored %d\0A\00"
@.str.3 = [27 x i8] c"epoch step not secured %d\0A\00"
define void @store_second(i8* nocapture %0) {
%2 = load i32, i32* @O_WRONLY
%3 = load i32, i32* @O_TRUNC
%4 = or i32 %3, %2
%5 = load i32, i32* @O_CREAT
%6 = or i32 %4, %5
%7 = tail call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %6, i32 511)
%8 = icmp slt i32 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %1
%10 = tail call i32 @write(i32 %7, i8* %0, i32 8)
%11 = icmp eq i32 %10, 8
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* @errno
%14 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %13)
br label %15
15: ; preds = %12, %9
%16 = tail call i32 @close(i32 %7)
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15, %1
%19 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), %15 ]
%20 = load i32, i32* @errno
%21 = tail call i32 (i8*, i32, ...) @printf(i8* %19, i32 %20)
br label %22
22: ; preds = %18, %15
ret void
}