#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 int8_t;

/* Variables and functions */
int read(int, int *, int);
int /*<<< orphan*/ usleep(int);
void do_write(int fd) {
  uint8_t *ptr;
  int8_t buf[100] = {0};
  int status, i, j;
  buf[0] = 1;
  buf[1] = 2;
  buf[2] = 3;
  buf[3] = 4;
  buf[4] = 5;
  buf[5] = 6;
  buf[6] = 7;
  buf[7] = 8;
  buf[8] = 9;
  buf[9] = 0;
  buf[98] = 9;
  buf[99] = 9;
  while (1) {
    status = read(fd, buf, 5);
    usleep(10);
  }
}


x86 assembly (clang, -O0):
<do_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1030 <memset@plt>
movl   $0x1,-0x1a0(%rbp)
movl   $0x2,-0x19c(%rbp)
movl   $0x3,-0x198(%rbp)
movl   $0x4,-0x194(%rbp)
movl   $0x5,-0x190(%rbp)
movl   $0x6,-0x18c(%rbp)
movl   $0x7,-0x188(%rbp)
movl   $0x8,-0x184(%rbp)
movl   $0x9,-0x180(%rbp)
movl   $0x0,-0x17c(%rbp)
movl   $0x9,-0x18(%rbp)
movl   $0x9,-0x14(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x1a0(%rbp),%rsi
mov    $0x5,%edx
call   1040 <read@plt>
mov    %eax,-0x1a4(%rbp)
mov    $0xa,%edi
call   1050 <usleep@plt>
jmp    11c3 <do_write+0x93>

x86 assembly (clang, -O2):
<do_write>:
push   %r14
push   %rbx
sub    $0x198,%rsp
mov    %edi,%ebx
lea    0x20(%rsp),%rdi
mov    $0x170,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movaps 0xeac(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x9,0x20(%rsp)
movabs $0x900000009,%rax
mov    %rax,0x188(%rsp)
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x5,%edx
call   1040 <read@plt>
mov    $0xa,%edi
call   1050 <usleep@plt>
jmp    1190 <do_write+0x60>

LLVM IR (-O0):
define void @do_write(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [100 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %2
%8 = bitcast [100 x i32]* %4 to i8*
%9 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
store i32 1, i32* %9
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 1
store i32 2, i32* %10
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 2
store i32 3, i32* %11
%12 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 3
store i32 4, i32* %12
%13 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 4
store i32 5, i32* %13
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 5
store i32 6, i32* %14
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 6
store i32 7, i32* %15
%16 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 7
store i32 8, i32* %16
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 8
store i32 9, i32* %17
%18 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 9
store i32 0, i32* %18
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 98
store i32 9, i32* %19
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 99
store i32 9, i32* %20
br label %21
21: ; preds = %1, %21
%22 = load i32, i32* %2
%23 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%24 = call i32 @read(i32 %22, i32* %23, i32 5)
store i32 %24, i32* %5
%25 = call i32 @usleep(i32 10)
br label %21
}

LLVM IR (-O2):
define void @do_write(i32 %0) {
%2 = alloca [100 x i32]
%3 = bitcast [100 x i32]* %2 to i8*
%4 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 8
%5 = bitcast i32* %4 to i8*
%6 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%7 = bitcast [100 x i32]* %2 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %7
%8 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 4
%9 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> <i32 5, i32 6, i32 7, i32 8>, <4 x i32>* %9
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 8
store i32 9, i32* %10
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 98
store i32 9, i32* %11
%12 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 99
store i32 9, i32* %12
br label %13
13: ; preds = %13, %1
%14 = call i32 @read(i32 %0, i32* %6, i32 5)
%15 = tail call i32 @usleep(i32 10)
br label %13
}