#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main() {
  int ix, iy;
  char inbuf[256];
  ix = -1;
  while (fgets(inbuf, 256 - 1, stdin) != NULL) {
    sscanf(inbuf, "%X", &iy);
    if (ix == iy)
      fprintf(stderr, "Duplicate code point: %04X\n", ix);
    else
      ix = iy;
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
mov    0x2e81(%rip),%rax
mov    (%rax),%edx
mov    $0xff,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
je     11c8 <main+0x88>
lea    -0x110(%rbp),%rdi
lea    0xe75(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11bd <main+0x7d>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe50(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11c3 <main+0x83>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1159 <main+0x19>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    0x2e90(%rip),%r13
mov    0x0(%r13),%edx
lea    0x10(%rsp),%rdi
mov    $0xff,%esi
call   1030 <fgets@plt>
test   %rax,%rax
jne    1177 <main+0x37>
xor    %edi,%edi
call   1060 <exit@plt>
mov    $0xffffffff,%ebp
lea    0xe7d(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r15
jmp    11a9 <main+0x69>
nop
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1030 <fgets@plt>
mov    %r12d,%ebp
test   %rax,%rax
je     1170 <main+0x30>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <sscanf@plt>
mov    0xc(%rsp),%r12d
cmp    %r12d,%ebp
jne    1190 <main+0x50>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe32(%rip),%rsi
mov    %ebp,%edx
call   1040 <fprintf@plt>
mov    %ebp,%r12d
jmp    1190 <main+0x50>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%X\00"
@stderr = global i32 0
@.str.1 = [28 x i8] c"Duplicate code point: %04X\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [256 x i8]
store i32 0, i32* %1
store i32 -1, i32* %2
br label %5
5: ; preds = %22, %0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32* @fgets(i8* %6, i32 255, i32 %7)
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %23
10: ; preds = %5
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = load i32, i32* %2
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %22
20: ; preds = %10
%21 = load i32, i32* %3
store i32 %21, i32* %2
br label %22
22: ; preds = %20, %16
br label %5
23: ; preds = %5
%24 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%X\00"
@stderr = global i32 0
@.str.1 = [28 x i8] c"Duplicate code point: %04X\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32* @fgets(i8* %4, i32 255, i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %21, label %8
8: ; preds = %0, %16
%9 = phi i32 [ %17, %16 ], [ -1, %0 ]
%10 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp eq i32 %9, %11
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %16
16: ; preds = %8, %13
%17 = phi i32 [ %9, %13 ], [ %11, %8 ]
%18 = load i32, i32* @stdin
%19 = call i32* @fgets(i8* %4, i32 255, i32 %18)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %8
21: ; preds = %16, %0
%22 = call i32 @exit(i32 0)
unreachable
}