#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int triggerCheckpoint() {
  int fd;
  fd = open("/proc/self/checkpoint", 1 | O_CREAT, 1);
  if (fd == -1) {
    fprintf(stderr, "Error doing self checkpoint \n");
    return 0;
  }
  printf("Checkpoint was done successfuly\n");
  return 1;
}


x86 assembly (clang, -O0):
<triggerCheckpoint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2eb9(%rip),%rax
mov    (%rax),%esi
or     $0x1,%esi
lea    0xeb5(%rip),%rdi
mov    $0x1,%edx
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1183 <triggerCheckpoint+0x53>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1196 <triggerCheckpoint+0x66>
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<triggerCheckpoint>:
push   %rbx
mov    0x2ec0(%rip),%rax
mov    (%rax),%esi
or     $0x1,%esi
lea    0xebc(%rip),%rdi
mov    $0x1,%ebx
mov    $0x1,%edx
call   1050 <open@plt>
cmp    $0xffffffff,%eax
je     1166 <triggerCheckpoint+0x36>
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
jmp    117d <triggerCheckpoint+0x4d>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
call   1040 <fprintf@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"/proc/self/checkpoint\00"
@O_CREAT = global i32 0
@stderr = global i32 0
@.str.1 = [30 x i8] c"Error doing self checkpoint \0A\00"
@.str.2 = [33 x i8] c"Checkpoint was done successfuly\0A\00"
define i32 @triggerCheckpoint() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @O_CREAT
%4 = or i32 1, %3
%5 = call i32 @open(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %4, i32 1)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %13
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %13
13: ; preds = %11, %8
%14 = load i32, i32* %1
ret i32 %14
}

LLVM IR (-O2):
@.str = [22 x i8] c"/proc/self/checkpoint\00"
@O_CREAT = global i32 0
@stderr = global i32 0
@.str.1 = [30 x i8] c"Error doing self checkpoint \0A\00"
@str = [32 x i8] c"Checkpoint was done successfuly\00"
define i32 @triggerCheckpoint() {
%1 = load i32, i32* @O_CREAT
%2 = or i32 %1, 1
%3 = tail call i32 @open(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %2, i32 1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %10
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = phi i32 [ 0, %5 ], [ 1, %8 ]
ret i32 %11
}