#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 *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char str[10] = {0};
  int i, n;
  n = 0;
  printf("Enter str. in upper: ");
  scanf("%s", str);
  printf("str : %s\n", str);
  for (i = 0; str[i] != '\0'; i++) {
    if (str[i] >= 'A' && str[i] <= 'Z')
      str[i] += ('a' - 'A');
  }
  printf("lower str : %s\n", str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xe(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
movl   $0x0,-0x18(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xe(%rbp),%rsi
lea    0xea7(%rip),%rdi
call   1050 <scanf@plt>
lea    -0xe(%rbp),%rsi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11e6 <main+0xb6>
movslq -0x14(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%eax
cmp    $0x41,%eax
jl     11d3 <main+0xa3>
movslq -0x14(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%eax
cmp    $0x5a,%eax
jg     11d3 <main+0xa3>
movslq -0x14(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%ecx
add    $0x20,%ecx
mov    %cl,-0xe(%rbp,%rax,1)
jmp    11d8 <main+0xa8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118d <main+0x5d>
lea    -0xe(%rbp),%rsi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movw   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1040 <scanf@plt>
lea    0xec4(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%al
test   %al,%al
je     119a <main+0x7a>
lea    0x1(%rsp),%rcx
jmp    118b <main+0x6b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rcx),%eax
add    $0x1,%rcx
test   %al,%al
je     119a <main+0x7a>
lea    -0x41(%rax),%edx
cmp    $0x19,%dl
ja     1180 <main+0x60>
add    $0x20,%al
mov    %al,-0x1(%rcx)
jmp    1180 <main+0x60>
lea    0xe78(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter str. in upper: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [10 x i8] c"str : %s\0A\00"
@.str.3 = [16 x i8] c"lower str : %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [10 x i8]* %2 to i8*
store i32 0, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %9)
store i32 0, i32* %3
br label %11
11: ; preds = %41, %0
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %44
18: ; preds = %11
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp sge i32 %23, 65
br i1 %24, label %25, label %40
25: ; preds = %18
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp sle i32 %30, 90
br i1 %31, label %32, label %40
32: ; preds = %25
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = add nsw i32 %37, 32
%39 = trunc i32 %38 to i8
store i8 %39, i8* %35
br label %40
40: ; preds = %32, %25, %18
br label %41
41: ; preds = %40
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %11
44: ; preds = %11
%45 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %45)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Enter str. in upper: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [10 x i8] c"str : %s\0A\00"
@.str.3 = [16 x i8] c"lower str : %s\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 0
br i1 %7, label %21, label %8
8: ; preds = %0, %16
%9 = phi i64 [ %17, %16 ], [ 0, %0 ]
%10 = phi i8 [ %19, %16 ], [ %6, %0 ]
%11 = phi i8* [ %18, %16 ], [ %2, %0 ]
%12 = add i8 %10, -65
%13 = icmp ult i8 %12, 26
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = add nuw nsw i8 %10, 32
store i8 %15, i8* %11
br label %16
16: ; preds = %8, %14
%17 = add nuw i64 %9, 1
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %8
21: ; preds = %16, %0
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %2)
ret i32 0
}