#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, int);
int fscanf(int /*<<< orphan*/ *, char *, unsigned short *);
int /*<<< orphan*/ *pfseed;
int *pseed;
void seedit(char *flag) {
  FILE *fopen(), *pfseed;
  unsigned short seedv[3], seedv2[3], *seed48(), *pseed;
  int i;
  if (flag[0] == 's') {
    pfseed = fopen("seedms", "r");
    if (pfseed == NULL) {
      seedv[0] = 3579;
      seedv[1] = 27011;
      seedv[2] = 59243;
    } else {
      seedv2[0] = 3579;
      seedv2[1] = 27011;
      seedv2[2] = 59243;
      for (i = 0; i < 3; i++) {
        if (fscanf(pfseed, " %hd", seedv + i) < 1)
          seedv[i] = seedv2[i];
      }
      fclose(pfseed);
    }
    seed48(seedv);
  } else {
    pfseed = fopen("seedms", "w");
    pseed = seed48(seedv);
    fprintf(pfseed, "%d %d %d\n", pseed[0], pseed[1], pseed[2]);
  }
}


x86 assembly (clang, -O0):
<seedit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x73,%eax
jne    122e <seedit+0xde>
lea    0xe8d(%rip),%rdi
lea    0xe8d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a5 <seedit+0x55>
movw   $0xdfb,-0x16(%rbp)
movw   $0x6983,-0x14(%rbp)
movw   $0xe76b,-0x12(%rbp)
jmp    121e <seedit+0xce>
movw   $0xdfb,-0x1c(%rbp)
movw   $0x6983,-0x1a(%rbp)
movw   $0xe76b,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
jge    1215 <seedit+0xc5>
mov    -0x10(%rbp),%rdi
lea    -0x16(%rbp),%rdx
movslq -0x2c(%rbp),%rax
shl    $0x1,%rax
add    %rax,%rdx
lea    0xe27(%rip),%rsi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jge    1202 <seedit+0xb2>
movslq -0x2c(%rbp),%rax
mov    -0x1c(%rbp,%rax,2),%cx
movslq -0x2c(%rbp),%rax
mov    %cx,-0x16(%rbp,%rax,2)
jmp    1207 <seedit+0xb7>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11be <seedit+0x6e>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x16(%rbp),%rdi
mov    $0x0,%al
call   1060 <seed48@plt>
jmp    127c <seedit+0x12c>
lea    0xdcb(%rip),%rdi
lea    0xdd2(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x16(%rbp),%rdi
mov    $0x0,%al
call   1060 <seed48@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rax
movzwl (%rax),%edx
mov    -0x28(%rbp),%rax
movzwl 0x2(%rax),%ecx
mov    -0x28(%rbp),%rax
movzwl 0x4(%rax),%r8d
lea    0xd99(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seedit>:
push   %rbx
sub    $0x10,%rsp
cmpb   $0x73,(%rdi)
jne    11e4 <seedit+0x94>
lea    0xe9b(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1223 <seedit+0xd3>
mov    %rax,%rbx
lea    0xe85(%rip),%rsi
lea    0xa(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
test   %eax,%eax
jg     119c <seedit+0x4c>
movw   $0xdfb,0xa(%rsp)
lea    0xc(%rsp),%rdx
lea    0xe61(%rip),%rsi
mov    %rbx,%rdi
call   1040 <fscanf@plt>
test   %eax,%eax
jg     11bb <seedit+0x6b>
movw   $0x6983,0xc(%rsp)
lea    0xe(%rsp),%rdx
lea    0xe42(%rip),%rsi
mov    %rbx,%rdi
call   1040 <fscanf@plt>
test   %eax,%eax
jg     11da <seedit+0x8a>
movw   $0xe76b,0xe(%rsp)
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    1232 <seedit+0xe2>
lea    0xe15(%rip),%rdi
lea    0xe1c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xa(%rsp),%rdi
xor    %eax,%eax
call   1060 <seed48@plt>
movzwl (%rax),%edx
movzwl 0x2(%rax),%ecx
movzwl 0x4(%rax),%r8d
lea    0xdf7(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fprintf@plt>
jmp    123e <seedit+0xee>
movl   $0x69830dfb,0xa(%rsp)
69
movw   $0xe76b,0xe(%rsp)
lea    0xa(%rsp),%rdi
xor    %eax,%eax
call   1060 <seed48@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"seedms\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c" %hd\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [10 x i8] c"%d %d %d\0A\00"
@pfseed = global i32* null
@pseed = global i32* null
define void @seedit(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [3 x i16]
%5 = alloca [3 x i16]
%6 = alloca i16*
%7 = alloca i32
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 115
br i1 %12, label %13, label %54
13: ; preds = %1
%14 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %3
%15 = load i32*, i32** %3
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = getelementptr inbounds [3 x i16], [3 x i16]* %4, i64 0, i64 0
store i16 3579, i16* %18
%19 = getelementptr inbounds [3 x i16], [3 x i16]* %4, i64 0, i64 1
store i16 27011, i16* %19
%20 = getelementptr inbounds [3 x i16], [3 x i16]* %4, i64 0, i64 2
store i16 -6293, i16* %20
br label %51
21: ; preds = %13
%22 = getelementptr inbounds [3 x i16], [3 x i16]* %5, i64 0, i64 0
store i16 3579, i16* %22
%23 = getelementptr inbounds [3 x i16], [3 x i16]* %5, i64 0, i64 1
store i16 27011, i16* %23
%24 = getelementptr inbounds [3 x i16], [3 x i16]* %5, i64 0, i64 2
store i16 -6293, i16* %24
store i32 0, i32* %7
br label %25
25: ; preds = %45, %21
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 3
br i1 %27, label %28, label %48
28: ; preds = %25
%29 = load i32*, i32** %3
%30 = getelementptr inbounds [3 x i16], [3 x i16]* %4, i64 0, i64 0
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i16, i16* %30, i64 %32
%34 = call i32 @fscanf(i32* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i16* %33)
%35 = icmp slt i32 %34, 1
br i1 %35, label %36, label %44
36: ; preds = %28
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [3 x i16], [3 x i16]* %5, i64 0, i64 %38
%40 = load i16, i16* %39
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [3 x i16], [3 x i16]* %4, i64 0, i64 %42
store i16 %40, i16* %43
br label %44
44: ; preds = %36, %28
br label %45
45: ; preds = %44
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %25
48: ; preds = %25
%49 = load i32*, i32** %3
%50 = call i32 @fclose(i32* %49)
br label %51
51: ; preds = %48, %17
%52 = getelementptr inbounds [3 x i16], [3 x i16]* %4, i64 0, i64 0
%53 = call i16* (i16*, ...) bitcast (i16* (...)* @seed48 to i16* (i16*, ...)*)(i16* %52)
br label %72
54: ; preds = %1
%55 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %55, i32** %3
%56 = getelementptr inbounds [3 x i16], [3 x i16]* %4, i64 0, i64 0
%57 = call i16* (i16*, ...) bitcast (i16* (...)* @seed48 to i16* (i16*, ...)*)(i16* %56)
store i16* %57, i16** %6
%58 = load i32*, i32** %3
%59 = load i16*, i16** %6
%60 = getelementptr inbounds i16, i16* %59, i64 0
%61 = load i16, i16* %60
%62 = zext i16 %61 to i32
%63 = load i16*, i16** %6
%64 = getelementptr inbounds i16, i16* %63, i64 1
%65 = load i16, i16* %64
%66 = zext i16 %65 to i32
%67 = load i16*, i16** %6
%68 = getelementptr inbounds i16, i16* %67, i64 2
%69 = load i16, i16* %68
%70 = zext i16 %69 to i32
%71 = call i32 @fprintf(i32* %58, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %62, i32 %66, i32 %70)
br label %72
72: ; preds = %54, %51
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"seedms\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c" %hd\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [10 x i8] c"%d %d %d\0A\00"
@pfseed = global i32* null
@pseed = global i32* null
define void @seedit(i8* nocapture %0) {
%2 = alloca [3 x i16]
%3 = bitcast [3 x i16]* %2 to i8*
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 115
br i1 %5, label %6, label %32
6: ; preds = %1
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
%9 = getelementptr inbounds [3 x i16], [3 x i16]* %2, i64 0, i64 0
br i1 %8, label %10, label %13
10: ; preds = %6
store i16 3579, i16* %9
%11 = getelementptr inbounds [3 x i16], [3 x i16]* %2, i64 0, i64 1
store i16 27011, i16* %11
%12 = getelementptr inbounds [3 x i16], [3 x i16]* %2, i64 0, i64 2
store i16 -6293, i16* %12
br label %29
13: ; preds = %6
%14 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i16* %9)
%15 = icmp slt i32 %14, 1
br i1 %15, label %16, label %17
16: ; preds = %13
store i16 3579, i16* %9
br label %17
17: ; preds = %13, %16
%18 = getelementptr inbounds [3 x i16], [3 x i16]* %2, i64 0, i64 1
%19 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i16* %18)
%20 = icmp slt i32 %19, 1
br i1 %20, label %21, label %22
21: ; preds = %17
store i16 27011, i16* %18
br label %22
22: ; preds = %21, %17
%23 = getelementptr inbounds [3 x i16], [3 x i16]* %2, i64 0, i64 2
%24 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i16* %23)
%25 = icmp slt i32 %24, 1
br i1 %25, label %26, label %27
26: ; preds = %22
store i16 -6293, i16* %23
br label %27
27: ; preds = %26, %22
%28 = call i32 @fclose(i32* %7)
br label %29
29: ; preds = %27, %10
%30 = getelementptr inbounds [3 x i16], [3 x i16]* %2, i64 0, i64 0
%31 = call i16* (i16*, ...) bitcast (i16* (...)* @seed48 to i16* (i16*, ...)*)(i16* %30)
br label %45
32: ; preds = %1
%33 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%34 = getelementptr inbounds [3 x i16], [3 x i16]* %2, i64 0, i64 0
%35 = call i16* (i16*, ...) bitcast (i16* (...)* @seed48 to i16* (i16*, ...)*)(i16* %34)
%36 = load i16, i16* %35
%37 = zext i16 %36 to i32
%38 = getelementptr inbounds i16, i16* %35, i64 1
%39 = load i16, i16* %38
%40 = zext i16 %39 to i32
%41 = getelementptr inbounds i16, i16* %35, i64 2
%42 = load i16, i16* %41
%43 = zext i16 %42 to i32
%44 = call i32 @fprintf(i32* %33, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %37, i32 %40, i32 %43)
br label %45
45: ; preds = %32, %29
ret void
}