#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 */
scalar_t__ EOF;
int /*<<< orphan*/ convertUtf8ToWchars(char const **, unsigned char **, size_t);
int /*<<< orphan*/ onOutputError();
int /*<<< orphan*/ stdout;
int strlen(char const *);
scalar_t__ writeHexadecimalCharacter(int /*<<< orphan*/, unsigned char);
void putHexadecimal(const char *string) {
  size_t size = strlen(string) + 1;
  unsigned char characters[size];
  const char *byte = string;
  unsigned char *character = characters;
  unsigned char *end = character;
  convertUtf8ToWchars(&byte, &end, size);
  while (character < end) {
    if (writeHexadecimalCharacter(stdout, *character) == EOF)
      onOutputError();
    character += 1;
  }
}


x86 assembly (clang, -O0):
<putHexadecimal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
mov    %rsp,%rax
mov    %rax,-0x18(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,%rsp
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1050 <convertUtf8ToWchars@plt>
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    11f1 <putHexadecimal+0xb1>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rax
movzbl (%rax),%esi
call   1040 <writeHexadecimalCharacter@plt>
mov    0x2e18(%rip),%rcx
cmp    (%rcx),%rax
jne    11e0 <putHexadecimal+0xa0>
mov    $0x0,%al
call   1060 <onOutputError@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11a6 <putHexadecimal+0x66>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putHexadecimal>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
call   1030 <strlen@plt>
cltq
lea    0x1(%rax),%rdx
mov    %rsp,%rbx
add    $0x10,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %r14,-0x28(%rbp)
mov    %rbx,-0x20(%rbp)
lea    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <convertUtf8ToWchars@plt>
cmp    -0x20(%rbp),%rbx
jae    11c3 <putHexadecimal+0x83>
mov    0x2e4a(%rip),%r14
mov    0x2e53(%rip),%r15
jmp    11aa <putHexadecimal+0x6a>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    -0x20(%rbp),%rbx
jae    11c3 <putHexadecimal+0x83>
mov    (%r14),%edi
movzbl (%rbx),%esi
call   1040 <writeHexadecimalCharacter@plt>
cmp    (%r15),%rax
jne    11a0 <putHexadecimal+0x60>
xor    %eax,%eax
call   1060 <onOutputError@plt>
jmp    11a0 <putHexadecimal+0x60>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@EOF = global i64 0
define void @putHexadecimal(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = add nsw i32 %10, 1
%12 = sext i32 %11 to i64
store i64 %12, i64* %3
%13 = load i64, i64* %3
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %4
%15 = alloca i8, i64 %13
store i64 %13, i64* %5
%16 = load i8*, i8** %2
store i8* %16, i8** %6
store i8* %15, i8** %7
%17 = load i8*, i8** %7
store i8* %17, i8** %8
%18 = load i64, i64* %3
%19 = call i32 @convertUtf8ToWchars(i8** %6, i8** %8, i64 %18)
br label %20
20: ; preds = %33, %1
%21 = load i8*, i8** %7
%22 = load i8*, i8** %8
%23 = icmp ult i8* %21, %22
br i1 %23, label %24, label %36
24: ; preds = %20
%25 = load i32, i32* @stdout
%26 = load i8*, i8** %7
%27 = load i8, i8* %26
%28 = call i64 @writeHexadecimalCharacter(i32 %25, i8 zeroext %27)
%29 = load i64, i64* @EOF
%30 = icmp eq i64 %28, %29
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = call i32 (...) @onOutputError()
br label %33
33: ; preds = %31, %24
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i64 1
store i8* %35, i8** %7
br label %20
36: ; preds = %20
%37 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@EOF = global i64 0
define void @putHexadecimal(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = tail call i32 @strlen(i8* %0)
%5 = add nsw i32 %4, 1
%6 = sext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = bitcast i8** %2 to i8*
store i8* %0, i8** %2
%9 = bitcast i8** %3 to i8*
store i8* %7, i8** %3
%10 = call i32 @convertUtf8ToWchars(i8** %2, i8** %3, i64 %6)
%11 = load i8*, i8** %3
%12 = icmp ult i8* %7, %11
br i1 %12, label %13, label %26
13: ; preds = %1, %22
%14 = phi i8* [ %23, %22 ], [ %7, %1 ]
%15 = load i32, i32* @stdout
%16 = load i8, i8* %14
%17 = call i64 @writeHexadecimalCharacter(i32 %15, i8 zeroext %16)
%18 = load i64, i64* @EOF
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = call i32 (...) @onOutputError()
br label %22
22: ; preds = %20, %13
%23 = getelementptr inbounds i8, i8* %14, i64 1
%24 = load i8*, i8** %3
%25 = icmp ult i8* %23, %24
br i1 %25, label %13, label %26
26: ; preds = %22, %1
ret void
}