#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);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ usleep(int);
int write(int, char *, int /*<<< orphan*/);
void *sendThread(void *parameters) {
  char sendBuff[256];
  memset(&sendBuff[0], 0, 256);
  snprintf(&sendBuff[0], 256, "hello!");
  int fd;
  int len;
  fd = *((int *)parameters);
  while (1) {
    len = write(fd, &sendBuff[0], strlen(&sendBuff[0]));
    printf("sent:%d!\n", len);
    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>
mov    %eax,-0x118(%rbp)
mov    -0x118(%rbp),%esi
lea    0xe14(%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   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0xf4240,%edi
call   1080 <usleep@plt>
jmp    11a0 <sendThread+0x40>

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

LLVM IR (-O2):
@.str = [7 x i8] c"hello!\00"
@.str.1 = [10 x i8] c"sent:%d!\0A\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 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = call i32 @usleep(i32 1000000)
br label %8
}