#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 */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int input_words(FILE *fp, char *word, char *cog, char *sim, char *syn) {
  int i, read;
  size_t n;
  char *str[4] = {word, cog, sim, syn};
  printf("please input 4 elements:\n");
  for (n = 1024, i = 0; i < 4; i++, n = 1024) {
    printf("%d: ", i);
    fflush(stdout);
    read = getline(&str[i], &n, fp);
    str[i][read - 1] = '\0';
    if (read == -1)
      return 1;
    if (!strcmp(word, "end"))
      return 1;
  }
  printf("--------------------------------------------------\n");
  return 0;
}


x86 assembly (clang, -O0):
<input_words>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x400,-0x40(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    124d <input_words+0x10d>
mov    -0x34(%rbp),%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
movslq -0x34(%rbp),%rax
lea    -0x60(%rbp),%rdi
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rdx
lea    -0x40(%rbp),%rsi
call   1060 <getline@plt>
mov    %eax,-0x38(%rbp)
movslq -0x34(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rax
mov    -0x38(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
cmpl   $0xffffffff,-0x38(%rbp)
jne    120d <input_words+0xcd>
movl   $0x1,-0x4(%rbp)
jmp    1262 <input_words+0x122>
mov    -0x18(%rbp),%rdi
lea    0xe07(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1232 <input_words+0xf2>
movl   $0x1,-0x4(%rbp)
jmp    1262 <input_words+0x122>
jmp    1237 <input_words+0xf7>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
movq   $0x400,-0x40(%rbp)
jmp    1199 <input_words+0x59>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input_words>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,0x10(%rsp)
mov    %rdx,0x18(%rsp)
mov    %rcx,0x20(%rsp)
mov    %r8,0x28(%rsp)
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
movq   $0x400,0x8(%rsp)
lea    0xe6e(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e3e(%rip),%r12
mov    (%r12),%edi
call   1060 <fflush@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    %r14,%rdx
call   1070 <getline@plt>
mov    0x10(%rsp),%rcx
cltq
movb   $0x0,-0x1(%rax,%rcx,1)
mov    $0x1,%ebp
cmp    $0xffffffff,%eax
je     1330 <input_words+0x1e0>
lea    0xe27(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1330 <input_words+0x1e0>
lea    0x18(%rsp),%r15
movq   $0x400,0x8(%rsp)
lea    0xdfd(%rip),%rdi
mov    $0x1,%ebp
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12),%edi
call   1060 <fflush@plt>
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
call   1070 <getline@plt>
mov    0x18(%rsp),%rcx
cltq
movb   $0x0,-0x1(%rax,%rcx,1)
cmp    $0xffffffff,%eax
je     1330 <input_words+0x1e0>
lea    0xdbc(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1330 <input_words+0x1e0>
lea    0x20(%rsp),%r15
movq   $0x400,0x8(%rsp)
lea    0xd92(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12),%edi
call   1060 <fflush@plt>
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
call   1070 <getline@plt>
mov    0x20(%rsp),%rcx
cltq
movb   $0x0,-0x1(%rax,%rcx,1)
cmp    $0xffffffff,%eax
je     1330 <input_words+0x1e0>
lea    0xd56(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1330 <input_words+0x1e0>
lea    0x28(%rsp),%r15
movq   $0x400,0x8(%rsp)
lea    0xd30(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12),%edi
call   1060 <fflush@plt>
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
call   1070 <getline@plt>
mov    0x28(%rsp),%rcx
cltq
movb   $0x0,-0x1(%rax,%rcx,1)
cmp    $0xffffffff,%eax
je     1330 <input_words+0x1e0>
lea    0xcf8(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1330 <input_words+0x1e0>
movq   $0x400,0x8(%rsp)
lea    0xcf9(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"please input 4 elements:\0A\00"
@.str.1 = [5 x i8] c"%d: \00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"end\00"
@.str.3 = [52 x i8] c"--------------------------------------------------\0A\00"
define i32 @input_words(i32* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
%15 = alloca [4 x i8*]
store i32* %0, i32** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
%16 = getelementptr inbounds [4 x i8*], [4 x i8*]* %15, i64 0, i64 0
%17 = load i8*, i8** %8
store i8* %17, i8** %16
%18 = getelementptr inbounds i8*, i8** %16, i64 1
%19 = load i8*, i8** %9
store i8* %19, i8** %18
%20 = getelementptr inbounds i8*, i8** %18, i64 1
%21 = load i8*, i8** %10
store i8* %21, i8** %20
%22 = getelementptr inbounds i8*, i8** %20, i64 1
%23 = load i8*, i8** %11
store i8* %23, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i64 1024, i64* %14
store i32 0, i32* %12
br label %25
25: ; preds = %55, %5
%26 = load i32, i32* %12
%27 = icmp slt i32 %26, 4
br i1 %27, label %28, label %58
28: ; preds = %25
%29 = load i32, i32* %12
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* @stdout
%32 = call i32 @fflush(i32 %31)
%33 = load i32, i32* %12
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [4 x i8*], [4 x i8*]* %15, i64 0, i64 %34
%36 = load i32*, i32** %7
%37 = call i32 @getline(i8** %35, i64* %14, i32* %36)
store i32 %37, i32* %13
%38 = load i32, i32* %12
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [4 x i8*], [4 x i8*]* %15, i64 0, i64 %39
%41 = load i8*, i8** %40
%42 = load i32, i32* %13
%43 = sub nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %41, i64 %44
store i8 0, i8* %45
%46 = load i32, i32* %13
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %49
48: ; preds = %28
store i32 1, i32* %6
br label %60
49: ; preds = %28
%50 = load i8*, i8** %8
%51 = call i32 @strcmp(i8* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%52 = icmp ne i32 %51, 0
br i1 %52, label %54, label %53
53: ; preds = %49
store i32 1, i32* %6
br label %60
54: ; preds = %49
br label %55
55: ; preds = %54
%56 = load i32, i32* %12
%57 = add nsw i32 %56, 1
store i32 %57, i32* %12
store i64 1024, i64* %14
br label %25
58: ; preds = %25
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %6
br label %60
60: ; preds = %58, %53, %48
%61 = load i32, i32* %6
ret i32 %61
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%d: \00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"end\00"
@str = [25 x i8] c"please input 4 elements:\00"
@str.4 = [51 x i8] c"--------------------------------------------------\00"
define i32 @input_words(i32* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i64
%7 = alloca [4 x i8*]
%8 = bitcast i64* %6 to i8*
%9 = bitcast [4 x i8*]* %7 to i8*
%10 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
store i8* %1, i8** %10
%11 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 1
store i8* %2, i8** %11
%12 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 2
store i8* %3, i8** %12
%13 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 3
store i8* %4, i8** %13
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
store i64 1024, i64* %6
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 0)
%16 = load i32, i32* @stdout
%17 = call i32 @fflush(i32 %16)
%18 = call i32 @getline(i8** %10, i64* %6, i32* %0)
%19 = load i8*, i8** %10
%20 = add nsw i32 %18, -1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 0, i8* %22
%23 = icmp eq i32 %18, -1
br i1 %23, label %68, label %65
24: ; preds = %65
store i64 1024, i64* %6
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 1)
%26 = load i32, i32* @stdout
%27 = call i32 @fflush(i32 %26)
%28 = call i32 @getline(i8** %11, i64* %6, i32* %0)
%29 = load i8*, i8** %11
%30 = add nsw i32 %28, -1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 0, i8* %32
%33 = icmp eq i32 %28, -1
br i1 %33, label %68, label %34
34: ; preds = %24
%35 = call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp eq i32 %35, 0
br i1 %36, label %68, label %37
37: ; preds = %34
store i64 1024, i64* %6
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 2)
%39 = load i32, i32* @stdout
%40 = call i32 @fflush(i32 %39)
%41 = call i32 @getline(i8** %12, i64* %6, i32* %0)
%42 = load i8*, i8** %12
%43 = add nsw i32 %41, -1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
store i8 0, i8* %45
%46 = icmp eq i32 %41, -1
br i1 %46, label %68, label %47
47: ; preds = %37
%48 = call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%49 = icmp eq i32 %48, 0
br i1 %49, label %68, label %50
50: ; preds = %47
store i64 1024, i64* %6
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 3)
%52 = load i32, i32* @stdout
%53 = call i32 @fflush(i32 %52)
%54 = call i32 @getline(i8** %13, i64* %6, i32* %0)
%55 = load i8*, i8** %13
%56 = add nsw i32 %54, -1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
store i8 0, i8* %58
%59 = icmp eq i32 %54, -1
br i1 %59, label %68, label %60
60: ; preds = %50
%61 = call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%62 = icmp eq i32 %61, 0
br i1 %62, label %68, label %63
63: ; preds = %60
store i64 1024, i64* %6
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.4, i64 0, i64 0))
br label %68
65: ; preds = %5
%66 = call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %24
68: ; preds = %65, %5, %24, %34, %37, %47, %50, %60, %63
%69 = phi i32 [ 0, %63 ], [ 1, %60 ], [ 1, %50 ], [ 1, %47 ], [ 1, %37 ], [ 1, %34 ], [ 1, %24 ], [ 1, %5 ], [ 1, %65 ]
ret i32 %69
}