#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 */
void *finddevice(char *);
scalar_t__ getprop(void *, char const *, char *, int);
void *find_node_by_alias(const char *alias) {
  void *devp = finddevice("/aliases");
  if (devp) {
    char path[256];
    if (getprop(devp, alias, path, 256) > 0) {
      return finddevice(path);
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<find_node_by_alias>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xeca(%rip),%rdi
call   1040 <finddevice@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1187 <find_node_by_alias+0x67>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x120(%rbp),%rdx
mov    $0x100,%ecx
call   1030 <getprop@plt>
cmp    $0x0,%rax
jle    1182 <find_node_by_alias+0x62>
lea    -0x120(%rbp),%rdi
call   1040 <finddevice@plt>
mov    %rax,-0x8(%rbp)
jmp    118f <find_node_by_alias+0x6f>
jmp    1187 <find_node_by_alias+0x67>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_node_by_alias>:
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%rbx
lea    0xece(%rip),%rdi
call   1040 <finddevice@plt>
test   %rax,%rax
je     115e <find_node_by_alias+0x3e>
mov    %rsp,%rdx
mov    %rax,%rdi
mov    %rbx,%rsi
mov    $0x100,%ecx
call   1030 <getprop@plt>
test   %rax,%rax
jle    115e <find_node_by_alias+0x3e>
mov    %rsp,%rdi
call   1040 <finddevice@plt>
jmp    1160 <find_node_by_alias+0x40>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"/aliases\00"
define i8* @find_node_by_alias(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [256 x i8]
store i8* %0, i8** %3
%6 = call i8* @finddevice(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %19
9: ; preds = %1
%10 = load i8*, i8** %4
%11 = load i8*, i8** %3
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%13 = call i64 @getprop(i8* %10, i8* %11, i8* %12, i32 256)
%14 = icmp sgt i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%17 = call i8* @finddevice(i8* %16)
store i8* %17, i8** %2
br label %20
18: ; preds = %9
br label %19
19: ; preds = %18, %1
store i8* null, i8** %2
br label %20
20: ; preds = %19, %15
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@.str = [9 x i8] c"/aliases\00"
define i8* @find_node_by_alias(i8* %0) {
%2 = alloca [256 x i8]
%3 = tail call i8* @finddevice(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %12, label %5
5: ; preds = %1
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%7 = call i64 @getprop(i8* %3, i8* %0, i8* %6, i32 256)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = call i8* @finddevice(i8* %6)
br label %12
11: ; preds = %5
br label %12
12: ; preds = %1, %11, %9
%13 = phi i8* [ %10, %9 ], [ null, %11 ], [ null, %1 ]
ret i8* %13
}