#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 */
long kernel__Char__distance(char, char);
short kernel__Char__is_upper(char);
char kernel__Char__to_lower(char self) {
  char var;
  short int var1;
  long var2;
  long var4;
  char var5;
  char var6;
  long var7;
  long var8;
  long var10;
  char var11;
  char var13;
  var1 = kernel__Char__is_upper(self);
  if (var1) {
    {
      var4 = (unsigned char)self;
      var2 = var4;
      goto RET_LABEL3;
    RET_LABEL3:
      (void)0;
    }
    var5 = 'a';
    var6 = 'A';
    var7 = kernel__Char__distance(var5, var6);
    {
      var10 = var2 + var7;
      var8 = var10;
      goto RET_LABEL9;
    RET_LABEL9:
      (void)0;
    }
    {
      var13 = var8;
      var11 = var13;
      goto RET_LABEL12;
    RET_LABEL12:
      (void)0;
    }
    var = var11;
    goto RET_LABEL;
  } else {
    var = self;
    goto RET_LABEL;
  }
RET_LABEL:;
  return var;
}


x86 assembly (clang, -O0):
<kernel__Char__to_lower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%edi
call   1030 <kernel__Char__is_upper@plt>
mov    %ax,-0x4(%rbp)
cmpw   $0x0,-0x4(%rbp)
je     119d <kernel__Char__to_lower+0x7d>
movzbl -0x1(%rbp),%eax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
movb   $0x61,-0x19(%rbp)
movb   $0x41,-0x1a(%rbp)
mov    -0x19(%rbp),%al
movsbl %al,%edi
movsbl -0x1a(%rbp),%esi
call   1040 <kernel__Char__distance@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %al,-0x3a(%rbp)
mov    -0x3a(%rbp),%al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
mov    %al,-0x2(%rbp)
jmp    11a3 <kernel__Char__to_lower+0x83>
mov    -0x1(%rbp),%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel__Char__to_lower>:
push   %rbx
mov    %edi,%ebx
call   1030 <kernel__Char__is_upper@plt>
test   %ax,%ax
je     1140 <kernel__Char__to_lower+0x20>
mov    $0x61,%edi
mov    $0x41,%esi
call   1040 <kernel__Char__distance@plt>
add    %bl,%al
mov    %eax,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define signext i8 @kernel__Char__to_lower(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
%4 = alloca i16
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8
%8 = alloca i8
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i8
%13 = alloca i8
store i8 %0, i8* %2
%14 = load i8, i8* %2
%15 = call signext i16 @kernel__Char__is_upper(i8 signext %14)
store i16 %15, i16* %4
%16 = load i16, i16* %4
%17 = icmp ne i16 %16, 0
br i1 %17, label %18, label %36
18: ; preds = %1
%19 = load i8, i8* %2
%20 = zext i8 %19 to i64
store i64 %20, i64* %6
%21 = load i64, i64* %6
store i64 %21, i64* %5
br label %22
22: ; preds = %18
store i8 97, i8* %7
store i8 65, i8* %8
%23 = load i8, i8* %7
%24 = load i8, i8* %8
%25 = call i64 @kernel__Char__distance(i8 signext %23, i8 signext %24)
store i64 %25, i64* %9
%26 = load i64, i64* %5
%27 = load i64, i64* %9
%28 = add nsw i64 %26, %27
store i64 %28, i64* %11
%29 = load i64, i64* %11
store i64 %29, i64* %10
br label %30
30: ; preds = %22
%31 = load i64, i64* %10
%32 = trunc i64 %31 to i8
store i8 %32, i8* %13
%33 = load i8, i8* %13
store i8 %33, i8* %12
br label %34
34: ; preds = %30
%35 = load i8, i8* %12
store i8 %35, i8* %3
br label %38
36: ; preds = %1
%37 = load i8, i8* %2
store i8 %37, i8* %3
br label %38
38: ; preds = %36, %34
%39 = load i8, i8* %3
ret i8 %39
}

LLVM IR (-O2):
define signext i8 @kernel__Char__to_lower(i8 signext %0) {
%2 = tail call signext i16 @kernel__Char__is_upper(i8 signext %0)
%3 = icmp eq i16 %2, 0
br i1 %3, label %8, label %4
4: ; preds = %1
%5 = tail call i64 @kernel__Char__distance(i8 signext 97, i8 signext 65)
%6 = trunc i64 %5 to i8
%7 = add i8 %6, %0
br label %8
8: ; preds = %1, %4
%9 = phi i8 [ %7, %4 ], [ %0, %1 ]
ret i8 %9
}