#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*/ printf(char *, int);
int self();
int /*<<< orphan*/ send(int, void *, scalar_t__);
scalar_t__ strlen(char *);
int /*<<< orphan*/ usleep(int);
void fun1() {
  char *str = "Hello, world!";
  printf("process %d start\n", self());
  while (1) {
    usleep(1000);
    printf("process %d execution\n", self());
    send(1, (void *)str, strlen(str) + 1);
  }
}


x86 assembly (clang, -O0):
<fun1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <self@plt>
mov    %eax,%esi
lea    0xe9b(%rip),%rdi
call   1050 <printf@plt>
mov    $0x3e8,%edi
call   1070 <usleep@plt>
mov    $0x0,%al
call   1060 <self@plt>
mov    %eax,%esi
lea    0xe8e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x18(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    $0x1,%edi
call   1040 <send@plt>
jmp    1178 <fun1+0x28>

x86 assembly (clang, -O2):
<fun1>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <self@plt>
lea    0xebc(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    0xec0(%rip),%r14
lea    0xe99(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    $0x3e8,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1050 <self@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0xe,%edx
mov    $0x1,%edi
mov    %rbx,%rsi
call   1030 <send@plt>
jmp    1170 <fun1+0x30>

LLVM IR (-O0):
@.str = [14 x i8] c"Hello, world!\00"
@.str.1 = [18 x i8] c"process %d start\0A\00"
@.str.2 = [22 x i8] c"process %d execution\0A\00"
define void @fun1() {
%1 = alloca i8*
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %1
%2 = call i32 (...) @self()
%3 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %2)
br label %4
4: ; preds = %0, %4
%5 = call i32 @usleep(i32 1000)
%6 = call i32 (...) @self()
%7 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = load i8*, i8** %1
%9 = load i8*, i8** %1
%10 = call i64 @strlen(i8* %9)
%11 = add nsw i64 %10, 1
%12 = call i32 @send(i32 1, i8* %8, i64 %11)
br label %4
}

LLVM IR (-O2):
@.str = [14 x i8] c"Hello, world!\00"
@.str.1 = [18 x i8] c"process %d start\0A\00"
@.str.2 = [22 x i8] c"process %d execution\0A\00"
define void @fun1() {
%1 = tail call i32 (...) @self()
%2 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %3
3: ; preds = %3, %0
%4 = tail call i32 @usleep(i32 1000)
%5 = tail call i32 (...) @self()
%6 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = tail call i32 @send(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 14)
br label %3
}