#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*/ printf(char *, ...);
int readln(char *, int);
char *trimstr(char *);
int main() {
  int len;
  char s[120];
  while ((len = readln(s, 120)) != 0) {
    if (len == 1)
      continue;
    printf("len=%d\n", len);
    printf("TRIMMED:%s", trimstr(s));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x80(%rbp),%rdi
mov    $0x78,%esi
call   1040 <readln@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     119b <main+0x6b>
cmpl   $0x1,-0x8(%rbp)
jne    116b <main+0x3b>
jmp    1142 <main+0x12>
mov    -0x8(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x80(%rbp),%rdi
call   1050 <trimstr@plt>
mov    %rax,%rsi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1142 <main+0x12>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rsp,%rbx
lea    0xeba(%rip),%r14
lea    0xebb(%rip),%r15
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x78,%esi
call   1040 <readln@plt>
cmp    $0x1,%eax
je     1150 <main+0x20>
test   %eax,%eax
je     1189 <main+0x59>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1050 <trimstr@plt>
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1150 <main+0x20>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"len=%d\0A\00"
@.str.1 = [11 x i8] c"TRIMMED:%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [120 x i8]
store i32 0, i32* %1
br label %4
4: ; preds = %12, %11, %0
%5 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 0
%6 = call i32 @readln(i8* %5, i32 120)
store i32 %6, i32* %2
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %4
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %8
br label %4
12: ; preds = %8
%13 = load i32, i32* %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 0
%16 = call i8* @trimstr(i8* %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %4
18: ; preds = %4
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [8 x i8] c"len=%d\0A\00"
@.str.1 = [11 x i8] c"TRIMMED:%s\00"
define i32 @main() {
%1 = alloca [120 x i8]
%2 = getelementptr inbounds [120 x i8], [120 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %9, %0
%4 = call i32 @readln(i8* %2, i32 120)
switch i32 %4, label %5 [
i32 0, label %10
i32 1, label %9
]
5: ; preds = %3
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %4)
%7 = call i8* @trimstr(i8* %2)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %5, %3
br label %3
10: ; preds = %3
ret i32 0
}