#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 /*<<< orphan*/ printf(char *, unsigned short, unsigned short,
                          unsigned short);
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);
    printf("\n%d %d %d\n", seedv[0], seedv[1], seedv[2]);
  } else {
    pfseed = fopen("seedms", "w");
    pseed = seed48(seedv);
    fprintf(pfseed, "%d %d %d\n", pseed[0], pseed[1], pseed[2]);
    fclose(pfseed);
  }
}


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    125c <seedit+0xfc>
lea    0xe7d(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b5 <seedit+0x55>
movw   $0xdfb,-0x16(%rbp)
movw   $0x6983,-0x14(%rbp)
movw   $0xe76b,-0x12(%rbp)
jmp    122e <seedit+0xce>
movw   $0xdfb,-0x1c(%rbp)
movw   $0x6983,-0x1a(%rbp)
movw   $0xe76b,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
jge    1225 <seedit+0xc5>
mov    -0x10(%rbp),%rdi
lea    -0x16(%rbp),%rdx
movslq -0x2c(%rbp),%rax
shl    $0x1,%rax
add    %rax,%rdx
lea    0xe17(%rip),%rsi
call   1050 <fscanf@plt>
cmp    $0x1,%eax
jge    1212 <seedit+0xb2>
movslq -0x2c(%rbp),%rax
mov    -0x1c(%rbp,%rax,2),%cx
movslq -0x2c(%rbp),%rax
mov    %cx,-0x16(%rbp,%rax,2)
jmp    1217 <seedit+0xb7>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11ce <seedit+0x6e>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x16(%rbp),%rdi
mov    $0x0,%al
call   1070 <seed48@plt>
mov    -0x16(%rbp),%cx
mov    -0x14(%rbp),%ax
lea    0xdc6(%rip),%rdi
movzwl %cx,%esi
movzwl %ax,%edx
movzwl -0x12(%rbp),%ecx
call   1040 <printf@plt>
jmp    12b3 <seedit+0x153>
lea    0xd9d(%rip),%rdi
lea    0xdaf(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x16(%rbp),%rdi
mov    $0x0,%al
call   1070 <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    0xd6a(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seedit>:
push   %rbx
sub    $0x10,%rsp
cmpb   $0x73,(%rdi)
jne    11f4 <seedit+0x94>
lea    0xe8b(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     123b <seedit+0xdb>
mov    %rax,%rbx
lea    0xe75(%rip),%rsi
lea    0xa(%rsp),%rdx
mov    %rax,%rdi
call   1050 <fscanf@plt>
test   %eax,%eax
jg     11ac <seedit+0x4c>
movw   $0xdfb,0xa(%rsp)
lea    0xc(%rsp),%rdx
lea    0xe51(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fscanf@plt>
test   %eax,%eax
jg     11cb <seedit+0x6b>
movw   $0x6983,0xc(%rsp)
lea    0xe(%rsp),%rdx
lea    0xe32(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fscanf@plt>
test   %eax,%eax
jg     11ea <seedit+0x8a>
movw   $0xe76b,0xe(%rsp)
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    124a <seedit+0xea>
lea    0xe05(%rip),%rdi
lea    0xe17(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xa(%rsp),%rdi
xor    %eax,%eax
call   1070 <seed48@plt>
movzwl (%rax),%edx
movzwl 0x2(%rax),%ecx
movzwl 0x4(%rax),%r8d
lea    0xde6(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    1271 <seedit+0x111>
movl   $0x69830dfb,0xa(%rsp)
69
movw   $0xe76b,0xe(%rsp)
lea    0xa(%rsp),%rdi
xor    %eax,%eax
call   1070 <seed48@plt>
movzwl 0xa(%rsp),%esi
movzwl 0xc(%rsp),%edx
movzwl 0xe(%rsp),%ecx
lea    0xda2(%rip),%rdi
call   1040 <printf@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 = [11 x i8] c"\0A%d %d %d\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [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 %61
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)
%54 = getelementptr inbounds [3 x i16], [3 x i16]* %4, i64 0, i64 0
%55 = load i16, i16* %54
%56 = getelementptr inbounds [3 x i16], [3 x i16]* %4, i64 0, i64 1
%57 = load i16, i16* %56
%58 = getelementptr inbounds [3 x i16], [3 x i16]* %4, i64 0, i64 2
%59 = load i16, i16* %58
%60 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i16 zeroext %55, i16 zeroext %57, i16 zeroext %59)
br label %81
61: ; preds = %1
%62 = 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.4, i64 0, i64 0))
store i32* %62, i32** %3
%63 = getelementptr inbounds [3 x i16], [3 x i16]* %4, i64 0, i64 0
%64 = call i16* (i16*, ...) bitcast (i16* (...)* @seed48 to i16* (i16*, ...)*)(i16* %63)
store i16* %64, i16** %6
%65 = load i32*, i32** %3
%66 = load i16*, i16** %6
%67 = getelementptr inbounds i16, i16* %66, i64 0
%68 = load i16, i16* %67
%69 = zext i16 %68 to i32
%70 = load i16*, i16** %6
%71 = getelementptr inbounds i16, i16* %70, i64 1
%72 = load i16, i16* %71
%73 = zext i16 %72 to i32
%74 = load i16*, i16** %6
%75 = getelementptr inbounds i16, i16* %74, i64 2
%76 = load i16, i16* %75
%77 = zext i16 %76 to i32
%78 = call i32 @fprintf(i32* %65, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %69, i32 %73, i32 %77)
%79 = load i32*, i32** %3
%80 = call i32 @fclose(i32* %79)
br label %81
81: ; preds = %61, %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 = [11 x i8] c"\0A%d %d %d\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [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 %38
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)
%32 = load i16, i16* %30
%33 = getelementptr inbounds [3 x i16], [3 x i16]* %2, i64 0, i64 1
%34 = load i16, i16* %33
%35 = getelementptr inbounds [3 x i16], [3 x i16]* %2, i64 0, i64 2
%36 = load i16, i16* %35
%37 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i16 zeroext %32, i16 zeroext %34, i16 zeroext %36)
br label %52
38: ; preds = %1
%39 = 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.4, i64 0, i64 0))
%40 = getelementptr inbounds [3 x i16], [3 x i16]* %2, i64 0, i64 0
%41 = call i16* (i16*, ...) bitcast (i16* (...)* @seed48 to i16* (i16*, ...)*)(i16* %40)
%42 = load i16, i16* %41
%43 = zext i16 %42 to i32
%44 = getelementptr inbounds i16, i16* %41, i64 1
%45 = load i16, i16* %44
%46 = zext i16 %45 to i32
%47 = getelementptr inbounds i16, i16* %41, i64 2
%48 = load i16, i16* %47
%49 = zext i16 %48 to i32
%50 = call i32 @fprintf(i32* %39, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %43, i32 %46, i32 %49)
%51 = call i32 @fclose(i32* %39)
br label %52
52: ; preds = %38, %29
ret void
}