#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*/ copyLine(char *, char *);
int getLine(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reverseLine(char *, char *);
int main() {
  char line[100], largestLine[100];
  int length;
  int maxFound = 0;
  while ((length = getLine(line, 100)) > 0) {
    printf("Line length = %d, content : %s\n", length, line);
    if (length > maxFound) {
      maxFound = length;
      copyLine(largestLine, line);
    }
  }
  if (maxFound > 0)
    printf("Your longest line was : %s\n", largestLine);
  reverseLine(line, largestLine);
  printf("In reverse it becomes : %s\n", line);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xe8(%rbp)
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
call   1060 <getLine@plt>
mov    %eax,-0xe4(%rbp)
cmp    $0x0,%eax
jle    11c4 <main+0x84>
mov    -0xe4(%rbp),%esi
lea    -0x70(%rbp),%rdx
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xe4(%rbp),%eax
cmp    -0xe8(%rbp),%eax
jle    11bf <main+0x7f>
mov    -0xe4(%rbp),%eax
mov    %eax,-0xe8(%rbp)
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1050 <copyLine@plt>
jmp    115c <main+0x1c>
cmpl   $0x0,-0xe8(%rbp)
jle    11e6 <main+0xa6>
lea    -0xe0(%rbp),%rsi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1040 <reverseLine@plt>
lea    -0x70(%rbp),%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xe0,%rsp
lea    0x70(%rsp),%rdi
mov    $0x64,%esi
call   1060 <getLine@plt>
test   %eax,%eax
jle    11ca <main+0x8a>
mov    %eax,%ebp
lea    0xe95(%rip),%r14
lea    0x70(%rsp),%r12
mov    %rsp,%r15
xor    %ebx,%ebx
jmp    1193 <main+0x53>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x64,%esi
call   1060 <getLine@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    11b5 <main+0x75>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
cmp    %ebx,%ebp
jle    1180 <main+0x40>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <copyLine@plt>
mov    %ebp,%ebx
jmp    1180 <main+0x40>
test   %ebx,%ebx
jle    11ca <main+0x8a>
lea    0xe60(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x70(%rsp),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <reverseLine@plt>
lea    0xe5b(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Line length = %d, content : %s\0A\00"
@.str.1 = [28 x i8] c"Your longest line was : %s\0A\00"
@.str.2 = [28 x i8] c"In reverse it becomes : %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
br label %6
6: ; preds = %22, %0
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%8 = call i32 @getLine(i8* %7, i32 100)
store i32 %8, i32* %4
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %6
%11 = load i32, i32* %4
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %11, i8* %12)
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = icmp sgt i32 %14, %15
br i1 %16, label %17, label %22
17: ; preds = %10
%18 = load i32, i32* %4
store i32 %18, i32* %5
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%21 = call i32 @copyLine(i8* %19, i8* %20)
br label %22
22: ; preds = %17, %10
br label %6
23: ; preds = %6
%24 = load i32, i32* %5
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %26, %23
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%32 = call i32 @reverseLine(i8* %30, i8* %31)
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Line length = %d, content : %s\0A\00"
@.str.1 = [28 x i8] c"Your longest line was : %s\0A\00"
@.str.2 = [28 x i8] c"In reverse it becomes : %s\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 @getLine(i8* %3, i32 100)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %22
7: ; preds = %0, %14
%8 = phi i32 [ %16, %14 ], [ %5, %0 ]
%9 = phi i32 [ %15, %14 ], [ 0, %0 ]
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %8, i8* %3)
%11 = icmp sgt i32 %8, %9
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 @copyLine(i8* %4, i8* %3)
br label %14
14: ; preds = %12, %7
%15 = phi i32 [ %8, %12 ], [ %9, %7 ]
%16 = call i32 @getLine(i8* %3, i32 100)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %7, label %18
18: ; preds = %14
%19 = icmp sgt i32 %15, 0
br i1 %19, label %20, label %22
20: ; preds = %18
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %22
22: ; preds = %0, %20, %18
%23 = call i32 @reverseLine(i8* %3, i8* %4)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %3)
ret i32 0
}