#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 rtsp_client {
  int dummy;
};

/* Variables and functions */
char *rtsp_digest_get_sub_value(char const *, char *);
char *rtsp_get_header(struct rtsp_client *, char *, int /*<<< orphan*/);
char *rtsp_digest_auth_get_username(struct rtsp_client *c) {
  const char *p;
  if (c == NULL)
    return NULL;
  p = rtsp_get_header(c, "Authorization", 0);
  if (p == NULL)
    return NULL;
  return rtsp_digest_get_sub_value(p, "username");
}


x86 assembly (clang, -O0):
<rtsp_digest_auth_get_username>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1144 <rtsp_digest_auth_get_username+0x24>
movq   $0x0,-0x8(%rbp)
jmp    1186 <rtsp_digest_auth_get_username+0x66>
mov    -0x10(%rbp),%rdi
lea    0xeb1(%rip),%rsi
xor    %edx,%edx
call   1030 <rtsp_get_header@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1172 <rtsp_digest_auth_get_username+0x52>
movq   $0x0,-0x8(%rbp)
jmp    1186 <rtsp_digest_auth_get_username+0x66>
mov    -0x18(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1040 <rtsp_digest_get_sub_value@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtsp_digest_auth_get_username>:
test   %rdi,%rdi
je     114d <rtsp_digest_auth_get_username+0x2d>
push   %rax
lea    0xed3(%rip),%rsi
xor    %edx,%edx
call   1030 <rtsp_get_header@plt>
test   %rax,%rax
lea    0x8(%rsp),%rsp
je     114d <rtsp_digest_auth_get_username+0x2d>
lea    0xec9(%rip),%rsi
mov    %rax,%rdi
jmp    1040 <rtsp_digest_get_sub_value@plt>
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.rtsp_client = type { i32 }
@.str = [14 x i8] c"Authorization\00"
@.str.1 = [9 x i8] c"username\00"
define i8* @rtsp_digest_auth_get_username(%struct.rtsp_client* %0) {
%2 = alloca i8*
%3 = alloca %struct.rtsp_client*
%4 = alloca i8*
store %struct.rtsp_client* %0, %struct.rtsp_client** %3
%5 = load %struct.rtsp_client*, %struct.rtsp_client** %3
%6 = icmp eq %struct.rtsp_client* %5, null
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* null, i8** %2
br label %17
8: ; preds = %1
%9 = load %struct.rtsp_client*, %struct.rtsp_client** %3
%10 = call i8* @rtsp_get_header(%struct.rtsp_client* %9, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 0)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %8
store i8* null, i8** %2
br label %17
14: ; preds = %8
%15 = load i8*, i8** %4
%16 = call i8* @rtsp_digest_get_sub_value(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i8* %16, i8** %2
br label %17
17: ; preds = %14, %13, %7
%18 = load i8*, i8** %2
ret i8* %18
}

LLVM IR (-O2):
%struct.rtsp_client = type { i32 }
@.str = [14 x i8] c"Authorization\00"
@.str.1 = [9 x i8] c"username\00"
define i8* @rtsp_digest_auth_get_username(%struct.rtsp_client* %0) {
%2 = icmp eq %struct.rtsp_client* %0, null
br i1 %2, label %8, label %3
3: ; preds = %1
%4 = tail call i8* @rtsp_get_header(%struct.rtsp_client* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 0)
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i8* @rtsp_digest_get_sub_value(i8* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %3, %1, %6
%9 = phi i8* [ %7, %6 ], [ null, %1 ], [ null, %3 ]
ret i8* %9
}