#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ gets(char *);
scalar_t__ islower(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int tolower(char);
int toupper(char);
int main() {
  char str[100];
  int i;
  printf("%s\n", "Enter your word: ");
  printf("> ");
  fflush(stdin);
  gets(str);
  printf("%s", "The converted string is: ");
  for (i = 0; i < strlen(str); i++) {
    if (islower(str[i]) != 0)
      printf("%c", toupper(str[i]));
    else
      printf("%c", tolower(str[i]));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
lea    -0x70(%rbp),%rdi
call   1070 <gets@plt>
lea    0xe56(%rip),%rdi
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x78(%rbp),%eax
cmp    %ecx,%eax
jge    1260 <main+0xf0>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%edi
call   1030 <islower@plt>
cmp    $0x0,%rax
je     122f <main+0xbf>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%edi
call   1040 <toupper@plt>
mov    %eax,%esi
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    124d <main+0xdd>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%edi
call   1080 <tolower@plt>
mov    %eax,%esi
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1252 <main+0xe2>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11d8 <main+0x68>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xe62(%rip),%rdi
call   1060 <puts@plt>
lea    0xe68(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1090 <gets@plt>
lea    0xe44(%rip),%rdi
lea    0xe40(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
test   %eax,%eax
jle    123b <main+0xab>
xor    %ebx,%ebx
mov    %rsp,%r14
jmp    121f <main+0x8f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   10a0 <tolower@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
mov    %r14,%rdi
call   1070 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    123b <main+0xab>
movsbl (%rsp,%rbx,1),%edi
call   1040 <islower@plt>
movzbl (%rsp,%rbx,1),%ecx
movsbl %cl,%edi
test   %rax,%rax
je     1200 <main+0x70>
call   1050 <toupper@plt>
jmp    1205 <main+0x75>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [18 x i8] c"Enter your word: \00"
@.str.2 = [3 x i8] c"> \00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [26 x i8] c"The converted string is: \00"
@.str.5 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i32 @fflush(i32 %6)
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%9 = call i32 @gets(i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %11
11: ; preds = %38, %0
%12 = load i32, i32* %3
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %41
16: ; preds = %11
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = call i64 @islower(i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %16
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = call i32 @toupper(i8 signext %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %28)
br label %37
30: ; preds = %16
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = call i32 @tolower(i8 signext %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %30, %23
br label %38
38: ; preds = %37
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %11
41: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"Enter your word: \00"
@.str.2 = [3 x i8] c"> \00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [26 x i8] c"The converted string is: \00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = tail call i32 @fflush(i32 %5)
%7 = call i32 @gets(i8* %2)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @strlen(i8* %2)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %29
11: ; preds = %0, %22
%12 = phi i64 [ %25, %22 ], [ 0, %0 ]
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = call i64 @islower(i8 signext %14)
%16 = icmp eq i64 %15, 0
%17 = load i8, i8* %13
br i1 %16, label %20, label %18
18: ; preds = %11
%19 = call i32 @toupper(i8 signext %17)
br label %22
20: ; preds = %11
%21 = call i32 @tolower(i8 signext %17)
br label %22
22: ; preds = %18, %20
%23 = phi i32 [ %19, %18 ], [ %21, %20 ]
%24 = call i32 @putchar(i32 %23)
%25 = add nuw nsw i64 %12, 1
%26 = call i32 @strlen(i8* %2)
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %11, label %29
29: ; preds = %22, %0
ret i32 0
}