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

/* 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 buff[1024];
  memset(buff, '\0', sizeof(buff));
  fprintf(stdout, "Going to set full buffering on\n");
  setvbuf(stdout, buff, _IOFBF, 1024);
  fprintf(stdout, "This is yiibai.com\n");
  fprintf(stdout, "This output will go into buff\n");
  fflush(stdout);
  fprintf(stdout, "and this will appear when programm\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    0xe63(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%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    0xe5e(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%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    0xe7e(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe84(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
call   1050 <fflush@plt>
mov    (%rbx),%edi
lea    0xe8e(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xea4(%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 = [32 x i8] c"Going to set full buffering on\0A\00"
@_IOFBF = global i32 0
@.str.1 = [20 x i8] c"This is yiibai.com\0A\00"
@.str.2 = [31 x i8] c"This output will go into buff\0A\00"
@.str.3 = [36 x i8] c"and this will appear when programm\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 ([32 x i8], [32 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 ([36 x i8], [36 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 = [32 x i8] c"Going to set full buffering on\0A\00"
@_IOFBF = global i32 0
@.str.1 = [20 x i8] c"This is yiibai.com\0A\00"
@.str.2 = [31 x i8] c"This output will go into buff\0A\00"
@.str.3 = [36 x i8] c"and this will appear when programm\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 ([32 x i8], [32 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 ([36 x i8], [36 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
}