#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 rand();
char getValue(int s) {
  char c;
  int idx;
  int l;
  int o;
  int type = rand() % s;
  switch (type) {
  case 0:
    l = 10;
    o = 48;
    break;
  case 1:
    l = 26;
    o = 97;
    break;
  case 2:
    l = 26;
    o = 65;
    break;
  case 3:
    l = 15;
    o = 33;
    break;
  default:
    l = 26;
    o = 97;
  }
  return rand() % l + o;
}


x86 assembly (clang, -O0):
<getValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
call   1030 <rand@plt>
mov    -0x4(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x3,%rax
ja     119c <getValue+0x8c>
mov    -0x20(%rbp),%rax
lea    0xeb9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xa,-0x10(%rbp)
movl   $0x30,-0x14(%rbp)
jmp    11aa <getValue+0x9a>
movl   $0x1a,-0x10(%rbp)
movl   $0x61,-0x14(%rbp)
jmp    11aa <getValue+0x9a>
movl   $0x1a,-0x10(%rbp)
movl   $0x41,-0x14(%rbp)
jmp    11aa <getValue+0x9a>
movl   $0xf,-0x10(%rbp)
movl   $0x21,-0x14(%rbp)
jmp    11aa <getValue+0x9a>
movl   $0x1a,-0x10(%rbp)
movl   $0x61,-0x14(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
cltd
idivl  -0x10(%rbp)
add    -0x14(%rbp),%edx
mov    %dl,%al
movsbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getValue>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
cltd
idiv   %ebx
cmp    $0x3,%edx
ja     113d <getValue+0x2d>
movslq %edx,%rax
lea    0xed2(%rip),%rcx
mov    (%rcx,%rax,4),%ebx
lea    0xed8(%rip),%rcx
mov    (%rcx,%rax,4),%ebp
jmp    1147 <getValue+0x37>
mov    $0x1a,%ebp
mov    $0x61,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
cltd
idiv   %ebp
add    %edx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define signext i8 @getValue(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %2
%8 = call i32 (...) @rand()
%9 = load i32, i32* %2
%10 = srem i32 %8, %9
store i32 %10, i32* %7
%11 = load i32, i32* %7
switch i32 %11, label %16 [
i32 0, label %12
i32 1, label %13
i32 2, label %14
i32 3, label %15
]
12: ; preds = %1
store i32 10, i32* %5
store i32 48, i32* %6
br label %17
13: ; preds = %1
store i32 26, i32* %5
store i32 97, i32* %6
br label %17
14: ; preds = %1
store i32 26, i32* %5
store i32 65, i32* %6
br label %17
15: ; preds = %1
store i32 15, i32* %5
store i32 33, i32* %6
br label %17
16: ; preds = %1
store i32 26, i32* %5
store i32 97, i32* %6
br label %17
17: ; preds = %16, %15, %14, %13, %12
%18 = call i32 (...) @rand()
%19 = load i32, i32* %5
%20 = srem i32 %18, %19
%21 = load i32, i32* %6
%22 = add nsw i32 %20, %21
%23 = trunc i32 %22 to i8
ret i8 %23
}

LLVM IR (-O2):
@switch.table.getValue = [4 x i32] [i32 48, i32 97, i32 65, i32 33]
@switch.table.getValue.1 = [4 x i32] [i32 10, i32 26, i32 26, i32 15]
define signext i8 @getValue(i32 %0) {
%2 = tail call i32 (...) @rand()
%3 = srem i32 %2, %0
%4 = icmp ult i32 %3, 4
br i1 %4, label %5, label %12
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = getelementptr inbounds [4 x i32], [4 x i32]* @switch.table.getValue, i64 0, i64 %6
%8 = load i32, i32* %7
%9 = sext i32 %3 to i64
%10 = getelementptr inbounds [4 x i32], [4 x i32]* @switch.table.getValue.1, i64 0, i64 %9
%11 = load i32, i32* %10
br label %12
12: ; preds = %1, %5
%13 = phi i32 [ %8, %5 ], [ 97, %1 ]
%14 = phi i32 [ %11, %5 ], [ 26, %1 ]
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, %14
%17 = add nsw i32 %16, %13
%18 = trunc i32 %17 to i8
ret i8 %18
}