#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 */
scalar_t__ fflush(int /*<<< orphan*/);
scalar_t__ find_vdso_map(void **, void **);
size_t fwrite(void *, int, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int main(void) {
  void *start, *end;
  size_t size, written;
  if (find_vdso_map(&start, &end)) {
    return 1;
  }
  size = end - start;
  while (size) {
    written = fwrite(start, 1, size, stdout);
    if (!written) {
      return 1;
    }
    start += written;
    size -= written;
  }
  if (fflush(stdout)) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <find_vdso_map@plt>
cmp    $0x0,%rax
je     1162 <main+0x32>
movl   $0x1,-0x4(%rbp)
jmp    11fd <main+0xcd>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11d2 <main+0xa2>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    0x2e55(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1040 <fwrite@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11b2 <main+0x82>
movl   $0x1,-0x4(%rbp)
jmp    11fd <main+0xcd>
mov    -0x28(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    1171 <main+0x41>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
call   1030 <fflush@plt>
cmp    $0x0,%rax
je     11f6 <main+0xc6>
movl   $0x1,-0x4(%rbp)
jmp    11fd <main+0xcd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
call   1050 <find_vdso_map@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    11ac <main+0x7c>
mov    0x8(%rsp),%rbx
mov    (%rsp),%rdi
sub    %rdi,%rbx
je     1195 <main+0x65>
mov    0x2e7c(%rip),%r14
mov    $0x1,%ebp
nopl   0x0(%rax)
mov    (%r14),%ecx
mov    $0x1,%esi
mov    %rbx,%rdx
call   1040 <fwrite@plt>
test   %rax,%rax
je     11ac <main+0x7c>
mov    (%rsp),%rdi
add    %rax,%rdi
mov    %rdi,(%rsp)
sub    %rax,%rbx
jne    1170 <main+0x40>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
call   1030 <fflush@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
%6 = call i64 @find_vdso_map(i8** %2, i8** %3)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 1, i32* %1
br label %39
9: ; preds = %0
%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
store i64 %14, i64* %4
br label %15
15: ; preds = %26, %9
%16 = load i64, i64* %4
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %33
18: ; preds = %15
%19 = load i8*, i8** %2
%20 = load i64, i64* %4
%21 = load i32, i32* @stdout
%22 = call i64 @fwrite(i8* %19, i32 1, i64 %20, i32 %21)
store i64 %22, i64* %5
%23 = load i64, i64* %5
%24 = icmp ne i64 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %18
store i32 1, i32* %1
br label %39
26: ; preds = %18
%27 = load i64, i64* %5
%28 = load i8*, i8** %2
%29 = getelementptr i8, i8* %28, i64 %27
store i8* %29, i8** %2
%30 = load i64, i64* %5
%31 = load i64, i64* %4
%32 = sub i64 %31, %30
store i64 %32, i64* %4
br label %15
33: ; preds = %15
%34 = load i32, i32* @stdout
%35 = call i64 @fflush(i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
store i32 1, i32* %1
br label %39
38: ; preds = %33
store i32 0, i32* %1
br label %39
39: ; preds = %38, %37, %25, %8
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@stdout = global i32 0
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = bitcast i8** %1 to i8*
%4 = bitcast i8** %2 to i8*
%5 = call i64 @find_vdso_map(i8** %1, i8** %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %30
7: ; preds = %0
%8 = load i8*, i8** %2
%9 = load i8*, i8** %1
%10 = ptrtoint i8* %8 to i64
%11 = ptrtoint i8* %9 to i64
%12 = sub i64 %10, %11
%13 = icmp eq i64 %12, 0
br i1 %13, label %25, label %14
14: ; preds = %7, %20
%15 = phi i8* [ %22, %20 ], [ %9, %7 ]
%16 = phi i64 [ %23, %20 ], [ %12, %7 ]
%17 = load i32, i32* @stdout
%18 = call i64 @fwrite(i8* %15, i32 1, i64 %16, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %30, label %20
20: ; preds = %14
%21 = load i8*, i8** %1
%22 = getelementptr i8, i8* %21, i64 %18
store i8* %22, i8** %1
%23 = sub i64 %16, %18
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %14
25: ; preds = %20, %7
%26 = load i32, i32* @stdout
%27 = call i64 @fflush(i32 %26)
%28 = icmp ne i64 %27, 0
%29 = zext i1 %28 to i32
br label %30
30: ; preds = %14, %25, %0
%31 = phi i32 [ 1, %0 ], [ %29, %25 ], [ 1, %14 ]
ret i32 %31
}