#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strtoul(char *, int /*<<< orphan*/ *, int);
int main(void) {
  char message[1000];
  char hexa[1000 * 2];
  char caractere[8];
  int iMessage, ihexa;
  scanf("%[^\n]s\n", message);
  for (iMessage = 0; message[iMessage] != '\0'; ++iMessage) {
    sprintf(caractere, "%x", message[iMessage]);
    strcat(hexa, caractere);
  }
  printf("0x%s\n", hexa);
  for (ihexa = 0; hexa[ihexa] != '\0'; ihexa += 2) {
    char lettre[3];
    lettre[0] = hexa[ihexa];
    lettre[1] = hexa[ihexa + 1];
    lettre[2] = '\0';
    printf("%c", (int)strtoul(lettre, NULL, 16));
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xbe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3f0(%rbp),%rsi
lea    0xe90(%rip),%rdi
call   1040 <scanf@plt>
movl   $0x0,-0xbcc(%rbp)
movslq -0xbcc(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     11e0 <main+0x90>
lea    -0xbc8(%rbp),%rdi
movslq -0xbcc(%rbp),%rax
lea    0xe5c(%rip),%rsi
movsbl -0x3f0(%rbp,%rax,1),%edx
ff
call   1070 <sprintf@plt>
lea    -0xbc0(%rbp),%rdi
lea    -0xbc8(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0xbcc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbcc(%rbp)
jmp    117f <main+0x2f>
lea    -0xbc0(%rbp),%rsi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xbd0(%rbp)
movslq -0xbd0(%rbp),%rax
movsbl -0xbc0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1283 <main+0x133>
movslq -0xbd0(%rbp),%rax
mov    -0xbc0(%rbp,%rax,1),%al
mov    %al,-0xbd3(%rbp)
mov    -0xbd0(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0xbc0(%rbp,%rax,1),%al
mov    %al,-0xbd2(%rbp)
movb   $0x0,-0xbd1(%rbp)
lea    -0xbd3(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1050 <strtoul@plt>
mov    %eax,%esi
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xbd0(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xbd0(%rbp)
jmp    11ff <main+0xaf>
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xbe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xbd8,%rsp
lea    0xe8b(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x10(%rsp),%al
test   %al,%al
je     11c4 <main+0x64>
lea    0x11(%rsp),%rbx
lea    0xe75(%rip),%r14
lea    0x8(%rsp),%r12
lea    0x400(%rsp),%r15
movsbl %al,%edx
mov    %r12,%rdi
mov    %r14,%rsi
call   1080 <sprintf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11a0 <main+0x40>
lea    0xe40(%rip),%rdi
lea    0x400(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x400(%rsp),%al
test   %al,%al
je     1232 <main+0xd2>
lea    0x402(%rsp),%rbx
lea    0x5(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %al,0x5(%rsp)
movzbl -0x1(%rbx),%eax
mov    %al,0x6(%rsp)
movb   $0x0,0x7(%rsp)
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <strtoul@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x2,%rbx
test   %al,%al
jne    1200 <main+0xa0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0xbd8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%[^\0A]s\0A\00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [6 x i8] c"0x%s\0A\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca [2000 x i8]
%4 = alloca [8 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca [3 x i8]
store i32 0, i32* %1
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %8)
store i32 0, i32* %5
br label %10
10: ; preds = %27, %0
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %30
17: ; preds = %10
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %22)
%24 = getelementptr inbounds [2000 x i8], [2000 x i8]* %3, i64 0, i64 0
%25 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%26 = call i32 @strcat(i8* %24, i8* %25)
br label %27
27: ; preds = %17
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %10
30: ; preds = %10
%31 = getelementptr inbounds [2000 x i8], [2000 x i8]* %3, i64 0, i64 0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %31)
store i32 0, i32* %6
br label %33
33: ; preds = %57, %30
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [2000 x i8], [2000 x i8]* %3, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %60
40: ; preds = %33
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [2000 x i8], [2000 x i8]* %3, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
store i8 %44, i8* %45
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [2000 x i8], [2000 x i8]* %3, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 1
store i8 %50, i8* %51
%52 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 2
store i8 0, i8* %52
%53 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%54 = call i64 @strtoul(i8* %53, i32* null, i32 16)
%55 = trunc i64 %54 to i32
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %40
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 2
store i32 %59, i32* %6
br label %33
60: ; preds = %33
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%[^\0A]s\0A\00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [6 x i8] c"0x%s\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [2000 x i8]
%3 = alloca [8 x i8]
%4 = alloca [3 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %5)
%9 = load i8, i8* %5
%10 = icmp eq i8 %9, 0
br i1 %10, label %20, label %11
11: ; preds = %0, %11
%12 = phi i64 [ %16, %11 ], [ 0, %0 ]
%13 = phi i8 [ %18, %11 ], [ %9, %0 ]
%14 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %13)
%15 = call i32 @strcat(i8* %6, i8* %7)
%16 = add nuw i64 %12, 1
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %11
20: ; preds = %11, %0
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%22 = load i8, i8* %6
%23 = icmp eq i8 %22, 0
br i1 %23, label %41, label %24
24: ; preds = %20
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%26 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
%27 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
br label %28
28: ; preds = %24, %28
%29 = phi i64 [ 0, %24 ], [ %37, %28 ]
%30 = phi i8 [ %22, %24 ], [ %39, %28 ]
store i8 %30, i8* %25
%31 = or i64 %29, 1
%32 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 %31
%33 = load i8, i8* %32
store i8 %33, i8* %26
store i8 0, i8* %27
%34 = call i64 @strtoul(i8* nocapture %25, i32* null, i32 16)
%35 = trunc i64 %34 to i32
%36 = call i32 @putchar(i32 %35)
%37 = add nuw i64 %29, 2
%38 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 0
br i1 %40, label %41, label %28
41: ; preds = %28, %20
%42 = call i32 @putchar(i32 10)
ret i32 0
}