#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 */
typedef int /*<<< orphan*/ ack_file;

/* Variables and functions */
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ O_WRONLY;
int PATH_MAX;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char *,
                          int /*<<< orphan*/, int /*<<< orphan*/);
int write(int, char *, int);
void ack_dump(const char *dump_dir_path) {
  char ack_file[PATH_MAX];
  int fd;
  int rc;
  snprintf(ack_file, sizeof(ack_file), "%s/acknowledge", dump_dir_path);
  fd = open(ack_file, O_WRONLY);
  if (fd == -1) {
    syslog(LOG_ERR,
           "Failed to acknowledge platform dump: %s"
           " (%d:%s)\n",
           ack_file, errno, strerror(errno));
    return;
  }
  rc = write(fd, "ack\n", 4);
  if (rc != 4) {
    syslog(LOG_ERR,
           "Failed to acknowledge platform dump: %s"
           " (%d:%s)\n",
           ack_file, errno, strerror(errno));
  }
  close(fd);
}


x86 assembly (clang, -O0):
<ack_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e7d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
mov    %eax,%esi
mov    -0x8(%rbp),%rcx
lea    0xe5b(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x30(%rbp),%rdi
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1214 <ack_dump+0xb4>
mov    0x2df0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x38(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    -0x34(%rbp),%ecx
mov    %eax,%r8d
lea    0xe0c(%rip),%rsi
call   1060 <syslog@plt>
movl   $0x1,-0x24(%rbp)
jmp    1283 <ack_dump+0x123>
mov    -0x1c(%rbp),%edi
lea    0xe22(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
je     1274 <ack_dump+0x114>
mov    0x2d84(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2d90(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x40(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    -0x3c(%rbp),%ecx
mov    %eax,%r8d
lea    0xda0(%rip),%rsi
call   1060 <syslog@plt>
mov    -0x1c(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ack_dump>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rcx
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe6e(%rip),%rdx
mov    %rbx,%rdi
call   1040 <snprintf@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     1209 <ack_dump+0xa9>
mov    %eax,%r14d
lea    0xe86(%rip),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1030 <write@plt>
cmp    $0x4,%eax
je     11ff <ack_dump+0x9f>
mov    0x2dee(%rip),%rax
mov    (%rax),%r15d
mov    0x2dfc(%rip),%rax
mov    (%rax),%r12d
mov    %r12d,%edi
call   1080 <strerror@plt>
lea    0xe21(%rip),%rsi
mov    %r15d,%edi
mov    %rbx,%rdx
mov    %r12d,%ecx
mov    %eax,%r8d
call   1060 <syslog@plt>
mov    %r14d,%edi
call   1050 <close@plt>
jmp    123d <ack_dump+0xdd>
mov    0x2db0(%rip),%rax
mov    (%rax),%r14d
mov    0x2dbe(%rip),%rax
mov    (%rax),%r15d
mov    %r15d,%edi
call   1080 <strerror@plt>
lea    0xde3(%rip),%rsi
mov    %r14d,%edi
mov    %rbx,%rdx
mov    %r15d,%ecx
mov    %eax,%r8d
call   1060 <syslog@plt>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [15 x i8] c"%s/acknowledge\00"
@O_WRONLY = global i32 0
@LOG_ERR = global i32 0
@.str.1 = [49 x i8] c"Failed to acknowledge platform dump: %s (%d:%s)\0A\00"
@errno = global i32 0
@.str.2 = [5 x i8] c"ack\0A\00"
define void @ack_dump(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
%8 = load i32, i32* @PATH_MAX
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %3
%11 = alloca i8, i64 %9
store i64 %9, i64* %4
%12 = trunc i64 %9 to i32
%13 = load i8*, i8** %2
%14 = call i32 @snprintf(i8* %11, i32 %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @O_WRONLY
%16 = call i32 @open(i8* %11, i32 %15)
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %25
19: ; preds = %1
%20 = load i32, i32* @LOG_ERR
%21 = load i32, i32* @errno
%22 = load i32, i32* @errno
%23 = call i32 @strerror(i32 %22)
%24 = call i32 @syslog(i32 %20, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 %21, i32 %23)
store i32 1, i32* %7
br label %39
25: ; preds = %1
%26 = load i32, i32* %5
%27 = call i32 @write(i32 %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = icmp ne i32 %28, 4
br i1 %29, label %30, label %36
30: ; preds = %25
%31 = load i32, i32* @LOG_ERR
%32 = load i32, i32* @errno
%33 = load i32, i32* @errno
%34 = call i32 @strerror(i32 %33)
%35 = call i32 @syslog(i32 %31, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 %32, i32 %34)
br label %36
36: ; preds = %30, %25
%37 = load i32, i32* %5
%38 = call i32 @close(i32 %37)
store i32 0, i32* %7
br label %39
39: ; preds = %36, %19
%40 = load i8*, i8** %3
%41 = load i32, i32* %7
switch i32 %41, label %43 [
i32 0, label %42
i32 1, label %42
]
42: ; preds = %39, %39
ret void
43: ; preds = %39
unreachable
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [15 x i8] c"%s/acknowledge\00"
@O_WRONLY = global i32 0
@LOG_ERR = global i32 0
@.str.1 = [49 x i8] c"Failed to acknowledge platform dump: %s (%d:%s)\0A\00"
@errno = global i32 0
@.str.2 = [5 x i8] c"ack\0A\00"
define void @ack_dump(i8* %0) {
%2 = load i32, i32* @PATH_MAX
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i32 @snprintf(i8* %4, i32 %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = load i32, i32* @O_WRONLY
%7 = call i32 @open(i8* %4, i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = load i32, i32* @LOG_ERR
%11 = load i32, i32* @errno
%12 = call i32 @strerror(i32 %11)
%13 = call i32 @syslog(i32 %10, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %4, i32 %11, i32 %12)
br label %24
14: ; preds = %1
%15 = call i32 @write(i32 %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%16 = icmp eq i32 %15, 4
br i1 %16, label %22, label %17
17: ; preds = %14
%18 = load i32, i32* @LOG_ERR
%19 = load i32, i32* @errno
%20 = call i32 @strerror(i32 %19)
%21 = call i32 @syslog(i32 %18, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %4, i32 %19, i32 %20)
br label %22
22: ; preds = %17, %14
%23 = call i32 @close(i32 %7)
br label %24
24: ; preds = %22, %9
ret void
}