#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 getc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stdin;
int main() {
  int c, nl;
  nl = 0;
  while ((c = getc(stdin)) != EOF) {
    printf("c is: %#08x\n", c);
    if (c == 0xA)
      ++nl;
  }
  printf("%d\n", nl);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0x2eab(%rip),%rax
mov    (%rax),%edi
call   1040 <getc@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e92(%rip),%rcx
cmp    (%rcx),%eax
je     117d <main+0x5d>
mov    -0x8(%rbp),%esi
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0xa,-0x8(%rbp)
jne    1178 <main+0x58>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1136 <main+0x16>
mov    -0xc(%rbp),%esi
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2eb9(%rip),%r15
mov    (%r15),%edi
call   1040 <getc@plt>
mov    0x2ea2(%rip),%r12
xor    %ebx,%ebx
cmp    (%r12),%eax
je     1184 <main+0x64>
mov    %eax,%ebp
xor    %ebx,%ebx
lea    0xeaf(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
xor    %eax,%eax
cmp    $0xa,%ebp
sete   %al
add    %eax,%ebx
mov    (%r15),%edi
call   1040 <getc@plt>
mov    %eax,%ebp
cmp    (%r12),%eax
jne    1160 <main+0x40>
lea    0xe82(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i32 0
@.str = [13 x i8] c"c is: %x\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %17, %0
%5 = load i32, i32* @stdin
%6 = call i32 @getc(i32 %5)
store i32 %6, i32* %2
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %18
9: ; preds = %4
%10 = load i32, i32* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 10
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %17
17: ; preds = %14, %9
br label %4
18: ; preds = %4
%19 = load i32, i32* %3
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
@.str = [13 x i8] c"c is: %x\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = load i32, i32* @stdin
%2 = tail call i32 @getc(i32 %1)
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %16, label %5
5: ; preds = %0, %5
%6 = phi i32 [ %13, %5 ], [ %2, %0 ]
%7 = phi i32 [ %11, %5 ], [ 0, %0 ]
%8 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %6)
%9 = icmp eq i32 %6, 10
%10 = zext i1 %9 to i32
%11 = add nuw nsw i32 %7, %10
%12 = load i32, i32* @stdin
%13 = tail call i32 @getc(i32 %12)
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %5
16: ; preds = %5, %0
%17 = phi i32 [ 0, %0 ], [ %11, %5 ]
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
ret i32 0
}