#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ get_line(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char, int /*<<< orphan*/);
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ time(int /*<<< orphan*/);
int /*<<< orphan*/ timlib_random(int);
int main(int argc, char **argv) {
  int up_to;
  char delimiter;
  char input_buffer[1024];
  if (argc != 3) {
    fprintf(stderr, "Usage: %s up_to delimiter\n", argv[0]);
    exit(1);
  }
  up_to = atoi(argv[1]);
  delimiter = *argv[2];
  srandom(time(0));
  while (get_line(input_buffer, stdin)) {
    printf("%s%c%ld\n", input_buffer, delimiter, timlib_random(up_to));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11c9 <main+0x49>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe46(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%al
mov    %al,-0x15(%rbp)
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
lea    -0x420(%rbp),%rdi
mov    0x2de6(%rip),%rax
mov    (%rax),%esi
call   1040 <get_line@plt>
cmp    $0x0,%rax
je     1255 <main+0xd5>
lea    -0x420(%rbp),%rax
mov    %rax,-0x430(%rbp)
mov    -0x15(%rbp),%al
mov    %al,-0x421(%rbp)
mov    -0x14(%rbp),%edi
call   10a0 <timlib_random@plt>
mov    -0x430(%rbp),%rsi
mov    %eax,%ecx
mov    -0x421(%rbp),%al
lea    0xdd3(%rip),%rdi
movsbl %al,%edx
call   1050 <printf@plt>
jmp    11f4 <main+0x74>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    121a <main+0x9a>
mov    0x8(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%r15d
mov    0x10(%rbx),%rax
mov    (%rax),%bl
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
mov    0x2e26(%rip),%r12
mov    (%r12),%esi
mov    %rsp,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     1208 <main+0x88>
movsbl %bl,%ebp
lea    0xe3e(%rip),%r14
mov    %rsp,%rbx
mov    %r15d,%edi
call   10a0 <timlib_random@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1050 <printf@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
jne    11e0 <main+0x60>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdd3(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"Usage: %s up_to delimiter\0A\00"
@stdin = global i32 0
@.str.1 = [9 x i8] c"%s%c%ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
%8 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %6
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = load i8, i8* %25
store i8 %26, i8* %7
%27 = call i32 @time(i32 0)
%28 = call i32 @srandom(i32 %27)
br label %29
29: ; preds = %34, %18
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%31 = load i32, i32* @stdin
%32 = call i64 @get_line(i8* %30, i32 %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %29
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%36 = load i8, i8* %7
%37 = load i32, i32* %6
%38 = call i32 @timlib_random(i32 %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %35, i8 signext %36, i32 %38)
br label %29
40: ; preds = %29
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"Usage: %s up_to delimiter\0A\00"
@stdin = global i32 0
@.str.1 = [9 x i8] c"%s%c%ld\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 3
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = load i8, i8* %16
%18 = tail call i32 @time(i32 0)
%19 = tail call i32 @srandom(i32 %18)
%20 = load i32, i32* @stdin
%21 = call i64 @get_line(i8* %4, i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %11, %23
%24 = call i32 @timlib_random(i32 %14)
%25 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8 signext %17, i32 %24)
%26 = load i32, i32* @stdin
%27 = call i64 @get_line(i8* %4, i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %23
29: ; preds = %23, %11
ret i32 0
}