#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_VariableStringBuffer(char *, char *, int);
void CL_NextDemo(void) {
  char v[256];
  Cvar_VariableStringBuffer("nextdemo", v, sizeof(v));
  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    $0x100,%rsp
lea    -0x100(%rbp),%rsi
lea    0xe97(%rip),%rdi
mov    $0x100,%edx
call   1070 <Cvar_VariableStringBuffer@plt>
lea    -0x100(%rbp),%rsi
lea    0xe88(%rip),%rdi
call   1060 <Com_DPrintf@plt>
cmpb   $0x0,-0x100(%rbp)
jne    1198 <CL_NextDemo+0x48>
jmp    11ca <CL_NextDemo+0x7a>
lea    0xe61(%rip),%rdi
lea    0xe73(%rip),%rsi
call   1050 <Cvar_Set@plt>
lea    -0x100(%rbp),%rdi
call   1030 <Cbuf_AddText@plt>
lea    0xe5a(%rip),%rdi
call   1030 <Cbuf_AddText@plt>
mov    $0x0,%al
call   1040 <Cbuf_Execute@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CL_NextDemo>:
push   %rbx
sub    $0x100,%rsp
lea    0xea1(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0x100,%edx
call   1070 <Cvar_VariableStringBuffer@plt>
lea    0xe93(%rip),%rdi
mov    %rbx,%rsi
call   1060 <Com_DPrintf@plt>
cmpb   $0x0,(%rsp)
je     11b2 <CL_NextDemo+0x62>
lea    0xe75(%rip),%rdi
lea    0xe87(%rip),%rsi
call   1050 <Cvar_Set@plt>
mov    %rsp,%rdi
call   1030 <Cbuf_AddText@plt>
lea    0xe72(%rip),%rdi
call   1030 <Cbuf_AddText@plt>
xor    %eax,%eax
call   1040 <Cbuf_Execute@plt>
add    $0x100,%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 [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i32 @Cvar_VariableStringBuffer(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %2, i32 256)
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%5 = call i32 @Com_DPrintf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %0
br label %16
10: ; preds = %0
%11 = 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))
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%13 = call i32 @Cbuf_AddText(i8* %12)
%14 = call i32 @Cbuf_AddText(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (...) @Cbuf_Execute()
br label %16
16: ; preds = %10, %9
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 [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i32 @Cvar_VariableStringBuffer(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %2, i32 256)
%4 = call i32 @Com_DPrintf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %0
%8 = 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))
%9 = call i32 @Cbuf_AddText(i8* %2)
%10 = call i32 @Cbuf_AddText(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (...) @Cbuf_Execute()
br label %12
12: ; preds = %0, %7
ret void
}