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

/* Variables and functions */
char EOF;
scalar_t__ abs(char);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ gmp_randseed_ui(int /*<<< orphan*/, unsigned long);
void random_seeding(gmp_randstate_t r_state) {
  FILE *ran = fopen("/dev/urandom", "r");
  char i1, i2, i3, i4;
  i1 = fgetc(ran);
  if (i1 == EOF)
    goto end;
  i2 = fgetc(ran);
  if (i2 == EOF)
    goto end;
  i3 = fgetc(ran);
  if (i3 == EOF)
    goto end;
  i4 = fgetc(ran);
  if (i4 == EOF)
    goto end;
  gmp_randseed_ui(r_state, (unsigned long int)abs(i1) *
                               (unsigned long int)abs(i2 * i3 * i4));
end:
  fclose(ran);
}


x86 assembly (clang, -O0):
<random_seeding>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe9e(%rip),%rdi
lea    0xea4(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    0x2e5f(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1199 <random_seeding+0x49>
jmp    124b <random_seeding+0xfb>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x12(%rbp)
movsbl -0x12(%rbp),%eax
mov    0x2e38(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11c0 <random_seeding+0x70>
jmp    124b <random_seeding+0xfb>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x13(%rbp)
movsbl -0x13(%rbp),%eax
mov    0x2e11(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11e7 <random_seeding+0x97>
jmp    124b <random_seeding+0xfb>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x14(%rbp)
movsbl -0x14(%rbp),%eax
mov    0x2dea(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    120e <random_seeding+0xbe>
jmp    124b <random_seeding+0xfb>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
movsbl -0x11(%rbp),%edi
call   1030 <abs@plt>
mov    %rax,-0x20(%rbp)
movsbl -0x12(%rbp),%eax
movsbl -0x13(%rbp),%ecx
imul   %ecx,%eax
movsbl -0x14(%rbp),%ecx
imul   %ecx,%eax
movsbl %al,%edi
call   1030 <abs@plt>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%edi
imul   %rax,%rsi
call   1070 <gmp_randseed_ui@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_seeding>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0xe9c(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <fgetc@plt>
mov    0x2e66(%rip),%r13
cmp    0x0(%r13),%al
je     11e9 <random_seeding+0x99>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    0x0(%r13),%al
je     11e9 <random_seeding+0x99>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    0x0(%r13),%al
je     11e9 <random_seeding+0x99>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    0x0(%r13),%al
je     11e9 <random_seeding+0x99>
movsbl %r14b,%edi
mov    %eax,%r13d
call   1030 <abs@plt>
mov    %rax,%r14
mov    %r12d,%eax
mul    %r15b
mul    %r13b
movsbl %al,%edi
call   1030 <abs@plt>
imul   %rax,%r14
mov    %ebp,%edi
mov    %r14,%rsi
call   1070 <gmp_randseed_ui@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/urandom\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
define void @random_seeding(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
store i32 %0, i32* %2
%8 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %3
%9 = load i32*, i32** %3
%10 = call signext i8 @fgetc(i32* %9)
store i8 %10, i8* %4
%11 = load i8, i8* %4
%12 = sext i8 %11 to i32
%13 = load i8, i8* @EOF
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %12, %14
br i1 %15, label %16, label %17
16: ; preds = %1
br label %60
17: ; preds = %1
%18 = load i32*, i32** %3
%19 = call signext i8 @fgetc(i32* %18)
store i8 %19, i8* %5
%20 = load i8, i8* %5
%21 = sext i8 %20 to i32
%22 = load i8, i8* @EOF
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %21, %23
br i1 %24, label %25, label %26
25: ; preds = %17
br label %60
26: ; preds = %17
%27 = load i32*, i32** %3
%28 = call signext i8 @fgetc(i32* %27)
store i8 %28, i8* %6
%29 = load i8, i8* %6
%30 = sext i8 %29 to i32
%31 = load i8, i8* @EOF
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %30, %32
br i1 %33, label %34, label %35
34: ; preds = %26
br label %60
35: ; preds = %26
%36 = load i32*, i32** %3
%37 = call signext i8 @fgetc(i32* %36)
store i8 %37, i8* %7
%38 = load i8, i8* %7
%39 = sext i8 %38 to i32
%40 = load i8, i8* @EOF
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %39, %41
br i1 %42, label %43, label %44
43: ; preds = %35
br label %60
44: ; preds = %35
%45 = load i32, i32* %2
%46 = load i8, i8* %4
%47 = call i64 @abs(i8 signext %46)
%48 = load i8, i8* %5
%49 = sext i8 %48 to i32
%50 = load i8, i8* %6
%51 = sext i8 %50 to i32
%52 = mul nsw i32 %49, %51
%53 = load i8, i8* %7
%54 = sext i8 %53 to i32
%55 = mul nsw i32 %52, %54
%56 = trunc i32 %55 to i8
%57 = call i64 @abs(i8 signext %56)
%58 = mul i64 %47, %57
%59 = call i32 @gmp_randseed_ui(i32 %45, i64 %58)
br label %60
60: ; preds = %44, %43, %34, %25, %16
%61 = load i32*, i32** %3
%62 = call i32 @fclose(i32* %61)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/urandom\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
define void @random_seeding(i32 %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call signext i8 @fgetc(i32* %2)
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %25, label %6
6: ; preds = %1
%7 = tail call signext i8 @fgetc(i32* %2)
%8 = load i8, i8* @EOF
%9 = icmp eq i8 %7, %8
br i1 %9, label %25, label %10
10: ; preds = %6
%11 = tail call signext i8 @fgetc(i32* %2)
%12 = load i8, i8* @EOF
%13 = icmp eq i8 %11, %12
br i1 %13, label %25, label %14
14: ; preds = %10
%15 = tail call signext i8 @fgetc(i32* %2)
%16 = load i8, i8* @EOF
%17 = icmp eq i8 %15, %16
br i1 %17, label %25, label %18
18: ; preds = %14
%19 = tail call i64 @abs(i8 signext %3)
%20 = mul i8 %11, %7
%21 = mul i8 %20, %15
%22 = tail call i64 @abs(i8 signext %21)
%23 = mul i64 %22, %19
%24 = tail call i32 @gmp_randseed_ui(i32 %0, i64 %23)
br label %25
25: ; preds = %14, %10, %6, %1, %18
%26 = tail call i32 @fclose(i32* %2)
ret void
}