#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 */
struct timespec {
  int member_1;
  scalar_t__ tv_nsec;
  scalar_t__ tv_sec;
  int /*<<< orphan*/ member_0;
};
typedef long ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ nanosleep(struct timespec const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
long read(int /*<<< orphan*/, unsigned char *, long);
long sendfile(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/ *,
              long);
int /*<<< orphan*/ stderr;
char *strerror(int);
long write(int /*<<< orphan*/, unsigned char *, long);
int main(int argc, char **argv) {
  const struct timespec sleep_interval = {0, ((100) * 1000 * 1000)};
  int i;
  ssize_t sfrv;
  FILE *fp;
  FILE *rand;
  struct timespec now, then;
  char use_sendfile = 1;
  unsigned char buf[((long)(1 * 1024 * 1024))];
  fp = fopen("deletemetempfile.file", "w");
  if (!fp) {
    fprintf(stderr, "Unable to open my temp file: %s.  Dying.\n",
            strerror(errno));
    exit(1);
  }
  rand = fopen("/dev/urandom", "r");
  if (!rand) {
    fprintf(stderr, "Unable to open urandom: %s.  Dying.\n", strerror(errno));
    exit(1);
  }
  for (i = 0; i < (100); i++) {
    clock_gettime(CLOCK_MONOTONIC, &then);
    if (use_sendfile) {
      sfrv =
          sendfile(fileno(fp), fileno(rand), NULL, ((long)(1 * 1024 * 1024)));
    } else {
      sfrv = read(fileno(rand), buf, ((long)(1 * 1024 * 1024)));
      if (sfrv != ((long)(1 * 1024 * 1024))) {
        fprintf(stderr, "Failed read() on rand: %s", strerror(errno));
        exit(1);
      }
      sfrv = write(fileno(fp), buf, ((long)(1 * 1024 * 1024)));
    }
    fflush(fp);
    clock_gettime(CLOCK_MONOTONIC, &now);
    printf("%3ld.%09ldms",
           (now.tv_sec - then.tv_sec - (now.tv_nsec < then.tv_nsec ? 1 : 0)),
           (now.tv_nsec +
            (now.tv_nsec < then.tv_nsec ? 1 * 1000 * 1000 * 1000 : 0) -
            then.tv_nsec));
    if (sfrv == -1) {
      printf(" [Failed write: %d returned: %s]\n", errno, strerror(errno));
      if (use_sendfile) {
        fprintf(stderr, "Falling back to read(2) and write(2) due to failed "
                        "sendfile(2).\n");
        use_sendfile = 0;
      }
    } else if (sfrv != ((long)(1 * 1024 * 1024))) {
      printf(" [Short write: only %ld/%ld written!?]\n", sfrv,
             ((long)(1 * 1024 * 1024)));
    } else {
      printf("\n");
    }
    nanosleep(&sleep_interval, NULL);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1000c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe20(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe1d(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe1a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe17(%rip),%rax
mov    %rax,-0x18(%rbp)
movb   $0x1,-0x91(%rbp)
lea    0xe0d(%rip),%rdi
lea    0xe1c(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    126c <main+0xac>
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1000a4(%rbp)
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x1000a4(%rbp),%edi
mov    %rax,%rdx
lea    0xddd(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xdef(%rip),%rdi
lea    0xdf5(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    12cc <main+0x10c>
mov    0x2d43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1000a8(%rbp)
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x1000a8(%rbp),%edi
mov    %rax,%rdx
lea    0xdb6(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x64,-0x34(%rbp)
jge    14ff <main+0x33f>
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rsi
call   1030 <clock_gettime@plt>
cmpb   $0x0,-0x91(%rbp)
je     1336 <main+0x176>
mov    -0x48(%rbp),%rdi
call   1090 <fileno@plt>
mov    %eax,-0x1000ac(%rbp)
mov    -0x50(%rbp),%rdi
call   1090 <fileno@plt>
mov    -0x1000ac(%rbp),%edi
mov    %eax,%esi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x100000,%ecx
call   10b0 <sendfile@plt>
mov    %rax,-0x40(%rbp)
jmp    13c2 <main+0x202>
mov    -0x50(%rbp),%rdi
call   1090 <fileno@plt>
mov    %eax,%edi
lea    -0x1000a0(%rbp),%rsi
mov    $0x100000,%edx
call   1070 <read@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x100000,-0x40(%rbp)
je     13a2 <main+0x1e2>
mov    0x2c6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1000b0(%rbp)
mov    0x2c56(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x1000b0(%rbp),%edi
mov    %rax,%rdx
lea    0xd05(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x48(%rbp),%rdi
call   1090 <fileno@plt>
mov    %eax,%edi
lea    -0x1000a0(%rbp),%rsi
mov    $0x100000,%edx
call   1040 <write@plt>
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rdi
call   10a0 <fflush@plt>
mov    0x2c16(%rip),%rax
mov    (%rax),%edi
lea    -0x70(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x60(%rbp),%rsi
sub    -0x80(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x88(%rbp),%rdi
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %rdi,%rdx
cmovl  %ecx,%eax
cltq
sub    %rax,%rsi
mov    -0x68(%rbp),%rdx
mov    -0x68(%rbp),%rdi
mov    -0x88(%rbp),%r8
xor    %eax,%eax
mov    $0x3b9aca00,%ecx
cmp    %r8,%rdi
cmovl  %ecx,%eax
cltq
add    %rax,%rdx
sub    -0x88(%rbp),%rdx
lea    0xc7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0xffffffffffffffff,-0x40(%rbp)
jne    14a7 <main+0x2e7>
mov    0x2b86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1000b4(%rbp)
mov    0x2b77(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x1000b4(%rbp),%esi
mov    %rax,%rdx
lea    0xc4d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpb   $0x0,-0x91(%rbp)
je     14a2 <main+0x2e2>
mov    0x2b4d(%rip),%rax
mov    (%rax),%edi
lea    0xc4b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movb   $0x0,-0x91(%rbp)
jmp    14e4 <main+0x324>
cmpq   $0x100000,-0x40(%rbp)
je     14d1 <main+0x311>
mov    -0x40(%rbp),%rsi
lea    0xc60(%rip),%rdi
mov    $0x100000,%edx
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14df <main+0x31f>
lea    0xc46(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14e4 <main+0x324>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <nanosleep@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12d3 <main+0x113>
xor    %eax,%eax
add    $0x1000c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100078,%rsp
movups 0xe28(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movups 0xe0c(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xe20(%rip),%rdi
lea    0xe2f(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1423 <main+0x253>
mov    %rax,%r14
lea    0xe43(%rip),%rdi
lea    0xe49(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1443 <main+0x273>
mov    $0x1,%r12b
mov    $0x64,%r13d
mov    0x2d9f(%rip),%rbp
lea    0x70(%rsp),%rbx
jmp    1275 <main+0xa5>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1070 <nanosleep@plt>
add    $0xffffffff,%r13d
lea    0x70(%rsp),%rbx
je     13db <main+0x20b>
mov    0x0(%rbp),%edi
lea    0x30(%rsp),%rsi
call   1040 <clock_gettime@plt>
test   %r12b,%r12b
je     12c0 <main+0xf0>
mov    %r14,%rdi
call   10a0 <fileno@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rdi
call   10a0 <fileno@plt>
mov    $0x100000,%ecx
mov    %ebp,%edi
mov    0x2d3f(%rip),%rbp
mov    %eax,%esi
xor    %edx,%edx
call   10c0 <sendfile@plt>
jmp    12fc <main+0x12c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rsp),%rdi
call   10a0 <fileno@plt>
mov    $0x100000,%edx
mov    %eax,%edi
mov    %rbx,%rsi
call   1080 <read@plt>
cmp    $0x100000,%rax
jne    13ef <main+0x21f>
mov    %r14,%rdi
call   10a0 <fileno@plt>
mov    $0x100000,%edx
mov    %eax,%edi
mov    %rbx,%rsi
call   1050 <write@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   10b0 <fflush@plt>
mov    0x0(%rbp),%edi
lea    0x50(%rsp),%rsi
call   1040 <clock_gettime@plt>
mov    0x58(%rsp),%rdx
mov    0x60(%rsp),%rsi
mov    0x38(%rsp),%rax
mov    %rdx,%rcx
sub    %rax,%rcx
add    $0x3b9aca00,%rcx
xor    %edi,%edi
sub    %rax,%rdx
cmovl  %rcx,%rdx
setl   %dil
sub    0x40(%rsp),%rsi
sub    %rdi,%rsi
lea    0xd64(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x100000,%r15
je     1250 <main+0x80>
cmp    $0xffffffffffffffff,%r15
jne    13c0 <main+0x1f0>
mov    0x2c63(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10f0 <strerror@plt>
lea    0xd40(%rip),%rdi
mov    %ebp,%esi
mov    0x2c62(%rip),%rbp
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
test   %r12b,%r12b
mov    $0x0,%r12d
je     125a <main+0x8a>
mov    0x2c32(%rip),%rax
mov    (%rax),%edi
xor    %r12d,%r12d
lea    0xd2d(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    125a <main+0x8a>
xchg   %ax,%ax
mov    $0x100000,%edx
lea    0xd54(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    125a <main+0x8a>
xor    %eax,%eax
add    $0x100078,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2be2(%rip),%rax
mov    (%rax),%ebx
mov    0x2bd1(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xc89(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2bae(%rip),%rax
mov    (%rax),%ebx
mov    0x2b9d(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xbf7(%rip),%rsi
jmp    140d <main+0x23d>
mov    0x2b8e(%rip),%rax
mov    (%rax),%ebx
mov    0x2b7d(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xc10(%rip),%rsi
jmp    140d <main+0x23d>

LLVM IR (-O0):
%struct.timespec = type { i32, i64, i64, i32 }
@__const.main.sleep_interval = %struct.timespec { i32 0, i64 100000000, i64 0, i32 0 }
@.str = [22 x i8] c"deletemetempfile.file\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [42 x i8] c"Unable to open my temp file: %s. Dying.\0A\00"
@errno = global i32 0
@.str.3 = [13 x i8] c"/dev/urandom\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [37 x i8] c"Unable to open urandom: %s. Dying.\0A\00"
@CLOCK_MONOTONIC = global i32 0
@.str.6 = [26 x i8] c"Failed read() on rand: %s\00"
@.str.7 = [13 x i8] c"%3ld.%09ldms\00"
@.str.8 = [34 x i8] c" [Failed write: %d returned: %s]\0A\00"
@.str.9 = [65 x i8] c"Falling back to read(2) and write(2) due to failed sendfile(2).\0A\00"
@.str.10 = [40 x i8] c" [Short write: only %ld/%ld written!?]\0A\00"
@.str.11 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timespec
%7 = alloca i32
%8 = alloca i64
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca %struct.timespec
%12 = alloca %struct.timespec
%13 = alloca i8
%14 = alloca [1048576 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = bitcast %struct.timespec* %6 to i8*
store i8 1, i8* %13
%16 = call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %9
%17 = load i32*, i32** %9
%18 = icmp ne i32* %17, null
br i1 %18, label %25, label %19
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i32, i32* @errno
%22 = call i8* @strerror(i32 %21)
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %2
%26 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %26, i32** %10
%27 = load i32*, i32** %10
%28 = icmp ne i32* %27, null
br i1 %28, label %35, label %29
29: ; preds = %25
%30 = load i32, i32* @stderr
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %25
store i32 0, i32* %7
br label %36
36: ; preds = %126, %35
%37 = load i32, i32* %7
%38 = icmp slt i32 %37, 100
br i1 %38, label %39, label %129
39: ; preds = %36
%40 = load i32, i32* @CLOCK_MONOTONIC
%41 = call i32 @clock_gettime(i32 %40, %struct.timespec* %12)
%42 = load i8, i8* %13
%43 = icmp ne i8 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %39
%45 = load i32*, i32** %9
%46 = call i32 @fileno(i32* %45)
%47 = load i32*, i32** %10
%48 = call i32 @fileno(i32* %47)
%49 = call i64 @sendfile(i32 %46, i32 %48, i32* null, i64 1048576)
store i64 %49, i64* %8
br label %68
50: ; preds = %39
%51 = load i32*, i32** %10
%52 = call i32 @fileno(i32* %51)
%53 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %14, i64 0, i64 0
%54 = call i64 @read(i32 %52, i8* %53, i64 1048576)
store i64 %54, i64* %8
%55 = load i64, i64* %8
%56 = icmp ne i64 %55, 1048576
br i1 %56, label %57, label %63
57: ; preds = %50
%58 = load i32, i32* @stderr
%59 = load i32, i32* @errno
%60 = call i8* @strerror(i32 %59)
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %60)
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %50
%64 = load i32*, i32** %9
%65 = call i32 @fileno(i32* %64)
%66 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %14, i64 0, i64 0
%67 = call i64 @write(i32 %65, i8* %66, i64 1048576)
store i64 %67, i64* %8
br label %68
68: ; preds = %63, %44
%69 = load i32*, i32** %9
%70 = call i32 @fflush(i32* %69)
%71 = load i32, i32* @CLOCK_MONOTONIC
%72 = call i32 @clock_gettime(i32 %71, %struct.timespec* %11)
%73 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 2
%74 = load i64, i64* %73
%75 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 2
%76 = load i64, i64* %75
%77 = sub nsw i64 %74, %76
%78 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 1
%79 = load i64, i64* %78
%80 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 1
%81 = load i64, i64* %80
%82 = icmp slt i64 %79, %81
%83 = zext i1 %82 to i64
%84 = select i1 %82, i32 1, i32 0
%85 = sext i32 %84 to i64
%86 = sub nsw i64 %77, %85
%87 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 1
%88 = load i64, i64* %87
%89 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 1
%90 = load i64, i64* %89
%91 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 1
%92 = load i64, i64* %91
%93 = icmp slt i64 %90, %92
%94 = zext i1 %93 to i64
%95 = select i1 %93, i32 1000000000, i32 0
%96 = sext i32 %95 to i64
%97 = add nsw i64 %88, %96
%98 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 1
%99 = load i64, i64* %98
%100 = sub nsw i64 %97, %99
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i64 %86, i64 %100)
%102 = load i64, i64* %8
%103 = icmp eq i64 %102, -1
br i1 %103, label %104, label %115
104: ; preds = %68
%105 = load i32, i32* @errno
%106 = load i32, i32* @errno
%107 = call i8* @strerror(i32 %106)
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i32 %105, i8* %107)
%109 = load i8, i8* %13
%110 = icmp ne i8 %109, 0
br i1 %110, label %111, label %114
111: ; preds = %104
%112 = load i32, i32* @stderr
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.9, i64 0, i64 0))
store i8 0, i8* %13
br label %114
114: ; preds = %111, %104
br label %124
115: ; preds = %68
%116 = load i64, i64* %8
%117 = icmp ne i64 %116, 1048576
br i1 %117, label %118, label %121
118: ; preds = %115
%119 = load i64, i64* %8
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0), i64 %119, i64 1048576)
br label %123
121: ; preds = %115
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %123
123: ; preds = %121, %118
br label %124
124: ; preds = %123, %114
%125 = call i32 @nanosleep(%struct.timespec* %6, i32* null)
br label %126
126: ; preds = %124
%127 = load i32, i32* %7
%128 = add nsw i32 %127, 1
store i32 %128, i32* %7
br label %36
129: ; preds = %36
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { i32, i64, i64, i32 }
@__const.main.sleep_interval = %struct.timespec { i32 0, i64 100000000, i64 0, i32 0 }
@.str = [22 x i8] c"deletemetempfile.file\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [42 x i8] c"Unable to open my temp file: %s. Dying.\0A\00"
@errno = global i32 0
@.str.3 = [13 x i8] c"/dev/urandom\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [37 x i8] c"Unable to open urandom: %s. Dying.\0A\00"
@CLOCK_MONOTONIC = global i32 0
@.str.6 = [26 x i8] c"Failed read() on rand: %s\00"
@.str.7 = [13 x i8] c"%3ld.%09ldms\00"
@.str.8 = [34 x i8] c" [Failed write: %d returned: %s]\0A\00"
@.str.9 = [65 x i8] c"Falling back to read(2) and write(2) due to failed sendfile(2).\0A\00"
@.str.10 = [40 x i8] c" [Short write: only %ld/%ld written!?]\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timespec
%4 = alloca %struct.timespec
%5 = alloca %struct.timespec
%6 = alloca [1048576 x i8]
%7 = bitcast %struct.timespec* %3 to i8*
%8 = bitcast %struct.timespec* %4 to i8*
%9 = bitcast %struct.timespec* %5 to i8*
%10 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %6, i64 0, i64 0
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i32, i32* @errno
%16 = tail call i8* @strerror(i32 %15)
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %27, label %22
22: ; preds = %19
%23 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 2
%24 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 2
%25 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 1
%26 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
br label %33
27: ; preds = %19
%28 = load i32, i32* @stderr
%29 = load i32, i32* @errno
%30 = tail call i8* @strerror(i32 %29)
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i8* %30)
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %22, %84
%34 = phi i8 [ 1, %22 ], [ %85, %84 ]
%35 = phi i32 [ 0, %22 ], [ %87, %84 ]
%36 = load i32, i32* @CLOCK_MONOTONIC
%37 = call i32 @clock_gettime(i32 %36, %struct.timespec* %5)
%38 = icmp eq i8 %34, 0
br i1 %38, label %43, label %39
39: ; preds = %33
%40 = call i32 @fileno(i32* %11)
%41 = call i32 @fileno(i32* %20)
%42 = call i64 @sendfile(i32 %40, i32 %41, i32* null, i64 1048576)
br label %56
43: ; preds = %33
%44 = call i32 @fileno(i32* %20)
%45 = call i64 @read(i32 %44, i8* %10, i64 1048576)
%46 = icmp eq i64 %45, 1048576
br i1 %46, label %53, label %47
47: ; preds = %43
%48 = load i32, i32* @stderr
%49 = load i32, i32* @errno
%50 = call i8* @strerror(i32 %49)
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %50)
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %43
%54 = call i32 @fileno(i32* %11)
%55 = call i64 @write(i32 %54, i8* %10, i64 1048576)
br label %56
56: ; preds = %53, %39
%57 = phi i64 [ %42, %39 ], [ %55, %53 ]
%58 = call i32 @fflush(i32* %11)
%59 = load i32, i32* @CLOCK_MONOTONIC
%60 = call i32 @clock_gettime(i32 %59, %struct.timespec* %4)
%61 = load i64, i64* %23
%62 = load i64, i64* %24
%63 = sub i64 %61, %62
%64 = load i64, i64* %25
%65 = load i64, i64* %26
%66 = icmp slt i64 %64, %65
%67 = sext i1 %66 to i64
%68 = add i64 %63, %67
%69 = select i1 %66, i64 1000000000, i64 0
%70 = sub i64 %64, %65
%71 = add i64 %70, %69
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i64 %68, i64 %71)
switch i64 %57, label %80 [
i64 -1, label %73
i64 1048576, label %82
]
73: ; preds = %56
%74 = load i32, i32* @errno
%75 = call i8* @strerror(i32 %74)
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i32 %74, i8* %75)
br i1 %38, label %84, label %77
77: ; preds = %73
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.9, i64 0, i64 0))
br label %84
80: ; preds = %56
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0), i64 %57, i64 1048576)
br label %84
82: ; preds = %56
%83 = call i32 @putchar(i32 10)
br label %84
84: ; preds = %80, %82, %73, %77
%85 = phi i8 [ 0, %77 ], [ 0, %73 ], [ %34, %80 ], [ %34, %82 ]
%86 = call i32 @nanosleep(%struct.timespec* %3, i32* null)
%87 = add nuw nsw i32 %35, 1
%88 = icmp eq i32 %87, 100
br i1 %88, label %89, label %33
89: ; preds = %84
ret i32 0
}