#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 */
struct mntent {
  char *mnt_fsname;
};

/* Variables and functions */
char *root_device_name();
scalar_t__ strcmp(char *, char *);
char *mnt_device_path(struct mntent *m) {
  char *p;
  if (strcmp(m->mnt_fsname, "$ROOT") == 0) {
    p = root_device_name();
    if (p)
      return p;
  }
  return m->mnt_fsname;
}


x86 assembly (clang, -O0):
<mnt_device_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xec6(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1171 <mnt_device_path+0x51>
mov    $0x0,%al
call   1030 <root_device_name@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     116c <mnt_device_path+0x4c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    117c <mnt_device_path+0x5c>
jmp    1171 <mnt_device_path+0x51>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mnt_device_path>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
lea    0xed2(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1146 <mnt_device_path+0x26>
xor    %eax,%eax
call   1030 <root_device_name@plt>
test   %rax,%rax
je     1146 <mnt_device_path+0x26>
pop    %rbx
ret
mov    (%rbx),%rax
pop    %rbx
ret

LLVM IR (-O0):
%struct.mntent = type { i8* }
@.str = [6 x i8] c"$ROOT\00"
define i8* @mnt_device_path(%struct.mntent* %0) {
%2 = alloca i8*
%3 = alloca %struct.mntent*
%4 = alloca i8*
store %struct.mntent* %0, %struct.mntent** %3
%5 = load %struct.mntent*, %struct.mntent** %3
%6 = getelementptr inbounds %struct.mntent, %struct.mntent* %5, i32 0, i32 0
%7 = load i8*, i8** %6
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %1
%11 = call i8* (...) @root_device_name()
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = load i8*, i8** %4
store i8* %15, i8** %2
br label %21
16: ; preds = %10
br label %17
17: ; preds = %16, %1
%18 = load %struct.mntent*, %struct.mntent** %3
%19 = getelementptr inbounds %struct.mntent, %struct.mntent* %18, i32 0, i32 0
%20 = load i8*, i8** %19
store i8* %20, i8** %2
br label %21
21: ; preds = %17, %14
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
%struct.mntent = type { i8* }
@.str = [6 x i8] c"$ROOT\00"
define i8* @mnt_device_path(%struct.mntent* nocapture %0) {
%2 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 0, i32 0
%3 = load i8*, i8** %2
%4 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = tail call i8* (...) @root_device_name()
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %6, %1
%10 = load i8*, i8** %2
br label %11
11: ; preds = %6, %9
%12 = phi i8* [ %10, %9 ], [ %7, %6 ]
ret i8* %12
}