#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ rmdir(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stdout;
scalar_t__ system(char *);
int udisk_umount(char *directory) {
  char cmd[255 + 1];
  fprintf(stdout, "umount U disk from %s\n", directory);
  snprintf(cmd, 255, "sudo umount %s\n", directory);
  if (system(cmd) < 0) {
    return -1;
  }
  rmdir(directory);
  return 0;
}


x86 assembly (clang, -O0):
<udisk_umount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe9d(%rip),%rsi
call   1060 <fprintf@plt>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0xff,%esi
lea    0xe98(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x110(%rbp),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
jge    11a6 <udisk_umount+0x66>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b6 <udisk_umount+0x76>
mov    -0x10(%rbp),%rdi
call   1030 <rmdir@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udisk_umount>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
lea    0xea3(%rip),%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
lea    0xeab(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xff,%esi
mov    %rbx,%rcx
call   1050 <snprintf@plt>
mov    %r14,%rdi
call   1040 <system@plt>
test   %rax,%rax
js     1198 <udisk_umount+0x58>
mov    %rbx,%rdi
call   1030 <rmdir@plt>
xor    %eax,%eax
jmp    119d <udisk_umount+0x5d>
mov    $0xffffffff,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [23 x i8] c"umount U disk from %s\0A\00"
@.str.1 = [16 x i8] c"sudo umount %s\0A\00"
define i32 @udisk_umount(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [256 x i8]
store i8* %0, i8** %3
%5 = load i32, i32* @stdout
%6 = load i8*, i8** %3
%7 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%9 = load i8*, i8** %3
%10 = call i32 @snprintf(i8* %8, i32 255, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%12 = call i64 @system(i8* %11)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %1
store i32 -1, i32* %2
br label %18
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = call i32 @rmdir(i8* %16)
store i32 0, i32* %2
br label %18
18: ; preds = %15, %14
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [23 x i8] c"umount U disk from %s\0A\00"
@.str.1 = [16 x i8] c"sudo umount %s\0A\00"
define i32 @udisk_umount(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @stdout
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = call i32 @snprintf(i8* %3, i32 255, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%7 = call i64 @system(i8* %3)
%8 = icmp slt i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = call i32 @rmdir(i8* %0)
br label %11
11: ; preds = %1, %9
%12 = phi i32 [ 0, %9 ], [ -1, %1 ]
ret i32 %12
}