#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*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void ConstructDataHeader(char *sLine, char *sName, int iType) {
  strcpy(sLine, "!");
  strcat(sLine, sName);
  strcat(sLine, " ");
  switch (iType & 0x000000F0) {
  case 0x00000010:
    strcat(sLine, "single");
    break;
  case 0x00000020:
    strcat(sLine, "array");
    break;
  case 0x00000040:
    strcat(sLine, "table");
    return;
  }
  strcat(sLine, " ");
  switch (iType & 0x0000000F) {
  case 0x00000001:
    strcat(sLine, "int");
    break;
  case 0x00000002:
    strcat(sLine, "dbl");
    break;
  case 0x00000003:
    strcat(sLine, "str");
    break;
  }
}


x86 assembly (clang, -O0):
<ConstructDataHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x14(%rbp),%eax
and    $0xf0,%eax
mov    %eax,-0x18(%rbp)
sub    $0x10,%eax
je     119b <ConstructDataHeader+0x7b>
jmp    1179 <ConstructDataHeader+0x59>
mov    -0x18(%rbp),%eax
sub    $0x20,%eax
je     11b0 <ConstructDataHeader+0x90>
jmp    118a <ConstructDataHeader+0x6a>
mov    -0x18(%rbp),%eax
sub    $0x40,%eax
je     11c5 <ConstructDataHeader+0xa5>
jmp    11da <ConstructDataHeader+0xba>
mov    -0x8(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1040 <strcat@plt>
jmp    11da <ConstructDataHeader+0xba>
mov    -0x8(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1040 <strcat@plt>
jmp    11da <ConstructDataHeader+0xba>
mov    -0x8(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1040 <strcat@plt>
jmp    125d <ConstructDataHeader+0x13d>
mov    -0x8(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x14(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     1223 <ConstructDataHeader+0x103>
jmp    1201 <ConstructDataHeader+0xe1>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     1238 <ConstructDataHeader+0x118>
jmp    1212 <ConstructDataHeader+0xf2>
mov    -0x1c(%rbp),%eax
sub    $0x3,%eax
je     124d <ConstructDataHeader+0x12d>
jmp    125d <ConstructDataHeader+0x13d>
mov    -0x8(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   1040 <strcat@plt>
jmp    125d <ConstructDataHeader+0x13d>
mov    -0x8(%rbp),%rdi
lea    0xdd8(%rip),%rsi
call   1040 <strcat@plt>
jmp    125d <ConstructDataHeader+0x13d>
mov    -0x8(%rbp),%rdi
lea    0xdc7(%rip),%rsi
call   1040 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConstructDataHeader>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecd(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcat@plt>
lea    0xeb8(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
mov    %ebp,%eax
and    $0xf0,%al
cmp    $0x10,%al
je     116b <ConstructDataHeader+0x4b>
cmp    $0x40,%al
je     11ac <ConstructDataHeader+0x8c>
cmp    $0x20,%al
jne    117a <ConstructDataHeader+0x5a>
lea    0xea2(%rip),%rsi
jmp    1172 <ConstructDataHeader+0x52>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
and    $0xf,%ebp
add    $0xffffffff,%ebp
cmp    $0x2,%ebp
ja     11a7 <ConstructDataHeader+0x87>
movslq %ebp,%rax
lea    0xe86(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
jmp    11b3 <ConstructDataHeader+0x93>
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <strcat@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"!\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [7 x i8] c"single\00"
@.str.3 = [6 x i8] c"array\00"
@.str.4 = [6 x i8] c"table\00"
@.str.5 = [4 x i8] c"int\00"
@.str.6 = [4 x i8] c"dbl\00"
@.str.7 = [4 x i8] c"str\00"
define void @ConstructDataHeader(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = call i32 @strcat(i8* %9, i8* %10)
%12 = load i8*, i8** %4
%13 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* %6
%15 = and i32 %14, 240
switch i32 %15, label %25 [
i32 16, label %16
i32 32, label %19
i32 64, label %22
]
16: ; preds = %3
%17 = load i8*, i8** %4
%18 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %25
19: ; preds = %3
%20 = load i8*, i8** %4
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %25
22: ; preds = %3
%23 = load i8*, i8** %4
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %39
25: ; preds = %3, %19, %16
%26 = load i8*, i8** %4
%27 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* %6
%29 = and i32 %28, 15
switch i32 %29, label %39 [
i32 1, label %30
i32 2, label %33
i32 3, label %36
]
30: ; preds = %25
%31 = load i8*, i8** %4
%32 = call i32 @strcat(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %39
33: ; preds = %25
%34 = load i8*, i8** %4
%35 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %39
36: ; preds = %25
%37 = load i8*, i8** %4
%38 = call i32 @strcat(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %39
39: ; preds = %22, %25, %36, %33, %30
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"!\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [7 x i8] c"single\00"
@.str.3 = [6 x i8] c"array\00"
@.str.4 = [6 x i8] c"table\00"
@.str.5 = [4 x i8] c"int\00"
@.str.6 = [4 x i8] c"dbl\00"
@.str.7 = [4 x i8] c"str\00"
@reltable.ConstructDataHeader = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([3 x i32]* @reltable.ConstructDataHeader to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.6 to i64), i64 ptrtoint ([3 x i32]* @reltable.ConstructDataHeader to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.7 to i64), i64 ptrtoint ([3 x i32]* @reltable.ConstructDataHeader to i64)) to i32)]
define void @ConstructDataHeader(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strcat(i8* %0, i8* %1)
%6 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = trunc i32 %2 to i8
%8 = and i8 %7, -16
switch i8 %8, label %13 [
i8 16, label %10
i8 32, label %9
i8 64, label %22
]
9: ; preds = %3
br label %10
10: ; preds = %3, %9
%11 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %9 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %3 ]
%12 = tail call i32 @strcat(i8* %0, i8* %11)
br label %13
13: ; preds = %10, %3
%14 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = and i32 %2, 15
%16 = add nsw i32 %15, -1
%17 = icmp ult i32 %16, 3
br i1 %17, label %18, label %25
18: ; preds = %13
%19 = sext i32 %16 to i64
%20 = shl i64 %19, 2
%21 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.ConstructDataHeader to i8*), i64 %20)
br label %22
22: ; preds = %18, %3
%23 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %3 ], [ %21, %18 ]
%24 = tail call i32 @strcat(i8* %0, i8* %23)
br label %25
25: ; preds = %13, %22
ret void
}