#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__ EOF;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ putchar(unsigned long);
int /*<<< orphan*/ stderr;
long strtoul(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  unsigned long count, next = 0;
  unsigned char *c;
  if (argc < 2 || argc > 3) {
    fprintf(stderr, "Usage: %s <seed_string> [<size>]\n", argv[0]);
    return 1;
  }
  c = (unsigned char *)argv[1];
  do {
    next = next * 11 + *c;
  } while (*c++);
  count = (argc == 3) ? strtoul(argv[2], NULL, 0) : -1L;
  while (count--) {
    next = next * 1103515245 + 12345;
    if (putchar((next >> 16) & 0xff) == EOF)
      return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1162 <main+0x32>
cmpl   $0x3,-0x8(%rbp)
jle    118a <main+0x5a>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe87(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1266 <main+0x136>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
imul   $0xb,-0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movzbl (%rcx),%ecx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
cmpb   $0x0,(%rax)
jne    1196 <main+0x66>
cmpl   $0x3,-0x8(%rbp)
jne    11e7 <main+0xb7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %rax,-0x30(%rbp)
jmp    11f7 <main+0xc7>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    11f7 <main+0xc7>
mov    -0x30(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     125f <main+0x12f>
imul   $0x41c64e6d,-0x20(%rbp),%rax
41
add    $0x3039,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
shr    $0x10,%rdi
and    $0xff,%rdi
call   1030 <putchar@plt>
mov    0x2da3(%rip),%rcx
cmp    (%rcx),%rax
jne    125a <main+0x12a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1266 <main+0x136>
jmp    11ff <main+0xcf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    -0x4(%rdi),%eax
cmp    $0xfffffffd,%eax
ja     115f <main+0x2f>
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xeb0(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    11df <main+0xaf>
mov    0x8(%rsi),%rax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%rbx,%rbx,4),%rcx
lea    (%rbx,%rcx,2),%rbx
movzbl (%rax),%ecx
add    %rcx,%rbx
add    $0x1,%rax
test   %rcx,%rcx
jne    1170 <main+0x40>
mov    $0xffffffffffffffff,%r14
cmp    $0x3,%edi
jne    11a3 <main+0x73>
mov    0x10(%rsi),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %rax,%r14
add    $0x1,%r14
mov    0x2e3a(%rip),%r15
xchg   %ax,%ax
add    $0xffffffffffffffff,%r14
je     11dd <main+0xad>
imul   $0x41c64e6d,%rbx,%rbx
add    $0x3039,%rbx
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
cmp    (%r15),%rax
jne    11b0 <main+0x80>
mov    $0xffffffff,%eax
jmp    11df <main+0xaf>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: %s <seed_string> [<size>]\0A\00"
@EOF = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %7
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 3
br i1 %13, label %14, label %20
14: ; preds = %11, %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 1, i32* %3
br label %64
20: ; preds = %11
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
store i8* %23, i8** %8
br label %24
24: ; preds = %31, %20
%25 = load i64, i64* %7
%26 = mul i64 %25, 11
%27 = load i8*, i8** %8
%28 = load i8, i8* %27
%29 = zext i8 %28 to i64
%30 = add i64 %26, %29
store i64 %30, i64* %7
br label %31
31: ; preds = %24
%32 = load i8*, i8** %8
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %8
%34 = load i8, i8* %32
%35 = icmp ne i8 %34, 0
br i1 %35, label %24, label %36
36: ; preds = %31
%37 = load i32, i32* %4
%38 = icmp eq i32 %37, 3
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i64 @strtoul(i8* %42, i32* null, i32 0)
br label %45
44: ; preds = %36
br label %45
45: ; preds = %44, %39
%46 = phi i64 [ %43, %39 ], [ -1, %44 ]
store i64 %46, i64* %6
br label %47
47: ; preds = %62, %45
%48 = load i64, i64* %6
%49 = add i64 %48, -1
store i64 %49, i64* %6
%50 = icmp ne i64 %48, 0
br i1 %50, label %51, label %63
51: ; preds = %47
%52 = load i64, i64* %7
%53 = mul i64 %52, 1103515245
%54 = add i64 %53, 12345
store i64 %54, i64* %7
%55 = load i64, i64* %7
%56 = lshr i64 %55, 16
%57 = and i64 %56, 255
%58 = call i64 @putchar(i64 %57)
%59 = load i64, i64* @EOF
%60 = icmp eq i64 %58, %59
br i1 %60, label %61, label %62
61: ; preds = %51
store i32 -1, i32* %3
br label %64
62: ; preds = %51
br label %47
63: ; preds = %47
store i32 0, i32* %3
br label %64
64: ; preds = %63, %61, %14
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: %s <seed_string> [<size>]\0A\00"
@EOF = global i64 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add i32 %0, -4
%4 = icmp ult i32 %3, -2
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %42
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
br label %12
12: ; preds = %12, %9
%13 = phi i64 [ 0, %9 ], [ %18, %12 ]
%14 = phi i8* [ %11, %9 ], [ %19, %12 ]
%15 = mul i64 %13, 11
%16 = load i8, i8* %14
%17 = zext i8 %16 to i64
%18 = add i64 %15, %17
%19 = getelementptr inbounds i8, i8* %14, i64 1
%20 = icmp eq i8 %16, 0
br i1 %20, label %21, label %12
21: ; preds = %12
%22 = icmp eq i32 %0, 3
br i1 %22, label %23, label %27
23: ; preds = %21
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i64 @strtoul(i8* nocapture %25, i32* null, i32 0)
br label %27
27: ; preds = %21, %23
%28 = phi i64 [ -1, %21 ], [ %26, %23 ]
br label %29
29: ; preds = %27, %33
%30 = phi i64 [ %34, %33 ], [ %28, %27 ]
%31 = phi i64 [ %36, %33 ], [ %18, %27 ]
%32 = icmp eq i64 %30, 0
br i1 %32, label %42, label %33
33: ; preds = %29
%34 = add i64 %30, -1
%35 = mul i64 %31, 1103515245
%36 = add i64 %35, 12345
%37 = lshr i64 %36, 16
%38 = and i64 %37, 255
%39 = tail call i64 @putchar(i64 %38)
%40 = load i64, i64* @EOF
%41 = icmp eq i64 %39, %40
br i1 %41, label %42, label %29
42: ; preds = %29, %33, %5
%43 = phi i32 [ 1, %5 ], [ 0, %29 ], [ -1, %33 ]
ret i32 %43
}