#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 */
int char_is_lower(char);
int char_is_upper(char);
char char_change_case(char c) {
  if (char_is_upper(c) == 1) {
    int ascii = c;
    ascii += 32;
    return (char)ascii;
  }
  if (char_is_lower(c) == 1) {
    int ascii = c;
    ascii -= 32;
    return (char)ascii;
  }
  return c;
}


x86 assembly (clang, -O0):
<char_change_case>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%edi
call   1030 <char_is_upper@plt>
cmp    $0x1,%eax
jne    115b <char_change_case+0x3b>
movsbl -0x2(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %al,-0x1(%rbp)
jmp    118e <char_change_case+0x6e>
movsbl -0x2(%rbp),%edi
call   1040 <char_is_lower@plt>
cmp    $0x1,%eax
jne    1188 <char_change_case+0x68>
movsbl -0x2(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x20,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %al,-0x1(%rbp)
jmp    118e <char_change_case+0x6e>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<char_change_case>:
push   %rbx
mov    %edi,%ebx
call   1030 <char_is_upper@plt>
cmp    $0x1,%eax
jne    1132 <char_change_case+0x12>
lea    0x20(%rbx),%eax
pop    %rbx
ret
movsbl %bl,%ebx
mov    %ebx,%edi
call   1040 <char_is_lower@plt>
lea    -0x20(%rbx),%ecx
cmp    $0x1,%eax
movzbl %bl,%edx
movzbl %cl,%eax
cmovne %edx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define signext i8 @char_change_case(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store i8 %0, i8* %3
%6 = load i8, i8* %3
%7 = call i32 @char_is_upper(i8 signext %6)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %16
9: ; preds = %1
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = add nsw i32 %12, 32
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = trunc i32 %14 to i8
store i8 %15, i8* %2
br label %29
16: ; preds = %1
%17 = load i8, i8* %3
%18 = call i32 @char_is_lower(i8 signext %17)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
store i32 %22, i32* %5
%23 = load i32, i32* %5
%24 = sub nsw i32 %23, 32
store i32 %24, i32* %5
%25 = load i32, i32* %5
%26 = trunc i32 %25 to i8
store i8 %26, i8* %2
br label %29
27: ; preds = %16
%28 = load i8, i8* %3
store i8 %28, i8* %2
br label %29
29: ; preds = %27, %20, %9
%30 = load i8, i8* %2
ret i8 %30
}

LLVM IR (-O2):
define signext i8 @char_change_case(i8 signext %0) {
%2 = tail call i32 @char_is_upper(i8 signext %0)
%3 = icmp eq i32 %2, 1
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = add i8 %0, 32
br label %11
6: ; preds = %1
%7 = tail call i32 @char_is_lower(i8 signext %0)
%8 = icmp eq i32 %7, 1
%9 = add i8 %0, -32
%10 = select i1 %8, i8 %9, i8 %0
br label %11
11: ; preds = %6, %4
%12 = phi i8 [ %5, %4 ], [ %10, %6 ]
ret i8 %12
}