#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 */
struct timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ SYS_brk;
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(void *, char const *, size_t);
int /*<<< orphan*/ myfun();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
size_t strlen(char const *);
scalar_t__ syscall(int /*<<< orphan*/, intptr_t);
int main() {
  intptr_t here0 = 0;
  intptr_t here1 = 0;
  const char *str = "Hello World!";
  size_t len = strlen(str);
  here0 = (intptr_t)syscall(SYS_brk, 0);
  here1 = (intptr_t)syscall(SYS_brk, here0 + len + 1);
  printf("Starting dummy 0x"
         "%x"
         " 0x"
         "%x"
         "\n",
         here0, here1);
  memcpy((void *)here0, str, len + 1);
  printf("String: %s\n", (const char *)here0);
  syscall(SYS_brk, here0);
  while (1) {
    struct timeval tv = {0};
    sleep(2);
    gettimeofday(&tv, NULL);
    printf("Working "
           "%u"
           "."
           "%u"
           "\n",
           (size_t)tv.tv_sec, (size_t)tv.tv_usec);
    myfun();
  }
  printf("Stopping dummy\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe5a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <syscall@plt>
mov    %rax,-0x10(%rbp)
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
add    -0x28(%rbp),%rsi
add    $0x1,%rsi
call   1080 <syscall@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
add    $0x1,%rdx
call   1090 <memcpy@plt>
mov    -0x10(%rbp),%rsi
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
call   1080 <syscall@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <myfun@plt>
jmp    123a <main+0xba>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2e7a(%rip),%r14
mov    (%r14),%edi
xor    %esi,%esi
call   1060 <syscall@plt>
mov    %rax,%rbx
mov    (%r14),%edi
lea    0xd(%rax),%rsi
call   1060 <syscall@plt>
lea    0xe8f(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe6e(%rip),%rsi
mov    $0xd,%edx
mov    %rbx,%rdi
call   1070 <memcpy@plt>
lea    0xe81(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%edi
mov    %rbx,%rsi
call   1060 <syscall@plt>
mov    %rsp,%r14
lea    0xe6e(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
mov    $0x2,%edi
call   1080 <sleep@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    (%rsp),%rdx
mov    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <myfun@plt>
jmp    11e0 <main+0x80>

LLVM IR (-O0):
%struct.timeval = type { i64, i64, i32 }
@.str = [13 x i8] c"Hello World!\00"
@SYS_brk = global i32 0
@.str.1 = [26 x i8] c"Starting dummy 0x%x 0x%x\0A\00"
@.str.2 = [12 x i8] c"String: %s\0A\00"
@.str.3 = [15 x i8] c"Working %u.%u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = alloca %struct.timeval
store i32 0, i32* %1
store i64 0, i64* %2
store i64 0, i64* %3
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %4
%7 = load i8*, i8** %4
%8 = call i64 @strlen(i8* %7)
store i64 %8, i64* %5
%9 = load i32, i32* @SYS_brk
%10 = call i64 @syscall(i32 %9, i64 0)
store i64 %10, i64* %2
%11 = load i32, i32* @SYS_brk
%12 = load i64, i64* %2
%13 = load i64, i64* %5
%14 = add i64 %12, %13
%15 = add i64 %14, 1
%16 = call i64 @syscall(i32 %11, i64 %15)
store i64 %16, i64* %3
%17 = load i64, i64* %2
%18 = load i64, i64* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 %17, i64 %18)
%20 = load i64, i64* %2
%21 = inttoptr i64 %20 to i8*
%22 = load i8*, i8** %4
%23 = load i64, i64* %5
%24 = add i64 %23, 1
%25 = call i32 @memcpy(i8* %21, i8* %22, i64 %24)
%26 = load i64, i64* %2
%27 = inttoptr i64 %26 to i8*
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = load i32, i32* @SYS_brk
%30 = load i64, i64* %2
%31 = call i64 @syscall(i32 %29, i64 %30)
br label %32
32: ; preds = %0, %32
%33 = bitcast %struct.timeval* %6 to i8*
%34 = call i32 @sleep(i32 2)
%35 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%36 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%37 = load i64, i64* %36
%38 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%39 = load i64, i64* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i64 %37, i64 %39)
%41 = call i32 (...) @myfun()
br label %32
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64, i32 }
@.str = [13 x i8] c"Hello World!\00"
@SYS_brk = global i32 0
@.str.1 = [26 x i8] c"Starting dummy 0x%x 0x%x\0A\00"
@.str.2 = [12 x i8] c"String: %s\0A\00"
@.str.3 = [15 x i8] c"Working %u.%u\0A\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = load i32, i32* @SYS_brk
%3 = tail call i64 @syscall(i32 %2, i64 0)
%4 = load i32, i32* @SYS_brk
%5 = add i64 %3, 13
%6 = tail call i64 @syscall(i32 %4, i64 %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 %3, i64 %6)
%8 = inttoptr i64 %3 to i8*
%9 = tail call i32 @memcpy(i8* %8, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 13)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%11 = load i32, i32* @SYS_brk
%12 = tail call i64 @syscall(i32 %11, i64 %3)
%13 = bitcast %struct.timeval* %1 to i8*
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
br label %16
16: ; preds = %16, %0
%17 = tail call i32 @sleep(i32 2)
%18 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%19 = load i64, i64* %14
%20 = load i64, i64* %15
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i64 %19, i64 %20)
%22 = tail call i32 (...) @myfun()
br label %16
}