#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 */
typedef int /*<<< orphan*/ v;

/* Variables and functions */
int /*<<< orphan*/ Cbuf_AddText(char *);
int /*<<< orphan*/ Cbuf_Execute();
int /*<<< orphan*/ Com_DPrintf(char *, char *);
int /*<<< orphan*/ Cvar_Set(char *, char *);
int /*<<< orphan*/ Cvar_VariableString(char *);
int /*<<< orphan*/ Q_strncpyz(char *, int /*<<< orphan*/, int);
void CL_NextDemo(void) {
  char v[1024];
  Q_strncpyz(v, Cvar_VariableString("nextdemo"), sizeof(v));
  v[1024 - 1] = 0;
  Com_DPrintf("CL_NextDemo: %s\n", v);
  if (!v[0]) {
    return;
  }
  Cvar_Set("nextdemo", "");
  Cbuf_AddText(v);
  Cbuf_AddText("\n");
  Cbuf_Execute();
}


x86 assembly (clang, -O0):
<CL_NextDemo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
lea    -0x400(%rbp),%rax
mov    %rax,-0x408(%rbp)
lea    0xe80(%rip),%rdi
call   1070 <Cvar_VariableString@plt>
mov    -0x408(%rbp),%rdi
mov    %eax,%esi
mov    $0x400,%edx
call   1080 <Q_strncpyz@plt>
movb   $0x0,-0x1(%rbp)
lea    -0x400(%rbp),%rsi
lea    0xe5f(%rip),%rdi
call   1060 <Com_DPrintf@plt>
cmpb   $0x0,-0x400(%rbp)
jne    11c1 <CL_NextDemo+0x61>
jmp    11f3 <CL_NextDemo+0x93>
lea    0xe38(%rip),%rdi
lea    0xe4a(%rip),%rsi
call   1050 <Cvar_Set@plt>
lea    -0x400(%rbp),%rdi
call   1030 <Cbuf_AddText@plt>
lea    0xe31(%rip),%rdi
call   1030 <Cbuf_AddText@plt>
mov    $0x0,%al
call   1040 <Cbuf_Execute@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CL_NextDemo>:
push   %rbx
sub    $0x400,%rsp
lea    0xe91(%rip),%rdi
call   1070 <Cvar_VariableString@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x400,%edx
call   1080 <Q_strncpyz@plt>
movb   $0x0,0x3ff(%rsp)
lea    0xe74(%rip),%rdi
mov    %rbx,%rsi
call   1060 <Com_DPrintf@plt>
cmpb   $0x0,(%rsp)
je     11d1 <CL_NextDemo+0x71>
lea    0xe56(%rip),%rdi
lea    0xe68(%rip),%rsi
call   1050 <Cvar_Set@plt>
mov    %rsp,%rdi
call   1030 <Cbuf_AddText@plt>
lea    0xe53(%rip),%rdi
call   1030 <Cbuf_AddText@plt>
xor    %eax,%eax
call   1040 <Cbuf_Execute@plt>
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"nextdemo\00"
@.str.1 = [17 x i8] c"CL_NextDemo: %s\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c"\0A\00"
define void @CL_NextDemo() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = call i32 @Cvar_VariableString(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @Q_strncpyz(i8* %2, i32 %3, i32 1024)
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 1023
store i8 0, i8* %5
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%7 = call i32 @Com_DPrintf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %0
br label %18
12: ; preds = %0
%13 = call i32 @Cvar_Set(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%15 = call i32 @Cbuf_AddText(i8* %14)
%16 = call i32 @Cbuf_AddText(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 (...) @Cbuf_Execute()
br label %18
18: ; preds = %12, %11
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"nextdemo\00"
@.str.1 = [17 x i8] c"CL_NextDemo: %s\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c"\0A\00"
define void @CL_NextDemo() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @Cvar_VariableString(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @Q_strncpyz(i8* %2, i32 %3, i32 1024)
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 1023
store i8 0, i8* %5
%6 = call i32 @Com_DPrintf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %0
%10 = call i32 @Cvar_Set(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @Cbuf_AddText(i8* %2)
%12 = call i32 @Cbuf_AddText(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (...) @Cbuf_Execute()
br label %14
14: ; preds = %0, %9
ret void
}