#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 EOF;
int /*<<< orphan*/ ERANGE;
int /*<<< orphan*/ LC_CTYPE;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ err(int, char *, ...);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ errx(int, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ ferror(int /*<<< orphan*/);
int getchar();
int getopt(int, char **, char *);
int open(char const *, int /*<<< orphan*/, int /*<<< orphan*/);
char *optarg;
scalar_t__ optind;
int /*<<< orphan*/ putchar(int);
double random();
int randomize_fd(int, int, int, double);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ srandomdev();
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
double strtod(char *, char **);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  double denom;
  int ch, fd, random_exit, randomize_lines, random_type, ret, selected,
      unique_output, unbuffer_output;
  char *ep;
  const char *filename;
  denom = 0;
  filename = "/dev/fd/0";
  random_type = 0;
  random_exit = randomize_lines = unbuffer_output = 0;
  unique_output = 1;
  (void)setlocale(LC_CTYPE, "");
  while ((ch = getopt(argc, argv, "ef:hlruUw")) != -1)
    switch (ch) {
    case 'e':
      random_exit = 1;
      break;
    case 'f':
      randomize_lines = 1;
      if (strcmp(optarg, "-") != 0)
        filename = optarg;
      break;
    case 'l':
      randomize_lines = 1;
      random_type = 1;
      break;
    case 'r':
      unbuffer_output = 1;
      break;
    case 'u':
      randomize_lines = 1;
      unique_output = 1;
      break;
    case 'U':
      randomize_lines = 1;
      unique_output = 0;
      break;
    case 'w':
      randomize_lines = 1;
      random_type = 2;
      break;
    default:
    case '?':
      usage();
    }
  argc -= optind;
  argv += optind;
  switch (argc) {
  case 0:
    denom = (randomize_lines ? 1 : 2);
    break;
  case 1:
    errno = 0;
    denom = strtod(*argv, &ep);
    if (errno == ERANGE)
      err(1, "%s", *argv);
    if (denom <= 0 || *ep != '\0')
      errx(1, "denominator is not valid.");
    if (random_exit && denom > 256)
      errx(1, "denominator must be <= 256 for random exit.");
    break;
  default:
    usage();
  }
  srandomdev();
  if (unbuffer_output)
    setbuf(stdout, NULL);
  if (randomize_lines) {
    if ((fd = open(filename, O_RDONLY, 0)) < 0)
      err(1, "%s", filename);
    ret = randomize_fd(fd, random_type, unique_output, denom);
    if (!random_exit)
      return (ret);
  }
  if (random_exit)
    return (int)(denom * random() / 0x80000000UL);
  selected = (int)(denom * random() / 0x80000000UL) == 0;
  while ((ch = getchar()) != EOF) {
    if (selected)
      (void)putchar(ch);
    if (ch == '\n') {
      if (ferror(stdout))
        err(2, "stdout");
      selected = (int)(denom * random() / 0x80000000UL) == 0;
    }
  }
  if (ferror(stdin))
    err(2, "stdin");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xecc(%rip),%rax
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x38(%rbp)
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
call   10d0 <setlocale@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe8c(%rip),%rdx
call   1100 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     135a <main+0x15a>
mov    -0x1c(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x58(%rbp)
sub    $0x38,%eax
ja     1349 <main+0x149>
mov    -0x58(%rbp),%rax
lea    0xd6d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x24(%rbp)
jmp    1355 <main+0x155>
movl   $0x1,-0x28(%rbp)
mov    0x2d32(%rip),%rax
mov    (%rax),%rdi
lea    0xe38(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     12ec <main+0xec>
mov    0x2d13(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
jmp    1355 <main+0x155>
movl   $0x1,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    1355 <main+0x155>
movl   $0x1,-0x3c(%rbp)
jmp    1355 <main+0x155>
movl   $0x1,-0x28(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    1355 <main+0x155>
movl   $0x1,-0x28(%rbp)
movl   $0x0,-0x38(%rbp)
jmp    1355 <main+0x155>
movl   $0x1,-0x28(%rbp)
movl   $0x2,-0x2c(%rbp)
jmp    1355 <main+0x155>
jmp    134e <main+0x14e>
mov    $0x0,%al
call   10e0 <usage@plt>
jmp    1264 <main+0x64>
mov    0x2c5f(%rip),%rax
mov    (%rax),%edx
mov    -0x8(%rbp),%ecx
sub    %edx,%ecx
mov    %ecx,-0x8(%rbp)
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
lea    (%rax,%rcx,8),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x5c(%rbp)
test   %eax,%eax
je     139e <main+0x19e>
jmp    138d <main+0x18d>
mov    -0x5c(%rbp),%eax
sub    $0x1,%eax
je     13bf <main+0x1bf>
jmp    1479 <main+0x279>
mov    -0x28(%rbp),%edx
mov    $0x2,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1480 <main+0x280>
mov    0x2be2(%rip),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x48(%rbp),%rsi
call   1050 <strtod@plt>
movsd  %xmm0,-0x18(%rbp)
mov    0x2bc0(%rip),%rax
mov    (%rax),%eax
mov    0x2bc7(%rip),%rcx
cmp    (%rcx),%eax
jne    1413 <main+0x213>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    $0x1,%edi
lea    0xcfe(%rip),%rsi
mov    $0x0,%al
call   10b0 <err@plt>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jae    1431 <main+0x231>
mov    -0x48(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1442 <main+0x242>
mov    $0x1,%edi
lea    0xcd0(%rip),%rsi
call   1070 <errx@plt>
cmpl   $0x0,-0x24(%rbp)
je     1474 <main+0x274>
movsd  -0x18(%rbp),%xmm0
movsd  0xba7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1474 <main+0x274>
mov    $0x1,%edi
lea    0xcb8(%rip),%rsi
call   1070 <errx@plt>
jmp    1480 <main+0x280>
mov    $0x0,%al
call   10e0 <usage@plt>
mov    $0x0,%al
call   10c0 <srandomdev@plt>
cmpl   $0x0,-0x3c(%rbp)
je     14a3 <main+0x2a3>
mov    0x2b08(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <setbuf@plt>
cmpl   $0x0,-0x28(%rbp)
je     1514 <main+0x314>
mov    -0x50(%rbp),%rdi
mov    0x2b20(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <open@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jge    14e4 <main+0x2e4>
mov    -0x50(%rbp),%rdx
mov    $0x1,%edi
lea    0xc2d(%rip),%rsi
mov    $0x0,%al
call   10b0 <err@plt>
mov    -0x20(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x38(%rbp),%edx
movsd  -0x18(%rbp),%xmm0
call   1120 <randomize_fd@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    150f <main+0x30f>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1660 <main+0x460>
jmp    1514 <main+0x314>
cmpl   $0x0,-0x24(%rbp)
je     1553 <main+0x353>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    $0x0,%al
call   10a0 <random@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xac5(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
jmp    1660 <main+0x460>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    $0x0,%al
call   10a0 <random@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xa90(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1090 <getchar@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2a29(%rip),%rcx
cmp    (%rcx),%eax
je     162e <main+0x42e>
cmpl   $0x0,-0x34(%rbp)
je     15b9 <main+0x3b9>
mov    -0x1c(%rbp),%edi
call   1030 <putchar@plt>
cmpl   $0xa,-0x1c(%rbp)
jne    1629 <main+0x429>
mov    0x29d6(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     15ee <main+0x3ee>
mov    $0x2,%edi
lea    0xb6c(%rip),%rsi
mov    $0x0,%al
call   10b0 <err@plt>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    $0x0,%al
call   10a0 <random@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0x9f5(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x34(%rbp)
jmp    158e <main+0x38e>
mov    0x299b(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     1659 <main+0x459>
mov    $0x2,%edi
lea    0xb08(%rip),%rsi
mov    $0x0,%al
call   10b0 <err@plt>
xor    %edi,%edi
call   1110 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
call   10d0 <setlocale@plt>
lea    0xe6d(%rip),%rax
mov    %rax,0x28(%rsp)
movl   $0x1,0x20(%rsp)
lea    0xe63(%rip),%r13
lea    0xdc6(%rip),%r12
xor    %eax,%eax
xor    %r14d,%r14d
movl   $0x0,0x1c(%rsp)
movl   $0x0,0xc(%rsp)
jmp    1272 <main+0x72>
movl   $0x2,0x1c(%rsp)
mov    $0x1,%r14d
mov    %r15d,%eax
mov    %eax,%r15d
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1100 <getopt@plt>
lea    -0x55(%rax),%ecx
cmp    $0x22,%ecx
ja     1306 <main+0x106>
movslq (%r12,%rcx,4),%rcx
add    %r12,%rcx
mov    $0x1,%eax
jmp    *%rcx
movl   $0x0,0x20(%rsp)
jmp    1269 <main+0x69>
mov    $0x1,%r14d
mov    %r15d,%eax
movl   $0x1,0x1c(%rsp)
jmp    1272 <main+0x72>
movl   $0x1,0xc(%rsp)
mov    %r15d,%eax
jmp    1272 <main+0x72>
mov    0x2d2f(%rip),%rax
mov    (%rax),%r14
mov    %r14,%rdi
lea    0xdda(%rip),%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
mov    0x28(%rsp),%rax
cmovne %r14,%rax
mov    %rax,0x28(%rsp)
jmp    1269 <main+0x69>
mov    $0x1,%r14d
mov    %r15d,%eax
movl   $0x1,0x20(%rsp)
jmp    1272 <main+0x72>
cmp    $0xffffffff,%eax
je     131a <main+0x11a>
xor    %eax,%eax
call   10e0 <usage@plt>
mov    %r15d,%eax
jmp    1272 <main+0x72>
mov    0x2c9f(%rip),%rax
mov    (%rax),%r12
sub    %r12d,%ebp
cmp    $0x1,%ebp
je     1349 <main+0x149>
test   %ebp,%ebp
jne    13e7 <main+0x1e7>
cmp    $0x1,%r14d
mov    $0x1,%eax
adc    $0x0,%eax
cvtsi2sd %eax,%xmm0
jmp    13f2 <main+0x1f2>
mov    0x2c58(%rip),%rbp
movl   $0x0,0x0(%rbp)
mov    (%rbx,%r12,8),%rdi
lea    0x30(%rsp),%rsi
call   1050 <strtod@plt>
mov    0x0(%rbp),%eax
mov    0x2c49(%rip),%rcx
cmp    (%rcx),%eax
movsd  %xmm0,0x10(%rsp)
jne    1396 <main+0x196>
mov    (%rbx,%r12,8),%rdx
lea    0xd2e(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   10b0 <err@plt>
movsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
mov    0xc(%rsp),%ebx
jae    13ae <main+0x1ae>
mov    0x30(%rsp),%rax
cmpb   $0x0,(%rax)
je     13c5 <main+0x1c5>
lea    0xd00(%rip),%rsi
mov    $0x1,%edi
call   1070 <errx@plt>
movsd  0x10(%rsp),%xmm0
test   %r15d,%r15d
je     13fc <main+0x1fc>
ucomisd 0xc2e(%rip),%xmm0
jbe    13fc <main+0x1fc>
lea    0xcf4(%rip),%rsi
mov    $0x1,%edi
call   1070 <errx@plt>
jmp    13fc <main+0x1fc>
xor    %eax,%eax
call   10e0 <usage@plt>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0xc(%rsp),%ebx
xor    %eax,%eax
call   10c0 <srandomdev@plt>
test   %ebx,%ebx
je     1417 <main+0x217>
mov    0x2b92(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1060 <setbuf@plt>
test   %r14d,%r14d
je     146c <main+0x26c>
mov    0x2bb5(%rip),%rax
mov    (%rax),%esi
mov    0x28(%rsp),%rbp
mov    %rbp,%rdi
xor    %edx,%edx
call   10f0 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1450 <main+0x250>
lea    0xc71(%rip),%rsi
mov    $0x1,%edi
mov    %rbp,%rdx
xor    %eax,%eax
call   10b0 <err@plt>
mov    %ebx,%edi
mov    0x1c(%rsp),%esi
mov    0x20(%rsp),%edx
movsd  0x10(%rsp),%xmm0
call   1120 <randomize_fd@plt>
test   %r15d,%r15d
jne    1471 <main+0x271>
jmp    148e <main+0x28e>
test   %r15d,%r15d
je     149d <main+0x29d>
xor    %eax,%eax
call   10a0 <random@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
mulsd  0xb7e(%rip),%xmm1
cvttsd2si %xmm1,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   10a0 <random@plt>
movsd  %xmm0,0x20(%rsp)
xor    %eax,%eax
call   1090 <getchar@plt>
mov    0x2b10(%rip),%r12
cmp    (%r12),%eax
jne    14eb <main+0x2eb>
mov    0x2b0b(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
test   %rax,%rax
je     14e4 <main+0x2e4>
lea    0xc2a(%rip),%rsi
mov    $0x2,%edi
xor    %eax,%eax
call   10b0 <err@plt>
xor    %edi,%edi
call   1110 <exit@plt>
mov    %eax,%ebp
movsd  0x20(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
mulsd  0xb07(%rip),%xmm0
cvttsd2si %xmm0,%eax
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    0x2a8d(%rip),%r15
lea    0xbe1(%rip),%r14
jmp    154f <main+0x34f>
xor    %eax,%eax
call   10a0 <random@plt>
mulsd  0x10(%rsp),%xmm0
mulsd  0xad7(%rip),%xmm0
cvttsd2si %xmm0,%eax
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %eax,%ebp
cmp    (%r12),%eax
je     14be <main+0x2be>
test   %ebx,%ebx
je     155a <main+0x35a>
mov    %ebp,%edi
call   1030 <putchar@plt>
cmp    $0xa,%ebp
jne    153c <main+0x33c>
mov    (%r15),%edi
call   1040 <ferror@plt>
test   %rax,%rax
je     151c <main+0x31c>
mov    $0x2,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   10b0 <err@plt>
jmp    151c <main+0x31c>

LLVM IR (-O0):
@.str = [10 x i8] c"/dev/fd/0\00"
@LC_CTYPE = global i32 0
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [10 x i8] c"ef:hlruUw\00"
@optarg = global i8* null
@.str.3 = [2 x i8] c"-\00"
@optind = global i64 0
@errno = global i32 0
@ERANGE = global i32 0
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [26 x i8] c"denominator is not valid.\00"
@.str.6 = [44 x i8] c"denominator must be <= 256 for random exit.\00"
@stdout = global i32 0
@O_RDONLY = global i32 0
@EOF = global i32 0
@.str.7 = [7 x i8] c"stdout\00"
@stdin = global i32 0
@.str.8 = [6 x i8] c"stdin\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %6
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %17
store i32 0, i32* %11
store i32 0, i32* %15
store i32 0, i32* %10
store i32 0, i32* %9
store i32 1, i32* %14
%18 = load i32, i32* @LC_CTYPE
%19 = call i32 @setlocale(i32 %18, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %43, %2
%21 = load i32, i32* %4
%22 = load i8**, i8*** %5
%23 = call i32 @getopt(i32 %21, i8** %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i32 %23, i32* %7
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %44
25: ; preds = %20
%26 = load i32, i32* %7
switch i32 %26, label %40 [
i32 101, label %27
i32 102, label %28
i32 108, label %35
i32 114, label %36
i32 117, label %37
i32 85, label %38
i32 119, label %39
i32 63, label %41
]
27: ; preds = %25
store i32 1, i32* %9
br label %43
28: ; preds = %25
store i32 1, i32* %10
%29 = load i8*, i8** @optarg
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load i8*, i8** @optarg
store i8* %33, i8** %17
br label %34
34: ; preds = %32, %28
br label %43
35: ; preds = %25
store i32 1, i32* %10
store i32 1, i32* %11
br label %43
36: ; preds = %25
store i32 1, i32* %15
br label %43
37: ; preds = %25
store i32 1, i32* %10
store i32 1, i32* %14
br label %43
38: ; preds = %25
store i32 1, i32* %10
store i32 0, i32* %14
br label %43
39: ; preds = %25
store i32 1, i32* %10
store i32 2, i32* %11
br label %43
40: ; preds = %25
br label %41
41: ; preds = %25, %40
%42 = call i32 (...) @usage()
br label %43
43: ; preds = %41, %39, %38, %37, %36, %35, %34, %27
br label %20
44: ; preds = %20
%45 = load i64, i64* @optind
%46 = load i32, i32* %4
%47 = sext i32 %46 to i64
%48 = sub nsw i64 %47, %45
%49 = trunc i64 %48 to i32
store i32 %49, i32* %4
%50 = load i64, i64* @optind
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 %50
store i8** %52, i8*** %5
%53 = load i32, i32* %4
switch i32 %53, label %90 [
i32 0, label %54
i32 1, label %60
]
54: ; preds = %44
%55 = load i32, i32* %10
%56 = icmp ne i32 %55, 0
%57 = zext i1 %56 to i64
%58 = select i1 %56, i32 1, i32 2
%59 = sitofp i32 %58 to double
store double %59, double* %6
br label %92
60: ; preds = %44
store i32 0, i32* @errno
%61 = load i8**, i8*** %5
%62 = load i8*, i8** %61
%63 = call double @strtod(i8* %62, i8** %16)
store double %63, double* %6
%64 = load i32, i32* @errno
%65 = load i32, i32* @ERANGE
%66 = icmp eq i32 %64, %65
br i1 %66, label %67, label %71
67: ; preds = %60
%68 = load i8**, i8*** %5
%69 = load i8*, i8** %68
%70 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %69)
br label %71
71: ; preds = %67, %60
%72 = load double, double* %6
%73 = fcmp ole double %72, 0.000000e+00
br i1 %73, label %79, label %74
74: ; preds = %71
%75 = load i8*, i8** %16
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %74, %71
%80 = call i32 @errx(i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %81
81: ; preds = %79, %74
%82 = load i32, i32* %9
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %89
84: ; preds = %81
%85 = load double, double* %6
%86 = fcmp ogt double %85, 2.560000e+02
br i1 %86, label %87, label %89
87: ; preds = %84
%88 = call i32 @errx(i32 1, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
br label %89
89: ; preds = %87, %84, %81
br label %92
90: ; preds = %44
%91 = call i32 (...) @usage()
br label %92
92: ; preds = %90, %89, %54
%93 = call i32 (...) @srandomdev()
%94 = load i32, i32* %15
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %99
96: ; preds = %92
%97 = load i32, i32* @stdout
%98 = call i32 @setbuf(i32 %97, i32* null)
br label %99
99: ; preds = %96, %92
%100 = load i32, i32* %10
%101 = icmp ne i32 %100, 0
br i1 %101, label %102, label %121
102: ; preds = %99
%103 = load i8*, i8** %17
%104 = load i32, i32* @O_RDONLY
%105 = call i32 @open(i8* %103, i32 %104, i32 0)
store i32 %105, i32* %8
%106 = icmp slt i32 %105, 0
br i1 %106, label %107, label %110
107: ; preds = %102
%108 = load i8*, i8** %17
%109 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %108)
br label %110
110: ; preds = %107, %102
%111 = load i32, i32* %8
%112 = load i32, i32* %11
%113 = load i32, i32* %14
%114 = load double, double* %6
%115 = call i32 @randomize_fd(i32 %111, i32 %112, i32 %113, double %114)
store i32 %115, i32* %12
%116 = load i32, i32* %9
%117 = icmp ne i32 %116, 0
br i1 %117, label %120, label %118
118: ; preds = %110
%119 = load i32, i32* %12
store i32 %119, i32* %3
br label %174
120: ; preds = %110
br label %121
121: ; preds = %120, %99
%122 = load i32, i32* %9
%123 = icmp ne i32 %122, 0
br i1 %123, label %124, label %130
124: ; preds = %121
%125 = load double, double* %6
%126 = call double (...) @random()
%127 = fmul double %125, %126
%128 = fdiv double %127, 0x41E0000000000000
%129 = fptosi double %128 to i32
store i32 %129, i32* %3
br label %174
130: ; preds = %121
%131 = load double, double* %6
%132 = call double (...) @random()
%133 = fmul double %131, %132
%134 = fdiv double %133, 0x41E0000000000000
%135 = fptosi double %134 to i32
%136 = icmp eq i32 %135, 0
%137 = zext i1 %136 to i32
store i32 %137, i32* %13
br label %138
138: ; preds = %165, %130
%139 = call i32 (...) @getchar()
store i32 %139, i32* %7
%140 = load i32, i32* @EOF
%141 = icmp ne i32 %139, %140
br i1 %141, label %142, label %166
142: ; preds = %138
%143 = load i32, i32* %13
%144 = icmp ne i32 %143, 0
br i1 %144, label %145, label %148
145: ; preds = %142
%146 = load i32, i32* %7
%147 = call i32 @putchar(i32 %146)
br label %148
148: ; preds = %145, %142
%149 = load i32, i32* %7
%150 = icmp eq i32 %149, 10
br i1 %150, label %151, label %165
151: ; preds = %148
%152 = load i32, i32* @stdout
%153 = call i64 @ferror(i32 %152)
%154 = icmp ne i64 %153, 0
br i1 %154, label %155, label %157
155: ; preds = %151
%156 = call i32 (i32, i8*, ...) @err(i32 2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %157
157: ; preds = %155, %151
%158 = load double, double* %6
%159 = call double (...) @random()
%160 = fmul double %158, %159
%161 = fdiv double %160, 0x41E0000000000000
%162 = fptosi double %161 to i32
%163 = icmp eq i32 %162, 0
%164 = zext i1 %163 to i32
store i32 %164, i32* %13
br label %165
165: ; preds = %157, %148
br label %138
166: ; preds = %138
%167 = load i32, i32* @stdin
%168 = call i64 @ferror(i32 %167)
%169 = icmp ne i64 %168, 0
br i1 %169, label %170, label %172
170: ; preds = %166
%171 = call i32 (i32, i8*, ...) @err(i32 2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %172
172: ; preds = %170, %166
%173 = call i32 @exit(i32 0)
unreachable
174: ; preds = %124, %118
%175 = load i32, i32* %3
ret i32 %175
}

LLVM IR (-O2):
@.str = [10 x i8] c"/dev/fd/0\00"
@LC_CTYPE = global i32 0
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [10 x i8] c"ef:hlruUw\00"
@optarg = global i8* null
@.str.3 = [2 x i8] c"-\00"
@optind = global i64 0
@errno = global i32 0
@ERANGE = global i32 0
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [26 x i8] c"denominator is not valid.\00"
@.str.6 = [44 x i8] c"denominator must be <= 256 for random exit.\00"
@stdout = global i32 0
@O_RDONLY = global i32 0
@EOF = global i32 0
@.str.7 = [7 x i8] c"stdout\00"
@stdin = global i32 0
@.str.8 = [6 x i8] c"stdin\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = load i32, i32* @LC_CTYPE
%6 = tail call i32 @setlocale(i32 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %20, %2
%8 = phi i32 [ 0, %2 ], [ %21, %20 ]
%9 = phi i32 [ 0, %2 ], [ %22, %20 ]
%10 = phi i32 [ 0, %2 ], [ %23, %20 ]
%11 = phi i32 [ 1, %2 ], [ %24, %20 ]
%12 = phi i32 [ 0, %2 ], [ %25, %20 ]
%13 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %2 ], [ %26, %20 ]
%14 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
switch i32 %14, label %32 [
i32 -1, label %34
i32 101, label %20
i32 102, label %15
i32 108, label %27
i32 114, label %28
i32 117, label %29
i32 85, label %30
i32 119, label %31
]
15: ; preds = %7
%16 = load i8*, i8** @optarg
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8* %13, i8* %16
br label %20
20: ; preds = %15, %7, %32, %31, %30, %29, %28, %27
%21 = phi i32 [ %8, %32 ], [ %8, %31 ], [ %8, %30 ], [ %8, %29 ], [ %8, %28 ], [ %8, %27 ], [ 1, %7 ], [ %8, %15 ]
%22 = phi i32 [ %9, %32 ], [ 1, %31 ], [ 1, %30 ], [ 1, %29 ], [ %9, %28 ], [ 1, %27 ], [ %9, %7 ], [ 1, %15 ]
%23 = phi i32 [ %10, %32 ], [ 2, %31 ], [ %10, %30 ], [ %10, %29 ], [ %10, %28 ], [ 1, %27 ], [ %10, %7 ], [ %10, %15 ]
%24 = phi i32 [ %11, %32 ], [ %11, %31 ], [ 0, %30 ], [ 1, %29 ], [ %11, %28 ], [ %11, %27 ], [ %11, %7 ], [ %11, %15 ]
%25 = phi i32 [ %12, %32 ], [ %12, %31 ], [ %12, %30 ], [ %12, %29 ], [ 1, %28 ], [ %12, %27 ], [ %12, %7 ], [ %12, %15 ]
%26 = phi i8* [ %13, %32 ], [ %13, %31 ], [ %13, %30 ], [ %13, %29 ], [ %13, %28 ], [ %13, %27 ], [ %13, %7 ], [ %19, %15 ]
br label %7
27: ; preds = %7
br label %20
28: ; preds = %7
br label %20
29: ; preds = %7
br label %20
30: ; preds = %7
br label %20
31: ; preds = %7
br label %20
32: ; preds = %7
%33 = tail call i32 (...) @usage()
br label %20
34: ; preds = %7
%35 = load i64, i64* @optind
%36 = trunc i64 %35 to i32
%37 = sub i32 %0, %36
%38 = getelementptr inbounds i8*, i8** %1, i64 %35
switch i32 %37, label %66 [
i32 0, label %39
i32 1, label %43
]
39: ; preds = %34
%40 = icmp eq i32 %9, 0
%41 = select i1 %40, i32 2, i32 1
%42 = sitofp i32 %41 to double
br label %68
43: ; preds = %34
store i32 0, i32* @errno
%44 = load i8*, i8** %38
%45 = call double @strtod(i8* %44, i8** %3)
%46 = load i32, i32* @errno
%47 = load i32, i32* @ERANGE
%48 = icmp eq i32 %46, %47
br i1 %48, label %49, label %52
49: ; preds = %43
%50 = load i8*, i8** %38
%51 = tail call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %49, %43
%53 = fcmp ugt double %45, 0.000000e+00
br i1 %53, label %54, label %58
54: ; preds = %52
%55 = load i8*, i8** %3
%56 = load i8, i8* %55
%57 = icmp eq i8 %56, 0
br i1 %57, label %60, label %58
58: ; preds = %54, %52
%59 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %60
60: ; preds = %58, %54
%61 = icmp ne i32 %8, 0
%62 = fcmp ogt double %45, 2.560000e+02
%63 = select i1 %61, i1 %62, i1 false
br i1 %63, label %64, label %68
64: ; preds = %60
%65 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
br label %68
66: ; preds = %34
%67 = tail call i32 (...) @usage()
br label %68
68: ; preds = %60, %64, %66, %39
%69 = phi double [ 0.000000e+00, %66 ], [ %45, %64 ], [ %45, %60 ], [ %42, %39 ]
%70 = tail call i32 (...) @srandomdev()
%71 = icmp eq i32 %12, 0
br i1 %71, label %75, label %72
72: ; preds = %68
%73 = load i32, i32* @stdout
%74 = tail call i32 @setbuf(i32 %73, i32* null)
br label %75
75: ; preds = %72, %68
%76 = icmp eq i32 %9, 0
br i1 %76, label %86, label %77
77: ; preds = %75
%78 = load i32, i32* @O_RDONLY
%79 = tail call i32 @open(i8* %13, i32 %78, i32 0)
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %77
%82 = tail call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %13)
br label %83
83: ; preds = %81, %77
%84 = tail call i32 @randomize_fd(i32 %79, i32 %10, i32 %11, double %69)
%85 = icmp eq i32 %8, 0
br i1 %85, label %138, label %88
86: ; preds = %75
%87 = icmp eq i32 %8, 0
br i1 %87, label %93, label %88
88: ; preds = %83, %86
%89 = tail call double (...) @random()
%90 = fmul double %69, %89
%91 = fmul double %90, 0x3E00000000000000
%92 = fptosi double %91 to i32
br label %138
93: ; preds = %86
%94 = tail call double (...) @random()
%95 = tail call i32 (...) @getchar()
%96 = load i32, i32* @EOF
%97 = icmp eq i32 %95, %96
br i1 %97, label %130, label %98
98: ; preds = %93
%99 = fmul double %69, %94
%100 = fmul double %99, 0x3E00000000000000
%101 = fptosi double %100 to i32
%102 = icmp eq i32 %101, 0
%103 = zext i1 %102 to i32
br label %104
104: ; preds = %98, %125
%105 = phi i32 [ %127, %125 ], [ %95, %98 ]
%106 = phi i32 [ %126, %125 ], [ %103, %98 ]
%107 = icmp eq i32 %106, 0
br i1 %107, label %110, label %108
108: ; preds = %104
%109 = tail call i32 @putchar(i32 %105)
br label %110
110: ; preds = %108, %104
%111 = icmp eq i32 %105, 10
br i1 %111, label %112, label %125
112: ; preds = %110
%113 = load i32, i32* @stdout
%114 = tail call i64 @ferror(i32 %113)
%115 = icmp eq i64 %114, 0
br i1 %115, label %118, label %116
116: ; preds = %112
%117 = tail call i32 (i32, i8*, ...) @err(i32 2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %118
118: ; preds = %116, %112
%119 = tail call double (...) @random()
%120 = fmul double %69, %119
%121 = fmul double %120, 0x3E00000000000000
%122 = fptosi double %121 to i32
%123 = icmp eq i32 %122, 0
%124 = zext i1 %123 to i32
br label %125
125: ; preds = %118, %110
%126 = phi i32 [ %124, %118 ], [ %106, %110 ]
%127 = tail call i32 (...) @getchar()
%128 = load i32, i32* @EOF
%129 = icmp eq i32 %127, %128
br i1 %129, label %130, label %104
130: ; preds = %125, %93
%131 = load i32, i32* @stdin
%132 = tail call i64 @ferror(i32 %131)
%133 = icmp eq i64 %132, 0
br i1 %133, label %136, label %134
134: ; preds = %130
%135 = tail call i32 (i32, i8*, ...) @err(i32 2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %136
136: ; preds = %134, %130
%137 = tail call i32 @exit(i32 0)
unreachable
138: ; preds = %83, %88
%139 = phi i32 [ %92, %88 ], [ %84, %83 ]
ret i32 %139
}