#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);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fscanf(int /*<<< orphan*/, char *, int *, ...);
int /*<<< orphan*/ fwrite(int *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(void) {
  int addr = 0, neu, line, i;
  int v, v1;
  for (line = 0; line < 0x8000; line++, addr += 0x10) {
    if (1 != fscanf(stdin, "%05x:\n", &neu)) {
      fprintf(stderr, "look into this 20 line source\n");
      exit(1);
    }
    if (neu != addr) {
      fprintf(stderr, "%.5x %.5x\n", neu, addr);
      exit(1);
    }
    fprintf(stderr, "%.5x:", addr);
    for (i = 0; i < 0x8; i++) {
      if (2 != fscanf(stdin, "%1x%1x", &v, &v1))
        ;
      v = v | (v1 << 4);
      fprintf(stderr, "%02x", v);
      fwrite(&v, 1, 1, stdout);
    }
    fprintf(stderr, "\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x8000,-0x10(%rbp)
jge    12c3 <main+0x183>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1030 <fscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     11b5 <main+0x75>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     11e8 <main+0xa8>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe4f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe36(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    1295 <main+0x155>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
lea    0xe14(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
mov    $0x0,%al
call   1030 <fscanf@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
je     1246 <main+0x106>
jmp    1246 <main+0x106>
mov    -0x18(%rbp),%eax
mov    -0x1c(%rbp),%ecx
shl    $0x4,%ecx
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
lea    0xdd7(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1060 <fwrite@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1209 <main+0xc9>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
lea    0xd60(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x8(%rbp)
jmp    115d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e93(%rip),%r14
mov    0x2e7c(%rip),%r12
lea    0x10(%rsp),%r15
lea    0xed6(%rip),%r13
xor    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r14),%edi
lea    0xe86(%rip),%rsi
lea    0x14(%rsp),%rdx
xor    %eax,%eax
call   1030 <fscanf@plt>
cmp    $0x1,%eax
jne    1261 <main+0x121>
mov    %ebp,0xc(%rsp)
mov    0x14(%rsp),%edx
mov    (%r12),%edi
cmp    %ebx,%edx
jne    127d <main+0x13d>
lea    0xe87(%rip),%rsi
mov    %ebx,0x8(%rsp)
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x8,%ebx
mov    0x2e15(%rip),%r12
lea    0x4(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    (%r14),%edi
lea    0xe5d(%rip),%rsi
mov    %rbp,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1030 <fscanf@plt>
mov    0x10(%rsp),%edx
shl    $0x4,%edx
or     0x4(%rsp),%edx
mov    %edx,0x4(%rsp)
mov    (%r12),%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%ecx
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1060 <fwrite@plt>
add    $0xffffffff,%ebx
jne    11d0 <main+0x90>
mov    (%r12),%edi
lea    0xdd6(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0xc(%rsp),%ebp
add    $0x1,%ebp
mov    0x8(%rsp),%ebx
add    $0x10,%ebx
cmp    $0x8000,%ebp
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r12),%edi
lea    0xd9b(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xda2(%rip),%rsi
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [7 x i8] c"%05x:\0A\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"look into this 20 line source\0A\00"
@.str.2 = [11 x i8] c"%.5x %.5x\0A\00"
@.str.3 = [6 x i8] c"%.5x:\00"
@.str.4 = [7 x i8] c"%1x%1x\00"
@.str.5 = [5 x i8] c"%02x\00"
@stdout = global i32 0
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %4
br label %8
8: ; preds = %57, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 32768
br i1 %10, label %11, label %62
11: ; preds = %8
%12 = load i32, i32* @stdin
%13 = call i32 (i32, i8*, i32*, ...) @fscanf(i32 %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %3)
%14 = icmp ne i32 1, %13
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %11
%20 = load i32, i32* %3
%21 = load i32, i32* %2
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = load i32, i32* @stderr
%25 = load i32, i32* %3
%26 = load i32, i32* %2
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %19
%30 = load i32, i32* @stderr
%31 = load i32, i32* %2
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %31)
store i32 0, i32* %5
br label %33
33: ; preds = %51, %29
%34 = load i32, i32* %5
%35 = icmp slt i32 %34, 8
br i1 %35, label %36, label %54
36: ; preds = %33
%37 = load i32, i32* @stdin
%38 = call i32 (i32, i8*, i32*, ...) @fscanf(i32 %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %6, i32* %7)
%39 = icmp ne i32 2, %38
br i1 %39, label %40, label %41
40: ; preds = %36
br label %41
41: ; preds = %40, %36
%42 = load i32, i32* %6
%43 = load i32, i32* %7
%44 = shl i32 %43, 4
%45 = or i32 %42, %44
store i32 %45, i32* %6
%46 = load i32, i32* @stderr
%47 = load i32, i32* %6
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %47)
%49 = load i32, i32* @stdout
%50 = call i32 @fwrite(i32* %6, i32 1, i32 1, i32 %49)
br label %51
51: ; preds = %41
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 1
store i32 %53, i32* %5
br label %33
54: ; preds = %33
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %57
57: ; preds = %54
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
store i32 %59, i32* %4
%60 = load i32, i32* %2
%61 = add nsw i32 %60, 16
store i32 %61, i32* %2
br label %8
62: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [7 x i8] c"%05x:\0A\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"look into this 20 line source\0A\00"
@.str.2 = [11 x i8] c"%.5x %.5x\0A\00"
@.str.3 = [6 x i8] c"%.5x:\00"
@.str.4 = [7 x i8] c"%1x%1x\00"
@.str.5 = [5 x i8] c"%02x\00"
@stdout = global i32 0
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
br label %7
7: ; preds = %0, %40
%8 = phi i32 [ 0, %0 ], [ %43, %40 ]
%9 = phi i32 [ 0, %0 ], [ %44, %40 ]
%10 = load i32, i32* @stdin
%11 = call i32 (i32, i8*, i32*, ...) @fscanf(i32 %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %1)
%12 = icmp eq i32 %11, 1
br i1 %12, label %17, label %13
13: ; preds = %7
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %7
%18 = load i32, i32* %1
%19 = icmp eq i32 %18, %9
%20 = load i32, i32* @stderr
br i1 %19, label %24, label %21
21: ; preds = %17
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %9)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %17
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %9)
br label %26
26: ; preds = %24, %26
%27 = phi i32 [ 0, %24 ], [ %38, %26 ]
%28 = load i32, i32* @stdin
%29 = call i32 (i32, i8*, i32*, ...) @fscanf(i32 %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %2, i32* %3)
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = shl i32 %31, 4
%33 = or i32 %32, %30
store i32 %33, i32* %2
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %33)
%36 = load i32, i32* @stdout
%37 = call i32 @fwrite(i32* %2, i32 1, i32 1, i32 %36)
%38 = add nuw nsw i32 %27, 1
%39 = icmp eq i32 %38, 8
br i1 %39, label %40, label %26
40: ; preds = %26
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%43 = add nuw nsw i32 %8, 1
%44 = add nuw nsw i32 %9, 16
%45 = icmp eq i32 %43, 32768
br i1 %45, label %46, label %7
46: ; preds = %40
ret i32 0
}