#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 */
char tolower(char);
char *to_irc_lower(char *str, const size_t len) {
  for (size_t i = 0; i < len; i++)
    switch (str[i]) {
    case '\0':
    case ' ':
    case '\r':
    case '\n':
    case '':
      return NULL;
    case ',':
      i = len;
      break;
    case '/':
      str[i] = ',';
      break;
    case '[':
      str[i] = '{';
      break;
    case ']':
      str[i] = '}';
      break;
    case '\\':
      str[i] = '|';
      break;
    case '~':
      str[i] = '^';
      break;
    default:
      str[i] = tolower(str[i]);
      break;
    }
  return str;
}


x86 assembly (clang, -O0):
<to_irc_lower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    129f <to_irc_lower+0x18f>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x24(%rbp)
test   %eax,%eax
je     11fc <to_irc_lower+0xec>
jmp    1152 <to_irc_lower+0x42>
mov    -0x24(%rbp),%eax
sub    $0x7,%eax
je     11fc <to_irc_lower+0xec>
jmp    1163 <to_irc_lower+0x53>
mov    -0x24(%rbp),%eax
sub    $0xa,%eax
je     11fc <to_irc_lower+0xec>
jmp    1174 <to_irc_lower+0x64>
mov    -0x24(%rbp),%eax
sub    $0xd,%eax
je     11fc <to_irc_lower+0xec>
jmp    1185 <to_irc_lower+0x75>
mov    -0x24(%rbp),%eax
sub    $0x20,%eax
je     11fc <to_irc_lower+0xec>
jmp    1196 <to_irc_lower+0x86>
mov    -0x24(%rbp),%eax
sub    $0x2c,%eax
je     1209 <to_irc_lower+0xf9>
jmp    11a7 <to_irc_lower+0x97>
mov    -0x24(%rbp),%eax
sub    $0x2f,%eax
je     1216 <to_irc_lower+0x106>
jmp    11b8 <to_irc_lower+0xa8>
mov    -0x24(%rbp),%eax
sub    $0x5b,%eax
je     1227 <to_irc_lower+0x117>
jmp    11c9 <to_irc_lower+0xb9>
mov    -0x24(%rbp),%eax
sub    $0x5c,%eax
je     1249 <to_irc_lower+0x139>
jmp    11da <to_irc_lower+0xca>
mov    -0x24(%rbp),%eax
sub    $0x5d,%eax
je     1238 <to_irc_lower+0x128>
jmp    11eb <to_irc_lower+0xdb>
mov    -0x24(%rbp),%eax
sub    $0x7e,%eax
je     125a <to_irc_lower+0x14a>
jmp    126b <to_irc_lower+0x15b>
movq   $0x0,-0x8(%rbp)
jmp    12a7 <to_irc_lower+0x197>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1289 <to_irc_lower+0x179>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x2c,(%rax,%rcx,1)
jmp    1289 <to_irc_lower+0x179>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x7b,(%rax,%rcx,1)
jmp    1289 <to_irc_lower+0x179>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x7d,(%rax,%rcx,1)
jmp    1289 <to_irc_lower+0x179>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x7c,(%rax,%rcx,1)
jmp    1289 <to_irc_lower+0x179>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x5e,(%rax,%rcx,1)
jmp    1289 <to_irc_lower+0x179>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <tolower@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    128e <to_irc_lower+0x17e>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1128 <to_irc_lower+0x18>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<to_irc_lower>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r13
test   %rsi,%rsi
je     1191 <to_irc_lower+0x81>
mov    %rsi,%r14
xor    %r15d,%r15d
lea    0xed2(%rip),%r12
xor    %ebx,%ebx
jmp    1154 <to_irc_lower+0x44>
call   1030 <tolower@plt>
nopw   0x0(%rax,%rax,1)
mov    %al,0x0(%r13,%rbx,1)
mov    %rbx,%rcx
add    $0x1,%rcx
mov    %rcx,%rbx
cmp    %r14,%rcx
jae    1191 <to_irc_lower+0x81>
movsbl 0x0(%r13,%rbx,1),%edi
cmp    $0x5d,%edi
ja     1180 <to_irc_lower+0x70>
mov    $0x2c,%al
movslq (%r12,%rdi,4),%rdx
add    %r12,%rdx
mov    %r14,%rcx
jmp    *%rdx
mov    $0x7b,%al
jmp    1140 <to_irc_lower+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x7e,%edi
jne    1132 <to_irc_lower+0x22>
mov    $0x5e,%al
jmp    1140 <to_irc_lower+0x30>
mov    $0x7c,%al
jmp    1140 <to_irc_lower+0x30>
mov    $0x7d,%al
jmp    1140 <to_irc_lower+0x30>
mov    %r13,%r15
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @to_irc_lower(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 0, i64* %6
br label %7
7: ; preds = %50, %2
%8 = load i64, i64* %6
%9 = load i64, i64* %5
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %53
11: ; preds = %7
%12 = load i8*, i8** %4
%13 = load i64, i64* %6
%14 = getelementptr inbounds i8, i8* %12, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %40 [
i32 0, label %17
i32 32, label %17
i32 13, label %17
i32 10, label %17
i32 7, label %17
i32 44, label %18
i32 47, label %20
i32 91, label %24
i32 93, label %28
i32 92, label %32
i32 126, label %36
]
17: ; preds = %11, %11, %11, %11, %11
store i8* null, i8** %3
br label %55
18: ; preds = %11
%19 = load i64, i64* %5
store i64 %19, i64* %6
br label %49
20: ; preds = %11
%21 = load i8*, i8** %4
%22 = load i64, i64* %6
%23 = getelementptr inbounds i8, i8* %21, i64 %22
store i8 44, i8* %23
br label %49
24: ; preds = %11
%25 = load i8*, i8** %4
%26 = load i64, i64* %6
%27 = getelementptr inbounds i8, i8* %25, i64 %26
store i8 123, i8* %27
br label %49
28: ; preds = %11
%29 = load i8*, i8** %4
%30 = load i64, i64* %6
%31 = getelementptr inbounds i8, i8* %29, i64 %30
store i8 125, i8* %31
br label %49
32: ; preds = %11
%33 = load i8*, i8** %4
%34 = load i64, i64* %6
%35 = getelementptr inbounds i8, i8* %33, i64 %34
store i8 124, i8* %35
br label %49
36: ; preds = %11
%37 = load i8*, i8** %4
%38 = load i64, i64* %6
%39 = getelementptr inbounds i8, i8* %37, i64 %38
store i8 94, i8* %39
br label %49
40: ; preds = %11
%41 = load i8*, i8** %4
%42 = load i64, i64* %6
%43 = getelementptr inbounds i8, i8* %41, i64 %42
%44 = load i8, i8* %43
%45 = call signext i8 @tolower(i8 signext %44)
%46 = load i8*, i8** %4
%47 = load i64, i64* %6
%48 = getelementptr inbounds i8, i8* %46, i64 %47
store i8 %45, i8* %48
br label %49
49: ; preds = %40, %36, %32, %28, %24, %20, %18
br label %50
50: ; preds = %49
%51 = load i64, i64* %6
%52 = add i64 %51, 1
store i64 %52, i64* %6
br label %7
53: ; preds = %7
%54 = load i8*, i8** %4
store i8* %54, i8** %3
br label %55
55: ; preds = %53, %17
%56 = load i8*, i8** %3
ret i8* %56
}

