#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 *, size_t);
int /*<<< orphan*/ puts(char *);
size_t strlen(char *);
int main(int argc, char *argv[]) {
  size_t length;
  char buf[80];
  while (1) {
    puts("\nEnter a line of text, a blank line to exit.");
    gets(buf);
    length = strlen(buf);
    if (length != 0)
      printf("\nThat line is %u characters long.", length);
    else
      break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
lea    -0x70(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1198 <main+0x58>
mov    -0x18(%rbp),%rsi
lea    0xe9f(%rip),%rdi
call   1050 <printf@plt>
jmp    119d <main+0x5d>
jmp    11a2 <main+0x62>
jmp    1156 <main+0x16>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     11a8 <main+0x68>
lea    0xeb9(%rip),%r14
lea    0xe85(%rip),%r15
mov    %rsp,%rbx
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
jne    1180 <main+0x40>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [45 x i8] c"\0AEnter a line of text, a blank line to exit.\00"
@.str.1 = [34 x i8] c"\0AThat line is %u characters long.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca [80 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %2, %20
%9 = call i32 @puts(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%13 = call i64 @strlen(i8* %12)
store i64 %13, i64* %6
%14 = load i64, i64* %6
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %8
%17 = load i64, i64* %6
%18 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 %17)
br label %20
19: ; preds = %8
br label %21
20: ; preds = %16
br label %8
21: ; preds = %19
ret i32 0
}

LLVM IR (-O2):
@.str = [45 x i8] c"\0AEnter a line of text, a blank line to exit.\00"
@.str.1 = [34 x i8] c"\0AThat line is %u characters long.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %4)
%7 = call i64 @strlen(i8* %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %2, %9
%10 = phi i64 [ %14, %9 ], [ %7, %2 ]
%11 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 %10)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @gets(i8* %4)
%14 = call i64 @strlen(i8* %4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %9
16: ; preds = %9, %2
ret i32 0
}