#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 */
int /*<<< orphan*/ rtsp_add_response(struct rtsp_client *, char *, char *);
int /*<<< orphan*/ rtsp_create_response(struct rtsp_client *, int, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
int rtsp_create_basic_auth_response(struct rtsp_client *c, const char *realm) {
  char buffer[256];
  if (c == NULL)
    return -1;
  rtsp_create_response(c, 401, "Unauthorized");
  snprintf(buffer, 255, "Basic realm=\"%s\"", realm);
  rtsp_add_response(c, "WWW-Authenticate", buffer);
  return 0;
}


x86 assembly (clang, -O0):
<rtsp_create_basic_auth_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115a <rtsp_create_basic_auth_response+0x2a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a9 <rtsp_create_basic_auth_response+0x79>
mov    -0x10(%rbp),%rdi
mov    $0x191,%esi
lea    0xe96(%rip),%rdx
call   1040 <rtsp_create_response@plt>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0xff,%esi
lea    0xe87(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xe81(%rip),%rsi
call   1050 <rtsp_add_response@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtsp_create_basic_auth_response>:
test   %rdi,%rdi
je     1193 <rtsp_create_basic_auth_response+0x63>
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeb2(%rip),%rdx
mov    $0x191,%esi
call   1040 <rtsp_create_response@plt>
lea    0xeae(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0xff,%esi
mov    %r14,%rcx
call   1030 <snprintf@plt>
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
call   1050 <rtsp_add_response@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
%struct.rtsp_client = type { i32 }
@.str = [13 x i8] c"Unauthorized\00"
@.str.1 = [17 x i8] c"Basic realm=\22%s\22\00"
@.str.2 = [17 x i8] c"WWW-Authenticate\00"
define i32 @rtsp_create_basic_auth_response(%struct.rtsp_client* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.rtsp_client*
%5 = alloca i8*
%6 = alloca [256 x i8]
store %struct.rtsp_client* %0, %struct.rtsp_client** %4
store i8* %1, i8** %5
%7 = load %struct.rtsp_client*, %struct.rtsp_client** %4
%8 = icmp eq %struct.rtsp_client* %7, null
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 -1, i32* %3
br label %19
10: ; preds = %2
%11 = load %struct.rtsp_client*, %struct.rtsp_client** %4
%12 = call i32 @rtsp_create_response(%struct.rtsp_client* %11, i32 401, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%14 = load i8*, i8** %5
%15 = call i32 @snprintf(i8* %13, i32 255, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load %struct.rtsp_client*, %struct.rtsp_client** %4
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%18 = call i32 @rtsp_add_response(%struct.rtsp_client* %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %17)
store i32 0, i32* %3
br label %19
19: ; preds = %10, %9
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
%struct.rtsp_client = type { i32 }
@.str = [13 x i8] c"Unauthorized\00"
@.str.1 = [17 x i8] c"Basic realm=\22%s\22\00"
@.str.2 = [17 x i8] c"WWW-Authenticate\00"
define i32 @rtsp_create_basic_auth_response(%struct.rtsp_client* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = icmp eq %struct.rtsp_client* %0, null
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = tail call i32 @rtsp_create_response(%struct.rtsp_client* %0, i32 401, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @snprintf(i8* %4, i32 255, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%9 = call i32 @rtsp_add_response(%struct.rtsp_client* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %10
10: ; preds = %2, %6
%11 = phi i32 [ 0, %6 ], [ -1, %2 ]
ret i32 %11
}