#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*/ buildpacket(unsigned char *, int *, int, unsigned char *,
                               int);
int /*<<< orphan*/ convint(unsigned char *, int);
int listen(int, unsigned char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ write(int, unsigned char *, int);
void sethoffset(int fd, int hoffset) {
  unsigned char pak[1024];
  unsigned char buf[1024];
  int len, res;
  unsigned char p[2];
  convint(p, hoffset);
  buildpacket(pak, &len, 0x0f, p, 2);
  write(fd, pak, len);
  res = listen(fd, buf);
  if (!(res == 1 && buf[0] == 0x06))
    printf("ACK not received.  Check connection.\n");
}


x86 assembly (clang, -O0):
<sethoffset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x81a(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1070 <convint@plt>
lea    -0x410(%rbp),%rdi
lea    -0x81a(%rbp),%rcx
lea    -0x814(%rbp),%rsi
mov    $0xf,%edx
mov    $0x2,%r8d
call   1050 <buildpacket@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    -0x814(%rbp),%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
lea    -0x810(%rbp),%rsi
call   1060 <listen@plt>
mov    %eax,-0x818(%rbp)
cmpl   $0x1,-0x818(%rbp)
jne    11dc <sethoffset+0x8c>
movzbl -0x810(%rbp),%eax
cmp    $0x6,%eax
je     11e8 <sethoffset+0x98>
lea    0xe1d(%rip),%rdi
call   1040 <printf@plt>
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sethoffset>:
push   %r15
push   %r14
push   %rbx
sub    $0x810,%rsp
mov    %edi,%ebx
lea    0xe(%rsp),%r14
mov    %r14,%rdi
call   1070 <convint@plt>
lea    0x410(%rsp),%r15
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
mov    $0xf,%edx
mov    %r14,%rcx
mov    $0x2,%r8d
call   1050 <buildpacket@plt>
mov    0x8(%rsp),%edx
mov    %ebx,%edi
mov    %r15,%rsi
call   1040 <write@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
call   1060 <listen@plt>
cmp    $0x1,%eax
jne    11b4 <sethoffset+0x64>
cmpb   $0x6,0x10(%rsp)
je     11c0 <sethoffset+0x70>
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
add    $0x810,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [38 x i8] c"ACK not received. Check connection.\0A\00"
define void @sethoffset(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca [2 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%11 = load i32, i32* %4
%12 = call i32 @convint(i8* %10, i32 %11)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%15 = call i32 @buildpacket(i8* %13, i32* %7, i32 15, i8* %14, i32 2)
%16 = load i32, i32* %3
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%18 = load i32, i32* %7
%19 = call i32 @write(i32 %16, i8* %17, i32 %18)
%20 = load i32, i32* %3
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%22 = call i32 @listen(i32 %20, i8* %21)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %30
25: ; preds = %2
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = icmp eq i32 %28, 6
br i1 %29, label %32, label %30
30: ; preds = %25, %2
%31 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %32
32: ; preds = %30, %25
ret void
}

LLVM IR (-O2):
@str = [37 x i8] c"ACK not received. Check connection.\00"
define void @sethoffset(i32 %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca i32
%6 = alloca [2 x i8]
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = bitcast i32* %5 to i8*
%10 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%11 = call i32 @convint(i8* %10, i32 %1)
%12 = call i32 @buildpacket(i8* %7, i32* %5, i32 15, i8* %10, i32 2)
%13 = load i32, i32* %5
%14 = call i32 @write(i32 %0, i8* %7, i32 %13)
%15 = call i32 @listen(i32 %0, i8* %8)
%16 = icmp eq i32 %15, 1
%17 = load i8, i8* %8
%18 = icmp eq i8 %17, 6
%19 = select i1 %16, i1 %18, i1 false
br i1 %19, label %22, label %20
20: ; preds = %2
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %22
22: ; preds = %2, %20
ret void
}