#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 wint_t;

/* Variables and functions */
scalar_t__ iswlower(int);
scalar_t__ iswupper(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int towlower(int);
int towupper(int);
int main(int argc, char *argv[]) {
  int result = 0;
  wint_t ch;
  for (ch = 0; ch < 128; ++ch) {
    if (iswlower(ch)) {
      wint_t up = towupper(ch);
      wint_t low = towlower(ch);
      if ((ch != low) || (up == ch) || (up == low)) {
        printf("iswlower/towupper/towlower for character \\%x failed\n", ch);
        result++;
      }
    }
    if (iswupper(ch)) {
      wint_t low = towlower(ch);
      wint_t up = towupper(ch);
      if ((ch != up) || (low == ch) || (up == low)) {
        printf("iswupper/towlower/towupper for character \\%x failed\n", ch);
        result++;
      }
    }
  }
  ch = L'A';
  if (!iswupper(ch) || iswlower(ch)) {
    printf("!iswupper/iswlower (L'A') failed\n");
    result++;
  }
  ch = L'a';
  if (iswupper(ch) || !iswlower(ch)) {
    printf("iswupper/!iswlower (L'a') failed\n");
    result++;
  }
  if (towlower(L'A') != L'a') {
    printf("towlower(L'A') failed\n");
    result++;
  }
  if (towupper(L'a') != L'A') {
    printf("towupper(L'a') failed\n");
    result++;
  }
  if (result == 0)
    puts("All test successful!");
  return result != 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x80,-0x18(%rbp)
jge    127a <main+0x11a>
mov    -0x18(%rbp),%edi
call   1030 <iswlower@plt>
cmp    $0x0,%rax
je     11fc <main+0x9c>
mov    -0x18(%rbp),%edi
call   1080 <towupper@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
call   1070 <towlower@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    11dd <main+0x7d>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     11dd <main+0x7d>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    11f7 <main+0x97>
mov    -0x18(%rbp),%esi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11fc <main+0x9c>
mov    -0x18(%rbp),%edi
call   1060 <iswupper@plt>
cmp    $0x0,%rax
je     1267 <main+0x107>
mov    -0x18(%rbp),%edi
call   1070 <towlower@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
call   1080 <towupper@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x28(%rbp),%eax
jne    1248 <main+0xe8>
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1248 <main+0xe8>
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    1262 <main+0x102>
mov    -0x18(%rbp),%esi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1267 <main+0x107>
jmp    126c <main+0x10c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1184 <main+0x24>
movl   $0x41,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <iswupper@plt>
cmp    $0x0,%rax
je     12a5 <main+0x145>
mov    -0x18(%rbp),%edi
call   1030 <iswlower@plt>
cmp    $0x0,%rax
je     12bc <main+0x15c>
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x61,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <iswupper@plt>
cmp    $0x0,%rax
jne    12e7 <main+0x187>
mov    -0x18(%rbp),%edi
call   1030 <iswlower@plt>
cmp    $0x0,%rax
jne    12fe <main+0x19e>
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    $0x41,%edi
call   1070 <towlower@plt>
cmp    $0x61,%eax
je     1328 <main+0x1c8>
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    $0x61,%edi
call   1080 <towupper@plt>
cmp    $0x41,%eax
je     1352 <main+0x1f2>
lea    0xd83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1368 <main+0x208>
lea    0xd79(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,-0x14(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xec6(%rip),%r14
lea    0xe8a(%rip),%r15
xor    %r12d,%r12d
xor    %ebp,%ebp
jmp    119b <main+0x3b>
nopl   (%rax)
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r12d
add    $0x1,%ebp
cmp    $0x80,%ebp
je     11fd <main+0x9d>
mov    %ebp,%edi
call   1030 <iswlower@plt>
test   %rax,%rax
je     11d3 <main+0x73>
mov    %ebp,%edi
call   1080 <towupper@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1070 <towlower@plt>
cmp    %eax,%ebp
jne    11c3 <main+0x63>
cmp    %ebx,%ebp
je     11c3 <main+0x63>
cmp    %eax,%ebx
jne    11d3 <main+0x73>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r12d
mov    %ebp,%edi
call   1060 <iswupper@plt>
test   %rax,%rax
je     1190 <main+0x30>
mov    %ebp,%edi
call   1070 <towlower@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1080 <towupper@plt>
cmp    %eax,%ebp
jne    1180 <main+0x20>
cmp    %ebx,%ebp
je     1180 <main+0x20>
cmp    %ebx,%eax
jne    1190 <main+0x30>
jmp    1180 <main+0x20>
mov    $0x41,%edi
call   1060 <iswupper@plt>
test   %rax,%rax
je     121b <main+0xbb>
mov    $0x41,%edi
call   1030 <iswlower@plt>
test   %rax,%rax
je     122b <main+0xcb>
lea    0xe5d(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%r12d
mov    $0x61,%edi
call   1060 <iswupper@plt>
test   %rax,%rax
jne    1249 <main+0xe9>
mov    $0x61,%edi
call   1030 <iswlower@plt>
test   %rax,%rax
jne    1259 <main+0xf9>
lea    0xe50(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%r12d
mov    $0x41,%edi
call   1070 <towlower@plt>
cmp    $0x61,%eax
je     1278 <main+0x118>
lea    0xe68(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%r12d
mov    $0x61,%edi
call   1080 <towupper@plt>
cmp    $0x41,%eax
je     1297 <main+0x137>
lea    0xe33(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%r12d
test   %r12d,%r12d
jne    12a8 <main+0x148>
lea    0xdc7(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
test   %r12d,%r12d
setne  %al
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [53 x i8] c"iswlower/towupper/towlower for character \\%x failed\0A\00"
@.str.1 = [53 x i8] c"iswupper/towlower/towupper for character \\%x failed\0A\00"
@.str.2 = [34 x i8] c"!iswupper/iswlower (L'A') failed\0A\00"
@.str.3 = [34 x i8] c"iswupper/!iswlower (L'a') failed\0A\00"
@.str.4 = [23 x i8] c"towlower(L'A') failed\0A\00"
@.str.5 = [23 x i8] c"towupper(L'a') failed\0A\00"
@.str.6 = [21 x i8] c"All test successful!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %12
12: ; preds = %68, %2
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 128
br i1 %14, label %15, label %71
15: ; preds = %12
%16 = load i32, i32* %7
%17 = call i64 @iswlower(i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %41
19: ; preds = %15
%20 = load i32, i32* %7
%21 = call i32 @towupper(i32 %20)
store i32 %21, i32* %8
%22 = load i32, i32* %7
%23 = call i32 @towlower(i32 %22)
store i32 %23, i32* %9
%24 = load i32, i32* %7
%25 = load i32, i32* %9
%26 = icmp ne i32 %24, %25
br i1 %26, label %35, label %27
27: ; preds = %19
%28 = load i32, i32* %8
%29 = load i32, i32* %7
%30 = icmp eq i32 %28, %29
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = load i32, i32* %8
%33 = load i32, i32* %9
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %40
35: ; preds = %31, %27, %19
%36 = load i32, i32* %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %40
40: ; preds = %35, %31
br label %41
41: ; preds = %40, %15
%42 = load i32, i32* %7
%43 = call i64 @iswupper(i32 %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %67
45: ; preds = %41
%46 = load i32, i32* %7
%47 = call i32 @towlower(i32 %46)
store i32 %47, i32* %10
%48 = load i32, i32* %7
%49 = call i32 @towupper(i32 %48)
store i32 %49, i32* %11
%50 = load i32, i32* %7
%51 = load i32, i32* %11
%52 = icmp ne i32 %50, %51
br i1 %52, label %61, label %53
53: ; preds = %45
%54 = load i32, i32* %10
%55 = load i32, i32* %7
%56 = icmp eq i32 %54, %55
br i1 %56, label %61, label %57
57: ; preds = %53
%58 = load i32, i32* %11
%59 = load i32, i32* %10
%60 = icmp eq i32 %58, %59
br i1 %60, label %61, label %66
61: ; preds = %57, %53, %45
%62 = load i32, i32* %7
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i32 %62)
%64 = load i32, i32* %6
%65 = add nsw i32 %64, 1
store i32 %65, i32* %6
br label %66
66: ; preds = %61, %57
br label %67
67: ; preds = %66, %41
br label %68
68: ; preds = %67
%69 = load i32, i32* %7
%70 = add nsw i32 %69, 1
store i32 %70, i32* %7
br label %12
71: ; preds = %12
store i32 65, i32* %7
%72 = load i32, i32* %7
%73 = call i64 @iswupper(i32 %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %79
75: ; preds = %71
%76 = load i32, i32* %7
%77 = call i64 @iswlower(i32 %76)
%78 = icmp ne i64 %77, 0
br i1 %78, label %79, label %83
79: ; preds = %75, %71
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%81 = load i32, i32* %6
%82 = add nsw i32 %81, 1
store i32 %82, i32* %6
br label %83
83: ; preds = %79, %75
store i32 97, i32* %7
%84 = load i32, i32* %7
%85 = call i64 @iswupper(i32 %84)
%86 = icmp ne i64 %85, 0
br i1 %86, label %91, label %87
87: ; preds = %83
%88 = load i32, i32* %7
%89 = call i64 @iswlower(i32 %88)
%90 = icmp ne i64 %89, 0
br i1 %90, label %95, label %91
91: ; preds = %87, %83
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%93 = load i32, i32* %6
%94 = add nsw i32 %93, 1
store i32 %94, i32* %6
br label %95
95: ; preds = %91, %87
%96 = call i32 @towlower(i32 65)
%97 = icmp ne i32 %96, 97
br i1 %97, label %98, label %102
98: ; preds = %95
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%100 = load i32, i32* %6
%101 = add nsw i32 %100, 1
store i32 %101, i32* %6
br label %102
102: ; preds = %98, %95
%103 = call i32 @towupper(i32 97)
%104 = icmp ne i32 %103, 65
br i1 %104, label %105, label %109
105: ; preds = %102
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%107 = load i32, i32* %6
%108 = add nsw i32 %107, 1
store i32 %108, i32* %6
br label %109
109: ; preds = %105, %102
%110 = load i32, i32* %6
%111 = icmp eq i32 %110, 0
br i1 %111, label %112, label %114
112: ; preds = %109
%113 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %114
114: ; preds = %112, %109
%115 = load i32, i32* %6
%116 = icmp ne i32 %115, 0
%117 = zext i1 %116 to i32
ret i32 %117
}

LLVM IR (-O2):
@.str = [53 x i8] c"iswlower/towupper/towlower for character \\%x failed\0A\00"
@.str.1 = [53 x i8] c"iswupper/towlower/towupper for character \\%x failed\0A\00"
@.str.6 = [21 x i8] c"All test successful!\00"
@str = [33 x i8] c"!iswupper/iswlower (L'A') failed\00"
@str.7 = [33 x i8] c"iswupper/!iswlower (L'a') failed\00"
@str.8 = [22 x i8] c"towupper(L'a') failed\00"
@str.9 = [22 x i8] c"towlower(L'A') failed\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %34
%4 = phi i32 [ 0, %2 ], [ %35, %34 ]
%5 = phi i32 [ 0, %2 ], [ %36, %34 ]
%6 = tail call i64 @iswlower(i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %19, label %8
8: ; preds = %3
%9 = tail call i32 @towupper(i32 %5)
%10 = tail call i32 @towlower(i32 %5)
%11 = icmp ne i32 %5, %10
%12 = icmp eq i32 %9, %5
%13 = select i1 %11, i1 true, i1 %12
%14 = icmp eq i32 %9, %10
%15 = select i1 %13, i1 true, i1 %14
br i1 %15, label %16, label %19
16: ; preds = %8
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i32 %5)
%18 = add nsw i32 %4, 1
br label %19
19: ; preds = %16, %8, %3
%20 = phi i32 [ %4, %3 ], [ %18, %16 ], [ %4, %8 ]
%21 = tail call i64 @iswupper(i32 %5)
%22 = icmp eq i64 %21, 0
br i1 %22, label %34, label %23
23: ; preds = %19
%24 = tail call i32 @towlower(i32 %5)
%25 = tail call i32 @towupper(i32 %5)
%26 = icmp ne i32 %5, %25
%27 = icmp eq i32 %24, %5
%28 = select i1 %26, i1 true, i1 %27
%29 = icmp eq i32 %25, %24
%30 = select i1 %28, i1 true, i1 %29
br i1 %30, label %31, label %34
31: ; preds = %23
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%33 = add nsw i32 %20, 1
br label %34
34: ; preds = %31, %23, %19
%35 = phi i32 [ %20, %19 ], [ %33, %31 ], [ %20, %23 ]
%36 = add nuw nsw i32 %5, 1
%37 = icmp eq i32 %36, 128
br i1 %37, label %38, label %3
38: ; preds = %34
%39 = tail call i64 @iswupper(i32 65)
%40 = icmp eq i64 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = tail call i64 @iswlower(i32 65)
%43 = icmp eq i64 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %41, %38
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%46 = add nsw i32 %35, 1
br label %47
47: ; preds = %44, %41
%48 = phi i32 [ %46, %44 ], [ %35, %41 ]
%49 = tail call i64 @iswupper(i32 97)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = tail call i64 @iswlower(i32 97)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %51, %47
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.7, i64 0, i64 0))
%56 = add nsw i32 %48, 1
br label %57
57: ; preds = %54, %51
%58 = phi i32 [ %56, %54 ], [ %48, %51 ]
%59 = tail call i32 @towlower(i32 65)
%60 = icmp eq i32 %59, 97
br i1 %60, label %64, label %61
61: ; preds = %57
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
%63 = add nsw i32 %58, 1
br label %64
64: ; preds = %61, %57
%65 = phi i32 [ %63, %61 ], [ %58, %57 ]
%66 = tail call i32 @towupper(i32 97)
%67 = icmp eq i32 %66, 65
br i1 %67, label %71, label %68
68: ; preds = %64
%69 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0))
%70 = add nsw i32 %65, 1
br label %71
71: ; preds = %68, %64
%72 = phi i32 [ %70, %68 ], [ %65, %64 ]
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %71
%75 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %76
76: ; preds = %74, %71
%77 = icmp ne i32 %72, 0
%78 = zext i1 %77 to i32
ret i32 %78
}