#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*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, unsigned int *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int main(int argc, char *argv[]) {
  char in[41], out[20];
  unsigned int v;
  int i, ret;
  ret = read(STDIN_FILENO, in, 40);
  if (ret != 40)
    return 1;
  in[40] = '\0';
  for (i = 0; i < 20; i++) {
    sscanf(&in[2 * i], "%02x", &v);
    out[i] = v;
  }
  write(STDOUT_FILENO, out, 20);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rsi
mov    $0x28,%edx
call   1040 <read@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x28,-0x6c(%rbp)
je     1176 <main+0x46>
movl   $0x1,-0x4(%rbp)
jmp    11e3 <main+0xb3>
movb   $0x0,-0x18(%rbp)
movl   $0x0,-0x68(%rbp)
cmpl   $0x14,-0x68(%rbp)
jge    11c5 <main+0x95>
mov    -0x68(%rbp),%eax
shl    $0x1,%eax
cltq
lea    -0x40(%rbp),%rdi
add    %rax,%rdi
lea    0xe5f(%rip),%rsi
lea    -0x64(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x64(%rbp),%eax
mov    %al,%cl
movslq -0x68(%rbp),%rax
mov    %cl,-0x60(%rbp,%rax,1)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1181 <main+0x51>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
mov    $0x14,%edx
call   1030 <write@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
lea    0x30(%rsp),%r12
mov    %r12,%rsi
mov    $0x28,%edx
call   1040 <read@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x28,%ecx
jne    11bf <main+0x8f>
movb   $0x0,0x58(%rsp)
xor    %ebx,%ebx
lea    0xe90(%rip),%r14
lea    0xc(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <sscanf@plt>
movzbl 0xc(%rsp),%eax
mov    %al,0x10(%rsp,%rbx,1)
add    $0x1,%rbx
add    $0x2,%r12
cmp    $0x14,%rbx
jne    1180 <main+0x50>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rsi
mov    $0x14,%edx
call   1030 <write@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@.str = [5 x i8] c"%02x\00"
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [41 x i8]
%7 = alloca [20 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* @STDIN_FILENO
%12 = getelementptr inbounds [41 x i8], [41 x i8]* %6, i64 0, i64 0
%13 = call i32 @read(i32 %11, i8* %12, i32 40)
store i32 %13, i32* %10
%14 = load i32, i32* %10
%15 = icmp ne i32 %14, 40
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 1, i32* %3
br label %40
17: ; preds = %2
%18 = getelementptr inbounds [41 x i8], [41 x i8]* %6, i64 0, i64 40
store i8 0, i8* %18
store i32 0, i32* %9
br label %19
19: ; preds = %33, %17
%20 = load i32, i32* %9
%21 = icmp slt i32 %20, 20
br i1 %21, label %22, label %36
22: ; preds = %19
%23 = load i32, i32* %9
%24 = mul nsw i32 2, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [41 x i8], [41 x i8]* %6, i64 0, i64 %25
%27 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %8)
%28 = load i32, i32* %8
%29 = trunc i32 %28 to i8
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 %31
store i8 %29, i8* %32
br label %33
33: ; preds = %22
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
br label %19
36: ; preds = %19
%37 = load i32, i32* @STDOUT_FILENO
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%39 = call i32 @write(i32 %37, i8* %38, i32 20)
store i32 0, i32* %3
br label %40
40: ; preds = %36, %16
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@.str = [5 x i8] c"%02x\00"
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [41 x i8]
%4 = alloca [20 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%8 = bitcast i32* %5 to i8*
%9 = load i32, i32* @STDIN_FILENO
%10 = call i32 @read(i32 %9, i8* %6, i32 40)
%11 = icmp eq i32 %10, 40
br i1 %11, label %12, label %27
12: ; preds = %2
%13 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 40
store i8 0, i8* %13
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 0, %12 ], [ %22, %14 ]
%16 = shl nuw nsw i64 %15, 1
%17 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 %16
%18 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %5)
%19 = load i32, i32* %5
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 %15
store i8 %20, i8* %21
%22 = add nuw nsw i64 %15, 1
%23 = icmp eq i64 %22, 20
br i1 %23, label %24, label %14
24: ; preds = %14
%25 = load i32, i32* @STDOUT_FILENO
%26 = call i32 @write(i32 %25, i8* %7, i32 20)
br label %27
27: ; preds = %2, %24
%28 = phi i32 [ 0, %24 ], [ 1, %2 ]
ret i32 %28
}