#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 /*<<< orphan*/ sprintf(char *, char *, int);
char *rng_showstate(int *mystate, char *s) {
  int n, l, lp, *reg;
  l = mystate[1];
  lp = mystate[6];
  reg = &(mystate[(9 + l - 1)]);
  n = (reg[lp] >> 1) & 0x7fffffff;
  sprintf(s, "%.8X...", n);
  return s;
}


x86 assembly (clang, -O0):
<rng_showstate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x9,%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
sar    $0x1,%eax
and    $0x7fffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe8d(%rip),%rsi
call   1030 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rng_showstate>:
push   %rbx
mov    %rsi,%rbx
movslq 0x4(%rdi),%rax
movslq 0x18(%rdi),%rcx
lea    (%rdi,%rax,4),%rax
mov    0x20(%rax,%rcx,4),%edx
shr    %edx
lea    0xed3(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%.8X...\00"
define i8* @rng_showstate(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i32* %0, i32** %3
store i8* %1, i8** %4
%9 = load i32*, i32** %3
%10 = getelementptr inbounds i32, i32* %9, i64 1
%11 = load i32, i32* %10
store i32 %11, i32* %6
%12 = load i32*, i32** %3
%13 = getelementptr inbounds i32, i32* %12, i64 6
%14 = load i32, i32* %13
store i32 %14, i32* %7
%15 = load i32*, i32** %3
%16 = load i32, i32* %6
%17 = add nsw i32 9, %16
%18 = sub nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %15, i64 %19
store i32* %20, i32** %8
%21 = load i32*, i32** %8
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = ashr i32 %25, 1
%27 = and i32 %26, 2147483647
store i32 %27, i32* %5
%28 = load i8*, i8** %4
%29 = load i32, i32* %5
%30 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = load i8*, i8** %4
ret i8* %31
}

LLVM IR (-O2):
@.str = [8 x i8] c"%.8X...\00"
define i8* @rng_showstate(i32* nocapture %0, i8* returned writeonly %1) {
%3 = getelementptr inbounds i32, i32* %0, i64 1
%4 = load i32, i32* %3
%5 = getelementptr inbounds i32, i32* %0, i64 6
%6 = load i32, i32* %5
%7 = add nsw i32 %4, 8
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = sext i32 %6 to i64
%11 = getelementptr inbounds i32, i32* %9, i64 %10
%12 = load i32, i32* %11
%13 = lshr i32 %12, 1
%14 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %13)
ret i8* %1
}