#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 */
struct node {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ destroyList(struct node *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ insertNode(struct node **, struct node **, int);
int /*<<< orphan*/ printList(struct node *);
struct node *reverseByKNodes(struct node *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  struct node *head = NULL;
  struct node *tail = NULL;
  char buffer[2048];
  char *p = NULL;
  int k;
  int value;
  fgets(buffer, 2048, stdin);
  p = strtok(buffer, "abcdefghijklmnopqrstuvwxyz=\nABCDEFGIJKLMNOPQRSTUVWXYZ");
  sscanf(p, "%d", &k);
  fgets(buffer, 2048, stdin);
  p = strtok(buffer, "NULL > | \n");
  while (p != NULL) {
    sscanf(p, "%d", &value);
    insertNode(&head, &tail, value);
    p = strtok(NULL, "NULL null | > \n");
  }
  printList(head);
  head = reverseByKNodes(head, k);
  printList(head);
  destroyList(head);
  head = NULL;
  tail = NULL;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x828(%rbp)
lea    -0x820(%rbp),%rdi
mov    0x2e36(%rip),%rax
mov    (%rax),%edx
mov    $0x800,%esi
call   1060 <fgets@plt>
lea    -0x820(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x828(%rbp)
mov    -0x828(%rbp),%rdi
lea    0xe50(%rip),%rsi
lea    -0x82c(%rbp),%rdx
call   1070 <sscanf@plt>
lea    -0x820(%rbp),%rdi
mov    0x2de8(%rip),%rax
mov    (%rax),%edx
mov    $0x800,%esi
call   1060 <fgets@plt>
lea    -0x820(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x828(%rbp)
cmpq   $0x0,-0x828(%rbp)
je     127d <main+0x10d>
mov    -0x828(%rbp),%rdi
lea    0xdf4(%rip),%rsi
lea    -0x830(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x830(%rbp),%edx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <insertNode@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdd8(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x828(%rbp)
jmp    1226 <main+0xb6>
mov    -0x18(%rbp),%rdi
call   1090 <printList@plt>
mov    -0x18(%rbp),%rdi
mov    -0x82c(%rbp),%esi
call   1040 <reverseByKNodes@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <printList@plt>
mov    -0x18(%rbp),%rdi
call   1050 <destroyList@plt>
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
xor    %eax,%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x820,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x18(%rsp)
mov    0x2e4f(%rip),%r14
mov    (%r14),%edx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x800,%esi
call   1060 <fgets@plt>
lea    0xe4b(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strtok@plt>
lea    0xe72(%rip),%rsi
lea    0x14(%rsp),%rdx
mov    %rax,%rdi
call   1070 <sscanf@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x800,%esi
call   1060 <fgets@plt>
lea    0xe51(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strtok@plt>
test   %rax,%rax
je     1253 <main+0xe3>
lea    0xe3a(%rip),%r14
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0x18(%rsp),%r13
lea    0xe32(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1070 <sscanf@plt>
mov    0x10(%rsp),%edx
mov    %r12,%rdi
mov    %r13,%rsi
call   1030 <insertNode@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
jne    1220 <main+0xb0>
mov    0x8(%rsp),%rdi
jmp    1255 <main+0xe5>
xor    %edi,%edi
call   1090 <printList@plt>
mov    0x8(%rsp),%rdi
mov    0x14(%rsp),%esi
call   1040 <reverseByKNodes@plt>
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
call   1090 <printList@plt>
mov    0x8(%rsp),%rdi
call   1050 <destroyList@plt>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@stdin = global i32 0
@.str = [54 x i8] c"abcdefghijklmnopqrstuvwxyz=\0AABCDEFGIJKLMNOPQRSTUVWXYZ\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"NULL > | \0A\00"
@.str.3 = [16 x i8] c"NULL null | > \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.node*
%7 = alloca %struct.node*
%8 = alloca [2048 x i8]
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.node* null, %struct.node** %6
store %struct.node* null, %struct.node** %7
store i8* null, i8** %9
%12 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %12, i32 2048, i32 %13)
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%16 = call i8* @strtok(i8* %15, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
store i8* %16, i8** %9
%17 = load i8*, i8** %9
%18 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%19 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%20 = load i32, i32* @stdin
%21 = call i32 @fgets(i8* %19, i32 2048, i32 %20)
%22 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%23 = call i8* @strtok(i8* %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i8* %23, i8** %9
br label %24
24: ; preds = %27, %2
%25 = load i8*, i8** %9
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = load i8*, i8** %9
%29 = call i32 @sscanf(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %11)
%30 = load i32, i32* %11
%31 = call i32 @insertNode(%struct.node** %6, %struct.node** %7, i32 %30)
%32 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
store i8* %32, i8** %9
br label %24
33: ; preds = %24
%34 = load %struct.node*, %struct.node** %6
%35 = call i32 @printList(%struct.node* %34)
%36 = load %struct.node*, %struct.node** %6
%37 = load i32, i32* %10
%38 = call %struct.node* @reverseByKNodes(%struct.node* %36, i32 %37)
store %struct.node* %38, %struct.node** %6
%39 = load %struct.node*, %struct.node** %6
%40 = call i32 @printList(%struct.node* %39)
%41 = load %struct.node*, %struct.node** %6
%42 = call i32 @destroyList(%struct.node* %41)
store %struct.node* null, %struct.node** %6
store %struct.node* null, %struct.node** %7
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@stdin = global i32 0
@.str = [54 x i8] c"abcdefghijklmnopqrstuvwxyz=\0AABCDEFGIJKLMNOPQRSTUVWXYZ\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"NULL > | \0A\00"
@.str.3 = [16 x i8] c"NULL null | > \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.node*
%4 = alloca %struct.node*
%5 = alloca [2048 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = bitcast %struct.node** %3 to i8*
store %struct.node* null, %struct.node** %3
%9 = bitcast %struct.node** %4 to i8*
store %struct.node* null, %struct.node** %4
%10 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%11 = bitcast i32* %6 to i8*
%12 = bitcast i32* %7 to i8*
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %10, i32 2048, i32 %13)
%15 = call i8* @strtok(i8* %10, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%17 = load i32, i32* @stdin
%18 = call i32 @fgets(i8* %10, i32 2048, i32 %17)
%19 = call i8* @strtok(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %30, label %21
21: ; preds = %2, %21
%22 = phi i8* [ %26, %21 ], [ %19, %2 ]
%23 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%24 = load i32, i32* %7
%25 = call i32 @insertNode(%struct.node** %3, %struct.node** %4, i32 %24)
%26 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %21
28: ; preds = %21
%29 = load %struct.node*, %struct.node** %3
br label %30
30: ; preds = %28, %2
%31 = phi %struct.node* [ %29, %28 ], [ null, %2 ]
%32 = call i32 @printList(%struct.node* %31)
%33 = load %struct.node*, %struct.node** %3
%34 = load i32, i32* %6
%35 = call %struct.node* @reverseByKNodes(%struct.node* %33, i32 %34)
store %struct.node* %35, %struct.node** %3
%36 = call i32 @printList(%struct.node* %35)
%37 = load %struct.node*, %struct.node** %3
%38 = call i32 @destroyList(%struct.node* %37)
ret i32 0
}