#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
void *sendThread(void *parameters) {
  char sendBuff[256];
  memset(&sendBuff[0], 0, 256);
  snprintf(&sendBuff[0], 256, "hello!");
  int fd;
  fd = *((int *)parameters);
  while (1) {
    write(fd, &sendBuff[0], strlen(&sendBuff[0]));
    printf("sent!\n");
    usleep(1000000);
  }
  pthread_exit(0);
}


x86 assembly (clang, -O0):
<sendThread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
lea    -0x110(%rbp),%rdi
mov    $0x100,%esi
lea    0xe6b(%rip),%rdx
call   1060 <snprintf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x114(%rbp)
mov    -0x114(%rbp),%eax
mov    %eax,-0x124(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x120(%rbp)
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x124(%rbp),%edi
mov    -0x120(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xe20(%rip),%rdi
call   1050 <printf@plt>
mov    $0xf4240,%edi
call   1080 <usleep@plt>
jmp    11a6 <sendThread+0x46>

x86 assembly (clang, -O2):
<sendThread>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%rbp
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
lea    0xe79(%rip),%rdx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1060 <snprintf@plt>
mov    0x0(%rbp),%ebp
lea    0xe69(%rip),%r14
xchg   %ax,%ax
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0xf4240,%edi
call   1080 <usleep@plt>
jmp    11a0 <sendThread+0x40>

LLVM IR (-O0):
@.str = [7 x i8] c"hello!\00"
@.str.1 = [7 x i8] c"sent!\0A\00"
define i8* @sendThread(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca i32
store i8* %0, i8** %2
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 256)
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = call i32 @snprintf(i8* %7, i32 256, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = load i8*, i8** %2
%10 = bitcast i8* %9 to i32*
%11 = load i32, i32* %10
store i32 %11, i32* %4
br label %12
12: ; preds = %1, %12
%13 = load i32, i32* %4
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = call i32 @write(i32 %13, i8* %14, i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @usleep(i32 1000000)
br label %12
}

LLVM IR (-O2):
@.str = [7 x i8] c"hello!\00"
@str = [6 x i8] c"sent!\00"
define noalias i8* @sendThread(i8* nocapture %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 256)
%5 = call i32 @snprintf(i8* %3, i32 256, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = bitcast i8* %0 to i32*
%7 = load i32, i32* %6
br label %8
8: ; preds = %8, %1
%9 = call i32 @strlen(i8* %3)
%10 = call i32 @write(i32 %7, i8* %3, i32 %9)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%12 = call i32 @usleep(i32 1000000)
br label %8
}