#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*/ fprintf(int /*<<< orphan*/ *, char *, char const *);
scalar_t__ islower(char const);
scalar_t__ isupper(char const);
int strlen(char const *);
char tolower(char const);
char toupper(char const);
void writepsk(FILE *fhout, const char *pskstring) {
  static bool lflag = false;
  static bool uflag = false;
  static int p, l;
  static char lowerpskstring[64] = {};
  static char upperpskstring[64] = {};
  l = strlen(pskstring);
  if ((l < 8) || (l > 64))
    return;
  fprintf(fhout, "%s\n", pskstring);
  for (p = 0; p < l; p++) {
    if (islower(pskstring[p])) {
      upperpskstring[p] = toupper(pskstring[p]);
      uflag = true;
    } else
      upperpskstring[p] = pskstring[p];
    if (isupper(pskstring[p])) {
      lowerpskstring[p] = tolower(pskstring[p]);
      lflag = true;
    } else
      lowerpskstring[p] = pskstring[p];
  }
  upperpskstring[p] = 0;
  lowerpskstring[p] = 0;
  if (uflag == true)
    fprintf(fhout, "%s\n", upperpskstring);
  if (lflag == true)
    fprintf(fhout, "%s\n", lowerpskstring);
  if ((lowerpskstring[0] >= 'a') && (lowerpskstring[0] <= 'z')) {
    lowerpskstring[0] = toupper(lowerpskstring[0]);
    fprintf(fhout, "%s\n", lowerpskstring);
  }
  return;
}


