#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
char getchar();
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i, flag;
  char str[80], c;
  FILE *fp;
  fp = fopen("text", "w");
  flag = 1;
  while (flag == 1) {
    printf("input string:\n");
    gets(str);
    fprintf(fp, "%s", str);
    printf("continue?");
    c = getchar();
    if ((c == 'N') || (c == 'n'))
      flag = 0;
    getchar();
  }
  fclose(fp);
  fp = fopen("text", "r");
  while (fscanf(fp, "%s", str) != EOF) {
    for (i = 0; str[i] != '\0'; i++) {
      if ((str[i] > 'a') && (str[i] < 'z')) {
        str[i] -= 32;
      }
    }
    printf("%s\n", str);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
lea    0xe78(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x70(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1217 <main+0xa7>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1080 <gets@plt>
mov    -0x70(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xe49(%rip),%rsi
call   1070 <fprintf@plt>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x61(%rbp)
movsbl -0x61(%rbp),%eax
cmp    $0x4e,%eax
je     1204 <main+0x94>
movsbl -0x61(%rbp),%eax
cmp    $0x6e,%eax
jne    120b <main+0x9b>
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
jmp    119d <main+0x2d>
mov    -0x70(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xdd9(%rip),%rdi
lea    0xdf5(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xdd0(%rip),%rsi
call   1050 <fscanf@plt>
mov    0x2d96(%rip),%rcx
cmp    (%rcx),%rax
je     12d2 <main+0x162>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     12bb <main+0x14b>
movslq -0x8(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
cmp    $0x61,%eax
jle    12a8 <main+0x138>
movslq -0x8(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
cmp    $0x7a,%eax
jge    12a8 <main+0x138>
movslq -0x8(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%ecx
sub    $0x20,%ecx
mov    %cl,-0x60(%rbp,%rax,1)
jmp    12ad <main+0x13d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1262 <main+0xf2>
lea    -0x60(%rbp),%rsi
lea    0xd5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1237 <main+0xc7>
mov    -0x70(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
lea    0xe6c(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r15
lea    0xe6c(%rip),%r14
mov    %rsp,%r13
lea    0xe56(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1090 <gets@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1060 <fputs@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
mov    %eax,%ebx
and    $0xdf,%bl
xor    %eax,%eax
call   1080 <getchar@plt>
cmp    $0x4e,%bl
jne    11c0 <main+0x40>
mov    %r15,%rdi
call   1040 <fclose@plt>
lea    0xdf4(%rip),%rdi
lea    0xe01(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
lea    0xde5(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1070 <fscanf@plt>
mov    0x2db4(%rip),%r12
cmp    (%r12),%rax
jne    1252 <main+0xd2>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0x1(%rsp),%r13
mov    %rsp,%rbx
lea    0xda6(%rip),%r15
jmp    128c <main+0x10c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1070 <fscanf@plt>
cmp    (%r12),%rax
je     123a <main+0xba>
mov    (%rsp),%al
test   %al,%al
je     1270 <main+0xf0>
mov    %r13,%rcx
jmp    12ab <main+0x12b>
nopl   0x0(%rax,%rax,1)
movzbl (%rcx),%eax
add    $0x1,%rcx
test   %al,%al
je     1270 <main+0xf0>
lea    -0x62(%rax),%edx
cmp    $0x17,%dl
ja     12a0 <main+0x120>
add    $0xe0,%al
mov    %al,-0x1(%rcx)
jmp    12a0 <main+0x120>

LLVM IR (-O0):
@.str = [5 x i8] c"text\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [15 x i8] c"input string:\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [10 x i8] c"continue?\00"
@.str.5 = [2 x i8] c"r\00"
@EOF = global i64 0
@.str.6 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [80 x i8]
%5 = alloca i8
%6 = alloca i32*
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %6
store i32 1, i32* %3
br label %8
8: ; preds = %28, %0
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %30
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%14 = call i32 @gets(i8* %13)
%15 = load i32*, i32** %6
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%17 = call i32 @fprintf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%19 = call signext i8 (...) @getchar()
store i8 %19, i8* %5
%20 = load i8, i8* %5
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 78
br i1 %22, label %27, label %23
23: ; preds = %11
%24 = load i8, i8* %5
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 110
br i1 %26, label %27, label %28
27: ; preds = %23, %11
store i32 0, i32* %3
br label %28
28: ; preds = %27, %23
%29 = call signext i8 (...) @getchar()
br label %8
30: ; preds = %8
%31 = load i32*, i32** %6
%32 = call i32 @fclose(i32* %31)
%33 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %33, i32** %6
br label %34
34: ; preds = %74, %30
%35 = load i32*, i32** %6
%36 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%37 = call i64 @fscanf(i32* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %36)
%38 = load i64, i64* @EOF
%39 = icmp ne i64 %37, %38
br i1 %39, label %40, label %77
40: ; preds = %34
store i32 0, i32* %2
br label %41
41: ; preds = %71, %40
%42 = load i32, i32* %2
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %74
48: ; preds = %41
%49 = load i32, i32* %2
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp sgt i32 %53, 97
br i1 %54, label %55, label %70
55: ; preds = %48
%56 = load i32, i32* %2
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp slt i32 %60, 122
br i1 %61, label %62, label %70
62: ; preds = %55
%63 = load i32, i32* %2
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %64
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = sub nsw i32 %67, 32
%69 = trunc i32 %68 to i8
store i8 %69, i8* %65
br label %70
70: ; preds = %62, %55, %48
br label %71
71: ; preds = %70
%72 = load i32, i32* %2
%73 = add nsw i32 %72, 1
store i32 %73, i32* %2
br label %41
74: ; preds = %41
%75 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %75)
br label %34
77: ; preds = %34
%78 = load i32*, i32** %6
%79 = call i32 @fclose(i32* %78)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"text\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [10 x i8] c"continue?\00"
@.str.5 = [2 x i8] c"r\00"
@EOF = global i64 0
@str = [14 x i8] c"input string:\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%6 = call i32 @gets(i8* %2)
%7 = call i32 @fputs(i8* %2, i32* %3)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%9 = call signext i8 (...) @getchar()
%10 = and i8 %9, -33
%11 = icmp eq i8 %10, 78
%12 = call signext i8 (...) @getchar()
br i1 %11, label %13, label %4
13: ; preds = %4
%14 = call i32 @fclose(i32* %3)
%15 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%16 = call i64 @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%17 = load i64, i64* @EOF
%18 = icmp eq i64 %16, %17
br i1 %18, label %40, label %19
19: ; preds = %13, %35
%20 = load i8, i8* %2
%21 = icmp eq i8 %20, 0
br i1 %21, label %35, label %22
22: ; preds = %19, %30
%23 = phi i64 [ %31, %30 ], [ 0, %19 ]
%24 = phi i8 [ %33, %30 ], [ %20, %19 ]
%25 = phi i8* [ %32, %30 ], [ %2, %19 ]
%26 = add i8 %24, -98
%27 = icmp ult i8 %26, 24
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = add nsw i8 %24, -32
store i8 %29, i8* %25
br label %30
30: ; preds = %22, %28
%31 = add nuw i64 %23, 1
%32 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 0
br i1 %34, label %35, label %22
35: ; preds = %30, %19
%36 = call i32 @puts(i8* %2)
%37 = call i64 @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%38 = load i64, i64* @EOF
%39 = icmp eq i64 %37, %38
br i1 %39, label %40, label %19
40: ; preds = %35, %13
%41 = call i32 @fclose(i32* %15)
ret i32 0
}