#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 */
typedef int /*<<< orphan*/ time_t;

/* Variables and functions */
int /*<<< orphan*/ appaserver_error_starting_argv_append_file(int, char **,
                                                              char *);
int atoi(char *);
char *environ_get_application_name(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ srand48(int);
int /*<<< orphan*/ stderr;
scalar_t__ time(int /*<<< orphan*/ *);
int timlib_random(int);
int main(int argc, char **argv) {
  char *application_name;
  char session_number[10 + 1];
  char *ptr;
  int i, n;
  int seed;
  application_name = environ_get_application_name(argv[0]);
  appaserver_error_starting_argv_append_file(argc, argv, application_name);
  if (argc != 3) {
    fprintf(stderr, "Usage: %s ignored seed\n", argv[0]);
    exit(1);
  }
  seed = atoi(argv[2]);
  seed += time((time_t *)0);
  srand48(seed);
  ptr = session_number;
  n = timlib_random(9) - 1 + '1';
  *ptr++ = n;
  for (i = 0; i < 10 - 1; i++) {
    n = timlib_random(10) - 1 + '0';
    *ptr++ = n;
  }
  *ptr = '\0';
  printf("%s\n", session_number);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <environ_get_application_name@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   10b0 <appaserver_error_starting_argv_append_file@plt>
cmpl   $0x3,-0x8(%rbp)
je     11f6 <main+0x66>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe19(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x3c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %rax,%rcx
movslq -0x3c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
call   1070 <srand48@plt>
lea    -0x23(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x9,%edi
call   10a0 <timlib_random@plt>
sub    $0x1,%eax
add    $0x31,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
movl   $0x0,-0x34(%rbp)
cmpl   $0x9,-0x34(%rbp)
jge    129d <main+0x10d>
mov    $0xa,%edi
call   10a0 <timlib_random@plt>
sub    $0x1,%eax
add    $0x30,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    125c <main+0xcc>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x23(%rbp),%rsi
lea    0xd69(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rdi
call   1060 <environ_get_application_name@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   10b0 <appaserver_error_starting_argv_append_file@plt>
cmp    $0x3,%ebp
jne    1293 <main+0x103>
mov    0x10(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebx
xor    %edi,%edi
call   1050 <time@plt>
add    %eax,%ebx
mov    %ebx,%edi
call   1070 <srand48@plt>
mov    $0x9,%edi
call   10a0 <timlib_random@plt>
add    $0x30,%al
mov    %al,0xd(%rsp)
mov    $0xa,%edi
call   10a0 <timlib_random@plt>
add    $0x2f,%al
mov    %al,0xe(%rsp)
mov    $0xa,%edi
call   10a0 <timlib_random@plt>
add    $0x2f,%al
mov    %al,0xf(%rsp)
mov    $0xa,%edi
call   10a0 <timlib_random@plt>
add    $0x2f,%al
mov    %al,0x10(%rsp)
mov    $0xa,%edi
call   10a0 <timlib_random@plt>
add    $0x2f,%al
mov    %al,0x11(%rsp)
mov    $0xa,%edi
call   10a0 <timlib_random@plt>
add    $0x2f,%al
mov    %al,0x12(%rsp)
mov    $0xa,%edi
call   10a0 <timlib_random@plt>
add    $0x2f,%al
mov    %al,0x13(%rsp)
mov    $0xa,%edi
call   10a0 <timlib_random@plt>
add    $0x2f,%al
mov    %al,0x14(%rsp)
mov    $0xa,%edi
call   10a0 <timlib_random@plt>
add    $0x2f,%al
mov    %al,0x15(%rsp)
mov    $0xa,%edi
call   10a0 <timlib_random@plt>
add    $0x2f,%al
mov    %al,0x16(%rsp)
movb   $0x0,0x17(%rsp)
lea    0xd98(%rip),%rdi
lea    0xd(%rsp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd5a(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s ignored seed\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [11 x i8]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i8* @environ_get_application_name(i8* %14)
store i8* %15, i8** %6
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = load i8*, i8** %6
%19 = call i32 @appaserver_error_starting_argv_append_file(i32 %16, i8** %17, i8* %18)
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 3
br i1 %21, label %22, label %29
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %2
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %11
%34 = call i64 @time(i32* null)
%35 = load i32, i32* %11
%36 = sext i32 %35 to i64
%37 = add nsw i64 %36, %34
%38 = trunc i64 %37 to i32
store i32 %38, i32* %11
%39 = load i32, i32* %11
%40 = call i32 @srand48(i32 %39)
%41 = getelementptr inbounds [11 x i8], [11 x i8]* %7, i64 0, i64 0
store i8* %41, i8** %8
%42 = call i32 @timlib_random(i32 9)
%43 = sub nsw i32 %42, 1
%44 = add nsw i32 %43, 49
store i32 %44, i32* %10
%45 = load i32, i32* %10
%46 = trunc i32 %45 to i8
%47 = load i8*, i8** %8
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %8
store i8 %46, i8* %47
store i32 0, i32* %9
br label %49
49: ; preds = %60, %29
%50 = load i32, i32* %9
%51 = icmp slt i32 %50, 9
br i1 %51, label %52, label %63
52: ; preds = %49
%53 = call i32 @timlib_random(i32 10)
%54 = sub nsw i32 %53, 1
%55 = add nsw i32 %54, 48
store i32 %55, i32* %10
%56 = load i32, i32* %10
%57 = trunc i32 %56 to i8
%58 = load i8*, i8** %8
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** %8
store i8 %57, i8* %58
br label %60
60: ; preds = %52
%61 = load i32, i32* %9
%62 = add nsw i32 %61, 1
store i32 %62, i32* %9
br label %49
63: ; preds = %49
%64 = load i8*, i8** %8
store i8 0, i8* %64
%65 = getelementptr inbounds [11 x i8], [11 x i8]* %7, i64 0, i64 0
%66 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %65)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s ignored seed\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [11 x i8]
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%5 = load i8*, i8** %1
%6 = tail call i8* @environ_get_application_name(i8* %5)
%7 = tail call i32 @appaserver_error_starting_argv_append_file(i32 %0, i8** %1, i8* %6)
%8 = icmp eq i32 %0, 3
br i1 %8, label %14, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = tail call i64 @time(i32* null)
%19 = trunc i64 %18 to i32
%20 = add i32 %17, %19
%21 = tail call i32 @srand48(i32 %20)
%22 = tail call i32 @timlib_random(i32 9)
%23 = trunc i32 %22 to i8
%24 = add i8 %23, 48
%25 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 1
store i8 %24, i8* %4
%26 = tail call i32 @timlib_random(i32 10)
%27 = trunc i32 %26 to i8
%28 = add i8 %27, 47
%29 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 2
store i8 %28, i8* %25
%30 = tail call i32 @timlib_random(i32 10)
%31 = trunc i32 %30 to i8
%32 = add i8 %31, 47
%33 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 3
store i8 %32, i8* %29
%34 = tail call i32 @timlib_random(i32 10)
%35 = trunc i32 %34 to i8
%36 = add i8 %35, 47
%37 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 4
store i8 %36, i8* %33
%38 = tail call i32 @timlib_random(i32 10)
%39 = trunc i32 %38 to i8
%40 = add i8 %39, 47
%41 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 5
store i8 %40, i8* %37
%42 = tail call i32 @timlib_random(i32 10)
%43 = trunc i32 %42 to i8
%44 = add i8 %43, 47
%45 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 6
store i8 %44, i8* %41
%46 = tail call i32 @timlib_random(i32 10)
%47 = trunc i32 %46 to i8
%48 = add i8 %47, 47
%49 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 7
store i8 %48, i8* %45
%50 = tail call i32 @timlib_random(i32 10)
%51 = trunc i32 %50 to i8
%52 = add i8 %51, 47
%53 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 8
store i8 %52, i8* %49
%54 = tail call i32 @timlib_random(i32 10)
%55 = trunc i32 %54 to i8
%56 = add i8 %55, 47
%57 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 9
store i8 %56, i8* %53
%58 = tail call i32 @timlib_random(i32 10)
%59 = trunc i32 %58 to i8
%60 = add i8 %59, 47
%61 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 10
store i8 %60, i8* %57
store i8 0, i8* %61
%62 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 0
}