#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*/ BUFSIZ;
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
char **tail(int /*<<< orphan*/, int, int /*<<< orphan*/, int *);
int main(int argc, char **argv) {
  char **lines;
  int n, i;
  int pos = 0;
  if (argc < 2 || (n = atoi(argv[1])) < 1) {
    printf("You should enter the number of lines as the first paramenter.\n");
    exit(1);
  }
  lines = tail(stdin, n, BUFSIZ, &pos);
  for (i = 0; i < n; i++) {
    if (lines[(pos + i) % n] != NULL)
      printf("%s", lines[(pos + i) % n]);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1180 <main+0x40>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x1,%eax
jge    1198 <main+0x58>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%esi
mov    0x2e2d(%rip),%rax
mov    (%rax),%edx
lea    -0x24(%rbp),%rcx
call   1040 <tail@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    122f <main+0xef>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    -0x20(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    -0x30(%rbp),%rax
movslq %edx,%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     121c <main+0xdc>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%eax
add    -0x20(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    -0x38(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1221 <main+0xe1>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c1 <main+0x81>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
cmp    $0x2,%edi
jl     1171 <main+0x21>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
test   %eax,%eax
jg     1187 <main+0x37>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    %eax,%ebx
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
mov    0x2e3f(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    %ebx,%esi
call   1050 <tail@plt>
mov    %rax,%r14
lea    0xe4f(%rip),%r15
xor    %ebp,%ebp
jmp    11c7 <main+0x77>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
cmp    %ebp,%ebx
je     11e8 <main+0x98>
mov    0x4(%rsp),%eax
add    %ebp,%eax
cltd
idiv   %ebx
movslq %edx,%rax
mov    (%r14,%rax,8),%rsi
test   %rsi,%rsi
je     11c0 <main+0x70>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c0 <main+0x70>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [63 x i8] c"You should enter the number of lines as the first paramenter.\0A\00"
@stdin = global i32 0
@BUFSIZ = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %18, label %12
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %7
%17 = icmp slt i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %12, %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %12
%22 = load i32, i32* @stdin
%23 = load i32, i32* %7
%24 = load i32, i32* @BUFSIZ
%25 = call i8** @tail(i32 %22, i32 %23, i32 %24, i32* %9)
store i8** %25, i8*** %6
store i32 0, i32* %8
br label %26
26: ; preds = %53, %21
%27 = load i32, i32* %8
%28 = load i32, i32* %7
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %56
30: ; preds = %26
%31 = load i8**, i8*** %6
%32 = load i32, i32* %9
%33 = load i32, i32* %8
%34 = add nsw i32 %32, %33
%35 = load i32, i32* %7
%36 = srem i32 %34, %35
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %31, i64 %37
%39 = load i8*, i8** %38
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %52
41: ; preds = %30
%42 = load i8**, i8*** %6
%43 = load i32, i32* %9
%44 = load i32, i32* %8
%45 = add nsw i32 %43, %44
%46 = load i32, i32* %7
%47 = srem i32 %45, %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %42, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %41, %30
br label %53
53: ; preds = %52
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
store i32 %55, i32* %8
br label %26
56: ; preds = %26
%57 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdin = global i32 0
@BUFSIZ = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@str = [62 x i8] c"You should enter the number of lines as the first paramenter.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = icmp slt i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = icmp slt i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %6, %2
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %6
%15 = load i32, i32* @stdin
%16 = load i32, i32* @BUFSIZ
%17 = call i8** @tail(i32 %15, i32 %9, i32 %16, i32* %3)
br label %18
18: ; preds = %14, %29
%19 = phi i32 [ %30, %29 ], [ 0, %14 ]
%20 = load i32, i32* %3
%21 = add nsw i32 %20, %19
%22 = srem i32 %21, %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %17, i64 %23
%25 = load i8*, i8** %24
%26 = icmp eq i8* %25, null
br i1 %26, label %29, label %27
27: ; preds = %18
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %25)
br label %29
29: ; preds = %18, %27
%30 = add nuw nsw i32 %19, 1
%31 = icmp eq i32 %30, %9
br i1 %31, label %32, label %18
32: ; preds = %29
%33 = call i32 @exit(i32 0)
unreachable
}