#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 */
scalar_t__ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(void) {
  char qwords[5][40];
  char temp[40];
  int i = 0;
  printf("Enter %d words beginning with q: \n", 5);
  while (i < 5 && gets(temp)) {
    if (temp[0] != 'q')
      printf("%s doesn't begin with q!\n", temp);
    else {
      strcpy(qwords[i], temp);
      i++;
    }
  }
  puts("Here are the words accepted: ");
  for (i = 0; i < 5; i++)
    puts(qwords[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x104(%rbp)
lea    0xe9d(%rip),%rdi
mov    $0x5,%esi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
cmpl   $0x5,-0x104(%rbp)
mov    %al,-0x105(%rbp)
jge    119d <main+0x5d>
lea    -0x100(%rbp),%rdi
call   1060 <gets@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x105(%rbp)
mov    -0x105(%rbp),%al
test   $0x1,%al
jne    11b0 <main+0x70>
jmp    120f <main+0xcf>
movsbl -0x100(%rbp),%eax
cmp    $0x71,%eax
je     11da <main+0x9a>
lea    -0x100(%rbp),%rsi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    120a <main+0xca>
movslq -0x104(%rbp),%rax
lea    -0xd0(%rbp),%rdi
imul   $0x28,%rax,%rax
add    %rax,%rdi
lea    -0x100(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    116f <main+0x2f>
lea    0xe27(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x104(%rbp)
cmpl   $0x5,-0x104(%rbp)
jge    1260 <main+0x120>
movslq -0x104(%rbp),%rax
lea    -0xd0(%rbp),%rdi
imul   $0x28,%rax,%rax
add    %rax,%rdi
call   1040 <puts@plt>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    1225 <main+0xe5>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
lea    0xead(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%r15
lea    0xeba(%rip),%r14
xor    %ebx,%ebx
jmp    118f <main+0x4f>
nopl   (%rax)
movslq %ebx,%rbx
lea    (%rbx,%rbx,4),%rax
lea    (%rsp,%rax,8),%rdi
add    $0x30,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
add    $0x1,%ebx
cmp    $0x5,%ebx
jge    11b4 <main+0x74>
mov    %r15,%rdi
call   1060 <gets@plt>
test   %rax,%rax
je     11b4 <main+0x74>
cmpb   $0x71,(%rsp)
je     1170 <main+0x30>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x5,%ebx
jl     118f <main+0x4f>
lea    0xe82(%rip),%rdi
call   1040 <puts@plt>
lea    0x30(%rsp),%rdi
call   1040 <puts@plt>
lea    0x58(%rsp),%rdi
call   1040 <puts@plt>
lea    0x80(%rsp),%rdi
call   1040 <puts@plt>
lea    0xa8(%rsp),%rdi
call   1040 <puts@plt>
lea    0xd0(%rsp),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Enter %d words beginning with q: \0A\00"
@.str.1 = [26 x i8] c"%s doesn't begin with q!\0A\00"
@.str.2 = [30 x i8] c"Here are the words accepted: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x [40 x i8]]
%3 = alloca [40 x i8]
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 5)
br label %6
6: ; preds = %32, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 5
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%11 = call i64 @gets(i8* %10)
%12 = icmp ne i64 %11, 0
br label %13
13: ; preds = %9, %6
%14 = phi i1 [ false, %6 ], [ %12, %9 ]
br i1 %14, label %15, label %33
15: ; preds = %13
%16 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 113
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %32
23: ; preds = %15
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [5 x [40 x i8]], [5 x [40 x i8]]* %2, i64 0, i64 %25
%27 = getelementptr inbounds [40 x i8], [40 x i8]* %26, i64 0, i64 0
%28 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%29 = call i32 @strcpy(i8* %27, i8* %28)
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %32
32: ; preds = %23, %20
br label %6
33: ; preds = %13
%34 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %35
35: ; preds = %44, %33
%36 = load i32, i32* %4
%37 = icmp slt i32 %36, 5
br i1 %37, label %38, label %47
38: ; preds = %35
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [5 x [40 x i8]], [5 x [40 x i8]]* %2, i64 0, i64 %40
%42 = getelementptr inbounds [40 x i8], [40 x i8]* %41, i64 0, i64 0
%43 = call i32 @puts(i8* %42)
br label %44
44: ; preds = %38
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %35
47: ; preds = %35
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"Enter %d words beginning with q: \0A\00"
@.str.1 = [26 x i8] c"%s doesn't begin with q!\0A\00"
@.str.2 = [30 x i8] c"Here are the words accepted: \00"
define i32 @main() {
%1 = alloca [5 x [40 x i8]]
%2 = alloca [40 x i8]
%3 = getelementptr inbounds [5 x [40 x i8]], [5 x [40 x i8]]* %1, i64 0, i64 0, i64 0
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 5)
br label %6
6: ; preds = %0, %20
%7 = phi i32 [ 0, %0 ], [ %21, %20 ]
%8 = call i64 @gets(i8* %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %23, label %10
10: ; preds = %6
%11 = load i8, i8* %4
%12 = icmp eq i8 %11, 113
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %20
15: ; preds = %10
%16 = sext i32 %7 to i64
%17 = getelementptr inbounds [5 x [40 x i8]], [5 x [40 x i8]]* %1, i64 0, i64 %16, i64 0
%18 = call i32 @strcpy(i8* %17, i8* %4)
%19 = add nsw i32 %7, 1
br label %20
20: ; preds = %15, %13
%21 = phi i32 [ %7, %13 ], [ %19, %15 ]
%22 = icmp slt i32 %21, 5
br i1 %22, label %6, label %23
23: ; preds = %20, %6
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @puts(i8* %3)
%26 = getelementptr inbounds [5 x [40 x i8]], [5 x [40 x i8]]* %1, i64 0, i64 1, i64 0
%27 = call i32 @puts(i8* %26)
%28 = getelementptr inbounds [5 x [40 x i8]], [5 x [40 x i8]]* %1, i64 0, i64 2, i64 0
%29 = call i32 @puts(i8* %28)
%30 = getelementptr inbounds [5 x [40 x i8]], [5 x [40 x i8]]* %1, i64 0, i64 3, i64 0
%31 = call i32 @puts(i8* %30)
%32 = getelementptr inbounds [5 x [40 x i8]], [5 x [40 x i8]]* %1, i64 0, i64 4, i64 0
%33 = call i32 @puts(i8* %32)
ret i32 0
}