#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 */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int send_command_expect_ok(int, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int netplot_set_chart_legend_enabled(int server_connection_index, int enabled) {
  char buffer[256];
  memset(buffer, 0, 256);
  if (enabled) {
    strncpy(buffer, "set enable_legend=true\n", 256);
  } else {
    strncpy(buffer, "set enable_legend=false\n", 256);
  }
  return send_command_expect_ok(server_connection_index, buffer);
}


x86 assembly (clang, -O0):
<netplot_set_chart_legend_enabled>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
cmpl   $0x0,-0x8(%rbp)
je     117b <netplot_set_chart_legend_enabled+0x4b>
lea    -0x110(%rbp),%rdi
lea    0xe94(%rip),%rsi
mov    $0x100,%edx
call   1030 <strncpy@plt>
jmp    1193 <netplot_set_chart_legend_enabled+0x63>
lea    -0x110(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x100,%edx
call   1030 <strncpy@plt>
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
call   1050 <send_command_expect_ok@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<netplot_set_chart_legend_enabled>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %esi,%ebx
mov    %edi,%r14d
mov    %rsp,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
test   %ebx,%ebx
lea    0xebd(%rip),%rax
lea    0xe9e(%rip),%rsi
cmove  %rax,%rsi
mov    %rbp,%rdi
mov    $0x100,%edx
call   1030 <strncpy@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
call   1050 <send_command_expect_ok@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"set enable_legend=true\0A\00"
@.str.1 = [25 x i8] c"set enable_legend=false\0A\00"
define i32 @netplot_set_chart_legend_enabled(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [256 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 256)
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%12 = call i32 @strncpy(i8* %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 256)
br label %16
13: ; preds = %2
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%15 = call i32 @strncpy(i8* %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 256)
br label %16
16: ; preds = %13, %10
%17 = load i32, i32* %3
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%19 = call i32 @send_command_expect_ok(i32 %17, i8* %18)
ret i32 %19
}

LLVM IR (-O2):
@.str = [24 x i8] c"set enable_legend=true\0A\00"
@.str.1 = [25 x i8] c"set enable_legend=false\0A\00"
define i32 @netplot_set_chart_legend_enabled(i32 %0, i32 %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 0, i32 256)
%6 = icmp eq i32 %1, 0
%7 = select i1 %6, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0)
%8 = call i32 @strncpy(i8* %4, i8* %7, i32 256)
%9 = call i32 @send_command_expect_ok(i32 %0, i8* %4)
ret i32 %9
}