#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*/ die(char *, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
char *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int umount2(char *, int);
void umount_buffer(char *line) {
  char *next, *mnt, *end, *type;
  int result;
  if (!line || !*line)
    return;
  next = strchr(line, '\n');
  *next++ = '0';
  type = line;
  mnt = strchr(line, ' ');
  *mnt++ = '\0';
  end = strchr(mnt, ' ');
  *end = '\0';
  umount_buffer(next);
  if (strcmp(type, "rootfs"))
    return;
  result = umount2(mnt, 0x00000002);
  if (result < 0)
    die("umount of '%s' failed: %d: %s\n", mnt, errno, strerror(errno));
}


x86 assembly (clang, -O0):
<umount_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1184 <umount_buffer+0x24>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1189 <umount_buffer+0x29>
jmp    126c <umount_buffer+0x10c>
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x30,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <umount_buffer@plt>
mov    -0x28(%rbp),%rdi
lea    0xdfa(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     121a <umount_buffer+0xba>
jmp    126c <umount_buffer+0x10c>
mov    -0x18(%rbp),%rdi
mov    $0x2,%esi
call   1040 <umount2@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    126c <umount_buffer+0x10c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    0x2d9c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%edx
mov    %eax,%ecx
lea    0xda0(%rip),%rdi
call   1070 <die@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<umount_buffer>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     11da <umount_buffer+0x7a>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     11da <umount_buffer+0x7a>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
movb   $0x30,(%rax)
lea    0x1(%rax),%r15
mov    %rbx,%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
mov    %rax,%r14
movb   $0x0,(%rax)
add    $0x1,%r14
mov    %r14,%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
movb   $0x0,(%rax)
mov    %r15,%rdi
call   1030 <umount_buffer@plt>
lea    0xe44(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11da <umount_buffer+0x7a>
mov    %r14,%rdi
mov    $0x2,%esi
call   1040 <umount2@plt>
test   %eax,%eax
js     11e0 <umount_buffer+0x80>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2df9(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1080 <strerror@plt>
lea    0xe10(%rip),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
mov    %eax,%ecx
pop    %rbx
pop    %r14
pop    %r15
jmp    1070 <die@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"rootfs\00"
@.str.1 = [31 x i8] c"umount of '%s' failed: %d: %s\0A\00"
@errno = global i32 0
define void @umount_buffer(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %10, %1
br label %44
15: ; preds = %10
%16 = load i8*, i8** %2
%17 = call i8* @strchr(i8* %16, i8 signext 10)
store i8* %17, i8** %3
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
store i8 48, i8* %18
%20 = load i8*, i8** %2
store i8* %20, i8** %6
%21 = load i8*, i8** %2
%22 = call i8* @strchr(i8* %21, i8 signext 32)
store i8* %22, i8** %4
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %4
store i8 0, i8* %23
%25 = load i8*, i8** %4
%26 = call i8* @strchr(i8* %25, i8 signext 32)
store i8* %26, i8** %5
%27 = load i8*, i8** %5
store i8 0, i8* %27
%28 = load i8*, i8** %3
%29 = load i8*, i8** %6
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %15
br label %44
33: ; preds = %15
%34 = load i8*, i8** %4
%35 = call i32 @umount2(i8* %34, i32 2)
store i32 %35, i32* %7
%36 = load i32, i32* %7
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %33
%39 = load i8*, i8** %4
%40 = load i32, i32* @errno
%41 = load i32, i32* @errno
%42 = call i32 @strerror(i32 %41)
%43 = call i32 @die(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %39, i32 %40, i32 %42)
br label %44
44: ; preds = %14, %32, %38, %33
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"rootfs\00"
@.str.1 = [31 x i8] c"umount of '%s' failed: %d: %s\0A\00"
@errno = global i32 0
define void @umount_buffer(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %21, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %21, label %6
6: ; preds = %3
%7 = tail call i8* @strchr(i8* %0, i8 signext 10)
%8 = getelementptr inbounds i8, i8* %7, i64 1
store i8 48, i8* %7
%9 = tail call i8* @strchr(i8* %0, i8 signext 32)
%10 = getelementptr inbounds i8, i8* %9, i64 1
store i8 0, i8* %9
%11 = tail call i8* @strchr(i8* %10, i8 signext 32)
store i8 0, i8* %11
tail call void @umount_buffer(i8* %8)
%12 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %6
%15 = tail call i32 @umount2(i8* %10, i32 2)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i32, i32* @errno
%19 = tail call i32 @strerror(i32 %18)
%20 = tail call i32 @die(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 %18, i32 %19)
br label %21
21: ; preds = %14, %17, %6, %1, %3
ret void
}