#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*/ cmd;

/* Variables and functions */
scalar_t__ send_command_to_variable_server(int, char *);
int strlen(char const *);
int /*<<< orphan*/ strncat(char *, char const *, int);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int set_real_time(int socket, int enabled) {
  char cmd[256];
  const char *prefix = "trick.real_time_";
  char enab[16];
  const char *suffix = "()";
  if (enabled > 0)
    strncpy(enab, "enable", 16);
  else
    strncpy(enab, "disable", 16);
  if (sizeof(cmd) < (strlen(prefix) + strlen(enab) + strlen(suffix) + 1)) {
    return -1;
  } else {
    strncpy(cmd, prefix, sizeof(cmd));
    strncat(cmd, enab, (sizeof(cmd) - strlen(cmd) - 1));
    strncat(cmd, suffix, (sizeof(cmd) - strlen(cmd) - 1));
    if (send_command_to_variable_server(socket, cmd) < 0) {
      return -1;
    } else {
      return 0;
    }
  }
}


x86 assembly (clang, -O0):
<set_real_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xea8(%rip),%rax
mov    %rax,-0x118(%rbp)
lea    0xeab(%rip),%rax
mov    %rax,-0x138(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1194 <set_real_time+0x54>
lea    -0x130(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x10,%edx
call   1030 <strncpy@plt>
jmp    11ac <set_real_time+0x6c>
lea    -0x130(%rbp),%rdi
lea    0xe79(%rip),%rsi
mov    $0x10,%edx
call   1030 <strncpy@plt>
mov    -0x118(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x140(%rbp)
lea    -0x130(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x140(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x13c(%rbp)
mov    -0x138(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x13c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
movslq %eax,%rcx
mov    $0x100,%eax
cmp    %rcx,%rax
jae    1210 <set_real_time+0xd0>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ec <set_real_time+0x1ac>
lea    -0x110(%rbp),%rdi
mov    -0x118(%rbp),%rsi
mov    $0x100,%edx
call   1030 <strncpy@plt>
lea    -0x110(%rbp),%rax
mov    %rax,-0x160(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x158(%rbp)
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x160(%rbp),%rdi
mov    -0x158(%rbp),%rsi
movslq %eax,%rcx
mov    $0x100,%eax
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
call   1050 <strncat@plt>
lea    -0x110(%rbp),%rax
mov    %rax,-0x150(%rbp)
mov    -0x138(%rbp),%rax
mov    %rax,-0x148(%rbp)
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x150(%rbp),%rdi
mov    -0x148(%rbp),%rsi
movslq %eax,%rcx
mov    $0x100,%eax
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
call   1050 <strncat@plt>
mov    -0x8(%rbp),%edi
lea    -0x110(%rbp),%rsi
call   1060 <send_command_to_variable_server@plt>
cmp    $0x0,%rax
jge    12e5 <set_real_time+0x1a5>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ec <set_real_time+0x1ac>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_real_time>:
push   %rbp
push   %r14
push   %rbx
sub    $0x110,%rsp
mov    %edi,%r14d
test   %esi,%esi
lea    0xebd(%rip),%rax
lea    0xebd(%rip),%rsi
cmovg  %rax,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x10,%edx
call   1030 <strncpy@plt>
lea    0xe87(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
lea    0xe80(%rip),%rdi
call   1040 <strlen@plt>
add    %ebp,%ebx
lea    (%rax,%rbx,1),%ecx
add    $0xffffff00,%ecx
mov    $0xffffffff,%eax
cmp    $0xfffffeff,%ecx
jb     1210 <set_real_time+0xd0>
lea    0xe4b(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0xff,%ebp
mov    $0xff,%edx
sub    %eax,%edx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <strncat@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
sub    %eax,%ebp
lea    0xe1a(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1050 <strncat@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
call   1060 <send_command_to_variable_server@plt>
sar    $0x3f,%rax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"trick.real_time_\00"
@.str.1 = [3 x i8] c"()\00"
@.str.2 = [7 x i8] c"enable\00"
@.str.3 = [8 x i8] c"disable\00"
define i32 @set_real_time(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [256 x i8]
%7 = alloca i8*
%8 = alloca [16 x i8]
%9 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %9
%10 = load i32, i32* %5
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%14 = call i32 @strncpy(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 16)
br label %18
15: ; preds = %2
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%17 = call i32 @strncpy(i8* %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 16)
br label %18
18: ; preds = %15, %12
%19 = load i8*, i8** %7
%20 = call i32 @strlen(i8* %19)
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = add nsw i32 %20, %22
%24 = load i8*, i8** %9
%25 = call i32 @strlen(i8* %24)
%26 = add nsw i32 %23, %25
%27 = add nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = icmp ult i64 256, %28
br i1 %29, label %30, label %31
30: ; preds = %18
store i32 -1, i32* %3
br label %59
31: ; preds = %18
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%33 = load i8*, i8** %7
%34 = call i32 @strncpy(i8* %32, i8* %33, i32 256)
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%36 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%38 = call i32 @strlen(i8* %37)
%39 = sext i32 %38 to i64
%40 = sub i64 256, %39
%41 = sub i64 %40, 1
%42 = trunc i64 %41 to i32
%43 = call i32 @strncat(i8* %35, i8* %36, i32 %42)
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%45 = load i8*, i8** %9
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%47 = call i32 @strlen(i8* %46)
%48 = sext i32 %47 to i64
%49 = sub i64 256, %48
%50 = sub i64 %49, 1
%51 = trunc i64 %50 to i32
%52 = call i32 @strncat(i8* %44, i8* %45, i32 %51)
%53 = load i32, i32* %4
%54 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%55 = call i64 @send_command_to_variable_server(i32 %53, i8* %54)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %31
store i32 -1, i32* %3
br label %59
58: ; preds = %31
store i32 0, i32* %3
br label %59
59: ; preds = %58, %57, %30
%60 = load i32, i32* %3
ret i32 %60
}

LLVM IR (-O2):
@.str = [17 x i8] c"trick.real_time_\00"
@.str.1 = [3 x i8] c"()\00"
@.str.2 = [7 x i8] c"enable\00"
@.str.3 = [8 x i8] c"disable\00"
define i32 @set_real_time(i32 %0, i32 %1) {
%3 = alloca [256 x i8]
%4 = alloca [16 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%7 = icmp sgt i32 %1, 0
%8 = select i1 %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%9 = call i32 @strncpy(i8* %6, i8* %8, i32 16)
%10 = call i32 @strlen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @strlen(i8* %6)
%12 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = add i32 %10, -256
%14 = add i32 %13, %11
%15 = add i32 %14, %12
%16 = icmp ult i32 %15, -257
br i1 %16, label %28, label %17
17: ; preds = %2
%18 = call i32 @strncpy(i8* %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 256)
%19 = call i32 @strlen(i8* %5)
%20 = sub i32 255, %19
%21 = call i32 @strncat(i8* %5, i8* %6, i32 %20)
%22 = call i32 @strlen(i8* %5)
%23 = sub i32 255, %22
%24 = call i32 @strncat(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = call i64 @send_command_to_variable_server(i32 %0, i8* %5)
%26 = ashr i64 %25, 63
%27 = trunc i64 %26 to i32
br label %28
28: ; preds = %17, %2
%29 = phi i32 [ -1, %2 ], [ %27, %17 ]
ret i32 %29
}