#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 EOF;
int getchar();
int /*<<< orphan*/ putchar(int);
trimWhitespace() {
  int c, n;
  while ((c = getchar()) != EOF) {
    if (c == '\n') {
      putchar(c);
      while ((n = getchar()) == '\n') {
        ;
      }
      c = n;
    }
    putchar(c);
  }
  return 0;
}


x86 assembly (clang, -O0):
<trimWhitespace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    0x2eaf(%rip),%rcx
cmp    (%rcx),%eax
je     117e <trimWhitespace+0x5e>
cmpl   $0xa,-0x4(%rbp)
jne    1171 <trimWhitespace+0x51>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xa,%eax
jne    116b <trimWhitespace+0x4b>
jmp    1153 <trimWhitespace+0x33>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
jmp    1128 <trimWhitespace+0x8>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trimWhitespace>:
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb9(%rip),%rbx
jmp    114e <trimWhitespace+0x2e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%eax
je     117e <trimWhitespace+0x5e>
cmp    $0xa,%eax
jne    1140 <trimWhitespace+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1170 <trimWhitespace+0x50>
jmp    1140 <trimWhitespace+0x20>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @trimWhitespace() {
%1 = alloca i32
%2 = alloca i32
br label %3
3: ; preds = %19, %0
%4 = call i32 (...) @getchar()
store i32 %4, i32* %1
%5 = load i32, i32* @EOF
%6 = icmp ne i32 %4, %5
br i1 %6, label %7, label %22
7: ; preds = %3
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 10
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = load i32, i32* %1
%12 = call i32 @putchar(i32 %11)
br label %13
13: ; preds = %16, %10
%14 = call i32 (...) @getchar()
store i32 %14, i32* %2
%15 = icmp eq i32 %14, 10
br i1 %15, label %16, label %17
16: ; preds = %13
br label %13
17: ; preds = %13
%18 = load i32, i32* %2
store i32 %18, i32* %1
br label %19
19: ; preds = %17, %7
%20 = load i32, i32* %1
%21 = call i32 @putchar(i32 %20)
br label %3
22: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @trimWhitespace() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %18, label %4
4: ; preds = %0, %12
%5 = phi i32 [ %15, %12 ], [ %1, %0 ]
%6 = icmp eq i32 %5, 10
br i1 %6, label %7, label %12
7: ; preds = %4
%8 = tail call i32 @putchar(i32 10)
br label %9
9: ; preds = %9, %7
%10 = tail call i32 (...) @getchar()
%11 = icmp eq i32 %10, 10
br i1 %11, label %9, label %12
12: ; preds = %9, %4
%13 = phi i32 [ %5, %4 ], [ %10, %9 ]
%14 = tail call i32 @putchar(i32 %13)
%15 = tail call i32 (...) @getchar()
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %4
18: ; preds = %12, %0
ret i32 0
}