#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 */
long get_num(char *, char *);
char *long2str(char *, int /*<<< orphan*/);
int /*<<< orphan*/ tt_appendToTable(int, long, int, int);
char *macttAppendToTable(char *arg) {
  int fromTable, toTable, addTransTbl = 0;
  long topol;
  if ((toTable = (int)get_num("ttAddToTable", arg)) < 0) {
    toTable = -toTable;
    addTransTbl = 1;
  }
  if ((topol = get_num("ttAddToTable", arg)) < 0) {
    topol = -topol;
    addTransTbl = 1;
  }
  if ((fromTable = (int)get_num("ttAddToTable", arg)) < 0) {
    fromTable = -fromTable;
    addTransTbl = 1;
  }
  return long2str(arg,
                  tt_appendToTable(fromTable, topol, toTable, addTransTbl));
}


x86 assembly (clang, -O0):
<macttAppendToTable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeb2(%rip),%rdi
call   1030 <get_num@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    116e <macttAppendToTable+0x3e>
xor    %eax,%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe87(%rip),%rdi
call   1030 <get_num@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jge    119d <macttAppendToTable+0x6d>
xor    %eax,%eax
sub    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe58(%rip),%rdi
call   1030 <get_num@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    11c8 <macttAppendToTable+0x98>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1050 <tt_appendToTable@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1040 <long2str@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<macttAppendToTable>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xebb(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <get_num@plt>
mov    %rax,%rbx
mov    %ebx,%r12d
neg    %r12d
cmovs  %ebx,%r12d
shr    $0x1f,%ebx
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <get_num@plt>
mov    %rax,%r13
mov    %rax,%rbp
neg    %rbp
cmovs  %rax,%rbp
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <get_num@plt>
mov    %eax,%edi
neg    %edi
cmovs  %eax,%edi
test   %r13,%r13
mov    $0x1,%ecx
cmovs  %ecx,%ebx
test   %eax,%eax
cmovs  %ecx,%ebx
mov    %rbp,%rsi
mov    %r12d,%edx
mov    %ebx,%ecx
call   1050 <tt_appendToTable@plt>
mov    %r14,%rdi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <long2str@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"ttAddToTable\00"
define i8* @macttAppendToTable(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
store i8* %0, i8** %2
store i32 0, i32* %5
%7 = load i8*, i8** %2
%8 = call i64 @get_num(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = trunc i64 %8 to i32
store i32 %9, i32* %4
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* %4
%13 = sub nsw i32 0, %12
store i32 %13, i32* %4
store i32 1, i32* %5
br label %14
14: ; preds = %11, %1
%15 = load i8*, i8** %2
%16 = call i64 @get_num(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %15)
store i64 %16, i64* %6
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i64, i64* %6
%20 = sub nsw i64 0, %19
store i64 %20, i64* %6
store i32 1, i32* %5
br label %21
21: ; preds = %18, %14
%22 = load i8*, i8** %2
%23 = call i64 @get_num(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = trunc i64 %23 to i32
store i32 %24, i32* %3
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load i32, i32* %3
%28 = sub nsw i32 0, %27
store i32 %28, i32* %3
store i32 1, i32* %5
br label %29
29: ; preds = %26, %21
%30 = load i8*, i8** %2
%31 = load i32, i32* %3
%32 = load i64, i64* %6
%33 = load i32, i32* %4
%34 = load i32, i32* %5
%35 = call i32 @tt_appendToTable(i32 %31, i64 %32, i32 %33, i32 %34)
%36 = call i8* @long2str(i8* %30, i32 %35)
ret i8* %36
}

LLVM IR (-O2):
@.str = [13 x i8] c"ttAddToTable\00"
define i8* @macttAppendToTable(i8* %0) {
%2 = tail call i64 @get_num(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = trunc i64 %2 to i32
%4 = tail call i32 @llvm.abs.i32(i32 %3, i1 true)
%5 = lshr i32 %3, 31
%6 = tail call i64 @get_num(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = icmp slt i64 %6, 0
%8 = sub nsw i64 0, %6
%9 = select i1 %7, i64 %8, i64 %6
%10 = tail call i64 @get_num(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0)
%11 = trunc i64 %10 to i32
%12 = icmp slt i32 %11, 0
%13 = sub nsw i32 0, %11
%14 = select i1 %12, i32 %13, i32 %11
%15 = select i1 %12, i1 true, i1 %7
%16 = select i1 %15, i32 1, i32 %5
%17 = tail call i32 @tt_appendToTable(i32 %14, i64 %9, i32 %4, i32 %16)
%18 = tail call i8* @long2str(i8* %0, i32 %17)
ret i8* %18
}