#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
void main() {
  char string_1[10];
  char string_2[100];
  unsigned short int i = 0;
  unsigned short int j = 0;
  FILE *f = fopen("1.txt", "r");
  while (j < 3) {
    fgets(string_1, 10, f);
    for (i = 0; i < 10 && string_1[i] != '\n' && string_1[i] != EOF; i++) {
      printf("string_1 [ i = %d ] = %c;\n", i, string_1[i]);
    };
    printf("------------------------------------\n");
    printf("at step %d string_1 [ 0 ] = %c;\n", j, string_1[0]);
    printf("and full string = %s;\n\n", string_1);
    j++;
  };
  fclose(f);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movw   $0x0,-0x72(%rbp)
movw   $0x0,-0x74(%rbp)
lea    0xea2(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x80(%rbp)
movzwl -0x74(%rbp),%eax
cmp    $0x3,%eax
jge    1266 <main+0x126>
lea    -0xa(%rbp),%rdi
mov    -0x80(%rbp),%rdx
mov    $0xa,%esi
call   1050 <fgets@plt>
movw   $0x0,-0x72(%rbp)
movzwl -0x72(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x81(%rbp)
jge    11e0 <main+0xa0>
movzwl -0x72(%rbp),%eax
movsbl -0xa(%rbp,%rax,1),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x81(%rbp)
je     11e0 <main+0xa0>
movzwl -0x72(%rbp),%eax
movsbl -0xa(%rbp,%rax,1),%eax
mov    0x2e16(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x81(%rbp)
mov    -0x81(%rbp),%al
test   $0x1,%al
jne    11f3 <main+0xb3>
jmp    121f <main+0xdf>
movzwl -0x72(%rbp),%esi
movzwl -0x72(%rbp),%eax
movsbl -0xa(%rbp,%rax,1),%edx
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x72(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x72(%rbp)
jmp    1193 <main+0x53>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzwl -0x74(%rbp),%esi
movsbl -0xa(%rbp),%edx
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xa(%rbp),%rsi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x74(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x74(%rbp)
jmp    116e <main+0x2e>
mov    -0x80(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe9b(%rip),%rdi
lea    0xe9a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe(%rsp),%r14
mov    0x2e68(%rip),%r12
lea    0xebd(%rip),%r13
lea    0xe7a(%rip),%rbp
xor    %r15d,%r15d
jmp    11dd <main+0x8d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
movsbl 0xe(%rsp),%edx
lea    0xe6b(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15d
cmp    $0x3,%r15d
je     1365 <main+0x215>
mov    %r14,%rdi
mov    $0xa,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
movsbl 0xe(%rsp),%edx
cmp    $0xa,%edx
je     11a0 <main+0x50>
cmp    (%r12),%dl
je     11a0 <main+0x50>
mov    %rbp,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0xf(%rsp),%edx
cmp    $0xa,%edx
je     11a0 <main+0x50>
cmp    (%r12),%dl
je     11a0 <main+0x50>
mov    %rbp,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x10(%rsp),%edx
cmp    $0xa,%edx
je     11a0 <main+0x50>
cmp    (%r12),%dl
je     11a0 <main+0x50>
mov    %rbp,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x11(%rsp),%edx
cmp    $0xa,%edx
je     11a0 <main+0x50>
cmp    (%r12),%dl
je     11a0 <main+0x50>
mov    %rbp,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x12(%rsp),%edx
cmp    $0xa,%edx
je     11a0 <main+0x50>
cmp    (%r12),%dl
je     11a0 <main+0x50>
mov    %rbp,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x13(%rsp),%edx
cmp    $0xa,%edx
je     11a0 <main+0x50>
cmp    (%r12),%dl
je     11a0 <main+0x50>
mov    %rbp,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x14(%rsp),%edx
cmp    $0xa,%edx
je     11a0 <main+0x50>
cmp    (%r12),%dl
je     11a0 <main+0x50>
mov    %rbp,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x15(%rsp),%edx
cmp    $0xa,%edx
je     11a0 <main+0x50>
cmp    (%r12),%dl
je     11a0 <main+0x50>
mov    %rbp,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x16(%rsp),%edx
cmp    $0xa,%edx
je     11a0 <main+0x50>
cmp    (%r12),%dl
je     11a0 <main+0x50>
mov    %rbp,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x17(%rsp),%edx
cmp    $0xa,%edx
je     11a0 <main+0x50>
cmp    (%r12),%dl
je     11a0 <main+0x50>
mov    %rbp,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11a0 <main+0x50>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"1.txt\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [27 x i8] c"string_1 [ i = %d ] = %c;\0A\00"
@.str.3 = [38 x i8] c"------------------------------------\0A\00"
@.str.4 = [33 x i8] c"at step %d string_1 [ 0 ] = %c;\0A\00"
@.str.5 = [24 x i8] c"and full string = %s;\0A\0A\00"
define void @main() {
%1 = alloca [10 x i8]
%2 = alloca [100 x i8]
%3 = alloca i16
%4 = alloca i16
%5 = alloca i32*
store i16 0, i16* %3
store i16 0, i16* %4
%6 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %5
br label %7
7: ; preds = %49, %0
%8 = load i16, i16* %4
%9 = zext i16 %8 to i32
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %61
11: ; preds = %7
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%13 = load i32*, i32** %5
%14 = call i32 @fgets(i8* %12, i32 10, i32* %13)
store i16 0, i16* %3
br label %15
15: ; preds = %46, %11
%16 = load i16, i16* %3
%17 = zext i16 %16 to i32
%18 = icmp slt i32 %17, 10
br i1 %18, label %19, label %35
19: ; preds = %15
%20 = load i16, i16* %3
%21 = zext i16 %20 to i64
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 10
br i1 %25, label %26, label %35
26: ; preds = %19
%27 = load i16, i16* %3
%28 = zext i16 %27 to i64
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = load i8, i8* @EOF
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %31, %33
br label %35
35: ; preds = %26, %19, %15
%36 = phi i1 [ false, %19 ], [ false, %15 ], [ %34, %26 ]
br i1 %36, label %37, label %49
37: ; preds = %35
%38 = load i16, i16* %3
%39 = zext i16 %38 to i32
%40 = load i16, i16* %3
%41 = zext i16 %40 to i64
%42 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %39, i32 %44)
br label %46
46: ; preds = %37
%47 = load i16, i16* %3
%48 = add i16 %47, 1
store i16 %48, i16* %3
br label %15
49: ; preds = %35
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%51 = load i16, i16* %4
%52 = zext i16 %51 to i32
%53 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %52, i32 %55)
%57 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %57)
%59 = load i16, i16* %4
%60 = add i16 %59, 1
store i16 %60, i16* %4
br label %7
61: ; preds = %7
%62 = load i32*, i32** %5
%63 = call i32 @fclose(i32* %62)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"1.txt\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [27 x i8] c"string_1 [ i = %d ] = %c;\0A\00"
@.str.4 = [33 x i8] c"at step %d string_1 [ 0 ] = %c;\0A\00"
@.str.5 = [24 x i8] c"and full string = %s;\0A\0A\00"
@str = [37 x i8] c"------------------------------------\00"
define void @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 1
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 2
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 3
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 4
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 5
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 6
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 7
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 8
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 9
br label %13
13: ; preds = %0, %96
%14 = phi i32 [ 0, %0 ], [ %102, %96 ]
%15 = call i32 @fgets(i8* %2, i32 10, i32* %3)
%16 = load i8, i8* %2
%17 = icmp eq i8 %16, 10
%18 = load i8, i8* @EOF
%19 = icmp eq i8 %16, %18
%20 = select i1 %17, i1 true, i1 %19
br i1 %20, label %96, label %21
21: ; preds = %13
%22 = sext i8 %16 to i32
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 %22)
%24 = load i8, i8* %4
%25 = icmp eq i8 %24, 10
%26 = load i8, i8* @EOF
%27 = icmp eq i8 %24, %26
%28 = select i1 %25, i1 true, i1 %27
br i1 %28, label %96, label %29
29: ; preds = %21
%30 = sext i8 %24 to i32
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 %30)
%32 = load i8, i8* %5
%33 = icmp eq i8 %32, 10
%34 = load i8, i8* @EOF
%35 = icmp eq i8 %32, %34
%36 = select i1 %33, i1 true, i1 %35
br i1 %36, label %96, label %37
37: ; preds = %29
%38 = sext i8 %32 to i32
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 %38)
%40 = load i8, i8* %6
%41 = icmp eq i8 %40, 10
%42 = load i8, i8* @EOF
%43 = icmp eq i8 %40, %42
%44 = select i1 %41, i1 true, i1 %43
br i1 %44, label %96, label %45
45: ; preds = %37
%46 = sext i8 %40 to i32
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 %46)
%48 = load i8, i8* %7
%49 = icmp eq i8 %48, 10
%50 = load i8, i8* @EOF
%51 = icmp eq i8 %48, %50
%52 = select i1 %49, i1 true, i1 %51
br i1 %52, label %96, label %53
53: ; preds = %45
%54 = sext i8 %48 to i32
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 %54)
%56 = load i8, i8* %8
%57 = icmp eq i8 %56, 10
%58 = load i8, i8* @EOF
%59 = icmp eq i8 %56, %58
%60 = select i1 %57, i1 true, i1 %59
br i1 %60, label %96, label %61
61: ; preds = %53
%62 = sext i8 %56 to i32
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 5, i32 %62)
%64 = load i8, i8* %9
%65 = icmp eq i8 %64, 10
%66 = load i8, i8* @EOF
%67 = icmp eq i8 %64, %66
%68 = select i1 %65, i1 true, i1 %67
br i1 %68, label %96, label %69
69: ; preds = %61
%70 = sext i8 %64 to i32
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 6, i32 %70)
%72 = load i8, i8* %10
%73 = icmp eq i8 %72, 10
%74 = load i8, i8* @EOF
%75 = icmp eq i8 %72, %74
%76 = select i1 %73, i1 true, i1 %75
br i1 %76, label %96, label %77
77: ; preds = %69
%78 = sext i8 %72 to i32
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 7, i32 %78)
%80 = load i8, i8* %11
%81 = icmp eq i8 %80, 10
%82 = load i8, i8* @EOF
%83 = icmp eq i8 %80, %82
%84 = select i1 %81, i1 true, i1 %83
br i1 %84, label %96, label %85
85: ; preds = %77
%86 = sext i8 %80 to i32
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 8, i32 %86)
%88 = load i8, i8* %12
%89 = icmp eq i8 %88, 10
%90 = load i8, i8* @EOF
%91 = icmp eq i8 %88, %90
%92 = select i1 %89, i1 true, i1 %91
br i1 %92, label %96, label %93
93: ; preds = %85
%94 = sext i8 %88 to i32
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 9, i32 %94)
br label %96
96: ; preds = %93, %85, %77, %69, %61, %53, %45, %37, %29, %21, %13
%97 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%98 = load i8, i8* %2
%99 = sext i8 %98 to i32
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %14, i32 %99)
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %2)
%102 = add nuw nsw i32 %14, 1
%103 = icmp eq i32 %102, 3
br i1 %103, label %104, label %13
104: ; preds = %96
%105 = call i32 @fclose(i32* %3)
ret void
}