LLVM IR (-O2):
define i8* @to_irc_lower(i8* %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %21, label %4
4: ; preds = %2, %17
%5 = phi i64 [ %19, %17 ], [ 0, %2 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
switch i32 %8, label %13 [
i32 0, label %21
i32 32, label %21
i32 13, label %21
i32 10, label %21
i32 7, label %21
i32 44, label %17
i32 47, label %15
i32 91, label %9
i32 93, label %10
i32 92, label %11
i32 126, label %12
]
9: ; preds = %4
br label %15
10: ; preds = %4
br label %15
11: ; preds = %4
br label %15
12: ; preds = %4
br label %15
13: ; preds = %4
%14 = tail call signext i8 @tolower(i8 signext %7)
br label %15
15: ; preds = %4, %13, %12, %11, %10, %9
%16 = phi i8 [ 123, %9 ], [ 125, %10 ], [ 124, %11 ], [ 94, %12 ], [ %14, %13 ], [ 44, %4 ]
store i8 %16, i8* %6
br label %17
17: ; preds = %15, %4
%18 = phi i64 [ %1, %4 ], [ %5, %15 ]
%19 = add i64 %18, 1
%20 = icmp ult i64 %19, %1
br i1 %20, label %4, label %21
21: ; preds = %17, %4, %4, %4, %4, %4, %2
%22 = phi i8* [ %0, %2 ], [ null, %4 ], [ null, %4 ], [ null, %4 ], [ null, %4 ], [ null, %4 ], [ %0, %17 ]
ret i8* %22
}