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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ memcpy(unsigned long long *, unsigned char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int read(int, unsigned char **, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int fd;
  unsigned char random[10];
  char passwd[10 + 1];
  unsigned long long value;
  int pos;
  if ((fd = open("/dev/urandom", O_RDONLY)) < 0) {
    perror("open");
    return 1;
  }
  switch (read(fd, &random, sizeof(random))) {
  case sizeof(random):
    break;
  case -1:
    perror("read");
    return 1;
  default:
    fprintf(stderr, "read: EOF\n");
    return 1;
  }
  memcpy(&value, &random[2], sizeof(value));
  passwd[pos = 10] = 0;
  while (pos--) {
    passwd[pos] = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
        [value %
         (sizeof("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz") -
          1)];
    value /=
        (sizeof("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz") -
         1);
  }
  printf("%s\n", passwd);
  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    0x2e6b(%rip),%rax
mov    (%rax),%esi
lea    0xe7a(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11af <main+0x4f>
lea    0xe6f(%rip),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a5 <main+0x145>
mov    -0x14(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0xa,%edx
call   1040 <read@plt>
mov    %eax,%ecx
mov    %ecx,-0x40(%rbp)
sub    $0xffffffff,%eax
je     11e9 <main+0x89>
jmp    11d3 <main+0x73>
mov    -0x40(%rbp),%eax
sub    $0xa,%eax
jne    1201 <main+0xa1>
jmp    11e4 <main+0x84>
jmp    1222 <main+0xc2>
lea    0xe22(%rip),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a5 <main+0x145>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a5 <main+0x145>
lea    -0x1e(%rbp),%rsi
add    $0x2,%rsi
lea    -0x38(%rbp),%rdi
mov    $0x8,%edx
call   1060 <memcpy@plt>
movl   $0xa,-0x3c(%rbp)
movb   $0x0,-0x1f(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x3c(%rbp)
cmp    $0x0,%eax
je     128e <main+0x12e>
mov    -0x38(%rbp),%rax
mov    $0x3a,%ecx
xor    %edx,%edx
div    %rcx
lea    0xdb6(%rip),%rax
mov    (%rax,%rdx,1),%cl
movslq -0x3c(%rbp),%rax
mov    %cl,-0x29(%rbp,%rax,1)
mov    -0x38(%rbp),%rax
mov    $0x3a,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x38(%rbp)
jmp    1243 <main+0xe3>
lea    -0x29(%rbp),%rsi
lea    0xdc4(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
lea    0xe8c(%rip),%rdi
call   1070 <open@plt>
test   %eax,%eax
js     13e9 <main+0x289>
lea    0x1e(%rsp),%rsi
mov    %eax,%edi
mov    $0xa,%edx
call   1040 <read@plt>
cmp    $0xa,%eax
je     11bf <main+0x5f>
cmp    $0xffffffff,%eax
je     13f2 <main+0x292>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%eax
add    $0x28,%rsp
ret
lea    0x20(%rsp),%rsi
lea    0x10(%rsp),%rdi
mov    $0x8,%edx
call   1060 <memcpy@plt>
mov    0x10(%rsp),%rdi
mov    %rdi,%rax
shr    %rax
movabs $0x469ee58469ee5847,%r8
e5 9e 46
mul    %r8
mov    %rdx,%rax
movb   $0x0,0xf(%rsp)
mov    %rdx,%r10
shr    $0x3,%r10
imul   $0x3a,%r10,%rdx
mov    %rdi,%r9
mov    %rdi,%r11
mov    %rdi,%rcx
sub    %rdx,%rcx
lea    0xe11(%rip),%rsi
mov    (%rsi,%rcx,1),%cl
mov    %cl,0xe(%rsp)
shr    $0x4,%rax
mul    %r8
shr    $0x3,%rdx
imul   $0x3a,%rdx,%rax
sub    %rax,%r10
mov    (%rsi,%r10,1),%al
mov    %al,0xd(%rsp)
shr    $0x2,%r9
movabs $0x26f690490e4e88fb,%rcx
90 f6 26
mov    %r9,%rax
mul    %rcx
mov    %rdx,%rax
mov    %rdx,%rcx
shr    $0x7,%rcx
shr    $0x8,%rax
mul    %r8
shr    $0x3,%rdx
imul   $0x3a,%rdx,%rax
sub    %rax,%rcx
mov    (%rcx,%rsi,1),%al
mov    %al,0xc(%rsp)
movabs $0x55fcd47dea9ba9e3,%rcx
d4 fc 55
mov    %rdi,%rax
mul    %rcx
mov    %rdx,%rax
mov    %rdx,%rcx
shr    $0x10,%rcx
shr    $0x11,%rax
mul    %r8
shr    $0x3,%rdx
imul   $0x3a,%rdx,%rax
sub    %rax,%rcx
mov    (%rcx,%rsi,1),%al
mov    %al,0xb(%rsp)
movabs $0x17b8813d37e4522d,%rcx
81 b8 17
mov    %rdi,%rax
mul    %rcx
mov    %rdx,%rax
mov    %rdx,%rcx
shr    $0x14,%rcx
shr    $0x15,%rax
mul    %r8
shr    $0x3,%rdx
imul   $0x3a,%rdx,%rax
sub    %rax,%rcx
mov    (%rcx,%rsi,1),%al
mov    %al,0xa(%rsp)
movabs $0x68b2c7ad1a016ab5,%rcx
c7 b2 68
mov    %rdi,%rax
mul    %rcx
mov    %rdx,%rax
mov    %rdx,%rcx
shr    $0x1c,%rcx
shr    $0x1d,%rax
mul    %r8
shr    $0x3,%rdx
imul   $0x3a,%rdx,%rax
sub    %rax,%rcx
mov    (%rcx,%rsi,1),%al
mov    %al,0x9(%rsp)
movabs $0x39c3bd9d4c24179,%rcx
3b 9c 03
mov    %rdi,%rax
mul    %rcx
shr    $0x1d,%rdx
mov    $0x8d3dcb09,%ecx
mov    %rdx,%rax
imul   %rcx,%rax
shr    $0x25,%rax
imul   $0x3a,%eax,%eax
sub    %eax,%edx
mov    (%rdx,%rsi,1),%al
mov    %al,0x8(%rsp)
movabs $0x1fdec0e406b2cf35,%rdx
c0 de 1f
mov    %rdi,%rax
mul    %rdx
shr    $0x26,%rdx
mov    %rdx,%rax
imul   %rcx,%rax
shr    $0x25,%rax
imul   $0x3a,%eax,%eax
sub    %eax,%edx
mov    (%rdx,%rsi,1),%al
mov    %al,0x7(%rsp)
movabs $0x119561984a50ff9,%rdx
56 19 01
mov    %rdi,%rax
mul    %rdx
shr    $0x27,%rdx
mov    %rdx,%rax
imul   %rcx,%rax
shr    $0x25,%rax
imul   $0x3a,%eax,%eax
sub    %eax,%edx
mov    (%rdx,%rsi,1),%al
mov    %al,0x6(%rsp)
shr    $0x9,%r11
movabs $0x26ce152cc751a7,%rcx
mov    %r11,%rax
mul    %rcx
shr    $0x21,%rdx
imul   $0x469f,%edx,%eax
shr    $0x14,%eax
imul   $0x3a,%eax,%eax
sub    %eax,%edx
movzwl %dx,%eax
mov    (%rax,%rsi,1),%al
mov    %al,0x5(%rsp)
movabs $0xab46fc5bb65f9097,%rcx
fc 46 ab
mov    %rdi,%rax
mul    %rcx
shr    $0x3a,%rdx
mov    %rdx,0x10(%rsp)
lea    0xc85(%rip),%rdi
lea    0x5(%rsp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret
lea    0xc1d(%rip),%rdi
jmp    13f9 <main+0x299>
lea    0xc19(%rip),%rdi
call   1080 <perror@plt>
jmp    11b5 <main+0x55>

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/urandom\00"
@O_RDONLY = global i32 0
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [5 x i8] c"read\00"
@stderr = global i32 0
@.str.3 = [11 x i8] c"read: EOF\0A\00"
@.str.4 = [59 x i8] c"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\00"
@.str.5 = [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 i32
%7 = alloca [10 x i8]
%8 = alloca [11 x i8]
%9 = alloca i64
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* @O_RDONLY
%12 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 %12, i32* %6
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %47
16: ; preds = %2
%17 = load i32, i32* %6
%18 = bitcast [10 x i8]* %7 to i8**
%19 = call i32 @read(i32 %17, i8** %18, i32 10)
switch i32 %19, label %23 [
i32 10, label %20
i32 -1, label %21
]
20: ; preds = %16
br label %26
21: ; preds = %16
%22 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %47
23: ; preds = %16
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %47
26: ; preds = %20
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 2
%28 = call i32 @memcpy(i64* %9, i8* %27, i32 8)
store i32 10, i32* %10
%29 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 10
store i8 0, i8* %29
br label %30
30: ; preds = %34, %26
%31 = load i32, i32* %10
%32 = add nsw i32 %31, -1
store i32 %32, i32* %10
%33 = icmp ne i32 %31, 0
br i1 %33, label %34, label %44
34: ; preds = %30
%35 = load i64, i64* %9
%36 = urem i64 %35, 58
%37 = getelementptr inbounds [59 x i8], [59 x i8]* @.str.4, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 %40
store i8 %38, i8* %41
%42 = load i64, i64* %9
%43 = udiv i64 %42, 58
store i64 %43, i64* %9
br label %30
44: ; preds = %30
%45 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %45)
store i32 0, i32* %3
br label %47
47: ; preds = %44, %23, %21, %14
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/urandom\00"
@O_RDONLY = global i32 0
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [5 x i8] c"read\00"
@stderr = global i32 0
@.str.3 = [11 x i8] c"read: EOF\0A\00"
@.str.4 = [59 x i8] c"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i8]
%4 = alloca [11 x i8]
%5 = alloca i64
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%8 = bitcast i64* %5 to i8*
%9 = load i32, i32* @O_RDONLY
%10 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %85
14: ; preds = %2
%15 = bitcast [10 x i8]* %3 to i8**
%16 = call i32 @read(i32 %10, i8** %15, i32 10)
switch i32 %16, label %19 [
i32 10, label %22
i32 -1, label %17
]
17: ; preds = %14
%18 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %85
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %85
22: ; preds = %14
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 2
%24 = call i32 @memcpy(i64* %5, i8* %23, i32 8)
%25 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 10
store i8 0, i8* %25
%26 = load i64, i64* %5
%27 = urem i64 %26, 58
%28 = getelementptr inbounds [59 x i8], [59 x i8]* @.str.4, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 9
store i8 %29, i8* %30
%31 = udiv i64 %26, 58
%32 = urem i64 %31, 58
%33 = getelementptr inbounds [59 x i8], [59 x i8]* @.str.4, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 8
store i8 %34, i8* %35
%36 = udiv i64 %26, 3364
%37 = urem i64 %36, 58
%38 = getelementptr inbounds [59 x i8], [59 x i8]* @.str.4, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 7
store i8 %39, i8* %40
%41 = udiv i64 %26, 195112
%42 = urem i64 %41, 58
%43 = getelementptr inbounds [59 x i8], [59 x i8]* @.str.4, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 6
store i8 %44, i8* %45
%46 = udiv i64 %26, 11316496
%47 = urem i64 %46, 58
%48 = getelementptr inbounds [59 x i8], [59 x i8]* @.str.4, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 5
store i8 %49, i8* %50
%51 = udiv i64 %26, 656356768
%52 = urem i64 %51, 58
%53 = getelementptr inbounds [59 x i8], [59 x i8]* @.str.4, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 4
store i8 %54, i8* %55
%56 = udiv i64 %26, 38068692544
%57 = trunc i64 %56 to i32
%58 = urem i32 %57, 58
%59 = zext i32 %58 to i64
%60 = getelementptr inbounds [59 x i8], [59 x i8]* @.str.4, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 3
store i8 %61, i8* %62
%63 = udiv i64 %26, 2207984167552
%64 = trunc i64 %63 to i32
%65 = urem i32 %64, 58
%66 = zext i32 %65 to i64
%67 = getelementptr inbounds [59 x i8], [59 x i8]* @.str.4, i64 0, i64 %66
%68 = load i8, i8* %67
%69 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 2
store i8 %68, i8* %69
%70 = udiv i64 %26, 128063081718016
%71 = trunc i64 %70 to i32
%72 = urem i32 %71, 58
%73 = zext i32 %72 to i64
%74 = getelementptr inbounds [59 x i8], [59 x i8]* @.str.4, i64 0, i64 %73
%75 = load i8, i8* %74
%76 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 1
store i8 %75, i8* %76
%77 = udiv i64 %26, 7427658739644928
%78 = trunc i64 %77 to i16
%79 = urem i16 %78, 58
%80 = zext i16 %79 to i64
%81 = getelementptr inbounds [59 x i8], [59 x i8]* @.str.4, i64 0, i64 %80
%82 = load i8, i8* %81
store i8 %82, i8* %7
%83 = udiv i64 %26, 430804206899405824
store i64 %83, i64* %5
%84 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %7)
br label %85
85: ; preds = %22, %19, %17, %12
%86 = phi i32 [ 1, %12 ], [ 1, %19 ], [ 1, %17 ], [ 0, %22 ]
ret i32 %86
}