#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 /*<<< orphan*/ basename(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *safe_asprintf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int systemp(char *, char *);
char *mount_path_pmount(char *in_path) {
  char *out_path;
  int ret;
  ret = systemp("pmount %s", in_path);
  if (ret) {
    fprintf(stderr, "failed to pmount %s\n", in_path);
    return NULL;
  }
  out_path = safe_asprintf("/media/%s", basename(in_path));
  return out_path;
}


x86 assembly (clang, -O0):
<mount_path_pmount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea9(%rip),%rdi
call   1050 <systemp@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     118f <mount_path_pmount+0x4f>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe8d(%rip),%rsi
call   1030 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11b2 <mount_path_pmount+0x72>
mov    -0x10(%rbp),%rdi
call   1040 <basename@plt>
mov    %eax,%esi
lea    0xe7e(%rip),%rdi
call   1060 <safe_asprintf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mount_path_pmount>:
push   %rbx
mov    %rdi,%rbx
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
call   1050 <systemp@plt>
test   %eax,%eax
je     1173 <mount_path_pmount+0x33>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xea3(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    %rbx,%rdi
call   1040 <basename@plt>
lea    0xe9d(%rip),%rdi
mov    %eax,%esi
pop    %rbx
jmp    1060 <safe_asprintf@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"pmount %s\00"
@stderr = global i32 0
@.str.1 = [21 x i8] c"failed to pmount %s\0A\00"
@.str.2 = [10 x i8] c"/media/%s\00"
define i8* @mount_path_pmount(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @systemp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %3
%13 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %12)
store i8* null, i8** %2
br label %19
14: ; preds = %1
%15 = load i8*, i8** %3
%16 = call i32 @basename(i8* %15)
%17 = call i8* @safe_asprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %16)
store i8* %17, i8** %4
%18 = load i8*, i8** %4
store i8* %18, i8** %2
br label %19
19: ; preds = %14, %10
%20 = load i8*, i8** %2
ret i8* %20
}

LLVM IR (-O2):
@.str = [10 x i8] c"pmount %s\00"
@stderr = global i32 0
@.str.1 = [21 x i8] c"failed to pmount %s\0A\00"
@.str.2 = [10 x i8] c"/media/%s\00"
define i8* @mount_path_pmount(i8* %0) {
%2 = tail call i32 @systemp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %10
7: ; preds = %1
%8 = tail call i32 @basename(i8* %0)
%9 = tail call i8* @safe_asprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %7, %4
%11 = phi i8* [ null, %4 ], [ %9, %7 ]
ret i8* %11
}