#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*/ getline_my(char *, int);
int isspace(char);
int /*<<< orphan*/ printf(char *, ...);
void main() {
  int i = 0;
  char string[20];
  getline_my(string, 1000);
  printf("before check string = %s.\n", string);
  for (i = 0; isspace(string[i]); ++i) {
    printf("string [ %d ] = '%c' = %d; isspace ( string [ %d ] ) = %d;\n", i,
           string[i], string[i], i, isspace(string[i]));
  };
  printf("after cycle i = %d;\n", i);
  printf("after check string = %s.\n", string);
  for (i = 0; string[i] != '\0'; i++) {
    printf("string [ i = %d ] = %c;\n", i, string[i]);
  };
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x3e8,%esi
call   1050 <getline_my@plt>
lea    -0x20(%rbp),%rsi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%edi
call   1040 <isspace@plt>
cmp    $0x0,%eax
je     11db <main+0xab>
mov    -0x4(%rbp),%eax
mov    %eax,-0x30(%rbp)
movslq -0x4(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
mov    %eax,-0x2c(%rbp)
movslq -0x4(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
movslq -0x4(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%edi
call   1040 <isspace@plt>
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    %eax,%r9d
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1166 <main+0x36>
mov    -0x4(%rbp),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     123f <main+0x10f>
mov    -0x4(%rbp),%esi
movslq -0x4(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%edx
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1205 <main+0xd5>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x3e8,%esi
call   1050 <getline_my@plt>
lea    0xeb1(%rip),%rdi
xor    %ebx,%ebx
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movsbl (%rsp),%edi
call   1040 <isspace@plt>
test   %eax,%eax
je     11b3 <main+0x83>
lea    0xeac(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%rsp,%rbx,1),%ebp
mov    %ebp,%edi
call   1040 <isspace@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1030 <printf@plt>
movsbl 0x1(%rsp,%rbx,1),%edi
add    $0x1,%rbx
call   1040 <isspace@plt>
test   %eax,%eax
jne    1180 <main+0x50>
lea    0xe9d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%al
test   %al,%al
je     120c <main+0xdc>
lea    0xea4(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0x1(%rsp,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    11f0 <main+0xc0>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"before check string = %s.\0A\00"
@.str.1 = [60 x i8] c"string [ %d ] = '%c' = %d; isspace ( string [ %d ] ) = %d;\0A\00"
@.str.2 = [21 x i8] c"after cycle i = %d;\0A\00"
@.str.3 = [26 x i8] c"after check string = %s.\0A\00"
@.str.4 = [25 x i8] c"string [ i = %d ] = %c;\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
store i32 0, i32* %1
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = call i32 @getline_my(i8* %3, i32 1000)
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %5)
store i32 0, i32* %1
br label %7
7: ; preds = %33, %0
%8 = load i32, i32* %1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = call i32 @isspace(i8 signext %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %36
14: ; preds = %7
%15 = load i32, i32* %1
%16 = load i32, i32* %1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = load i32, i32* %1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = load i32, i32* %1
%27 = load i32, i32* %1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = call i32 @isspace(i8 signext %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %20, i32 %25, i32 %26, i32 %31)
br label %33
33: ; preds = %14
%34 = load i32, i32* %1
%35 = add nsw i32 %34, 1
store i32 %35, i32* %1
br label %7
36: ; preds = %7
%37 = load i32, i32* %1
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %39)
store i32 0, i32* %1
br label %41
41: ; preds = %56, %36
%42 = load i32, i32* %1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [20 x i8], [20 x i8]* %2, 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 %59
48: ; preds = %41
%49 = load i32, i32* %1
%50 = load i32, i32* %1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %49, i32 %54)
br label %56
56: ; preds = %48
%57 = load i32, i32* %1
%58 = add nsw i32 %57, 1
store i32 %58, i32* %1
br label %41
59: ; preds = %41
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"before check string = %s.\0A\00"
@.str.1 = [60 x i8] c"string [ %d ] = '%c' = %d; isspace ( string [ %d ] ) = %d;\0A\00"
@.str.2 = [21 x i8] c"after cycle i = %d;\0A\00"
@.str.3 = [26 x i8] c"after check string = %s.\0A\00"
@.str.4 = [25 x i8] c"string [ i = %d ] = %c;\0A\00"
define void @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = call i32 @getline_my(i8* %2, i32 1000)
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = load i8, i8* %2
%6 = call i32 @isspace(i8 signext %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %23, label %8
8: ; preds = %0, %8
%9 = phi i64 [ %16, %8 ], [ 0, %0 ]
%10 = phi i8* [ %17, %8 ], [ %2, %0 ]
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = call i32 @isspace(i8 signext %11)
%14 = trunc i64 %9 to i32
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %12, i32 %12, i32 %14, i32 %13)
%16 = add nuw i64 %9, 1
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = call i32 @isspace(i8 signext %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %8
21: ; preds = %8
%22 = trunc i64 %16 to i32
br label %23
23: ; preds = %21, %0
%24 = phi i32 [ 0, %0 ], [ %22, %21 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%27 = load i8, i8* %2
%28 = icmp eq i8 %27, 0
br i1 %28, label %39, label %29
29: ; preds = %23, %29
%30 = phi i64 [ %35, %29 ], [ 0, %23 ]
%31 = phi i8 [ %37, %29 ], [ %27, %23 ]
%32 = sext i8 %31 to i32
%33 = trunc i64 %30 to i32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %33, i32 %32)
%35 = add nuw i64 %30, 1
%36 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 0
br i1 %38, label %39, label %29
39: ; preds = %29, %23
ret void
}