#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 *);
scalar_t__ isupper(char);
scalar_t__ isxdigit(char);
char tolower(char);
char toupper(char);
void printstraightcapital(FILE *fh_out, int len, char *linein) {
  static int p, px;
  static char lineout[128] = {};
  px = 0;
  for (p = 0; p < len; p++) {
    if (isupper(linein[p])) {
      lineout[p] = tolower(linein[p]);
    } else {
      lineout[p] = linein[p];
    }
    if (isxdigit(lineout[p])) {
      px++;
    }
  }
  lineout[p] = 0;
  if ((p != px) && ((lineout[0] >= 'a') && (lineout[0] <= 'z'))) {
    lineout[0] = toupper(linein[0]);
    fprintf(fh_out, "%s\n", lineout);
  }
  return;
}


x86 assembly (clang, -O0):
<printstraightcapital>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,0x2ef7(%rip)
movl   $0x0,0x2ee9(%rip)
mov    0x2ee3(%rip),%eax
cmp    -0xc(%rbp),%eax
jge    1238 <printstraightcapital+0xe8>
mov    -0x18(%rbp),%rax
movslq 0x2ecf(%rip),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <isupper@plt>
cmp    $0x0,%rax
je     11d0 <printstraightcapital+0x80>
mov    -0x18(%rbp),%rax
movslq 0x2eb1(%rip),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <tolower@plt>
mov    %al,%dl
movslq 0x2e9f(%rip),%rcx
lea    0x2ea8(%rip),%rax
mov    %dl,(%rax,%rcx,1)
jmp    11ef <printstraightcapital+0x9f>
mov    -0x18(%rbp),%rax
movslq 0x2e85(%rip),%rcx
mov    (%rax,%rcx,1),%dl
movslq 0x2e7b(%rip),%rcx
lea    0x2e84(%rip),%rax
mov    %dl,(%rax,%rcx,1)
movslq 0x2e6a(%rip),%rcx
lea    0x2e73(%rip),%rax
movsbl (%rax,%rcx,1),%edi
call   1070 <isxdigit@plt>
cmp    $0x0,%rax
je     121f <printstraightcapital+0xcf>
mov    0x2e4e(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e45(%rip)
jmp    1224 <printstraightcapital+0xd4>
mov    0x2e36(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e2d(%rip)
jmp    1177 <printstraightcapital+0x27>
movslq 0x2e21(%rip),%rcx
lea    0x2e2a(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
mov    0x2e10(%rip),%eax
cmp    0x2e0e(%rip),%eax
je     12a5 <printstraightcapital+0x155>
movsbl 0x2e0d(%rip),%eax
cmp    $0x61,%eax
jl     12a5 <printstraightcapital+0x155>
movsbl 0x2dfd(%rip),%eax
cmp    $0x7a,%eax
jg     12a5 <printstraightcapital+0x155>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,0x2de2(%rip)
mov    -0x8(%rbp),%rdi
lea    0xd67(%rip),%rsi
lea    0x2dd0(%rip),%rdx
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printstraightcapital>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rdi,%r14
movl   $0x0,0x2efd(%rip)
movl   $0x0,0x2eef(%rip)
test   %esi,%esi
jle    11f2 <printstraightcapital+0xa2>
mov    %esi,%ebp
xor    %eax,%eax
lea    0x2ef0(%rip),%r15
jmp    11a3 <printstraightcapital+0x53>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x2eca(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ec1(%rip)
cmp    %ebp,%eax
jge    11ea <printstraightcapital+0x9a>
cltq
movsbl (%rbx,%rax,1),%edi
call   1060 <isupper@plt>
mov    %rax,%rcx
movslq 0x2ea8(%rip),%rdx
movzbl (%rbx,%rdx,1),%eax
test   %rcx,%rcx
je     11d0 <printstraightcapital+0x80>
movsbl %al,%edi
call   1050 <tolower@plt>
movslq 0x2e90(%rip),%rdx
mov    %al,(%rdx,%r15,1)
movsbl %al,%edi
call   1070 <isxdigit@plt>
test   %rax,%rax
je     1190 <printstraightcapital+0x40>
addl   $0x1,0x2e7c(%rip)
jmp    1190 <printstraightcapital+0x40>
mov    0x2e74(%rip),%ecx
jmp    11f6 <printstraightcapital+0xa6>
xor    %ecx,%ecx
xor    %eax,%eax
cltq
lea    0x2e71(%rip),%rdx
movb   $0x0,(%rax,%rdx,1)
cmp    %ecx,%eax
je     1243 <printstraightcapital+0xf3>
mov    0x2e63(%rip),%al
cmp    $0x61,%al
jl     1243 <printstraightcapital+0xf3>
cmp    $0x7a,%al
jg     1243 <printstraightcapital+0xf3>
movsbl (%rbx),%edi
call   1030 <toupper@plt>
mov    %al,0x2e4d(%rip)
lea    0x2e46(%rip),%rdx
lea    0xdcf(%rip),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@printstraightcapital.p = internal global i32 0
@printstraightcapital.px = internal global i32 0
@printstraightcapital.lineout = internal global [128 x i8] zeroinitializer
@.str = [4 x i8] c"%s\0A\00"
define void @printstraightcapital(i32* %0, i32 %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
store i32* %0, i32** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 0, i32* @printstraightcapital.px
store i32 0, i32* @printstraightcapital.p
br label %7
7: ; preds = %49, %3
%8 = load i32, i32* @printstraightcapital.p
%9 = load i32, i32* %5
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %52
11: ; preds = %7
%12 = load i8*, i8** %6
%13 = load i32, i32* @printstraightcapital.p
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = call i64 @isupper(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %11
%20 = load i8*, i8** %6
%21 = load i32, i32* @printstraightcapital.p
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = call signext i8 @tolower(i8 signext %24)
%26 = load i32, i32* @printstraightcapital.p
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [128 x i8], [128 x i8]* @printstraightcapital.lineout, i64 0, i64 %27
store i8 %25, i8* %28
br label %38
29: ; preds = %11
%30 = load i8*, i8** %6
%31 = load i32, i32* @printstraightcapital.p
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = load i32, i32* @printstraightcapital.p
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [128 x i8], [128 x i8]* @printstraightcapital.lineout, i64 0, i64 %36
store i8 %34, i8* %37
br label %38
38: ; preds = %29, %19
%39 = load i32, i32* @printstraightcapital.p
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [128 x i8], [128 x i8]* @printstraightcapital.lineout, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = call i64 @isxdigit(i8 signext %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %38
%46 = load i32, i32* @printstraightcapital.px
%47 = add nsw i32 %46, 1
store i32 %47, i32* @printstraightcapital.px
br label %48
48: ; preds = %45, %38
br label %49
49: ; preds = %48
%50 = load i32, i32* @printstraightcapital.p
%51 = add nsw i32 %50, 1
store i32 %51, i32* @printstraightcapital.p
br label %7
52: ; preds = %7
%53 = load i32, i32* @printstraightcapital.p
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [128 x i8], [128 x i8]* @printstraightcapital.lineout, i64 0, i64 %54
store i8 0, i8* %55
%56 = load i32, i32* @printstraightcapital.p
%57 = load i32, i32* @printstraightcapital.px
%58 = icmp ne i32 %56, %57
br i1 %58, label %59, label %74
59: ; preds = %52
%60 = load i8, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @printstraightcapital.lineout, i64 0, i64 0)
%61 = sext i8 %60 to i32
%62 = icmp sge i32 %61, 97
br i1 %62, label %63, label %74
63: ; preds = %59
%64 = load i8, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @printstraightcapital.lineout, i64 0, i64 0)
%65 = sext i8 %64 to i32
%66 = icmp sle i32 %65, 122
br i1 %66, label %67, label %74
67: ; preds = %63
%68 = load i8*, i8** %6
%69 = getelementptr inbounds i8, i8* %68, i64 0
%70 = load i8, i8* %69
%71 = call signext i8 @toupper(i8 signext %70)
store i8 %71, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @printstraightcapital.lineout, i64 0, i64 0)
%72 = load i32*, i32** %4
%73 = call i32 @fprintf(i32* %72, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([128 x i8], [128 x i8]* @printstraightcapital.lineout, i64 0, i64 0))
br label %74
74: ; preds = %67, %63, %59, %52
ret void
}

LLVM IR (-O2):
@printstraightcapital.p = internal unnamed_addr global i32 0
@printstraightcapital.px = internal unnamed_addr global i32 0
@printstraightcapital.lineout = internal global [128 x i8] zeroinitializer
@.str = [4 x i8] c"%s\0A\00"
define void @printstraightcapital(i32* nocapture %0, i32 %1, i8* nocapture %2) {
store i32 0, i32* @printstraightcapital.px
store i32 0, i32* @printstraightcapital.p
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %35
5: ; preds = %3, %29
%6 = phi i32 [ %31, %29 ], [ 0, %3 ]
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %2, i64 %7
%9 = load i8, i8* %8
%10 = tail call i64 @isupper(i8 signext %9)
%11 = icmp eq i64 %10, 0
%12 = load i32, i32* @printstraightcapital.p
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %2, i64 %13
%15 = load i8, i8* %14
br i1 %11, label %20, label %16
16: ; preds = %5
%17 = tail call signext i8 @tolower(i8 signext %15)
%18 = load i32, i32* @printstraightcapital.p
%19 = sext i32 %18 to i64
br label %20
20: ; preds = %5, %16
%21 = phi i64 [ %19, %16 ], [ %13, %5 ]
%22 = phi i8 [ %17, %16 ], [ %15, %5 ]
%23 = getelementptr inbounds [128 x i8], [128 x i8]* @printstraightcapital.lineout, i64 0, i64 %21
store i8 %22, i8* %23
%24 = tail call i64 @isxdigit(i8 signext %22)
%25 = icmp eq i64 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %20
%27 = load i32, i32* @printstraightcapital.px
%28 = add nsw i32 %27, 1
store i32 %28, i32* @printstraightcapital.px
br label %29
29: ; preds = %20, %26
%30 = load i32, i32* @printstraightcapital.p
%31 = add nsw i32 %30, 1
store i32 %31, i32* @printstraightcapital.p
%32 = icmp slt i32 %31, %1
br i1 %32, label %5, label %33
33: ; preds = %29
%34 = load i32, i32* @printstraightcapital.px
br label %35
35: ; preds = %33, %3
%36 = phi i32 [ 0, %3 ], [ %34, %33 ]
%37 = phi i32 [ 0, %3 ], [ %31, %33 ]
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [128 x i8], [128 x i8]* @printstraightcapital.lineout, i64 0, i64 %38
store i8 0, i8* %39
%40 = icmp ne i32 %37, %36
%41 = load i8, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @printstraightcapital.lineout, i64 0, i64 0)
%42 = icmp sgt i8 %41, 96
%43 = select i1 %40, i1 %42, i1 false
%44 = icmp slt i8 %41, 123
%45 = select i1 %43, i1 %44, i1 false
br i1 %45, label %46, label %50
46: ; preds = %35
%47 = load i8, i8* %2
%48 = tail call signext i8 @toupper(i8 signext %47)
store i8 %48, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @printstraightcapital.lineout, i64 0, i64 0)
%49 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([128 x i8], [128 x i8]* @printstraightcapital.lineout, i64 0, i64 0))
br label %50
50: ; preds = %46, %35
ret void
}