#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 getline(char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int lines = 0, endRun = 0;
  char message[81];
  printf("\nEnter a string (to exit type a space and press Enter): ");
  while ((message[0] != '\0') && (endRun == 0)) {
    endRun = getline(message);
    lines++;
  }
  printf("\n\nThe numbers of lines used for this string was: %d.\n", lines);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x60(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x61(%rbp)
je     1167 <main+0x47>
cmpl   $0x0,-0xc(%rbp)
sete   %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    1177 <main+0x57>
jmp    1191 <main+0x71>
lea    -0x60(%rbp),%rdi
call   1040 <getline@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114b <main+0x2b>
mov    -0x8(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
lea    0xed2(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <getline@plt>
add    $0x1,%ebx
cmpb   $0x0,(%rsp)
je     1155 <main+0x35>
test   %eax,%eax
je     1140 <main+0x20>
lea    0xedd(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [57 x i8] c"\0AEnter a string (to exit type a space and press Enter): \00"
@.str.1 = [54 x i8] c"\0A\0AThe numbers of lines used for this string was: %d.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [81 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %16, %0
%7 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
br label %14
14: ; preds = %11, %6
%15 = phi i1 [ false, %6 ], [ %13, %11 ]
br i1 %15, label %16, label %21
16: ; preds = %14
%17 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%18 = call i32 @getline(i8* %17)
store i32 %18, i32* %3
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
br label %6
21: ; preds = %14
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [57 x i8] c"\0AEnter a string (to exit type a space and press Enter): \00"
@.str.1 = [54 x i8] c"\0A\0AThe numbers of lines used for this string was: %d.\0A\00"
define i32 @main() {
%1 = alloca [81 x i8]
%2 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ %7, %4 ], [ 0, %0 ]
%6 = call i32 @getline(i8* %2)
%7 = add nuw nsw i32 %5, 1
%8 = load i8, i8* %2
%9 = icmp ne i8 %8, 0
%10 = icmp eq i32 %6, 0
%11 = select i1 %9, i1 %10, i1 false
br i1 %11, label %4, label %12
12: ; preds = %4
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %7)
ret i32 0
}