#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int uint32_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ write(int, char *, int);
void do_ack(int fd) {
  int i;
  char tx = 0xa1;
  uint8_t buf[2000] = {0};
  uint32_t size = sizeof(buf);
  while (1) {
    write(fd, &tx, 1);
    for (i = 0; i < 10000; i++)
      ;
    write(fd, &tx, 1);
    for (i = 0; i < 1000; i++)
      ;
    write(fd, &tx, 1);
  }
}


x86 assembly (clang, -O0):
<do_ack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f60,%rsp
mov    %edi,-0x4(%rbp)
movb   $0xa1,-0x9(%rbp)
lea    -0x1f50(%rbp),%rdi
xor    %esi,%esi
mov    $0x1f40,%edx
call   1040 <memset@plt>
movl   $0x1f40,-0x1f54(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x9(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x2710,-0x8(%rbp)
jge    1187 <do_ack+0x67>
jmp    1179 <do_ack+0x59>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1167 <do_ack+0x47>
mov    -0x4(%rbp),%edi
lea    -0x9(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jge    11bf <do_ack+0x9f>
jmp    11b1 <do_ack+0x91>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119f <do_ack+0x7f>
mov    -0x4(%rbp),%edi
lea    -0x9(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
jmp    114f <do_ack+0x2f>

x86 assembly (clang, -O2):
<do_ack>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
movb   $0xa1,0x7(%rsp)
lea    0x7(%rsp),%r14
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
jmp    1120 <do_ack+0x10>

LLVM IR (-O0):
define void @do_ack(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca [2000 x i32]
%6 = alloca i32
store i32 %0, i32* %2
store i8 -95, i8* %4
%7 = bitcast [2000 x i32]* %5 to i8*
store i32 8000, i32* %6
br label %8
8: ; preds = %1, %28
%9 = load i32, i32* %2
%10 = call i32 @write(i32 %9, i8* %4, i32 1)
store i32 0, i32* %3
br label %11
11: ; preds = %15, %8
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 10000
br i1 %13, label %14, label %18
14: ; preds = %11
br label %15
15: ; preds = %14
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %11
18: ; preds = %11
%19 = load i32, i32* %2
%20 = call i32 @write(i32 %19, i8* %4, i32 1)
store i32 0, i32* %3
br label %21
21: ; preds = %25, %18
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 1000
br i1 %23, label %24, label %28
24: ; preds = %21
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %21
28: ; preds = %21
%29 = load i32, i32* %2
%30 = call i32 @write(i32 %29, i8* %4, i32 1)
br label %8
}

LLVM IR (-O2):
define void @do_ack(i32 %0) {
%2 = alloca i8
store i8 -95, i8* %2
br label %3
3: ; preds = %3, %1
%4 = call i32 @write(i32 %0, i8* %2, i32 1)
%5 = call i32 @write(i32 %0, i8* %2, i32 1)
%6 = call i32 @write(i32 %0, i8* %2, i32 1)
br label %3
}