#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 */
typedef int /*<<< orphan*/ cwdbuf;

/* Variables and functions */
int /*<<< orphan*/ getcwd(char *, int);
int /*<<< orphan*/ msg(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  char cwdbuf[256];
  msg(stdout, "----------- NEW RUN");
  msg(stderr, "----------- NEW RUN");
  msg(stdout, "Working directory=%s", getcwd(cwdbuf, sizeof(cwdbuf)));
  for (;;) {
    sleep(2);
    msg(stdout, "Message to standard output.");
    msg(stderr, "Message to standard error.");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1050 <msg@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1050 <msg@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x114(%rbp)
lea    -0x110(%rbp),%rdi
mov    $0x100,%esi
call   1030 <getcwd@plt>
mov    -0x114(%rbp),%edi
mov    %eax,%edx
lea    0xe6e(%rip),%rsi
mov    $0x0,%al
call   1050 <msg@plt>
mov    $0x2,%edi
call   1040 <sleep@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%rip),%rsi
mov    $0x0,%al
call   1050 <msg@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
mov    $0x0,%al
call   1050 <msg@plt>
jmp    11ad <main+0x7d>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    0x2e93(%rip),%r15
mov    (%r15),%edi
lea    0xeb1(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <msg@plt>
mov    0x2e80(%rip),%r12
mov    (%r12),%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <msg@plt>
mov    (%r15),%ebx
mov    %rsp,%rdi
mov    $0x100,%esi
call   1030 <getcwd@plt>
lea    0xe8f(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <msg@plt>
lea    0xe92(%rip),%r14
lea    0xea7(%rip),%rbx
xchg   %ax,%ax
mov    $0x2,%edi
call   1040 <sleep@plt>
mov    (%r15),%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <msg@plt>
mov    (%r12),%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <msg@plt>
jmp    11a0 <main+0x70>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [20 x i8] c"----------- NEW RUN\00"
@stderr = global i32 0
@.str.1 = [21 x i8] c"Working directory=%s\00"
@.str.2 = [28 x i8] c"Message to standard output.\00"
@.str.3 = [27 x i8] c"Message to standard error.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @stdout
%8 = call i32 (i32, i8*, ...) @msg(i32 %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @stderr
%10 = call i32 (i32, i8*, ...) @msg(i32 %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stdout
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%13 = call i32 @getcwd(i8* %12, i32 256)
%14 = call i32 (i32, i8*, ...) @msg(i32 %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %15, %2
%16 = call i32 @sleep(i32 2)
%17 = load i32, i32* @stdout
%18 = call i32 (i32, i8*, ...) @msg(i32 %17, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @msg(i32 %19, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %15
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [20 x i8] c"----------- NEW RUN\00"
@stderr = global i32 0
@.str.1 = [21 x i8] c"Working directory=%s\00"
@.str.2 = [28 x i8] c"Message to standard output.\00"
@.str.3 = [27 x i8] c"Message to standard error.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdout
%6 = tail call i32 (i32, i8*, ...) @msg(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @msg(i32 %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @stdout
%10 = call i32 @getcwd(i8* %4, i32 256)
%11 = call i32 (i32, i8*, ...) @msg(i32 %9, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %12, %2
%13 = call i32 @sleep(i32 2)
%14 = load i32, i32* @stdout
%15 = call i32 (i32, i8*, ...) @msg(i32 %14, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @msg(i32 %16, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %12
}