#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ sflap_send(char *, int, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ toc_build_config(char *, int);
void serv_save_config() {
  char *buf = malloc(2048 * 2);
  char *buf2 = malloc(2048);
  toc_build_config(buf, 2048 * 2 / 2);
  snprintf(buf2, 2048, "toc_set_config {%s}", buf);
  sflap_send(buf2, -1, 2);
  free(buf2);
  free(buf);
}


x86 assembly (clang, -O0):
<serv_save_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1000,%edi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x800,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x800,%esi
call   1070 <toc_build_config@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x800,%esi
lea    0xe6a(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x10(%rbp),%rdi
mov    $0xffffffff,%esi
mov    $0x2,%edx
call   1060 <sflap_send@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serv_save_config>:
push   %r14
push   %rbx
push   %rax
mov    $0x1000,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x800,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x800,%esi
call   1070 <toc_build_config@plt>
lea    0xe7e(%rip),%rdx
mov    %rbx,%rdi
mov    $0x800,%esi
mov    %r14,%rcx
call   1040 <snprintf@plt>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
mov    $0x2,%edx
call   1060 <sflap_send@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"toc_set_config {%s}\00"
define void @serv_save_config() {
%1 = alloca i8*
%2 = alloca i8*
%3 = call i8* @malloc(i32 4096)
store i8* %3, i8** %1
%4 = call i8* @malloc(i32 2048)
store i8* %4, i8** %2
%5 = load i8*, i8** %1
%6 = call i32 @toc_build_config(i8* %5, i32 2048)
%7 = load i8*, i8** %2
%8 = load i8*, i8** %1
%9 = call i32 @snprintf(i8* %7, i32 2048, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %2
%11 = call i32 @sflap_send(i8* %10, i32 -1, i32 2)
%12 = load i8*, i8** %2
%13 = call i32 @free(i8* %12)
%14 = load i8*, i8** %1
%15 = call i32 @free(i8* %14)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"toc_set_config {%s}\00"
define void @serv_save_config() {
%1 = tail call dereferenceable_or_null(4096) i8* @malloc(i32 4096)
%2 = tail call dereferenceable_or_null(2048) i8* @malloc(i32 2048)
%3 = tail call i32 @toc_build_config(i8* %1, i32 2048)
%4 = tail call i32 @snprintf(i8* %2, i32 2048, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %1)
%5 = tail call i32 @sflap_send(i8* %2, i32 -1, i32 2)
%6 = tail call i32 @free(i8* %2)
%7 = tail call i32 @free(i8* %1)
ret void
}