#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 array_shift(char);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(char *);
scalar_t__ is_lower_case(char);
scalar_t__ is_upper_case(char);
int /*<<< orphan*/ process(char *);
int /*<<< orphan*/ scanf(char *, char *);
char to_upper(char);
void experiment() {
  char *alphabet = (char *)calloc(26, sizeof(char));
  char c;
  while (1) {
    scanf("%c", &c);
    if (c == '\n' || c == '\0') {
      process(alphabet);
      break;
    }
    if (is_lower_case(c))
      c = to_upper(c);
    if (is_upper_case(c))
      *(alphabet + array_shift(c)) = 1;
  }
  free(alphabet);
}


x86 assembly (clang, -O0):
<experiment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x1a,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x8(%rbp)
lea    0xe5e(%rip),%rdi
lea    -0x9(%rbp),%rsi
call   1080 <scanf@plt>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     11c5 <experiment+0x45>
movsbl -0x9(%rbp),%eax
cmp    $0x0,%eax
jne    11d3 <experiment+0x53>
mov    -0x8(%rbp),%rdi
call   1050 <process@plt>
jmp    1228 <experiment+0xa8>
movsbl -0x9(%rbp),%edi
call   1060 <is_lower_case@plt>
cmp    $0x0,%rax
je     11f2 <experiment+0x72>
movsbl -0x9(%rbp),%edi
call   10a0 <to_upper@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%edi
call   1090 <is_upper_case@plt>
cmp    $0x0,%rax
je     1223 <experiment+0xa3>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movsbl -0x9(%rbp),%edi
call   1040 <array_shift@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
movb   $0x1,(%rax,%rcx,1)
jmp    119b <experiment+0x1b>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<experiment>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x1a,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%rbx
lea    0xe5e(%rip),%r14
lea    0xf(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
movzbl 0xf(%rsp),%eax
cmp    $0xa,%al
je     1208 <experiment+0x88>
test   %al,%al
je     1208 <experiment+0x88>
movsbl %al,%edi
call   1060 <is_lower_case@plt>
mov    %rax,%rcx
movzbl 0xf(%rsp),%eax
test   %rcx,%rcx
je     11e9 <experiment+0x69>
movsbl %al,%edi
call   10a0 <to_upper@plt>
mov    %al,0xf(%rsp)
movsbl %al,%edi
call   1090 <is_upper_case@plt>
test   %rax,%rax
je     11b0 <experiment+0x30>
movsbl 0xf(%rsp),%edi
call   1040 <array_shift@plt>
cltq
movb   $0x1,(%rbx,%rax,1)
jmp    11b0 <experiment+0x30>
mov    %rbx,%rdi
call   1050 <process@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define void @experiment() {
%1 = alloca i8*
%2 = alloca i8
%3 = call i64 @calloc(i32 26, i32 1)
%4 = inttoptr i64 %3 to i8*
store i8* %4, i8** %1
br label %5
5: ; preds = %0, %34
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 10
br i1 %9, label %14, label %10
10: ; preds = %5
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10, %5
%15 = load i8*, i8** %1
%16 = call i32 @process(i8* %15)
br label %35
17: ; preds = %10
%18 = load i8, i8* %2
%19 = call i64 @is_lower_case(i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i8, i8* %2
%23 = call signext i8 @to_upper(i8 signext %22)
store i8 %23, i8* %2
br label %24
24: ; preds = %21, %17
%25 = load i8, i8* %2
%26 = call i64 @is_upper_case(i8 signext %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %24
%29 = load i8*, i8** %1
%30 = load i8, i8* %2
%31 = call i32 @array_shift(i8 signext %30)
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %29, i64 %32
store i8 1, i8* %33
br label %34
34: ; preds = %28, %24
br label %5
35: ; preds = %14
%36 = load i8*, i8** %1
%37 = call i32 @free(i8* %36)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @experiment() {
%1 = alloca i8
%2 = tail call i64 @calloc(i32 26, i32 1)
%3 = inttoptr i64 %2 to i8*
br label %4
4: ; preds = %25, %0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%6 = load i8, i8* %1
switch i8 %6, label %10 [
i8 10, label %7
i8 0, label %7
]
7: ; preds = %4, %4
%8 = call i32 @process(i8* %3)
%9 = call i32 @free(i8* %3)
ret void
10: ; preds = %4
%11 = call i64 @is_lower_case(i8 signext %6)
%12 = icmp eq i64 %11, 0
%13 = load i8, i8* %1
br i1 %12, label %16, label %14
14: ; preds = %10
%15 = call signext i8 @to_upper(i8 signext %13)
store i8 %15, i8* %1
br label %16
16: ; preds = %10, %14
%17 = phi i8 [ %15, %14 ], [ %13, %10 ]
%18 = call i64 @is_upper_case(i8 signext %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %16
%21 = load i8, i8* %1
%22 = call i32 @array_shift(i8 signext %21)
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %3, i64 %23
store i8 1, i8* %24
br label %25
25: ; preds = %20, %16
br label %4
}