#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*/ sendCustom(int, int, char *);
int /*<<< orphan*/ sprintf(char *, char *, short);
void sendBlink(int sockfd, short ledIndex, short timeOn, short period) {
  char payload[7];
  sprintf(payload, "%02x", ledIndex);
  sprintf(payload + 2, "%02x", timeOn);
  sprintf(payload + 4, "%02x", period);
  sendCustom(sockfd, 0x02, payload);
}


x86 assembly (clang, -O0):
<sendBlink>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cx,%ax
mov    %dx,%cx
mov    %si,%dx
mov    %edi,-0x4(%rbp)
mov    %dx,-0x6(%rbp)
mov    %cx,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
lea    -0x11(%rbp),%rdi
lea    0xeb5(%rip),%rsi
movswl -0x6(%rbp),%edx
call   1040 <sprintf@plt>
lea    -0x11(%rbp),%rdi
add    $0x2,%rdi
lea    0xe9d(%rip),%rsi
movswl -0x8(%rbp),%edx
call   1040 <sprintf@plt>
lea    -0x11(%rbp),%rdi
add    $0x4,%rdi
lea    0xe85(%rip),%rsi
movswl -0xa(%rbp),%edx
call   1040 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x11(%rbp),%rdx
mov    $0x2,%esi
call   1030 <sendCustom@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendBlink>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %esi,%edx
mov    %edi,%r14d
lea    0xec3(%rip),%rbx
lea    0x9(%rsp),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <sprintf@plt>
lea    0xb(%rsp),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <sprintf@plt>
lea    0xd(%rsp),%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1040 <sprintf@plt>
mov    %r14d,%edi
mov    $0x2,%esi
mov    %r12,%rdx
call   1030 <sendCustom@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%02x\00"
define void @sendBlink(i32 %0, i16 signext %1, i16 signext %2, i16 signext %3) {
%5 = alloca i32
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
%9 = alloca [7 x i8]
store i32 %0, i32* %5
store i16 %1, i16* %6
store i16 %2, i16* %7
store i16 %3, i16* %8
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %9, i64 0, i64 0
%11 = load i16, i16* %6
%12 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 signext %11)
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %9, i64 0, i64 0
%14 = getelementptr inbounds i8, i8* %13, i64 2
%15 = load i16, i16* %7
%16 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 signext %15)
%17 = getelementptr inbounds [7 x i8], [7 x i8]* %9, i64 0, i64 0
%18 = getelementptr inbounds i8, i8* %17, i64 4
%19 = load i16, i16* %8
%20 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 signext %19)
%21 = load i32, i32* %5
%22 = getelementptr inbounds [7 x i8], [7 x i8]* %9, i64 0, i64 0
%23 = call i32 @sendCustom(i32 %21, i32 2, i8* %22)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02x\00"
define void @sendBlink(i32 %0, i16 signext %1, i16 signext %2, i16 signext %3) {
%5 = alloca [7 x i8]
%6 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 signext %1)
%8 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 2
%9 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 signext %2)
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 4
%11 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 signext %3)
%12 = call i32 @sendCustom(i32 %0, i32 2, i8* %6)
ret void
}