#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*/ memcpy(unsigned char *, unsigned char *, unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int);
unsigned int strlen(unsigned char *);
unsigned int write(int, unsigned char *, int);
void XFS_FrameInfo(unsigned char *HZdata, int fd) {
  unsigned char Frame_Info[50];
  unsigned int HZ_Length;
  unsigned int i = 0;
  HZ_Length = strlen(HZdata);
  Frame_Info[0] = 0xFD;
  Frame_Info[1] = 0x00;
  Frame_Info[2] = HZ_Length + 2;
  Frame_Info[3] = 0x01;
  Frame_Info[4] = 0x01;
  memcpy(&Frame_Info[5], HZdata, HZ_Length);
  i = write(fd, Frame_Info, 5 + HZ_Length);
  printf("send i: %d\n", i);
  return;
}


x86 assembly (clang, -O0):
<XFS_FrameInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x44(%rbp)
movb   $0xfd,-0x40(%rbp)
movb   $0x0,-0x3f(%rbp)
mov    -0x44(%rbp),%eax
add    $0x2,%eax
mov    %al,-0x3e(%rbp)
movb   $0x1,-0x3d(%rbp)
movb   $0x1,-0x3c(%rbp)
lea    -0x40(%rbp),%rdi
add    $0x5,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x44(%rbp),%edx
call   1060 <memcpy@plt>
mov    -0xc(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    -0x44(%rbp),%edx
add    $0x5,%edx
call   1030 <write@plt>
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%esi
lea    0xe52(%rip),%rdi
call   1050 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XFS_FrameInfo>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%ebp
movw   $0xfd,(%rsp)
lea    0x2(%rbp),%eax
mov    %al,0x2(%rsp)
movw   $0x101,0x3(%rsp)
lea    0x5(%rsp),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1060 <memcpy@plt>
add    $0x5,%ebp
mov    %rsp,%rsi
mov    %r14d,%edi
mov    %ebp,%edx
call   1030 <write@plt>
lea    0xe71(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"send i: %d\0A\00"
define void @XFS_FrameInfo(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [50 x i8]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %7
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %6
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
store i8 -3, i8* %10
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 1
store i8 0, i8* %11
%12 = load i32, i32* %6
%13 = add i32 %12, 2
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 2
store i8 %14, i8* %15
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 3
store i8 1, i8* %16
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 4
store i8 1, i8* %17
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 5
%19 = load i8*, i8** %3
%20 = load i32, i32* %6
%21 = call i32 @memcpy(i8* %18, i8* %19, i32 %20)
%22 = load i32, i32* %4
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%24 = load i32, i32* %6
%25 = add i32 5, %24
%26 = call i32 @write(i32 %22, i8* %23, i32 %25)
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %27)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"send i: %d\0A\00"
define void @XFS_FrameInfo(i8* %0, i32 %1) {
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* %0)
store i8 -3, i8* %4
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 1
store i8 0, i8* %6
%7 = trunc i32 %5 to i8
%8 = add i8 %7, 2
%9 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 2
store i8 %8, i8* %9
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 3
store i8 1, i8* %10
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 4
store i8 1, i8* %11
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 5
%13 = call i32 @memcpy(i8* %12, i8* %0, i32 %5)
%14 = add i32 %5, 5
%15 = call i32 @write(i32 %1, i8* %4, i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %15)
ret void
}