#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ get_line(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ trim_right(char *, int);
int main(int argc, char **argv) {
  int length;
  char buffer[65536];
  if (argc != 2) {
    fprintf(stderr, "Usage: %s length\n", argv[0]);
    exit(1);
  }
  length = atoi(argv[1]);
  while (get_line(buffer, stdin)) {
    trim_right(buffer, length);
    printf("%s\n", buffer);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11a9 <main+0x49>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe66(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    -0x10020(%rbp),%rdi
mov    0x2e21(%rip),%rax
mov    (%rax),%esi
call   1040 <get_line@plt>
cmp    $0x0,%rax
je     11ff <main+0x9f>
lea    -0x10020(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <trim_right@plt>
lea    -0x10020(%rbp),%rsi
lea    0xe1d(%rip),%rdi
call   1050 <printf@plt>
jmp    11b9 <main+0x59>
xor    %eax,%eax
add    $0x10020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x10008,%rsp
cmp    $0x2,%edi
jne    11d5 <main+0x75>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
mov    0x2e64(%rip),%r15
mov    (%r15),%esi
mov    %rsp,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     11c5 <main+0x65>
mov    %rsp,%rbx
lea    0xe74(%rip),%r14
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <trim_right@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    (%r15),%esi
mov    %rbx,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
jne    11a0 <main+0x40>
xor    %eax,%eax
add    $0x10008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe18(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [18 x i8] c"Usage: %s length\0A\00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [65536 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %6
br label %22
22: ; preds = %27, %17
%23 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
%24 = load i32, i32* @stdin
%25 = call i64 @get_line(i8* %23, i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %22
%28 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
%29 = load i32, i32* %6
%30 = call i32 @trim_right(i8* %28, i32 %29)
%31 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %31)
br label %22
33: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"Usage: %s length\0A\00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [65536 x i8]
%4 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = load i32, i32* @stdin
%16 = call i64 @get_line(i8* %4, i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %11, %18
%19 = call i32 @trim_right(i8* %4, i32 %14)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%21 = load i32, i32* @stdin
%22 = call i64 @get_line(i8* %4, i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %18
24: ; preds = %18, %11
ret i32 0
}