#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 */
char EOF;
char getchar();
char gc() {
  extern char cc;
  extern long nrow, crow, ncol, ccol;
  if ((cc = getchar()) != EOF) {
    crow = nrow;
    ccol = ncol;
    if (cc == '\n') {
      nrow = crow + 1;
      ncol = 1;
    } else {
      nrow = crow;
      ncol = ccol + 1;
    }
  }
  return cc;
}


x86 assembly (clang, -O0):
<gc>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <getchar@plt>
mov    0x2eb6(%rip),%rcx
mov    %al,(%rcx)
movsbl %al,%eax
mov    0x2e92(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11d0 <gc+0xc0>
mov    0x2eb0(%rip),%rax
mov    (%rax),%rcx
mov    0x2e7e(%rip),%rax
mov    %rcx,(%rax)
mov    0x2e7c(%rip),%rax
mov    (%rax),%rcx
mov    0x2e82(%rip),%rax
mov    %rcx,(%rax)
mov    0x2e70(%rip),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    119f <gc+0x8f>
mov    0x2e4d(%rip),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    0x2e67(%rip),%rax
mov    %rcx,(%rax)
mov    0x2e3d(%rip),%rax
movq   $0x1,(%rax)
jmp    11cb <gc+0xbb>
mov    0x2e22(%rip),%rax
mov    (%rax),%rcx
mov    0x2e40(%rip),%rax
mov    %rcx,(%rax)
mov    0x2e26(%rip),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    0x2e08(%rip),%rax
mov    %rcx,(%rax)
jmp    11d0 <gc+0xc0>
mov    0x2e01(%rip),%rax
movsbl (%rax),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<gc>:
push   %rax
xor    %eax,%eax
call   1030 <getchar@plt>
mov    0x2eb9(%rip),%rcx
mov    %al,(%rcx)
mov    0x2e98(%rip),%rcx
cmp    (%rcx),%al
je     116d <gc+0x5d>
mov    0x2ebd(%rip),%r8
mov    (%r8),%rdi
mov    0x2e8b(%rip),%rcx
mov    %rdi,(%rcx)
mov    0x2e89(%rip),%rcx
mov    (%rcx),%rdx
mov    0x2e8f(%rip),%rsi
mov    %rdx,(%rsi)
cmp    $0xa,%al
jne    1166 <gc+0x56>
add    $0x1,%rdi
mov    %rdi,(%r8)
mov    $0x1,%edx
jmp    116a <gc+0x5a>
add    $0x1,%rdx
mov    %rdx,(%rcx)
pop    %rcx
ret

LLVM IR (-O0):
@cc = external global i8
@EOF = global i8 0
@nrow = external global i64
@crow = external global i64
@ncol = external global i64
@ccol = external global i64
define signext i8 @gc() {
%1 = call signext i8 (...) @getchar()
store i8 %1, i8* @cc
%2 = sext i8 %1 to i32
%3 = load i8, i8* @EOF
%4 = sext i8 %3 to i32
%5 = icmp ne i32 %2, %4
br i1 %5, label %6, label %20
6: ; preds = %0
%7 = load i64, i64* @nrow
store i64 %7, i64* @crow
%8 = load i64, i64* @ncol
store i64 %8, i64* @ccol
%9 = load i8, i8* @cc
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 10
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = load i64, i64* @crow
%14 = add nsw i64 %13, 1
store i64 %14, i64* @nrow
store i64 1, i64* @ncol
br label %19
15: ; preds = %6
%16 = load i64, i64* @crow
store i64 %16, i64* @nrow
%17 = load i64, i64* @ccol
%18 = add nsw i64 %17, 1
store i64 %18, i64* @ncol
br label %19
19: ; preds = %15, %12
br label %20
20: ; preds = %19, %0
%21 = load i8, i8* @cc
ret i8 %21
}

LLVM IR (-O2):
@cc = external global i8
@EOF = global i8 0
@nrow = external global i64
@crow = external global i64
@ncol = external global i64
@ccol = external global i64
define signext i8 @gc() {
%1 = tail call signext i8 (...) @getchar()
store i8 %1, i8* @cc
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %1, %2
br i1 %3, label %14, label %4
4: ; preds = %0
%5 = load i64, i64* @nrow
store i64 %5, i64* @crow
%6 = load i64, i64* @ncol
store i64 %6, i64* @ccol
%7 = icmp eq i8 %1, 10
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = add nsw i64 %5, 1
store i64 %9, i64* @nrow
br label %12
10: ; preds = %4
%11 = add nsw i64 %6, 1
br label %12
12: ; preds = %10, %8
%13 = phi i64 [ 1, %8 ], [ %11, %10 ]
store i64 %13, i64* @ncol
br label %14
14: ; preds = %12, %0
ret i8 %1
}