#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 getl(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main() {
  int len;
  char line[1024];
  while ((len = getl(line, 1024)) > 0) {
    printf("Before remove trailing blanks and tabs: %s", line);
    printf("Charaters in char array: ");
    int j;
    for (j = 0; j < strlen(line); ++j) {
      printf(" %d ", line[j]);
    }
    printf("\n");
    if (line[len - 1] == '\n') {
      int i = len - 2;
      while (i >= 0 && (line[i] == ' ' || line[i] == '\t')) {
        --i;
      }
      if (i > 0) {
        line[i + 1] = '\n';
        line[i + 2] = '\0';
      }
    }
    if (len > 2) {
      printf("After remove trailing blanks and tabs: %s", line);
      printf("Charaters in char array: ");
      for (j = 0; j < strlen(line); ++j) {
        printf(" %d ", line[j]);
      }
      printf("\n\n");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
call   1030 <getl@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1376 <main+0x246>
lea    -0x410(%rbp),%rsi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x414(%rbp)
mov    -0x414(%rbp),%eax
mov    %eax,-0x41c(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x41c(%rbp),%eax
cmp    %ecx,%eax
jge    11e5 <main+0xb5>
movslq -0x414(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%esi
ff
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    118c <main+0x5c>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    12d3 <main+0x1a3>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x418(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x418(%rbp)
mov    %al,-0x41d(%rbp)
jl     1274 <main+0x144>
movslq -0x418(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%ecx
ff
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x41e(%rbp)
je     1268 <main+0x138>
movslq -0x418(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0x9,%eax
sete   %al
mov    %al,-0x41e(%rbp)
mov    -0x41e(%rbp),%al
mov    %al,-0x41d(%rbp)
mov    -0x41d(%rbp),%al
test   $0x1,%al
jne    1287 <main+0x157>
jmp    129b <main+0x16b>
mov    -0x418(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x418(%rbp)
jmp    1218 <main+0xe8>
cmpl   $0x0,-0x418(%rbp)
jle    12ce <main+0x19e>
mov    -0x418(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0xa,-0x410(%rbp,%rax,1)
0a
mov    -0x418(%rbp),%eax
add    $0x2,%eax
cltq
movb   $0x0,-0x410(%rbp,%rax,1)
jmp    12d3 <main+0x1a3>
cmpl   $0x2,-0x8(%rbp)
jle    1371 <main+0x241>
lea    -0x410(%rbp),%rsi
lea    0xd5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x414(%rbp)
mov    -0x414(%rbp),%eax
mov    %eax,-0x424(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x424(%rbp),%eax
cmp    %ecx,%eax
jge    1363 <main+0x233>
movslq -0x414(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%esi
ff
lea    0xcfd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    130a <main+0x1da>
lea    0xd0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1142 <main+0x12>
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%rdi
mov    $0x400,%esi
call   1050 <getl@plt>
test   %eax,%eax
jle    12d6 <main+0x186>
mov    %eax,%r13d
lea    0xe80(%rip),%r14
mov    %rsp,%rbx
lea    0xea1(%rip),%r15
lea    0xeb4(%rip),%r12
jmp    11c4 <main+0x74>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xecd(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <getl@plt>
mov    %eax,%r13d
test   %eax,%eax
jle    12d6 <main+0x186>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    1211 <main+0xc1>
xor    %ebp,%ebp
nopl   0x0(%rax)
movsbl (%rsp,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     11f0 <main+0xa0>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    -0x1(%r13),%eax
cmpb   $0xa,(%rsp,%rax,1)
jne    1270 <main+0x120>
cmp    $0x2,%r13d
jl     1270 <main+0x120>
lea    -0x2(%r13),%eax
add    $0x1,%rax
jmp    1246 <main+0xf6>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffffffffffff,%rax
jle    1270 <main+0x120>
movzbl -0x1(%rsp,%rax,1),%ecx
cmp    $0x20,%cl
je     1240 <main+0xf0>
cmp    $0x9,%cl
je     1240 <main+0xf0>
cmp    $0x1,%eax
je     1270 <main+0x120>
mov    %eax,%ecx
movb   $0xa,(%rsp,%rcx,1)
add    $0x1,%eax
movb   $0x0,(%rsp,%rax,1)
nopw   0x0(%rax,%rax,1)
cmp    $0x3,%r13d
jl     11ac <main+0x5c>
lea    0xdc9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    11a0 <main+0x50>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movsbl (%rsp,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     12b0 <main+0x160>
jmp    11a0 <main+0x50>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Before remove trailing blanks and tabs: %s\00"
@.str.1 = [26 x i8] c"Charaters in char array: \00"
@.str.2 = [5 x i8] c" %d \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [42 x i8] c"After remove trailing blanks and tabs: %s\00"
@.str.5 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %102, %0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = call i32 @getl(i8* %7, i32 1024)
store i32 %8, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %103
10: ; preds = %6
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %14
14: ; preds = %26, %10
%15 = load i32, i32* %4
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %29
19: ; preds = %14
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %19
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %14
29: ; preds = %14
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%31 = load i32, i32* %2
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 10
br i1 %37, label %38, label %78
38: ; preds = %29
%39 = load i32, i32* %2
%40 = sub nsw i32 %39, 2
store i32 %40, i32* %5
br label %41
41: ; preds = %62, %38
%42 = load i32, i32* %5
%43 = icmp sge i32 %42, 0
br i1 %43, label %44, label %60
44: ; preds = %41
%45 = load i32, i32* %5
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 32
br i1 %50, label %58, label %51
51: ; preds = %44
%52 = load i32, i32* %5
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 9
br label %58
58: ; preds = %51, %44
%59 = phi i1 [ true, %44 ], [ %57, %51 ]
br label %60
60: ; preds = %58, %41
%61 = phi i1 [ false, %41 ], [ %59, %58 ]
br i1 %61, label %62, label %65
62: ; preds = %60
%63 = load i32, i32* %5
%64 = add nsw i32 %63, -1
store i32 %64, i32* %5
br label %41
65: ; preds = %60
%66 = load i32, i32* %5
%67 = icmp sgt i32 %66, 0
br i1 %67, label %68, label %77
68: ; preds = %65
%69 = load i32, i32* %5
%70 = add nsw i32 %69, 1
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %71
store i8 10, i8* %72
%73 = load i32, i32* %5
%74 = add nsw i32 %73, 2
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %75
store i8 0, i8* %76
br label %77
77: ; preds = %68, %65
br label %78
78: ; preds = %77, %29
%79 = load i32, i32* %2
%80 = icmp sgt i32 %79, 2
br i1 %80, label %81, label %102
81: ; preds = %78
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %82)
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %85
85: ; preds = %97, %81
%86 = load i32, i32* %4
%87 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%88 = call i32 @strlen(i8* %87)
%89 = icmp slt i32 %86, %88
br i1 %89, label %90, label %100
90: ; preds = %85
%91 = load i32, i32* %4
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %92
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %95)
br label %97
97: ; preds = %90
%98 = load i32, i32* %4
%99 = add nsw i32 %98, 1
store i32 %99, i32* %4
br label %85
100: ; preds = %85
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %102
102: ; preds = %100, %78
br label %6
103: ; preds = %6
%104 = load i32, i32* %1
ret i32 %104
}

LLVM IR (-O2):
@.str = [43 x i8] c"Before remove trailing blanks and tabs: %s\00"
@.str.1 = [26 x i8] c"Charaters in char array: \00"
@.str.2 = [5 x i8] c" %d \00"
@.str.4 = [42 x i8] c"After remove trailing blanks and tabs: %s\00"
@str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = call i32 @getl(i8* %2, i32 1024)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %72
5: ; preds = %0, %69
%6 = phi i32 [ %70, %69 ], [ %3, %0 ]
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %2)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @strlen(i8* %2)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %5, %11
%12 = phi i64 [ %17, %11 ], [ 0, %5 ]
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = add nuw nsw i64 %12, 1
%18 = call i32 @strlen(i8* %2)
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %11, label %21
21: ; preds = %11, %5
%22 = call i32 @putchar(i32 10)
%23 = add nsw i32 %6, -1
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 10
%28 = icmp sgt i32 %6, 1
%29 = select i1 %27, i1 %28, i1 false
br i1 %29, label %30, label %50
30: ; preds = %21
%31 = add nsw i32 %6, -2
%32 = zext i32 %31 to i64
br label %33
33: ; preds = %30, %37
%34 = phi i64 [ %32, %30 ], [ %38, %37 ]
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %34
%36 = load i8, i8* %35
switch i8 %36, label %40 [
i8 32, label %37
i8 9, label %37
]
37: ; preds = %33, %33
%38 = add nsw i64 %34, -1
%39 = icmp sgt i64 %34, 0
br i1 %39, label %33, label %50
40: ; preds = %33
%41 = trunc i64 %34 to i32
%42 = icmp eq i32 %41, 0
br i1 %42, label %50, label %43
43: ; preds = %40
%44 = add nuw nsw i64 %34, 1
%45 = and i64 %44, 4294967295
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %45
store i8 10, i8* %46
%47 = add nuw i64 %34, 2
%48 = and i64 %47, 4294967295
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %48
store i8 0, i8* %49
br label %50
50: ; preds = %37, %40, %43, %21
%51 = icmp sgt i32 %6, 2
br i1 %51, label %52, label %69
52: ; preds = %50
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%55 = call i32 @strlen(i8* %2)
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %67
57: ; preds = %52, %57
%58 = phi i64 [ %63, %57 ], [ 0, %52 ]
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %61)
%63 = add nuw nsw i64 %58, 1
%64 = call i32 @strlen(i8* %2)
%65 = sext i32 %64 to i64
%66 = icmp slt i64 %63, %65
br i1 %66, label %57, label %67
67: ; preds = %57, %52
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %69
69: ; preds = %67, %50
%70 = call i32 @getl(i8* %2, i32 1024)
%71 = icmp sgt i32 %70, 0
br i1 %71, label %5, label %72
72: ; preds = %69, %0
ret i32 0
}