#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, int);
void PRINT_STATIONS(int *l1, int *l2, int way, int n) {
  printf("line%d,station%d\n", way, n);
  int i;
  for (i = (n - 2); i >= 0; i--) {
    if (way == 1)
      way = l1[i];
    else
      way = l2[i];
    printf("line%d,station%d\n", way, i + 1);
  }
}


x86 assembly (clang, -O0):
<PRINT_STATIONS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     1199 <PRINT_STATIONS+0x89>
cmpl   $0x1,-0x14(%rbp)
jne    1168 <PRINT_STATIONS+0x58>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
jmp    1176 <PRINT_STATIONS+0x66>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1141 <PRINT_STATIONS+0x31>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PRINT_STATIONS>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%r13d
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xed3(%rip),%rdi
mov    %edx,%esi
mov    %ecx,%edx
call   1030 <printf@plt>
cmp    $0x2,%ebx
jl     1175 <PRINT_STATIONS+0x65>
lea    -0x2(%rbx),%ebp
add    $0xffffffff,%ebx
lea    0xeb8(%rip),%r12
nopl   0x0(%rax,%rax,1)
cmp    $0x1,%r13d
mov    %r14,%rax
cmove  %r15,%rax
mov    (%rax,%rbp,4),%r13d
mov    %r12,%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
add    $0xffffffff,%ebx
add    $0xffffffffffffffff,%rbp
jb     1150 <PRINT_STATIONS+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"line%d,station%d\0A\00"
define void @PRINT_STATIONS(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %7
%11 = load i32, i32* %8
%12 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11)
%13 = load i32, i32* %8
%14 = sub nsw i32 %13, 2
store i32 %14, i32* %9
br label %15
15: ; preds = %38, %4
%16 = load i32, i32* %9
%17 = icmp sge i32 %16, 0
br i1 %17, label %18, label %41
18: ; preds = %15
%19 = load i32, i32* %7
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %27
21: ; preds = %18
%22 = load i32*, i32** %5
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
store i32 %26, i32* %7
br label %33
27: ; preds = %18
%28 = load i32*, i32** %6
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = load i32, i32* %31
store i32 %32, i32* %7
br label %33
33: ; preds = %27, %21
%34 = load i32, i32* %7
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
%37 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %34, i32 %36)
br label %38
38: ; preds = %33
%39 = load i32, i32* %9
%40 = add nsw i32 %39, -1
store i32 %40, i32* %9
br label %15
41: ; preds = %15
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"line%d,station%d\0A\00"
define void @PRINT_STATIONS(i32* nocapture %0, i32* nocapture %1, i32 %2, i32 %3) {
%5 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3)
%6 = icmp sgt i32 %3, 1
br i1 %6, label %7, label %22
7: ; preds = %4
%8 = add nsw i32 %3, -2
%9 = zext i32 %8 to i64
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ %9, %7 ], [ %20, %10 ]
%12 = phi i32 [ %2, %7 ], [ %16, %10 ]
%13 = icmp eq i32 %12, 1
%14 = select i1 %13, i32* %0, i32* %1
%15 = getelementptr inbounds i32, i32* %14, i64 %11
%16 = load i32, i32* %15
%17 = trunc i64 %11 to i32
%18 = add i32 %17, 1
%19 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %18)
%20 = add nsw i64 %11, -1
%21 = icmp eq i64 %11, 0
br i1 %21, label %22, label %10
22: ; preds = %10, %4
ret void
}