#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*/ copy(char *, char *);
int getline(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int len;
  int max;
  char line[1000];
  char longest[1000];
  max = 0;
  while ((len = getline(line, 1000)) > 0) {
    if (line[len] == '\0') {
      printf("Check: %d\n", line[len - 1]);
    } else {
      printf("No Check: %d\n", line[len - 1]);
    }
    if (len > max) {
      max = len;
      copy(longest, line);
    }
  }
  if (max > 0)
    printf("%s", longest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1050 <getline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11e6 <main+0xb6>
movslq -0x8(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
jne    119e <main+0x6e>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x400(%rbp,%rax,1),%esi
ff
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bc <main+0x8c>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x400(%rbp,%rax,1),%esi
ff
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11e1 <main+0xb1>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0x7f0(%rbp),%rdi
lea    -0x400(%rbp),%rsi
call   1040 <copy@plt>
jmp    1149 <main+0x19>
cmpl   $0x0,-0xc(%rbp)
jle    1205 <main+0xd5>
lea    -0x7f0(%rbp),%rsi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7d8,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1050 <getline@plt>
test   %eax,%eax
jle    11db <main+0xab>
mov    %eax,%ebx
lea    0xea4(%rip),%r12
lea    0xe9a(%rip),%r13
lea    0x3f0(%rsp),%r14
mov    %rsp,%r15
xor    %ebp,%ebp
jmp    1193 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    $0x3e8,%esi
call   1050 <getline@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    11c1 <main+0x91>
mov    %ebx,%eax
cmpb   $0x0,(%rsp,%rax,1)
lea    -0x1(%rbx),%eax
movsbl (%rsp,%rax,1),%esi
mov    %r13,%rdi
cmove  %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    %ebp,%ebx
jle    1180 <main+0x50>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <copy@plt>
mov    %ebx,%ebp
jmp    1180 <main+0x50>
test   %ebp,%ebp
jle    11db <main+0xab>
lea    0xe42(%rip),%rdi
lea    0x3f0(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Check: %d\0A\00"
@.str.1 = [14 x i8] c"No Check: %d\0A\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1000 x i8]
%5 = alloca [1000 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
br label %6
6: ; preds = %42, %0
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%8 = call i32 @getline(i8* %7, i32 1000)
store i32 %8, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %43
10: ; preds = %6
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %10
%18 = load i32, i32* %2
%19 = sub nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %33
25: ; preds = %10
%26 = load i32, i32* %2
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %25, %17
%34 = load i32, i32* %2
%35 = load i32, i32* %3
%36 = icmp sgt i32 %34, %35
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load i32, i32* %2
store i32 %38, i32* %3
%39 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%40 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%41 = call i32 @copy(i8* %39, i8* %40)
br label %42
42: ; preds = %37, %33
br label %6
43: ; preds = %6
%44 = load i32, i32* %3
%45 = icmp sgt i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %46, %43
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"Check: %d\0A\00"
@.str.1 = [14 x i8] c"No Check: %d\0A\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%5 = call i32 @getline(i8* %3, i32 1000)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %32
7: ; preds = %0, %24
%8 = phi i32 [ %26, %24 ], [ %5, %0 ]
%9 = phi i32 [ %25, %24 ], [ 0, %0 ]
%10 = zext i32 %8 to i64
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
%14 = add nsw i32 %8, -1
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = select i1 %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %19, i32 %18)
%21 = icmp sgt i32 %8, %9
br i1 %21, label %22, label %24
22: ; preds = %7
%23 = call i32 @copy(i8* %4, i8* %3)
br label %24
24: ; preds = %22, %7
%25 = phi i32 [ %8, %22 ], [ %9, %7 ]
%26 = call i32 @getline(i8* %3, i32 1000)
%27 = icmp sgt i32 %26, 0
br i1 %27, label %7, label %28
28: ; preds = %24
%29 = icmp sgt i32 %25, 0
br i1 %29, label %30, label %32
30: ; preds = %28
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %32
32: ; preds = %0, %30, %28
ret i32 0
}