#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int strlen(char *);
int tolower(char);
int toupper(char);
int main(int argc, char *argv[]) {
  char buf[80];
  int ctr;
  while (1) {
    puts("Enter a line of text, a blank to exit.");
    gets(buf);
    if (strlen(buf) == 0)
      break;
    for (ctr = 0; ctr < strlen(buf); ctr++) {
      printf("%c", tolower(buf[ctr]));
    }
    printf("\n");
    for (ctr = 0; ctr < strlen(buf); ctr++) {
      printf("%c", toupper(buf[ctr]));
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
call   1040 <puts@plt>
lea    -0x60(%rbp),%rdi
call   1070 <gets@plt>
lea    -0x60(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
jne    11a2 <main+0x42>
jmp    1261 <main+0x101>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%eax
cmp    %ecx,%eax
jge    11f1 <main+0x91>
movslq -0x64(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%edi
call   1080 <tolower@plt>
mov    %eax,%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11a9 <main+0x49>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x6c(%rbp)
lea    -0x60(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
cmp    %ecx,%eax
jge    124e <main+0xee>
movslq -0x64(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%edi
call   1030 <toupper@plt>
mov    %eax,%esi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1206 <main+0xa6>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1176 <main+0x16>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
lea    0xe90(%rip),%rdi
call   1050 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <gets@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
je     1248 <main+0xe8>
mov    %rsp,%r15
lea    0xe66(%rip),%r14
jmp    11ca <main+0x6a>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   1070 <gets@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
je     1248 <main+0xe8>
mov    %r15,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    1203 <main+0xa3>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl (%rsp,%rbx,1),%edi
call   1080 <tolower@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
mov    %r15,%rdi
call   1060 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11e0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    11a0 <main+0x40>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl (%rsp,%rbx,1),%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
mov    %r15,%rdi
call   1060 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1220 <main+0xc0>
jmp    11a0 <main+0x40>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Enter a line of text, a blank to exit.\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [80 x i8]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %2, %49
%9 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %8
br label %51
16: ; preds = %8
store i32 0, i32* %7
br label %17
17: ; preds = %29, %16
%18 = load i32, i32* %7
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
%21 = icmp slt i32 %18, %20
br i1 %21, label %22, label %32
22: ; preds = %17
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = call i32 @tolower(i8 signext %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %22
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %17
32: ; preds = %17
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %34
34: ; preds = %46, %32
%35 = load i32, i32* %7
%36 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%37 = call i32 @strlen(i8* %36)
%38 = icmp slt i32 %35, %37
br i1 %38, label %39, label %49
39: ; preds = %34
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = call i32 @toupper(i8 signext %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %39
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %34
49: ; preds = %34
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %8
51: ; preds = %15
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c"Enter a line of text, a blank to exit.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %4)
%7 = call i32 @strlen(i8* %4)
%8 = icmp eq i32 %7, 0
br i1 %8, label %42, label %9
9: ; preds = %2, %36
%10 = call i32 @strlen(i8* %4)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %9, %12
%13 = phi i64 [ %18, %12 ], [ 0, %9 ]
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = call i32 @tolower(i8 signext %15)
%17 = call i32 @putchar(i32 %16)
%18 = add nuw nsw i64 %13, 1
%19 = call i32 @strlen(i8* %4)
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %18, %20
br i1 %21, label %12, label %22
22: ; preds = %12, %9
%23 = call i32 @putchar(i32 10)
%24 = call i32 @strlen(i8* %4)
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %36
26: ; preds = %22, %26
%27 = phi i64 [ %32, %26 ], [ 0, %22 ]
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = call i32 @toupper(i8 signext %29)
%31 = call i32 @putchar(i32 %30)
%32 = add nuw nsw i64 %27, 1
%33 = call i32 @strlen(i8* %4)
%34 = sext i32 %33 to i64
%35 = icmp slt i64 %32, %34
br i1 %35, label %26, label %36
36: ; preds = %26, %22
%37 = call i32 @putchar(i32 10)
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%39 = call i32 @gets(i8* %4)
%40 = call i32 @strlen(i8* %4)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %9
42: ; preds = %36, %2
ret i32 0
}