#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 /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ scanf(char *, char *);
void read_string(char A[]) {
  int i, j;
  char c;
  i = 0;
  scanf("%c", &c);
  while (i < 100) {
    A[i] = c;
    scanf("%c", &c);
    if (c == A[i]) {
      j = i;
      break;
    }
    i++;
  }
  for (i = 0; i <= j; i++) {
    A[i] = A[i] + A[i] - 'a' + 1;
    printf("%c", A[i]);
  }
}


x86 assembly (clang, -O0):
<read_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec6(%rip),%rdi
lea    -0x11(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x64,-0xc(%rbp)
jge    119c <read_string+0x7c>
mov    -0x11(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
lea    0xe9e(%rip),%rdi
lea    -0x11(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x11(%rbp),%eax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    118e <read_string+0x6e>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    119c <read_string+0x7c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <read_string+0x23>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1202 <read_string+0xe2>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
add    %ecx,%eax
sub    $0x61,%eax
add    $0x1,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
lea    0xe15(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a3 <read_string+0x83>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_string>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r12
lea    0xec9(%rip),%r14
lea    0xf(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
xor    %r13d,%r13d
mov    0xf(%rsp),%al
xchg   %ax,%ax
mov    %al,(%r12,%r13,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
movzbl 0xf(%rsp),%eax
cmp    (%r12,%r13,1),%al
je     117a <read_string+0x5a>
add    $0x1,%r13
cmp    $0x64,%r13
jne    1150 <read_string+0x30>
mov    $0x64,%r13d
add    $0x1,%r13
xor    %ebx,%ebx
lea    0xe79(%rip),%r14
nopw   0x0(%rax,%rax,1)
movzbl (%r12,%rbx,1),%eax
add    %al,%al
add    $0xa0,%al
mov    %al,(%r12,%rbx,1)
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1190 <read_string+0x70>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define void @read_string(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store i8* %0, i8** %2
store i32 0, i32* %3
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %7
7: ; preds = %28, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 100
br i1 %9, label %10, label %31
10: ; preds = %7
%11 = load i8, i8* %5
%12 = load i8*, i8** %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
store i8 %11, i8* %15
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%17 = load i8, i8* %5
%18 = sext i8 %17 to i32
%19 = load i8*, i8** %2
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %18, %24
br i1 %25, label %26, label %28
26: ; preds = %10
%27 = load i32, i32* %3
store i32 %27, i32* %4
br label %31
28: ; preds = %10
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %7
31: ; preds = %26, %7
store i32 0, i32* %3
br label %32
32: ; preds = %63, %31
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = icmp sle i32 %33, %34
br i1 %35, label %36, label %66
36: ; preds = %32
%37 = load i8*, i8** %2
%38 = load i32, i32* %3
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = load i8*, i8** %2
%44 = load i32, i32* %3
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = add nsw i32 %42, %48
%50 = sub nsw i32 %49, 97
%51 = add nsw i32 %50, 1
%52 = trunc i32 %51 to i8
%53 = load i8*, i8** %2
%54 = load i32, i32* %3
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
store i8 %52, i8* %56
%57 = load i8*, i8** %2
%58 = load i32, i32* %3
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
%61 = load i8, i8* %60
%62 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %61)
br label %63
63: ; preds = %36
%64 = load i32, i32* %3
%65 = add nsw i32 %64, 1
store i32 %65, i32* %3
br label %32
66: ; preds = %32
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @read_string(i8* nocapture %0) {
%2 = alloca i8
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = load i8, i8* %2
br label %5
5: ; preds = %1, %13
%6 = phi i8 [ %4, %1 ], [ %10, %13 ]
%7 = phi i64 [ 0, %1 ], [ %14, %13 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
store i8 %6, i8* %8
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%10 = load i8, i8* %2
%11 = load i8, i8* %8
%12 = icmp eq i8 %10, %11
br i1 %12, label %16, label %13
13: ; preds = %5
%14 = add nuw nsw i64 %7, 1
%15 = icmp eq i64 %14, 100
br i1 %15, label %16, label %5
16: ; preds = %5, %13
%17 = phi i64 [ %7, %5 ], [ 100, %13 ]
%18 = add nuw i64 %17, 1
%19 = and i64 %18, 4294967295
br label %20
20: ; preds = %16, %20
%21 = phi i64 [ 0, %16 ], [ %27, %20 ]
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = load i8, i8* %22
%24 = shl i8 %23, 1
%25 = add i8 %24, -96
store i8 %25, i8* %22
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %25)
%27 = add nuw nsw i64 %21, 1
%28 = icmp eq i64 %27, %19
br i1 %28, label %29, label %20
29: ; preds = %20
ret void
}