#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 PATH_MAX;
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
char *realpath(char *, char *);
int smrlog_unlink_master(char *);
void deletelog(int argc, char *argv[]) {
  char log_dir_buf[PATH_MAX];
  char *log_dir;
  int ret;
  if (argc != 1) {
    printf("deletelog <log_dir>\n");
    exit(1);
  }
  log_dir = realpath(argv[0], log_dir_buf);
  ret = smrlog_unlink_master(log_dir);
  if (ret < 0) {
    printf("Failed to deletelog errno:%d\n", errno);
    exit(1);
  }
  printf("OK deletelog succeeded log dir:%s\n", log_dir);
}


x86 assembly (clang, -O0):
<deletelog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
cmpl   $0x1,-0x4(%rbp)
je     119d <deletelog+0x5d>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x38(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <realpath@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <smrlog_unlink_master@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    11e8 <deletelog+0xa8>
mov    0x2e0a(%rip),%rax
mov    (%rax),%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x28(%rbp),%rsi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<deletelog>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    0x2e93(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rax
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rax
mov    %rax,%rsp
cmp    $0x1,%edi
jne    11a7 <deletelog+0x57>
mov    (%rsi),%rdi
mov    %rax,%rsi
call   1050 <realpath@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <smrlog_unlink_master@plt>
test   %eax,%eax
js     11bd <deletelog+0x6d>
lea    0xe88(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%esi
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [21 x i8] c"deletelog <log_dir>\0A\00"
@.str.1 = [30 x i8] c"Failed to deletelog errno:%d\0A\00"
@errno = global i32 0
@.str.2 = [35 x i8] c"OK deletelog succeeded log dir:%s\0A\00"
define void @deletelog(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = load i32, i32* @PATH_MAX
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %5
%12 = alloca i8, i64 %10
store i64 %10, i64* %6
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %4
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i8* @realpath(i8* %21, i8* %12)
store i8* %22, i8** %7
%23 = load i8*, i8** %7
%24 = call i32 @smrlog_unlink_master(i8* %23)
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %18
%28 = load i32, i32* @errno
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %18
%32 = load i8*, i8** %7
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %5
ret void
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str.1 = [30 x i8] c"Failed to deletelog errno:%d\0A\00"
@errno = global i32 0
@.str.2 = [35 x i8] c"OK deletelog succeeded log dir:%s\0A\00"
@str = [20 x i8] c"deletelog <log_dir>\00"
define void @deletelog(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = icmp eq i32 %0, 1
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = call i8* @realpath(i8* %11, i8* %5)
%13 = call i32 @smrlog_unlink_master(i8* %12)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* @errno
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %10
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %12)
ret void
}