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

/* Variables and functions */
int /*<<< orphan*/ STDERR_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  printf("printf()\n");
  fprintf(stdout, "fprintf(stdout)\n");
  fflush(stdout);
  fprintf(stderr, "fprintf(stderr)\n");
  fflush(stderr);
  write(STDOUT_FILENO, "write(1)\n", strlen("write(1)\n"));
  write(STDERR_FILENO, "write(2)\n", strlen("write(2)\n"));
  return 42;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
lea    0xe61(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%edx
lea    0xe50(%rip),%rsi
call   1030 <write@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0xe42(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%edx
lea    0xe31(%rip),%rsi
call   1030 <write@plt>
mov    $0x2a,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e61(%rip),%rbx
mov    (%rbx),%edi
lea    0xe90(%rip),%rsi
call   1060 <fprintf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
mov    0x2e55(%rip),%rbx
mov    (%rbx),%edi
lea    0xe85(%rip),%rsi
call   1060 <fprintf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%ebx
lea    0xe7a(%rip),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%ebx
lea    0xe60(%rip),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    $0x2a,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"printf()\0A\00"
@stdout = global i32 0
@.str.1 = [17 x i8] c"fprintf(stdout)\0A\00"
@stderr = global i32 0
@.str.2 = [17 x i8] c"fprintf(stderr)\0A\00"
@STDOUT_FILENO = global i32 0
@.str.3 = [10 x i8] c"write(1)\0A\00"
@STDERR_FILENO = global i32 0
@.str.4 = [10 x i8] c"write(2)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdout
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @stdout
%10 = call i32 @fflush(i32 %9)
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = call i32 @fflush(i32 %13)
%15 = load i32, i32* @STDOUT_FILENO
%16 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @write(i32 %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = load i32, i32* @STDERR_FILENO
%19 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @write(i32 %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %19)
ret i32 42
}

LLVM IR (-O2):
@stdout = global i32 0
@.str.1 = [17 x i8] c"fprintf(stdout)\0A\00"
@stderr = global i32 0
@.str.2 = [17 x i8] c"fprintf(stderr)\0A\00"
@STDOUT_FILENO = global i32 0
@.str.3 = [10 x i8] c"write(1)\0A\00"
@STDERR_FILENO = global i32 0
@.str.4 = [10 x i8] c"write(2)\0A\00"
@str = [9 x i8] c"printf()\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%4 = load i32, i32* @stdout
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* @stdout
%7 = tail call i32 @fflush(i32 %6)
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* @stderr
%11 = tail call i32 @fflush(i32 %10)
%12 = load i32, i32* @STDOUT_FILENO
%13 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i32 @write(i32 %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = load i32, i32* @STDERR_FILENO
%16 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%17 = tail call i32 @write(i32 %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %16)
ret i32 42
}