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

/* Variables and functions */
scalar_t__ islower(char);
scalar_t__ isupper(char);
char tolower(char);
char toupper(char);
void Transpose(char *str) {
  while (*str) {
    if (islower(*str)) {
      *str = toupper(*str);
    } else if (isupper(*str)) {
      *str = tolower(*str);
    }
    str++;
  }
}


x86 assembly (clang, -O0):
<Transpose>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c8 <Transpose+0x88>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <islower@plt>
cmp    $0x0,%rax
je     1188 <Transpose+0x48>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <toupper@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    11b7 <Transpose+0x77>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isupper@plt>
cmp    $0x0,%rax
je     11b2 <Transpose+0x72>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <tolower@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    11b7 <Transpose+0x77>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    114c <Transpose+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Transpose>:
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     118a <Transpose+0x4a>
mov    %rdi,%rbx
jmp    1163 <Transpose+0x23>
nopl   0x0(%rax)
call   1040 <toupper@plt>
mov    %al,(%rbx)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     118a <Transpose+0x4a>
movsbl %al,%edi
call   1030 <islower@plt>
movzbl (%rbx),%ecx
movsbl %cl,%edi
test   %rax,%rax
jne    1150 <Transpose+0x10>
call   1060 <isupper@plt>
test   %rax,%rax
je     1157 <Transpose+0x17>
movsbl (%rbx),%edi
call   1050 <tolower@plt>
jmp    1155 <Transpose+0x15>
pop    %rbx
ret

LLVM IR (-O0):
define void @Transpose(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %28, %1
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = icmp ne i8 %5, 0
br i1 %6, label %7, label %31
7: ; preds = %3
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = call i64 @islower(i8 signext %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = call signext i8 @toupper(i8 signext %14)
%16 = load i8*, i8** %2
store i8 %15, i8* %16
br label %28
17: ; preds = %7
%18 = load i8*, i8** %2
%19 = load i8, i8* %18
%20 = call i64 @isupper(i8 signext %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i8*, i8** %2
%24 = load i8, i8* %23
%25 = call signext i8 @tolower(i8 signext %24)
%26 = load i8*, i8** %2
store i8 %25, i8* %26
br label %27
27: ; preds = %22, %17
br label %28
28: ; preds = %27, %12
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %2
br label %3
31: ; preds = %3
ret void
}

LLVM IR (-O2):
define void @Transpose(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %24, label %4
4: ; preds = %1, %20
%5 = phi i8 [ %22, %20 ], [ %2, %1 ]
%6 = phi i8* [ %21, %20 ], [ %0, %1 ]
%7 = tail call i64 @islower(i8 signext %5)
%8 = icmp eq i64 %7, 0
%9 = load i8, i8* %6
br i1 %8, label %12, label %10
10: ; preds = %4
%11 = tail call signext i8 @toupper(i8 signext %9)
br label %18
12: ; preds = %4
%13 = tail call i64 @isupper(i8 signext %9)
%14 = icmp eq i64 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %12
%16 = load i8, i8* %6
%17 = tail call signext i8 @tolower(i8 signext %16)
br label %18
18: ; preds = %10, %15
%19 = phi i8 [ %17, %15 ], [ %11, %10 ]
store i8 %19, i8* %6
br label %20
20: ; preds = %18, %12
%21 = getelementptr inbounds i8, i8* %6, i64 1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %4
24: ; preds = %20, %1
ret void
}