#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 */
char *dec2hex(char, char *);
char str_int(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void constant2object_code(char *operand, char *object_code) {
  int i, j;
  char temp[50];
  strcpy(temp, operand);
  if (temp[0] == 'x' || temp[0] == 'X') {
    for (i = 0; i <= strlen(temp) - 2; i++)
      temp[i] = temp[i + 2];
    temp[strlen(temp) - 1] = 0;
    strcpy(object_code, temp);
  } else if (temp[0] == 'c' || temp[0] == 'C') {
    strcpy(object_code, "");
    for (i = 2; operand[i] != '\''; i++)
      strcat(object_code, dec2hex(operand[i], temp));
  } else {
    strcpy(temp, dec2hex(str_int(operand), temp));
    for (i = 6 - strlen(temp), j = 0; i; i--, j++)
      object_code[j] = '0';
    object_code[j] = 0;
    strcat(object_code, temp);
  }
}


x86 assembly (clang, -O0):
<constant2object_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
movsbl -0x50(%rbp),%eax
cmp    $0x78,%eax
je     1187 <constant2object_code+0x37>
movsbl -0x50(%rbp),%eax
cmp    $0x58,%eax
jne    11f4 <constant2object_code+0xa4>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x54(%rbp)
lea    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
sub    $0x2,%ecx
cmp    %ecx,%eax
jg     11cf <constant2object_code+0x7f>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
cltq
mov    -0x50(%rbp,%rax,1),%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118e <constant2object_code+0x3e>
lea    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x50(%rbp,%rax,1)
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1308 <constant2object_code+0x1b8>
movsbl -0x50(%rbp),%eax
cmp    $0x63,%eax
je     120e <constant2object_code+0xbe>
movsbl -0x50(%rbp),%eax
cmp    $0x43,%eax
jne    1278 <constant2object_code+0x128>
mov    -0x10(%rbp),%rdi
lea    0xde7(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x2,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x27,%eax
je     1273 <constant2object_code+0x123>
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
lea    -0x50(%rbp),%rsi
movsbl %al,%edi
call   1060 <dec2hex@plt>
mov    -0x60(%rbp),%rdi
mov    %rax,%rsi
call   1070 <strcat@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1225 <constant2object_code+0xd5>
jmp    1303 <constant2object_code+0x1b3>
lea    -0x50(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <str_int@plt>
lea    -0x50(%rbp),%rsi
movsbl %al,%edi
call   1060 <dec2hex@plt>
mov    -0x68(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    $0x6,%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     12ea <constant2object_code+0x19a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12bd <constant2object_code+0x16d>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1070 <strcat@plt>
jmp    1308 <constant2object_code+0x1b8>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<constant2object_code>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    (%rsp),%al
and    $0xdf,%al
cmp    $0x43,%al
je     11ef <constant2object_code+0x8f>
cmp    $0x58,%al
jne    1233 <constant2object_code+0xd3>
mov    %rsp,%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     11cf <constant2object_code+0x6f>
mov    $0xffffffffffffffff,%rbx
mov    %rsp,%r12
nopw   0x0(%rax,%rax,1)
movzbl 0x3(%rsp,%rbx,1),%eax
mov    %al,0x1(%rsp,%rbx,1)
mov    %r12,%rdi
call   1040 <strlen@plt>
add    $0xfffffffe,%eax
cltq
add    $0x1,%rbx
cmp    %rax,%rbx
jl     11b0 <constant2object_code+0x50>
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r15,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
jmp    1290 <constant2object_code+0x130>
lea    0xe0a(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    0x2(%rbx),%al
cmp    $0x27,%al
je     1290 <constant2object_code+0x130>
add    $0x3,%rbx
mov    %rsp,%r15
movsbl %al,%edi
mov    %r15,%rsi
call   1070 <dec2hex@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1080 <strcat@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0x27,%al
jne    1210 <constant2object_code+0xb0>
jmp    1290 <constant2object_code+0x130>
mov    %rbx,%rdi
call   1060 <str_int@plt>
movsbl %al,%edi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1070 <dec2hex@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x6,%eax
jne    1265 <constant2object_code+0x105>
xor    %ebx,%ebx
jmp    1280 <constant2object_code+0x120>
mov    $0x5,%ebx
sub    %eax,%ebx
add    $0x1,%rbx
mov    %r14,%rdi
mov    $0x30,%esi
mov    %rbx,%rdx
call   1050 <memset@plt>
movb   $0x0,(%r14,%rbx,1)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1080 <strcat@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define void @constant2object_code(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [50 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%9 = load i8*, i8** %3
%10 = call i32 @strcpy(i8* %8, i8* %9)
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 120
br i1 %14, label %20, label %15
15: ; preds = %2
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 88
br i1 %19, label %20, label %48
20: ; preds = %15, %2
store i32 0, i32* %5
br label %21
21: ; preds = %36, %20
%22 = load i32, i32* %5
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%24 = call i32 @strlen(i8* %23)
%25 = sub nsw i32 %24, 2
%26 = icmp sle i32 %22, %25
br i1 %26, label %27, label %39
27: ; preds = %21
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 %34
store i8 %32, i8* %35
br label %36
36: ; preds = %27
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %21
39: ; preds = %21
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%41 = call i32 @strlen(i8* %40)
%42 = sub nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 %43
store i8 0, i8* %44
%45 = load i8*, i8** %4
%46 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%47 = call i32 @strcpy(i8* %45, i8* %46)
br label %115
48: ; preds = %15
%49 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 99
br i1 %52, label %58, label %53
53: ; preds = %48
%54 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 67
br i1 %57, label %58, label %83
58: ; preds = %53, %48
%59 = load i8*, i8** %4
%60 = call i32 @strcpy(i8* %59, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 2, i32* %5
br label %61
61: ; preds = %79, %58
%62 = load i8*, i8** %3
%63 = load i32, i32* %5
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp ne i32 %67, 39
br i1 %68, label %69, label %82
69: ; preds = %61
%70 = load i8*, i8** %4
%71 = load i8*, i8** %3
%72 = load i32, i32* %5
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
%75 = load i8, i8* %74
%76 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%77 = call i8* @dec2hex(i8 signext %75, i8* %76)
%78 = call i32 @strcat(i8* %70, i8* %77)
br label %79
79: ; preds = %69
%80 = load i32, i32* %5
%81 = add nsw i32 %80, 1
store i32 %81, i32* %5
br label %61
82: ; preds = %61
br label %114
83: ; preds = %53
%84 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%85 = load i8*, i8** %3
%86 = call signext i8 @str_int(i8* %85)
%87 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%88 = call i8* @dec2hex(i8 signext %86, i8* %87)
%89 = call i32 @strcpy(i8* %84, i8* %88)
%90 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%91 = call i32 @strlen(i8* %90)
%92 = sub nsw i32 6, %91
store i32 %92, i32* %5
store i32 0, i32* %6
br label %93
93: ; preds = %101, %83
%94 = load i32, i32* %5
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %106
96: ; preds = %93
%97 = load i8*, i8** %4
%98 = load i32, i32* %6
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i8, i8* %97, i64 %99
store i8 48, i8* %100
br label %101
101: ; preds = %96
%102 = load i32, i32* %5
%103 = add nsw i32 %102, -1
store i32 %103, i32* %5
%104 = load i32, i32* %6
%105 = add nsw i32 %104, 1
store i32 %105, i32* %6
br label %93
106: ; preds = %93
%107 = load i8*, i8** %4
%108 = load i32, i32* %6
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds i8, i8* %107, i64 %109
store i8 0, i8* %110
%111 = load i8*, i8** %4
%112 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%113 = call i32 @strcat(i8* %111, i8* %112)
br label %114
114: ; preds = %106, %82
br label %115
115: ; preds = %114, %39
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define void @constant2object_code(i8* %0, i8* %1) {
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* %0)
%6 = load i8, i8* %4
%7 = and i8 %6, -33
switch i8 %7, label %42 [
i8 88, label %8
i8 67, label %28
]
8: ; preds = %2
%9 = call i32 @strlen(i8* %4)
%10 = icmp slt i32 %9, 2
br i1 %10, label %22, label %11
11: ; preds = %8, %11
%12 = phi i64 [ %17, %11 ], [ 0, %8 ]
%13 = add nuw nsw i64 %12, 2
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %12
store i8 %15, i8* %16
%17 = add nuw nsw i64 %12, 1
%18 = call i32 @strlen(i8* %4)
%19 = add nsw i32 %18, -2
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %12, %20
br i1 %21, label %11, label %22
22: ; preds = %11, %8
%23 = call i32 @strlen(i8* %4)
%24 = add nsw i32 %23, -1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %25
store i8 0, i8* %26
%27 = call i32 @strcpy(i8* %1, i8* %4)
br label %56
28: ; preds = %2
%29 = call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%30 = getelementptr inbounds i8, i8* %0, i64 2
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 39
br i1 %32, label %56, label %33
33: ; preds = %28, %33
%34 = phi i64 [ %38, %33 ], [ 2, %28 ]
%35 = phi i8 [ %40, %33 ], [ %31, %28 ]
%36 = call i8* @dec2hex(i8 signext %35, i8* %4)
%37 = call i32 @strcat(i8* %1, i8* %36)
%38 = add nuw i64 %34, 1
%39 = getelementptr inbounds i8, i8* %0, i64 %38
%40 = load i8, i8* %39
%41 = icmp eq i8 %40, 39
br i1 %41, label %56, label %33
42: ; preds = %2
%43 = call signext i8 @str_int(i8* %0)
%44 = call i8* @dec2hex(i8 signext %43, i8* %4)
%45 = call i32 @strcpy(i8* %4, i8* %44)
%46 = call i32 @strlen(i8* %4)
%47 = icmp eq i32 %46, 6
br i1 %47, label %52, label %48
48: ; preds = %42
%49 = sub i32 5, %46
%50 = zext i32 %49 to i64
%51 = add nuw nsw i64 %50, 1
br label %52
52: ; preds = %48, %42
%53 = phi i64 [ 0, %42 ], [ %51, %48 ]
%54 = getelementptr inbounds i8, i8* %1, i64 %53
store i8 0, i8* %54
%55 = call i32 @strcat(i8* %1, i8* %4)
br label %56
56: ; preds = %33, %28, %52, %22
ret void
}