#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 */
char *GetAttribute(char *, char *);
char *GetElement(char *, char const *);
int /*<<< orphan*/ free(char *);
char *GetName(const char *strXteds) {
  char *strElement;
  char *strAttribute;
  strElement = GetElement("Device", strXteds);
  if (NULL == strElement) {
    strElement = GetElement("Application", strXteds);
  }
  if (NULL == strElement)
    return NULL;
  strAttribute = GetAttribute("name", strElement);
  free(strElement);
  return strAttribute;
}


x86 assembly (clang, -O0):
<GetName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1040 <GetElement@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    1170 <GetName+0x40>
mov    -0x10(%rbp),%rsi
lea    0xea0(%rip),%rdi
call   1040 <GetElement@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    1189 <GetName+0x59>
movq   $0x0,-0x8(%rbp)
jmp    11ae <GetName+0x7e>
mov    -0x18(%rbp),%rsi
lea    0xe7f(%rip),%rdi
call   1050 <GetAttribute@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetName>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xec2(%rip),%rdi
mov    %r14,%rsi
call   1040 <GetElement@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1165 <GetName+0x35>
lea    0xeb2(%rip),%rdi
mov    %r14,%rsi
call   1040 <GetElement@plt>
mov    %rax,%rbx
test   %rax,%rax
je     118a <GetName+0x5a>
lea    0xea7(%rip),%rdi
mov    %rbx,%rsi
call   1050 <GetAttribute@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
jmp    1182 <GetName+0x52>

LLVM IR (-O0):
@.str = [7 x i8] c"Device\00"
@.str.1 = [12 x i8] c"Application\00"
@.str.2 = [5 x i8] c"name\00"
define i8* @GetName(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @GetElement(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %6)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp eq i8* null, %8
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i8* @GetElement(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %11)
store i8* %12, i8** %4
br label %13
13: ; preds = %10, %1
%14 = load i8*, i8** %4
%15 = icmp eq i8* null, %14
br i1 %15, label %16, label %17
16: ; preds = %13
store i8* null, i8** %2
br label %23
17: ; preds = %13
%18 = load i8*, i8** %4
%19 = call i8* @GetAttribute(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %18)
store i8* %19, i8** %5
%20 = load i8*, i8** %4
%21 = call i32 @free(i8* %20)
%22 = load i8*, i8** %5
store i8* %22, i8** %2
br label %23
23: ; preds = %17, %16
%24 = load i8*, i8** %2
ret i8* %24
}

LLVM IR (-O2):
@.str = [7 x i8] c"Device\00"
@.str.1 = [12 x i8] c"Application\00"
@.str.2 = [5 x i8] c"name\00"
define i8* @GetName(i8* %0) {
%2 = tail call i8* @GetElement(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i8* @GetElement(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = icmp eq i8* %5, null
br i1 %6, label %11, label %7
7: ; preds = %1, %4
%8 = phi i8* [ %5, %4 ], [ %2, %1 ]
%9 = tail call i8* @GetAttribute(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = tail call i32 @free(i8* %8)
br label %11
11: ; preds = %4, %7
%12 = phi i8* [ %9, %7 ], [ null, %4 ]
ret i8* %12
}