x86 assembly (clang, -O0):
<writepsk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,0x2eed(%rip)
cmpl   $0x8,0x2ee6(%rip)
jl     1199 <writepsk+0x39>
cmpl   $0x40,0x2ed9(%rip)
jle    119e <writepsk+0x3e>
jmp    1387 <writepsk+0x227>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe53(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,0x2eac(%rip)
mov    0x2ea6(%rip),%eax
cmp    0x2ea4(%rip),%eax
jge    12cd <writepsk+0x16d>
mov    -0x10(%rbp),%rax
movslq 0x2e8f(%rip),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <islower@plt>
cmp    $0x0,%rax
je     1222 <writepsk+0xc2>
mov    -0x10(%rbp),%rax
movslq 0x2e71(%rip),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <toupper@plt>
mov    %al,%dl
movslq 0x2e5f(%rip),%rcx
lea    0x2ea0(%rip),%rax
mov    %dl,(%rax,%rcx,1)
movl   $0x1,0x2e47(%rip)
jmp    1241 <writepsk+0xe1>
mov    -0x10(%rbp),%rax
movslq 0x2e3b(%rip),%rcx
mov    (%rax,%rcx,1),%dl
movslq 0x2e31(%rip),%rcx
lea    0x2e72(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
movslq 0x2e1c(%rip),%rcx
movsbl (%rax,%rcx,1),%edi
call   1080 <isupper@plt>
cmp    $0x0,%rax
je     1295 <writepsk+0x135>
mov    -0x10(%rbp),%rax
movslq 0x2dfe(%rip),%rcx
movsbl (%rax,%rcx,1),%edi
call   1070 <tolower@plt>
mov    %al,%dl
movslq 0x2dec(%rip),%rcx
lea    0x2ded(%rip),%rax
mov    %dl,(%rax,%rcx,1)
movl   $0x1,0x2dd0(%rip)
jmp    12b4 <writepsk+0x154>
mov    -0x10(%rbp),%rax
movslq 0x2dc8(%rip),%rcx
mov    (%rax,%rcx,1),%dl
movslq 0x2dbe(%rip),%rcx
lea    0x2dbf(%rip),%rax
mov    %dl,(%rax,%rcx,1)
jmp    12b9 <writepsk+0x159>
mov    0x2da9(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2da0(%rip)
jmp    11bc <writepsk+0x5c>
movslq 0x2d94(%rip),%rcx
lea    0x2dd5(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
movslq 0x2d82(%rip),%rcx
lea    0x2d83(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
cmpl   $0x1,0x2d6c(%rip)
jne    1315 <writepsk+0x1b5>
mov    -0x8(%rbp),%rdi
lea    0xcf7(%rip),%rsi
lea    0x2da0(%rip),%rdx
call   1060 <fprintf@plt>
cmpl   $0x1,0x2d44(%rip)
jne    1339 <writepsk+0x1d9>
mov    -0x8(%rbp),%rdi
lea    0xcd3(%rip),%rsi
lea    0x2d3c(%rip),%rdx
call   1060 <fprintf@plt>
movsbl 0x2d30(%rip),%eax
cmp    $0x61,%eax
jl     1382 <writepsk+0x222>
movsbl 0x2d20(%rip),%eax
cmp    $0x7a,%eax
jg     1382 <writepsk+0x222>
movsbl 0x2d10(%rip),%edi
call   1040 <toupper@plt>
mov    %al,0x2d05(%rip)
mov    -0x8(%rbp),%rdi
lea    0xc8a(%rip),%rsi
lea    0x2cf3(%rip),%rdx
call   1060 <fprintf@plt>
jmp    1387 <writepsk+0x227>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writepsk>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <strlen@plt>
mov    %eax,0x2ef0(%rip)
add    $0xffffffbf,%eax
cmp    $0xffffffc7,%eax
jb     12f2 <writepsk+0x192>
lea    0xe71(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
movl   $0x0,0x2ec4(%rip)
xor    %ecx,%ecx
cmpl   $0x0,0x2ebf(%rip)
jle    1261 <writepsk+0x101>
lea    0x2ef6(%rip),%r15
lea    0x2eaf(%rip),%r12
jmp    11e5 <writepsk+0x85>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %dl,(%rsi,%r12,1)
add    $0x1,%ecx
mov    %ecx,0x2e8b(%rip)
cmp    0x2e89(%rip),%ecx
jge    125e <writepsk+0xfe>
movslq %ecx,%rax
movsbl (%rbx,%rax,1),%edi
call   1030 <islower@plt>
movslq 0x2e70(%rip),%rcx
movzbl (%rbx,%rcx,1),%edx
test   %rax,%rax
je     1220 <writepsk+0xc0>
movsbl %dl,%edi
call   1040 <toupper@plt>
movslq 0x2e58(%rip),%rcx
mov    %al,(%rcx,%r15,1)
movb   $0x1,0x2e49(%rip)
jmp    1224 <writepsk+0xc4>
nopl   (%rax)
mov    %dl,(%rcx,%r15,1)
movsbl (%rbx,%rcx,1),%edi
call   1080 <isupper@plt>
mov    0x2e35(%rip),%ecx
movslq %ecx,%rsi
movzbl (%rbx,%rsi,1),%edx
test   %rax,%rax
je     11d0 <writepsk+0x70>
movsbl %dl,%edi
call   1070 <tolower@plt>
movslq 0x2e1a(%rip),%rcx
mov    %al,(%rcx,%r12,1)
movb   $0x1,0x2e07(%rip)
jmp    11d4 <writepsk+0x74>
movslq %ecx,%rcx
lea    0x2e48(%rip),%rax
movb   $0x0,(%rcx,%rax,1)
lea    0x2dfd(%rip),%rax
movb   $0x0,(%rcx,%rax,1)
cmpb   $0x1,0x2de6(%rip)
jne    1296 <writepsk+0x136>
lea    0xd79(%rip),%rsi
lea    0x2e22(%rip),%rdx
mov    %r14,%rdi
call   1060 <fprintf@plt>
cmpb   $0x1,0x2dc3(%rip)
jne    12b5 <writepsk+0x155>
lea    0xd5a(%rip),%rsi
lea    0x2dc3(%rip),%rdx
mov    %r14,%rdi
call   1060 <fprintf@plt>
mov    0x2db5(%rip),%al
lea    -0x61(%rax),%ecx
cmp    $0x19,%cl
ja     12f2 <writepsk+0x192>
movsbl %al,%edi
call   1040 <toupper@plt>
mov    %al,0x2d9f(%rip)
lea    0x2d98(%rip),%rdx
lea    0xd21(%rip),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <fprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@writepsk.lflag = internal global i32 0
@writepsk.uflag = internal global i32 0
@writepsk.p = internal global i32 0
@writepsk.l = internal global i32 0
@writepsk.lowerpskstring = internal global [64 x i8] zeroinitializer
@writepsk.upperpskstring = internal global [64 x i8] zeroinitializer
@.str = [4 x i8] c"%s\0A\00"
define void @writepsk(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* @writepsk.l
%7 = load i32, i32* @writepsk.l
%8 = icmp slt i32 %7, 8
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* @writepsk.l
%11 = icmp sgt i32 %10, 64
br i1 %11, label %12, label %13
12: ; preds = %9, %2
br label %111
13: ; preds = %9
%14 = load i32*, i32** %3
%15 = load i8*, i8** %4
%16 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 0, i32* @writepsk.p
br label %17
17: ; preds = %76, %13
%18 = load i32, i32* @writepsk.p
%19 = load i32, i32* @writepsk.l
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %79
21: ; preds = %17
%22 = load i8*, i8** %4
%23 = load i32, i32* @writepsk.p
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = call i64 @islower(i8 signext %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %39
29: ; preds = %21
%30 = load i8*, i8** %4
%31 = load i32, i32* @writepsk.p
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = call signext i8 @toupper(i8 signext %34)
%36 = load i32, i32* @writepsk.p
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [64 x i8], [64 x i8]* @writepsk.upperpskstring, i64 0, i64 %37
store i8 %35, i8* %38
store i32 1, i32* @writepsk.uflag
br label %48
39: ; preds = %21
%40 = load i8*, i8** %4
%41 = load i32, i32* @writepsk.p
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = load i32, i32* @writepsk.p
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [64 x i8], [64 x i8]* @writepsk.upperpskstring, i64 0, i64 %46
store i8 %44, i8* %47
br label %48
48: ; preds = %39, %29
%49 = load i8*, i8** %4
%50 = load i32, i32* @writepsk.p
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
%54 = call i64 @isupper(i8 signext %53)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %66
56: ; preds = %48
%57 = load i8*, i8** %4
%58 = load i32, i32* @writepsk.p
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
%61 = load i8, i8* %60
%62 = call signext i8 @tolower(i8 signext %61)
%63 = load i32, i32* @writepsk.p
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 %64
store i8 %62, i8* %65
store i32 1, i32* @writepsk.lflag
br label %75
66: ; preds = %48
%67 = load i8*, i8** %4
%68 = load i32, i32* @writepsk.p
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
%71 = load i8, i8* %70
%72 = load i32, i32* @writepsk.p
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 %73
store i8 %71, i8* %74
br label %75
75: ; preds = %66, %56
br label %76
76: ; preds = %75
%77 = load i32, i32* @writepsk.p
%78 = add nsw i32 %77, 1
store i32 %78, i32* @writepsk.p
br label %17
79: ; preds = %17
%80 = load i32, i32* @writepsk.p
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [64 x i8], [64 x i8]* @writepsk.upperpskstring, i64 0, i64 %81
store i8 0, i8* %82
%83 = load i32, i32* @writepsk.p
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 %84
store i8 0, i8* %85
%86 = load i32, i32* @writepsk.uflag
%87 = icmp eq i32 %86, 1
br i1 %87, label %88, label %91
88: ; preds = %79
%89 = load i32*, i32** %3
%90 = call i32 @fprintf(i32* %89, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([64 x i8], [64 x i8]* @writepsk.upperpskstring, i64 0, i64 0))
br label %91
91: ; preds = %88, %79
%92 = load i32, i32* @writepsk.lflag
%93 = icmp eq i32 %92, 1
br i1 %93, label %94, label %97
94: ; preds = %91
%95 = load i32*, i32** %3
%96 = call i32 @fprintf(i32* %95, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 0))
br label %97
97: ; preds = %94, %91
%98 = load i8, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 0)
%99 = sext i8 %98 to i32
%100 = icmp sge i32 %99, 97
br i1 %100, label %101, label %110
101: ; preds = %97
%102 = load i8, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 0)
%103 = sext i8 %102 to i32
%104 = icmp sle i32 %103, 122
br i1 %104, label %105, label %110
105: ; preds = %101
%106 = load i8, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 0)
%107 = call signext i8 @toupper(i8 signext %106)
store i8 %107, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 0)
%108 = load i32*, i32** %3
%109 = call i32 @fprintf(i32* %108, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 0))
br label %110
110: ; preds = %105, %101, %97
br label %111
111: ; preds = %110, %12
ret void
}

LLVM IR (-O2):
@writepsk.lflag = internal unnamed_addr global i1 false
@writepsk.uflag = internal unnamed_addr global i1 false
@writepsk.p = internal unnamed_addr global i32 0
@writepsk.l = internal unnamed_addr global i32 0
@writepsk.lowerpskstring = internal global [64 x i8] zeroinitializer
@writepsk.upperpskstring = internal global [64 x i8] zeroinitializer
@.str = [4 x i8] c"%s\0A\00"
define void @writepsk(i32* nocapture %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
store i32 %3, i32* @writepsk.l
%4 = add i32 %3, -65
%5 = icmp ult i32 %4, -57
br i1 %5, label %70, label %6
6: ; preds = %2
%7 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
store i32 0, i32* @writepsk.p
%8 = load i32, i32* @writepsk.l
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %52
10: ; preds = %6, %45
%11 = phi i32 [ %47, %45 ], [ 0, %6 ]
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = load i8, i8* %13
%15 = tail call i64 @islower(i8 signext %14)
%16 = icmp eq i64 %15, 0
%17 = load i32, i32* @writepsk.p
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %1, i64 %18
%20 = load i8, i8* %19
br i1 %16, label %26, label %21
21: ; preds = %10
%22 = tail call signext i8 @toupper(i8 signext %20)
%23 = load i32, i32* @writepsk.p
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [64 x i8], [64 x i8]* @writepsk.upperpskstring, i64 0, i64 %24
store i8 %22, i8* %25
store i1 true, i1* @writepsk.uflag
br label %28
26: ; preds = %10
%27 = getelementptr inbounds [64 x i8], [64 x i8]* @writepsk.upperpskstring, i64 0, i64 %18
store i8 %20, i8* %27
br label %28
28: ; preds = %26, %21
%29 = phi i64 [ %18, %26 ], [ %24, %21 ]
%30 = getelementptr inbounds i8, i8* %1, i64 %29
%31 = load i8, i8* %30
%32 = tail call i64 @isupper(i8 signext %31)
%33 = icmp eq i64 %32, 0
%34 = load i32, i32* @writepsk.p
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %1, i64 %35
%37 = load i8, i8* %36
br i1 %33, label %43, label %38
38: ; preds = %28
%39 = tail call signext i8 @tolower(i8 signext %37)
%40 = load i32, i32* @writepsk.p
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 %41
store i8 %39, i8* %42
store i1 true, i1* @writepsk.lflag
br label %45
43: ; preds = %28
%44 = getelementptr inbounds [64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 %35
store i8 %37, i8* %44
br label %45
45: ; preds = %38, %43
%46 = phi i32 [ %40, %38 ], [ %34, %43 ]
%47 = add nsw i32 %46, 1
store i32 %47, i32* @writepsk.p
%48 = load i32, i32* @writepsk.l
%49 = icmp slt i32 %47, %48
br i1 %49, label %10, label %50
50: ; preds = %45
%51 = sext i32 %47 to i64
br label %52
52: ; preds = %50, %6
%53 = phi i64 [ 0, %6 ], [ %51, %50 ]
%54 = getelementptr inbounds [64 x i8], [64 x i8]* @writepsk.upperpskstring, i64 0, i64 %53
store i8 0, i8* %54
%55 = getelementptr inbounds [64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 %53
store i8 0, i8* %55
%56 = load i1, i1* @writepsk.uflag
br i1 %56, label %57, label %59
57: ; preds = %52
%58 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([64 x i8], [64 x i8]* @writepsk.upperpskstring, i64 0, i64 0))
br label %59
59: ; preds = %57, %52
%60 = load i1, i1* @writepsk.lflag
br i1 %60, label %61, label %63
61: ; preds = %59
%62 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 0))
br label %63
63: ; preds = %61, %59
%64 = load i8, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 0)
%65 = add i8 %64, -97
%66 = icmp ult i8 %65, 26
br i1 %66, label %67, label %70
67: ; preds = %63
%68 = tail call signext i8 @toupper(i8 signext %64)
store i8 %68, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 0)
%69 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([64 x i8], [64 x i8]* @writepsk.lowerpskstring, i64 0, i64 0))
br label %70
70: ; preds = %63, %67, %2
ret void
}