#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 EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getchar();
int /*<<< orphan*/ puts(char *);
int scanf(char *, int *);
int read_column_numbers(int columns[], int max) {
  int num = 0;
  int ch;
  while (num < max && scanf("%d", &columns[num]) == 1 && columns[num] >= 0)
    num += 1;
  if (num % 2 != 0) {
    puts("Last column number is not paired.");
    exit(EXIT_FAILURE);
  }
  while ((ch = getchar()) != EOF && ch != '\n')
    ;
  return num;
}


x86 assembly (clang, -O0):
<read_column_numbers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x15(%rbp)
jge    11a4 <read_column_numbers+0x64>
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe83(%rip),%rdi
call   1050 <scanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
mov    %al,-0x15(%rbp)
jne    11a4 <read_column_numbers+0x64>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
setge  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11b4 <read_column_numbers+0x74>
jmp    11c2 <read_column_numbers+0x82>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1156 <read_column_numbers+0x16>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11f0 <read_column_numbers+0xb0>
lea    0xe26(%rip),%rdi
call   1030 <puts@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jmp    11f5 <read_column_numbers+0xb5>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
mov    0x2dde(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x16(%rbp)
je     121f <read_column_numbers+0xdf>
cmpl   $0xa,-0x14(%rbp)
setne  %al
mov    %al,-0x16(%rbp)
mov    -0x16(%rbp),%al
test   $0x1,%al
jne    122f <read_column_numbers+0xef>
jmp    1234 <read_column_numbers+0xf4>
jmp    11f5 <read_column_numbers+0xb5>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_column_numbers>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11ad <read_column_numbers+0x6d>
mov    %rdi,%rbx
mov    %esi,%r12d
xor    %r14d,%r14d
lea    0xea4(%rip),%r15
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    118a <read_column_numbers+0x4a>
cmpl   $0x0,(%rbx)
js     118a <read_column_numbers+0x4a>
add    $0xffffffffffffffff,%r14
add    $0x4,%rbx
mov    %r12,%rax
add    %r14,%rax
jne    1160 <read_column_numbers+0x20>
mov    %r12d,%r14d
jmp    118d <read_column_numbers+0x4d>
neg    %r14d
test   $0x1,%r14b
je     11b0 <read_column_numbers+0x70>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
xor    %r14d,%r14d
mov    0x2e31(%rip),%rbx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     11d0 <read_column_numbers+0x90>
cmp    (%rbx),%eax
jne    11c0 <read_column_numbers+0x80>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [34 x i8] c"Last column number is not paired.\00"
@EXIT_FAILURE = global i32 0
@EOF = global i32 0
define i32 @read_column_numbers(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %27, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %25
11: ; preds = %7
%12 = load i32*, i32** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %15)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %25
18: ; preds = %11
%19 = load i32*, i32** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = icmp sge i32 %23, 0
br label %25
25: ; preds = %18, %11, %7
%26 = phi i1 [ false, %11 ], [ false, %7 ], [ %24, %18 ]
br i1 %26, label %27, label %30
27: ; preds = %25
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %7
30: ; preds = %25
%31 = load i32, i32* %5
%32 = srem i32 %31, 2
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %30
br label %39
39: ; preds = %48, %38
%40 = call i32 (...) @getchar()
store i32 %40, i32* %6
%41 = load i32, i32* @EOF
%42 = icmp ne i32 %40, %41
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i32, i32* %6
%45 = icmp ne i32 %44, 10
br label %46
46: ; preds = %43, %39
%47 = phi i1 [ false, %39 ], [ %45, %43 ]
br i1 %47, label %48, label %49
48: ; preds = %46
br label %39
49: ; preds = %46
%50 = load i32, i32* %5
ret i32 %50
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [34 x i8] c"Last column number is not paired.\00"
@EXIT_FAILURE = global i32 0
@EOF = global i32 0
define i32 @read_column_numbers(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %25
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %14
%7 = phi i64 [ 0, %4 ], [ %15, %14 ]
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %19
11: ; preds = %6
%12 = load i32, i32* %8
%13 = icmp sgt i32 %12, -1
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = add nuw nsw i64 %7, 1
%16 = icmp eq i64 %15, %5
br i1 %16, label %21, label %6
17: ; preds = %11
%18 = trunc i64 %7 to i32
br label %21
19: ; preds = %6
%20 = trunc i64 %7 to i32
br label %21
21: ; preds = %14, %19, %17
%22 = phi i32 [ %18, %17 ], [ %20, %19 ], [ %1, %14 ]
%23 = and i32 %22, 1
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %2, %21
%26 = phi i32 [ %22, %21 ], [ 0, %2 ]
br label %31
27: ; preds = %21
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
%30 = tail call i32 @exit(i32 %29)
unreachable
31: ; preds = %25, %31
%32 = tail call i32 (...) @getchar()
%33 = load i32, i32* @EOF
%34 = icmp ne i32 %32, %33
%35 = icmp ne i32 %32, 10
%36 = and i1 %35, %34
br i1 %36, label %31, label %37
37: ; preds = %31
ret i32 %26
}