#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*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
scalar_t__ send_report(int, unsigned char *, int);
void send_msg(int fd, char c0, char c1, char c2, char c3, char c4, char c5) {
  unsigned char b[6];
  b[0] = c0;
  b[1] = c1;
  b[2] = c2;
  b[3] = c3;
  b[4] = c4;
  b[5] = c5;
  if (send_report(fd, b, 6) < 0) {
    perror("error sending to device");
    close(fd);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<send_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %r8d,-0x20(%rbp)
mov    %ecx,%eax
mov    -0x20(%rbp),%ecx
mov    %eax,-0x1c(%rbp)
mov    %edx,%eax
mov    -0x1c(%rbp),%edx
mov    %eax,-0x18(%rbp)
mov    %esi,%eax
mov    -0x18(%rbp),%esi
mov    %eax,-0x14(%rbp)
mov    %edi,%r8d
mov    -0x14(%rbp),%edi
mov    %r9b,%al
mov    0x10(%rbp),%r9b
mov    %r8d,-0x4(%rbp)
mov    %dil,-0x5(%rbp)
mov    %sil,-0x6(%rbp)
mov    %dl,-0x7(%rbp)
mov    %cl,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x5(%rbp),%al
mov    %al,-0xf(%rbp)
mov    -0x6(%rbp),%al
mov    %al,-0xe(%rbp)
mov    -0x7(%rbp),%al
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%al
mov    %al,-0xc(%rbp)
mov    -0x9(%rbp),%al
mov    %al,-0xb(%rbp)
mov    0x10(%rbp),%al
mov    %al,-0xa(%rbp)
mov    -0x4(%rbp),%edi
lea    -0xf(%rbp),%rsi
mov    $0x6,%edx
call   1060 <send_report@plt>
cmp    $0x0,%rax
jge    11e3 <send_msg+0xa3>
lea    0xe34(%rip),%rdi
call   1040 <perror@plt>
mov    -0x4(%rbp),%edi
call   1030 <close@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_msg>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    0x20(%rsp),%al
mov    %sil,0xa(%rsp)
mov    %dl,0xb(%rsp)
mov    %cl,0xc(%rsp)
mov    %r8b,0xd(%rsp)
mov    %r9b,0xe(%rsp)
mov    %al,0xf(%rsp)
lea    0xa(%rsp),%rsi
mov    $0x6,%edx
call   1060 <send_report@plt>
test   %rax,%rax
js     1180 <send_msg+0x40>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe79(%rip),%rdi
call   1040 <perror@plt>
mov    %ebx,%edi
call   1030 <close@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"error sending to device\00"
define void @send_msg(i32 %0, i8 signext %1, i8 signext %2, i8 signext %3, i8 signext %4, i8 signext %5, i8 signext %6) {
%8 = alloca i32
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca i8
%13 = alloca i8
%14 = alloca i8
%15 = alloca [6 x i8]
store i32 %0, i32* %8
store i8 %1, i8* %9
store i8 %2, i8* %10
store i8 %3, i8* %11
store i8 %4, i8* %12
store i8 %5, i8* %13
store i8 %6, i8* %14
%16 = load i8, i8* %9
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %15, i64 0, i64 0
store i8 %16, i8* %17
%18 = load i8, i8* %10
%19 = getelementptr inbounds [6 x i8], [6 x i8]* %15, i64 0, i64 1
store i8 %18, i8* %19
%20 = load i8, i8* %11
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %15, i64 0, i64 2
store i8 %20, i8* %21
%22 = load i8, i8* %12
%23 = getelementptr inbounds [6 x i8], [6 x i8]* %15, i64 0, i64 3
store i8 %22, i8* %23
%24 = load i8, i8* %13
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %15, i64 0, i64 4
store i8 %24, i8* %25
%26 = load i8, i8* %14
%27 = getelementptr inbounds [6 x i8], [6 x i8]* %15, i64 0, i64 5
store i8 %26, i8* %27
%28 = load i32, i32* %8
%29 = getelementptr inbounds [6 x i8], [6 x i8]* %15, i64 0, i64 0
%30 = call i64 @send_report(i32 %28, i8* %29, i32 6)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %7
%33 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%34 = load i32, i32* %8
%35 = call i32 @close(i32 %34)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"error sending to device\00"
define void @send_msg(i32 %0, i8 signext %1, i8 signext %2, i8 signext %3, i8 signext %4, i8 signext %5, i8 signext %6) {
%8 = alloca [6 x i8]
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
store i8 %1, i8* %9
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 1
store i8 %2, i8* %10
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 2
store i8 %3, i8* %11
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 3
store i8 %4, i8* %12
%13 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 4
store i8 %5, i8* %13
%14 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 5
store i8 %6, i8* %14
%15 = call i64 @send_report(i32 %0, i8* %9, i32 6)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %7
%18 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @close(i32 %0)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %7
ret void
}