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


x86 assembly (clang, -O0):
<infomem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e8a(%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,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x38(%rbp)
cmpl   $0x1,-0x4(%rbp)
je     11b5 <infomem+0x65>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x40(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <realpath@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1060 <smrlog_info_master@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1204 <infomem+0xb4>
mov    0x2dee(%rip),%rax
mov    (%rax),%esi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpq   $0x0,-0x38(%rbp)
je     122a <infomem+0xda>
mov    -0x38(%rbp),%rsi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rsi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<infomem>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    0x2e83(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rax
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rax
mov    %rax,%rsp
movq   $0x0,-0x10(%rbp)
cmp    $0x1,%edi
jne    11da <infomem+0x7a>
mov    (%rsi),%rdi
mov    %rax,%rsi
call   1060 <realpath@plt>
mov    %rax,%rbx
lea    -0x10(%rbp),%rsi
mov    %rax,%rdi
call   1070 <smrlog_info_master@plt>
test   %eax,%eax
js     11f0 <infomem+0x90>
mov    -0x10(%rbp),%rdi
test   %rdi,%rdi
je     11c2 <infomem+0x62>
call   1040 <puts@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    0xe55(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe5e(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%esi
lea    0xe00(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

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

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