#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 itimerval {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ free(char *);
void *malloc(int);
int /*<<< orphan*/ mygetitimer(int /*<<< orphan*/, struct itimerval *);
int /*<<< orphan*/ myopen(char *, int);
int /*<<< orphan*/ mywrite(char *, int);
int main(void) {
  char *buf = malloc(sizeof(char) * 6), *buf2 = malloc(sizeof(char) * 6);
  struct itimerval *itval = malloc(sizeof(struct itimerval) - 1);
  int diff = buf2 - buf;
  buf[0] = 'h';
  buf[1] = 'e';
  buf[2] = 'l';
  buf[3] = 'l';
  buf[4] = 'o';
  buf[5] = 'x';
  mywrite(buf + 3, 5);
  mywrite(buf - 1, 5);
  mywrite(buf + 1, diff);
  myopen(buf + 3, 0x0);
  mygetitimer(0, itval);
  free(buf);
  mywrite(buf, 5);
  mywrite(buf + 3, 5);
  mywrite(buf + 1, diff);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x6,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x6,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x68,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x65,0x1(%rax)
mov    -0x10(%rbp),%rax
movb   $0x6c,0x2(%rax)
mov    -0x10(%rbp),%rax
movb   $0x6c,0x3(%rax)
mov    -0x10(%rbp),%rax
movb   $0x6f,0x4(%rax)
mov    -0x10(%rbp),%rax
movb   $0x78,0x5(%rax)
mov    -0x10(%rbp),%rdi
add    $0x3,%rdi
mov    $0x5,%esi
call   1040 <mywrite@plt>
mov    -0x10(%rbp),%rdi
add    $0xffffffffffffffff,%rdi
mov    $0x5,%esi
call   1040 <mywrite@plt>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x24(%rbp),%esi
call   1040 <mywrite@plt>
mov    -0x10(%rbp),%rdi
add    $0x3,%rdi
xor    %esi,%esi
call   1050 <myopen@plt>
mov    -0x20(%rbp),%rsi
xor    %edi,%edi
call   1060 <mygetitimer@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
mov    $0x5,%esi
call   1040 <mywrite@plt>
mov    -0x10(%rbp),%rdi
add    $0x3,%rdi
mov    $0x5,%esi
call   1040 <mywrite@plt>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x24(%rbp),%esi
call   1040 <mywrite@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0x6,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    $0x6,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
sub    %ebx,%r14d
movl   $0x6c6c6568,(%rbx)
lea    0x1(%rbx),%r15
lea    0x3(%rbx),%r12
movw   $0x786f,0x4(%rbx)
mov    %r12,%rdi
mov    $0x5,%esi
call   1040 <mywrite@plt>
lea    -0x1(%rbx),%rdi
mov    $0x5,%esi
call   1040 <mywrite@plt>
mov    %r15,%rdi
mov    %r14d,%esi
call   1040 <mywrite@plt>
mov    %r12,%rdi
xor    %esi,%esi
call   1050 <myopen@plt>
xor    %edi,%edi
mov    %r13,%rsi
call   1060 <mygetitimer@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <mywrite@plt>
mov    %r12,%rdi
mov    $0x5,%esi
call   1040 <mywrite@plt>
mov    %r15,%rdi
mov    %r14d,%esi
call   1040 <mywrite@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.itimerval = type { i32 }
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca %struct.itimerval*
%5 = alloca i32
store i32 0, i32* %1
%6 = call i8* @malloc(i32 6)
store i8* %6, i8** %2
%7 = call i8* @malloc(i32 6)
store i8* %7, i8** %3
%8 = call i8* @malloc(i32 3)
%9 = bitcast i8* %8 to %struct.itimerval*
store %struct.itimerval* %9, %struct.itimerval** %4
%10 = load i8*, i8** %3
%11 = load i8*, i8** %2
%12 = ptrtoint i8* %10 to i64
%13 = ptrtoint i8* %11 to i64
%14 = sub i64 %12, %13
%15 = trunc i64 %14 to i32
store i32 %15, i32* %5
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 0
store i8 104, i8* %17
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i64 1
store i8 101, i8* %19
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i64 2
store i8 108, i8* %21
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 3
store i8 108, i8* %23
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i64 4
store i8 111, i8* %25
%26 = load i8*, i8** %2
%27 = getelementptr inbounds i8, i8* %26, i64 5
store i8 120, i8* %27
%28 = load i8*, i8** %2
%29 = getelementptr inbounds i8, i8* %28, i64 3
%30 = call i32 @mywrite(i8* %29, i32 5)
%31 = load i8*, i8** %2
%32 = getelementptr inbounds i8, i8* %31, i64 -1
%33 = call i32 @mywrite(i8* %32, i32 5)
%34 = load i8*, i8** %2
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = load i32, i32* %5
%37 = call i32 @mywrite(i8* %35, i32 %36)
%38 = load i8*, i8** %2
%39 = getelementptr inbounds i8, i8* %38, i64 3
%40 = call i32 @myopen(i8* %39, i32 0)
%41 = load %struct.itimerval*, %struct.itimerval** %4
%42 = call i32 @mygetitimer(i32 0, %struct.itimerval* %41)
%43 = load i8*, i8** %2
%44 = call i32 @free(i8* %43)
%45 = load i8*, i8** %2
%46 = call i32 @mywrite(i8* %45, i32 5)
%47 = load i8*, i8** %2
%48 = getelementptr inbounds i8, i8* %47, i64 3
%49 = call i32 @mywrite(i8* %48, i32 5)
%50 = load i8*, i8** %2
%51 = getelementptr inbounds i8, i8* %50, i64 1
%52 = load i32, i32* %5
%53 = call i32 @mywrite(i8* %51, i32 %52)
ret i32 0
}

LLVM IR (-O2):
%struct.itimerval = type { i32 }
define i32 @main() {
%1 = tail call dereferenceable_or_null(6) i8* @malloc(i32 6)
%2 = tail call dereferenceable_or_null(6) i8* @malloc(i32 6)
%3 = tail call dereferenceable_or_null(3) i8* @malloc(i32 3)
%4 = bitcast i8* %3 to %struct.itimerval*
%5 = ptrtoint i8* %2 to i64
%6 = ptrtoint i8* %1 to i64
%7 = sub i64 %5, %6
%8 = trunc i64 %7 to i32
store i8 104, i8* %1
%9 = getelementptr inbounds i8, i8* %1, i64 1
store i8 101, i8* %9
%10 = getelementptr inbounds i8, i8* %1, i64 2
store i8 108, i8* %10
%11 = getelementptr inbounds i8, i8* %1, i64 3
store i8 108, i8* %11
%12 = getelementptr inbounds i8, i8* %1, i64 4
store i8 111, i8* %12
%13 = getelementptr inbounds i8, i8* %1, i64 5
store i8 120, i8* %13
%14 = tail call i32 @mywrite(i8* %11, i32 5)
%15 = getelementptr inbounds i8, i8* %1, i64 -1
%16 = tail call i32 @mywrite(i8* %15, i32 5)
%17 = tail call i32 @mywrite(i8* %9, i32 %8)
%18 = tail call i32 @myopen(i8* %11, i32 0)
%19 = tail call i32 @mygetitimer(i32 0, %struct.itimerval* %4)
%20 = tail call i32 @free(i8* %1)
%21 = tail call i32 @mywrite(i8* %1, i32 5)
%22 = tail call i32 @mywrite(i8* %11, i32 5)
%23 = tail call i32 @mywrite(i8* %9, i32 %8)
ret i32 0
}