#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
size_t strlen(char *);
int main(void) {
  char name[100];
  printf("Enter a name: ");
  gets(name);
  printf("\nThe ASCII value of %s is:\n", name);
  printf("\tHEX format: ");
  for (size_t i = 0; i < strlen(name); i++) {
    printf("%X", name[i]);
  }
  printf("\n\tDEC format: ");
  for (size_t i = 0; i < strlen(name); i++) {
    printf("%d", name[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x70(%rbp),%rsi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x88(%rbp),%rax
cmp    %rcx,%rax
jae    11d0 <main+0xa0>
mov    -0x78(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x78(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x78(%rbp)
jmp    1181 <main+0x51>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x80(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x90(%rbp),%rax
cmp    %rcx,%rax
jae    1235 <main+0x105>
mov    -0x80(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%esi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x80(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x80(%rbp)
jmp    11e6 <main+0xb6>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
lea    0xeb6(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl (%rsp),%esi
test   %esi,%esi
je     11cf <main+0x9f>
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%rax
jb     11cf <main+0x9f>
mov    $0x1,%ebx
lea    0xe98(%rip),%r14
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    %rax,%rbx
jb     11b0 <main+0x80>
lea    0xe66(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl (%rsp),%esi
test   %esi,%esi
je     122f <main+0xff>
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%rax
jb     122f <main+0xff>
mov    $0x1,%ebx
lea    0xe3e(%rip),%r14
mov    %rsp,%r15
movsbl (%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    %rax,%rbx
jb     1210 <main+0xe0>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Enter a name: \00"
@.str.1 = [28 x i8] c"\0AThe ASCII value of %s is:\0A\00"
@.str.2 = [14 x i8] c"\09HEX format: \00"
@.str.3 = [3 x i8] c"%X\00"
@.str.4 = [15 x i8] c"\0A\09DEC format: \00"
@.str.5 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i64 0, i64* %3
br label %11
11: ; preds = %22, %0
%12 = load i64, i64* %3
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%14 = call i64 @strlen(i8* %13)
%15 = icmp ult i64 %12, %14
br i1 %15, label %16, label %25
16: ; preds = %11
%17 = load i64, i64* %3
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %16
%23 = load i64, i64* %3
%24 = add i64 %23, 1
store i64 %24, i64* %3
br label %11
25: ; preds = %11
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
store i64 0, i64* %4
br label %27
27: ; preds = %38, %25
%28 = load i64, i64* %4
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%30 = call i64 @strlen(i8* %29)
%31 = icmp ult i64 %28, %30
br i1 %31, label %32, label %41
32: ; preds = %27
%33 = load i64, i64* %4
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %32
%39 = load i64, i64* %4
%40 = add i64 %39, 1
store i64 %40, i64* %4
br label %27
41: ; preds = %27
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Enter a name: \00"
@.str.1 = [28 x i8] c"\0AThe ASCII value of %s is:\0A\00"
@.str.2 = [14 x i8] c"\09HEX format: \00"
@.str.3 = [3 x i8] c"%X\00"
@.str.4 = [15 x i8] c"\0A\09DEC format: \00"
@.str.5 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %0
%10 = sext i8 %7 to i32
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = call i64 @strlen(i8* %2)
%13 = icmp ugt i64 %12, 1
br i1 %13, label %23, label %14
14: ; preds = %23, %9, %0
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%16 = load i8, i8* %2
%17 = icmp eq i8 %16, 0
br i1 %17, label %32, label %18
18: ; preds = %14
%19 = sext i8 %16 to i32
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %19)
%21 = call i64 @strlen(i8* %2)
%22 = icmp ugt i64 %21, 1
br i1 %22, label %33, label %32
23: ; preds = %9, %23
%24 = phi i64 [ %29, %23 ], [ 1, %9 ]
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = add nuw i64 %24, 1
%30 = call i64 @strlen(i8* %2)
%31 = icmp ult i64 %29, %30
br i1 %31, label %23, label %14
32: ; preds = %33, %18, %14
ret i32 0
33: ; preds = %18, %33
%34 = phi i64 [ %39, %33 ], [ 1, %18 ]
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %37)
%39 = add nuw i64 %34, 1
%40 = call i64 @strlen(i8* %2)
%41 = icmp ult i64 %39, %40
br i1 %41, label %33, label %32
}