#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*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ _IOFBF;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
int main() {
  char buffer[1024];
  memset(buffer, '\0', sizeof(buffer));
  fprintf(stdout, "set full buffer\n");
  setvbuf(stdout, buffer, _IOFBF, 1024);
  fprintf(stdout, "Linkerist Heracles\n");
  fprintf(stdout, "This output will go into buff\n");
  fflush(stdout);
  fprintf(stdout, "just a test line for sleep\n");
  fprintf(stdout, "will come after sleeping 5 seconds\n");
  sleep(5);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1030 <memset@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rsi
mov    0x2e37(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%ecx
call   1060 <setvbuf@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
lea    0xe4f(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
lea    0xe56(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   1070 <sleep@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1030 <memset@plt>
mov    0x2e6d(%rip),%rbx
mov    (%rbx),%edi
lea    0xe84(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
mov    0x2e4e(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rsi
mov    $0x400,%ecx
call   1060 <setvbuf@plt>
mov    (%rbx),%edi
lea    0xe6f(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe75(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
call   1050 <fflush@plt>
mov    (%rbx),%edi
lea    0xe7f(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe8d(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   1070 <sleep@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [17 x i8] c"set full buffer\0A\00"
@_IOFBF = global i32 0
@.str.1 = [20 x i8] c"Linkerist Heracles\0A\00"
@.str.2 = [31 x i8] c"This output will go into buff\0A\00"
@.str.3 = [28 x i8] c"just a test line for sleep\0A\00"
@.str.4 = [36 x i8] c"will come after sleeping 5 seconds\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
store i32 0, i32* %1
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i8 signext 0, i32 1024)
%5 = load i32, i32* @stdout
%6 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdout
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%9 = load i32, i32* @_IOFBF
%10 = call i32 @setvbuf(i32 %7, i8* %8, i32 %9, i32 1024)
%11 = load i32, i32* @stdout
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @stdout
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @stdout
%16 = call i32 @fflush(i32 %15)
%17 = load i32, i32* @stdout
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%19 = load i32, i32* @stdout
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 @sleep(i32 5)
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [17 x i8] c"set full buffer\0A\00"
@_IOFBF = global i32 0
@.str.1 = [20 x i8] c"Linkerist Heracles\0A\00"
@.str.2 = [31 x i8] c"This output will go into buff\0A\00"
@.str.3 = [28 x i8] c"just a test line for sleep\0A\00"
@.str.4 = [36 x i8] c"will come after sleeping 5 seconds\0A\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = call i32 @memset(i8* %2, i8 signext 0, i32 1024)
%4 = load i32, i32* @stdout
%5 = call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdout
%7 = load i32, i32* @_IOFBF
%8 = call i32 @setvbuf(i32 %6, i8* %2, i32 %7, i32 1024)
%9 = load i32, i32* @stdout
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @stdout
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* @stdout
%14 = call i32 @fflush(i32 %13)
%15 = load i32, i32* @stdout
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* @stdout
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @sleep(i32 5)
ret i32 0
}