#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 ssize_t;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, char const *,
                            int /*<<< orphan*/, char const *);
int /*<<< orphan*/ strcmp(char const *, char *);
int /*<<< orphan*/ strlen(char const *);
int write_to_fd(int, char *);
ssize_t jasm_write(int sockfd, const char *__src, const char *data_type) {
  if (!__src || !strcmp(data_type, "data/nodata"))
    return -6;
  char final[4096];
  snprintf(final, 4096, "Data-Type: %s\nData-Size: %ld\n\n%s", data_type,
           strlen(__src), __src);
  return write_to_fd(sockfd, final);
}


x86 assembly (clang, -O0):
<jasm_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117a <jasm_write+0x3a>
mov    -0x18(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1186 <jasm_write+0x46>
movl   $0xfffffffa,-0x4(%rbp)
jmp    11e0 <jasm_write+0xa0>
lea    -0x1020(%rbp),%rax
mov    %rax,-0x1030(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x1028(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1030(%rbp),%rdi
mov    -0x1028(%rbp),%rcx
mov    %eax,%r8d
mov    -0x10(%rbp),%r9
mov    $0x1000,%esi
lea    0xe43(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%edi
lea    -0x1020(%rbp),%rsi
call   1060 <write_to_fd@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jasm_write>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1008,%rsp
mov    $0xfffffffa,%ebp
test   %rsi,%rsi
je     11a8 <jasm_write+0x68>
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %edi,%r14d
lea    0xe99(%rip),%rsi
mov    %rdx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11a8 <jasm_write+0x68>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xe8a(%rip),%rdx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x1000,%esi
mov    %r15,%rcx
mov    %eax,%r8d
mov    %rbx,%r9
call   1040 <snprintf@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
call   1060 <write_to_fd@plt>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"data/nodata\00"
@.str.1 = [33 x i8] c"Data-Type: %s\0AData-Size: %ld\0A\0A%s\00"
define i32 @jasm_write(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [4096 x i8]
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = load i8*, i8** %7
%13 = call i32 @strcmp(i8* %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %11, %3
store i32 -6, i32* %4
br label %26
16: ; preds = %11
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%18 = load i8*, i8** %7
%19 = load i8*, i8** %6
%20 = call i32 @strlen(i8* %19)
%21 = load i8*, i8** %6
%22 = call i32 @snprintf(i8* %17, i32 4096, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32 %20, i8* %21)
%23 = load i32, i32* %5
%24 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%25 = call i32 @write_to_fd(i32 %23, i8* %24)
store i32 %25, i32* %4
br label %26
26: ; preds = %16, %15
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@.str = [12 x i8] c"data/nodata\00"
@.str.1 = [33 x i8] c"Data-Type: %s\0AData-Size: %ld\0A\0A%s\00"
define i32 @jasm_write(i32 %0, i8* %1, i8* %2) {
%4 = alloca [4096 x i8]
%5 = icmp eq i8* %1, null
br i1 %5, label %14, label %6
6: ; preds = %3
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %2, i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %6
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%11 = tail call i32 @strlen(i8* %1)
%12 = call i32 @snprintf(i8* %10, i32 4096, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32 %11, i8* %1)
%13 = call i32 @write_to_fd(i32 %0, i8* %10)
br label %14
14: ; preds = %3, %6, %9
%15 = phi i32 [ %13, %9 ], [ -6, %6 ], [ -6, %3 ]
ret i32 %15
}