#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 serial_write(int, char *, int);
int send_header(int fd, int Inum, int Onum) {
  short num[2] = {(short)Inum, (short)Onum};
  char soh = 0x01;
  if (serial_write(fd, &soh, 1) < 1)
    return -1;
  if (serial_write(fd, (char *)num, 4) < 4)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<send_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %ax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %ax,-0x12(%rbp)
movb   $0x1,-0x15(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x15(%rbp),%rsi
mov    $0x1,%edx
call   1030 <serial_write@plt>
cmp    $0x1,%eax
jge    1159 <send_header+0x49>
movl   $0xffffffff,-0x4(%rbp)
jmp    1186 <send_header+0x76>
mov    -0x8(%rbp),%edi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
call   1030 <serial_write@plt>
cmp    $0x4,%eax
jge    117f <send_header+0x6f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1186 <send_header+0x76>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_header>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    %si,0xc(%rsp)
mov    %dx,0xe(%rsp)
movb   $0x1,0xb(%rsp)
lea    0xb(%rsp),%rsi
mov    $0x1,%edx
call   1030 <serial_write@plt>
test   %eax,%eax
jle    1158 <send_header+0x48>
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1030 <serial_write@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x4,%ecx
setl   %al
neg    %eax
jmp    115d <send_header+0x4d>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @send_header(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [2 x i16]
%9 = alloca i8
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%10 = getelementptr inbounds [2 x i16], [2 x i16]* %8, i64 0, i64 0
%11 = load i32, i32* %6
%12 = trunc i32 %11 to i16
store i16 %12, i16* %10
%13 = getelementptr inbounds i16, i16* %10, i64 1
%14 = load i32, i32* %7
%15 = trunc i32 %14 to i16
store i16 %15, i16* %13
store i8 1, i8* %9
%16 = load i32, i32* %5
%17 = call i32 @serial_write(i32 %16, i8* %9, i32 1)
%18 = icmp slt i32 %17, 1
br i1 %18, label %19, label %20
19: ; preds = %3
store i32 -1, i32* %4
br label %28
20: ; preds = %3
%21 = load i32, i32* %5
%22 = getelementptr inbounds [2 x i16], [2 x i16]* %8, i64 0, i64 0
%23 = bitcast i16* %22 to i8*
%24 = call i32 @serial_write(i32 %21, i8* %23, i32 4)
%25 = icmp slt i32 %24, 4
br i1 %25, label %26, label %27
26: ; preds = %20
store i32 -1, i32* %4
br label %28
27: ; preds = %20
store i32 0, i32* %4
br label %28
28: ; preds = %27, %26, %19
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
define i32 @send_header(i32 %0, i32 %1, i32 %2) {
%4 = alloca [2 x i16]
%5 = alloca i8
%6 = bitcast [2 x i16]* %4 to i8*
%7 = getelementptr inbounds [2 x i16], [2 x i16]* %4, i64 0, i64 0
%8 = trunc i32 %1 to i16
store i16 %8, i16* %7
%9 = getelementptr inbounds [2 x i16], [2 x i16]* %4, i64 0, i64 1
%10 = trunc i32 %2 to i16
store i16 %10, i16* %9
store i8 1, i8* %5
%11 = call i32 @serial_write(i32 %0, i8* %5, i32 1)
%12 = icmp slt i32 %11, 1
br i1 %12, label %17, label %13
13: ; preds = %3
%14 = call i32 @serial_write(i32 %0, i8* %6, i32 4)
%15 = icmp slt i32 %14, 4
%16 = sext i1 %15 to i32
br label %17
17: ; preds = %13, %3
%18 = phi i32 [ -1, %3 ], [ %16, %13 ]
ret i32 %18
}