#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*/ *gets(char *);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ strcmp(char *, char *);
int main(void) {
  char input[100][81];
  int ct = 0;
  printf("Enter up to %d lines (type quit to quit): \n", 100);
  while (ct < 100 && gets(input[ct]) != NULL &&
         strcmp(input[ct], "quit") != 0) {
    ct++;
  }
  printf("%d strings entered\n", ct);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1fc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1fb4(%rbp)
lea    0xead(%rip),%rdi
mov    $0x64,%esi
call   1030 <printf@plt>
xor    %eax,%eax
cmpl   $0x64,-0x1fb4(%rbp)
mov    %al,-0x1fb5(%rbp)
jge    11cf <main+0x9f>
movslq -0x1fb4(%rbp),%rax
lea    -0x1fb0(%rbp),%rdi
imul   $0x51,%rax,%rax
add    %rax,%rdi
call   1050 <gets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x1fb5(%rbp)
je     11cf <main+0x9f>
movslq -0x1fb4(%rbp),%rax
lea    -0x1fb0(%rbp),%rdi
imul   $0x51,%rax,%rax
add    %rax,%rdi
lea    0xe6f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1fb5(%rbp)
mov    -0x1fb5(%rbp),%al
test   $0x1,%al
jne    11e2 <main+0xb2>
jmp    11f6 <main+0xc6>
mov    -0x1fb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1fb4(%rbp)
jmp    115d <main+0x2d>
mov    -0x1fb4(%rbp),%esi
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1fc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1fb0,%rsp
lea    0xebd(%rip),%rdi
mov    $0x64,%esi
call   1030 <printf@plt>
mov    %rsp,%rbx
xor    %r14d,%r14d
lea    0xed2(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <gets@plt>
test   %rax,%rax
je     1191 <main+0x61>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1191 <main+0x61>
add    $0x1,%r14
add    $0x51,%rbx
cmp    $0x64,%r14
jne    1160 <main+0x30>
mov    $0x64,%r14d
lea    0xe99(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1fb0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Enter up to %d lines (type quit to quit): \0A\00"
@.str.1 = [5 x i8] c"quit\00"
@.str.2 = [20 x i8] c"%d strings entered\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x [81 x i8]]
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%4 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 100)
br label %5
5: ; preds = %24, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 100
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [100 x [81 x i8]], [100 x [81 x i8]]* %2, i64 0, i64 %10
%12 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%13 = call i32* @gets(i8* %12)
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %22
15: ; preds = %8
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100 x [81 x i8]], [100 x [81 x i8]]* %2, i64 0, i64 %17
%19 = getelementptr inbounds [81 x i8], [81 x i8]* %18, i64 0, i64 0
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br label %22
22: ; preds = %15, %8, %5
%23 = phi i1 [ false, %8 ], [ false, %5 ], [ %21, %15 ]
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %5
27: ; preds = %22
%28 = load i32, i32* %3
%29 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"Enter up to %d lines (type quit to quit): \0A\00"
@.str.1 = [5 x i8] c"quit\00"
@.str.2 = [20 x i8] c"%d strings entered\0A\00"
define i32 @main() {
%1 = alloca [100 x [81 x i8]]
%2 = getelementptr inbounds [100 x [81 x i8]], [100 x [81 x i8]]* %1, i64 0, i64 0, i64 0
%3 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 100)
br label %4
4: ; preds = %0, %12
%5 = phi i64 [ 0, %0 ], [ %13, %12 ]
%6 = getelementptr inbounds [100 x [81 x i8]], [100 x [81 x i8]]* %1, i64 0, i64 %5, i64 0
%7 = call i32* @gets(i8* %6)
%8 = icmp eq i32* %7, null
br i1 %8, label %15, label %9
9: ; preds = %4
%10 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %9
%13 = add nuw nsw i64 %5, 1
%14 = icmp eq i64 %13, 100
br i1 %14, label %19, label %4
15: ; preds = %4
%16 = trunc i64 %5 to i32
br label %19
17: ; preds = %9
%18 = trunc i64 %5 to i32
br label %19
19: ; preds = %12, %17, %15
%20 = phi i32 [ %16, %15 ], [ %18, %17 ], [ 100, %12 ]
%21 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %20)
ret i32 0
}